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

# Create an image generation job

> Submit an image generation request with a supported public model ID. The response is a Job. Upload reference images with POST /files when the selected model supports them. See the model guide for supported inputs, limits, and defaults, and the pricing page for current rates. The charge appears in the returned Job. Reuse the same Idempotency-Key and body to retrieve the original Job without another charge. Poll GET /jobs/{jobId} for the stored output.



## OpenAPI

````yaml /api-reference/openapi.json post /images/generation
openapi: 3.1.0
info:
  title: CreatOK API
  version: 1.3.0
  description: >-
    Asynchronous media generation and TikTok Shop publishing API. Authenticate
    with a Bearer organization API key (cok_). Personal CLI/MCP keys are not
    accepted. Resource responses are returned directly, without a code/data
    envelope. Each response includes X-Request-Id.
servers:
  - url: https://api.creatok.ai/v1
security: []
paths:
  /images/generation:
    post:
      summary: Create an image generation job
      description: >-
        Submit an image generation request with a supported public model ID. The
        response is a Job. Upload reference images with POST /files when the
        selected model supports them. See the model guide for supported inputs,
        limits, and defaults, and the pricing page for current rates. The charge
        appears in the returned Job. Reuse the same Idempotency-Key and body to
        retrieve the original Job without another charge. Poll GET /jobs/{jobId}
        for the stored output.
      operationId: createImageGeneration
      parameters:
        - name: Idempotency-Key
          in: header
          schema:
            type: string
            minLength: 1
            maxLength: 255
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              text:
                value:
                  model: gpt-image-2
                  input:
                    prompt: A product photograph of a ceramic mug on a clean desk
                    resolution: 1K
                    quality: low
                    aspectRatio: '1:1'
              edit:
                value:
                  model: gpt-image-2
                  input:
                    prompt: Place the mug in a bright kitchen
                    referenceImageKeys:
                      - file_11111111-1111-4111-8111-111111111111
      responses:
        '202':
          description: A Job resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Job'
        '400':
          description: Request failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Request failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: Request failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Request failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Request failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Request failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Request failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKey: []
components:
  schemas:
    ImageGenerationRequest:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        model:
          type: string
          enum:
            - gpt-image-2
        input:
          type: object
          properties:
            prompt:
              type: string
              minLength: 1
              maxLength: 5000
            resolution:
              default: 2K
              type: string
              enum:
                - 1K
                - 2K
                - 4K
            quality:
              default: low
              type: string
              enum:
                - low
                - medium
                - high
            aspectRatio:
              default: '1:1'
              type: string
              enum:
                - auto
                - '1:1'
                - '16:9'
                - '9:16'
                - '4:3'
                - '3:4'
                - '3:2'
                - '2:3'
                - '5:4'
                - '4:5'
                - '2:1'
                - '1:2'
                - '21:9'
                - '9:21'
            referenceImageKeys:
              default: []
              maxItems: 16
              type: array
              items:
                type: string
                minLength: 1
                description: >-
                  A file_id returned by POST /files, or its upload_fields.key.
                  Must belong to the authenticated organization.
          required:
            - prompt
            - resolution
            - quality
            - aspectRatio
            - referenceImageKeys
          additionalProperties: false
        max_cost_usd:
          type: string
          pattern: ^\d+(\.\d{1,6})?$
        metadata:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - model
        - input
      additionalProperties: false
    Job:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          const: job
        capability:
          type: string
        model:
          anyOf:
            - type: string
            - type: 'null'
        status:
          type: string
          enum:
            - queued
            - running
            - succeeded
            - failed
            - canceled
        input:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        output:
          type: object
          properties:
            files:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                  url:
                    type: string
                required:
                  - type
                  - url
                additionalProperties: false
          required:
            - files
          additionalProperties: false
        cost:
          type: object
          properties:
            amount_usd:
              type: string
              description: >-
                Original charge in USD, as a decimal string with six places. It
                does not decrease after a refund.
            refunded_usd:
              type: string
              description: >-
                Actual refunded USD, as a decimal string with six places; zero
                until a refund is recorded.
          required:
            - amount_usd
            - refunded_usd
          additionalProperties: false
        error:
          anyOf:
            - type: object
              properties:
                code:
                  type: string
                message:
                  type: string
              required:
                - code
                - message
              additionalProperties: false
            - type: 'null'
        metadata:
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
        created_at:
          type: string
        completed_at:
          anyOf:
            - type: string
            - type: 'null'
        expires_at:
          anyOf:
            - type: string
            - type: 'null'
      required:
        - id
        - object
        - capability
        - model
        - status
        - input
        - output
        - cost
        - error
        - metadata
        - created_at
        - completed_at
        - expires_at
      additionalProperties: false
    Error:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
            code:
              type: string
            message:
              type: string
            param:
              type: string
            request_id:
              type: string
          required:
            - type
            - code
            - message
            - request_id
          additionalProperties: false
      required:
        - error
      additionalProperties: false
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: CreatOK organization API key

````

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