> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zerogen.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quote a generation

> Validates and prices a request exactly as create would, and returns the maximum charge create would reserve. Nothing starts and nothing is held.

Needs the `generations:create` scope.



## OpenAPI

````yaml /openapi.json post /generations/quote
openapi: 3.1.0
info:
  title: ZeroGen API
  version: v1
  description: >-
    Generate images and video with every model in ZeroGen from your own servers.
    Generated from the API's contracts by `npm run openapi` in apps/web; do not
    edit by hand.
servers:
  - url: https://api.zerogen.com/v1
security:
  - bearerAuth: []
tags:
  - name: Account
    description: The calling key and the organization's balance.
  - name: Models
    description: The models an organization can run and their schemas.
  - name: Generations
    description: Quote, create, read, list and cancel generations.
  - name: Uploads
    description: Upload files into the Library to use as inputs.
paths:
  /generations/quote:
    post:
      tags:
        - Generations
      summary: Quote a generation
      description: >-
        Validates and prices a request exactly as create would, and returns the
        maximum charge create would reserve. Nothing starts and nothing is held.


        Needs the `generations:create` scope.
      operationId: quoteGeneration
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateGenerationRequest'
            example:
              model: black-forest-labs/flux-2-pro/generate
              prompt: A lighthouse at dawn, fog over the water
              output:
                count: 1
      responses:
        '200':
          description: The quote.
          headers:
            Request-Id:
              $ref: '#/components/headers/Request-Id'
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
            Idempotent-Replayed:
              $ref: '#/components/headers/Idempotent-Replayed'
            Deprecation:
              $ref: '#/components/headers/Deprecation'
            Sunset:
              $ref: '#/components/headers/Sunset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Quote'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '415':
          $ref: '#/components/responses/UnsupportedMediaType'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >-
        Makes retries safe: a retry with the same key and body returns the first
        response for 24 hours instead of repeating the work. Reusing a key with
        a different body returns 409.
      schema:
        type: string
        minLength: 1
        maxLength: 255
        pattern: ^[\x21-\x7e]+$
  schemas:
    CreateGenerationRequest:
      type: object
      properties:
        model:
          type: string
          maxLength: 200
          pattern: >-
            ^[a-z0-9]+(?:[.-][a-z0-9]+)*\/[a-z0-9]+(?:[.-][a-z0-9]+)*\/[a-z0-9]+(?:[.-][a-z0-9]+)*$
        prompt:
          type: string
          maxLength: 20000
        inputs:
          maxItems: 50
          type: array
          items:
            anyOf:
              - type: object
                properties:
                  role:
                    type: string
                    enum:
                      - source
                      - reference
                      - face-reference
                      - start-frame
                      - end-frame
                      - keyframe
                      - mask
                  asset:
                    type: string
                    pattern: >-
                      ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
                    description: Library asset ID
                  timeSeconds:
                    description: >-
                      Keyframes only, and required for them: seconds from the
                      start of the video, on one of the model's frames
                    type: number
                    minimum: 0
                required:
                  - role
                  - asset
                additionalProperties: false
              - type: object
                properties:
                  role:
                    type: string
                    enum:
                      - source
                      - reference
                      - face-reference
                      - start-frame
                      - end-frame
                      - keyframe
                      - mask
                  url:
                    type: string
                    maxLength: 2048
                    format: uri
                    description: An https URL ZeroGen imports into the library before use
                    pattern: ^https://
                  timeSeconds:
                    description: >-
                      Keyframes only, and required for them: seconds from the
                      start of the video, on one of the model's frames
                    type: number
                    minimum: 0
                required:
                  - role
                  - url
                additionalProperties: false
        output:
          type: object
          properties:
            count:
              type: integer
              minimum: 1
              maximum: 4
            size:
              description: 'Image size: auto or WIDTHxHEIGHT in pixels, such as 1024x1536'
              type: string
              maxLength: 40
            quality:
              type: string
              maxLength: 40
            background:
              type: string
              maxLength: 40
            format:
              type: string
              enum:
                - png
                - jpeg
                - webp
            aspectRatio:
              type: string
              maxLength: 20
            resolution:
              type: string
              maxLength: 20
            durationSeconds:
              type: number
              exclusiveMinimum: 0
              maximum: 600
            includeAudio:
              type: boolean
          additionalProperties: false
        parameters:
          type: object
          propertyNames:
            type: string
            pattern: ^[A-Za-z][A-Za-z0-9_]{0,63}$
          additionalProperties:
            anyOf:
              - type: string
                maxLength: 200
              - type: number
              - type: boolean
          description: Only the parameters the model's schema lists
        maxCostMicroUsd:
          type: integer
          minimum: 0
          maximum: 9007199254740991
          description: Refuse to start when the quote exceeds this amount
        test:
          type: object
          properties:
            outputs:
              minItems: 1
              maxItems: 4
              type: array
              items:
                type: string
                enum:
                  - succeeded
                  - provider_error
                  - provider_timeout
                  - content_moderation
                  - input_rejected
              description: >-
                Each output's outcome, in order: succeeded, or the error code a
                live output can end with. Outputs left out succeed
            reject:
              type: string
              enum:
                - insufficient_balance
                - rate_limited
                - model_unavailable
              description: >-
                Create only: refuse with this live response and start nothing
                (402 insufficient_balance, 429 rate_limited with Retry-After,
                400 model_unavailable)
            delaySeconds:
              type: integer
              minimum: 0
              maximum: 60
              description: >-
                Seconds before each output ends, to rehearse polling and Prefer:
                wait
          additionalProperties: false
          description: >-
            Test keys only: rehearse each output's outcome; live keys are
            refused when it is present
        projectId:
          type: string
          pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          description: >-
            The project the outputs land in; the organization's default project
            when omitted. Test keys use their sandbox.
        folderId:
          anyOf:
            - type: string
              pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
            - type: 'null'
          description: >-
            A folder in that project to file the outputs in; null or omitted for
            Unfiled
        naming:
          type: object
          properties:
            presetId:
              type: string
              pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
              description: A naming preset in the generation's project
            values:
              type: object
              propertyNames:
                type: string
                maxLength: 64
              additionalProperties:
                anyOf:
                  - type: string
                    maxLength: 80
                  - type: integer
                    minimum: 0
                    maximum: 99999999
              maxProperties: 12
              description: >-
                Field values by field ID; fields left out take the preset's
                defaults
          required:
            - presetId
            - values
          additionalProperties: false
      required:
        - model
      additionalProperties: false
    Quote:
      type: object
      properties:
        model:
          type: string
          maxLength: 200
          pattern: >-
            ^[a-z0-9]+(?:[.-][a-z0-9]+)*\/[a-z0-9]+(?:[.-][a-z0-9]+)*\/[a-z0-9]+(?:[.-][a-z0-9]+)*$
        billing:
          type: object
          properties:
            mode:
              type: string
              enum:
                - platform
                - byok
                - test
            quotedMicroUsd:
              type: integer
              minimum: 0
              maximum: 9007199254740991
              description: Reserved maximum expected charge
          required:
            - mode
            - quotedMicroUsd
          additionalProperties: false
      required:
        - model
        - billing
      additionalProperties: false
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
      additionalProperties: false
    Error:
      type: object
      properties:
        code:
          type: string
          pattern: ^[a-z][a-z0-9_]{0,79}$
        message:
          type: string
        param:
          type: string
        retryable:
          type: boolean
        details:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - code
        - message
        - retryable
      additionalProperties: false
  headers:
    Request-Id:
      description: Identifies the request; quote it when contacting support.
      schema:
        type: string
    RateLimit-Limit:
      description: Requests the key may make in the current window.
      schema:
        type: integer
    RateLimit-Remaining:
      description: Requests left in the current window.
      schema:
        type: integer
    RateLimit-Reset:
      description: Seconds until the current window resets.
      schema:
        type: integer
    Idempotent-Replayed:
      description: >-
        true when this response replays an earlier request with the same
        Idempotency-Key.
      schema:
        type: string
        enum:
          - 'true'
    Deprecation:
      description: When the model was deprecated, as @ followed by Unix seconds.
      schema:
        type: string
    Sunset:
      description: When the deprecated model stops accepting requests (HTTP date).
      schema:
        type: string
    WWW-Authenticate:
      description: Bearer realm="ZeroGen API".
      schema:
        type: string
    Retry-After:
      description: Seconds to wait before retrying.
      schema:
        type: integer
  responses:
    BadRequest:
      description: >-
        The request is malformed or invalid: invalid_request, validation_failed,
        model_unavailable or input_import_failed.
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: 'invalid_api_key: the key is missing, revoked or expired.'
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        WWW-Authenticate:
          $ref: '#/components/headers/WWW-Authenticate'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    PaymentRequired:
      description: >-
        insufficient_balance or spend_limit_reached: the available balance or a
        spend limit cannot cover the quote. cost_limit_exceeded: the quote is
        above maxCostMicroUsd.
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: >-
        permission_denied: the key lacks the scope this endpoint needs, the
        request came from a browser, or the API isn't enabled for the
        organization.
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: >-
        not_found: no such resource for this caller, including a projectId the
        caller can't use.
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Conflict:
      description: >-
        idempotency_conflict: the Idempotency-Key was used for a different
        request. idempotency_in_progress: the first request with this key hasn't
        finished. invalid_state: the request can't go ahead as things stand,
        such as a generation that needs a person's approval in ZeroGen.
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    PayloadTooLarge:
      description: The request body is larger than 128 KB.
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UnsupportedMediaType:
      description: Send the body as application/json.
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TooManyRequests:
      description: >-
        rate_limited: the key or its owner is over the rate limit, or the
        organization is at its running cap. Retry after Retry-After seconds.
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        Retry-After:
          $ref: '#/components/headers/Retry-After'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalError:
      description: 'internal: something went wrong. Retry.'
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ServiceUnavailable:
      description: >-
        unavailable or pricing_unavailable: API keys, billing or pricing can't
        be reached right now. Retry.
      headers:
        Request-Id:
          $ref: '#/components/headers/Request-Id'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'A ZeroGen API key: zg_ for a live key, zg_test_ for a test key.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.