openapi: 3.1.0
info:
  title: Beato Developer API
  version: 1.0.0
servers:
  - url: https://api.beato.app
security:
  - bearerKey: []
paths:
  /v1/models:
    get:
      operationId: listModels
      security: []
      responses:
        '200':
          description: Model catalog. A null price means the model is unpriced.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      required: [id, kind, parameters, price_cents, currency, available]
                      properties:
                        id: { $ref: '#/components/schemas/Model' }
                        kind: { enum: [image, video] }
                        parameters: { type: array, items: { type: string } }
                        price_cents: { type: [integer, 'null'] }
                        currency: { const: USD }
                        available: { type: boolean }
        default: { $ref: '#/components/responses/Error' }
  /v1/balance:
    get:
      operationId: getBalance
      responses:
        '200':
          description: Available and held USD cents.
          content:
            application/json:
              schema:
                type: object
                required: [available_cents, held_cents, currency]
                properties:
                  available_cents: { type: integer }
                  held_cents: { type: integer }
                  currency: { const: USD }
        default: { $ref: '#/components/responses/Error' }
  /v1/assets:
    post:
      operationId: uploadAsset
      requestBody:
        required: true
        content:
          image/jpeg: { schema: { type: string, format: binary } }
          image/png: { schema: { type: string, format: binary } }
      responses:
        '201':
          description: Asset ID for the authenticated account.
          content:
            application/json:
              schema:
                type: object
                required: [id, expires_in]
                properties:
                  id: { type: string, format: uuid }
                  expires_in: { const: 86400 }
        default: { $ref: '#/components/responses/Error' }
  /v1/jobs:
    post:
      operationId: createJob
      parameters:
        - in: header
          name: Idempotency-Key
          required: true
          schema: { type: string, minLength: 1, maxLength: 128, pattern: '^[!-~]+$' }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [model, prompt]
              additionalProperties: false
              properties:
                model: { $ref: '#/components/schemas/Model' }
                prompt: { type: string, minLength: 1, maxLength: 2000 }
                aspect_ratio: { enum: ['1:1', '16:9', '9:16'] }
                asset_id: { type: string, format: uuid }
              if: { properties: { model: { enum: [nano-banana-edit, kling-2.6-image-to-video] } } }
              then: { required: [asset_id], not: { required: [aspect_ratio] } }
              else: { not: { required: [asset_id] } }
      responses:
        '202': { $ref: '#/components/responses/Job' }
        '402': { $ref: '#/components/responses/Error' }
        '409': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
        '503': { $ref: '#/components/responses/Error' }
        default: { $ref: '#/components/responses/Error' }
  /v1/jobs/{id}:
    get:
      operationId: getJob
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string, format: uuid }
      responses:
        '200': { $ref: '#/components/responses/Job' }
        default: { $ref: '#/components/responses/Error' }
components:
  securitySchemes:
    bearerKey: { type: http, scheme: bearer }
  schemas:
    Model:
      enum: [nano-banana, nano-banana-edit, kling-2.6-text-to-video, kling-2.6-image-to-video]
    Job:
      type: object
      required: [id, model, status, price_cents, currency, created_at, finished_at, results, results_expires_at, error]
      properties:
        id: { type: string, format: uuid }
        model: { $ref: '#/components/schemas/Model' }
        status: { enum: [queued, running, reconciling, succeeded, failed] }
        price_cents: { type: integer }
        currency: { const: USD }
        created_at: { type: string, format: date-time }
        finished_at: { type: [string, 'null'], format: date-time }
        results_expires_at: { type: [string, 'null'], format: date-time }
        error:
          type: [object, 'null']
          properties:
            code: { type: string }
        results:
          type: array
          items:
            type: object
            required: [url]
            properties:
              url: { type: string, format: uri }
  responses:
    Job:
      description: Current state of a job owned by the account.
      content:
        application/json:
          schema: { $ref: '#/components/schemas/Job' }
    Error:
      description: Request could not be processed.
      headers:
        Retry-After:
          description: Seconds before retrying, when provided.
          schema: { type: integer }
      content:
        application/json:
          schema:
            type: object
            required: [error]
            properties:
              error:
                type: object
                required: [code, request_id]
                properties:
                  code: { type: string }
                  request_id: { type: string, format: uuid }
