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

# Submit an APIMart-compatible GPT Image 2 text-to-image task



## OpenAPI

````yaml /openapi/gateway-openapi.json post /apimart/v1/images/generations
openapi: 3.1.0
info:
  title: YIR Async AI Gateway
  version: 1.0.0-stage3a2
  description: >-
    Source-compatible asynchronous image generation routes certified by YIR.
    Authenticate every request with a YIR API key. Provider credentials are
    managed by YIR and must never be sent by clients.
servers:
  - url: https://gateway.yir.ai
    description: YIR production Gateway
security:
  - BearerAuth: []
tags:
  - name: KIE GPT Image 2
  - name: APIMart GPT Image 2
paths:
  /apimart/v1/images/generations:
    post:
      tags:
        - APIMart GPT Image 2
      summary: Submit an APIMart-compatible GPT Image 2 text-to-image task
      operationId: submitAPIMartGPTImage2TextToImage
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            Optional caller-generated key. Reusing a key with a different
            request is rejected.
          schema:
            type: string
            maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/APIMartImageGenerationRequest'
            example:
              model: gpt-image-2
              prompt: A quiet observatory above a sea of clouds
              size: '16:9'
              resolution: 1k
              'n': 1
      responses:
        '200':
          description: Task accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIMartSubmitResponse'
        default:
          $ref: '#/components/responses/APIMartError'
      security:
        - BearerAuth: []
components:
  schemas:
    APIMartImageGenerationRequest:
      type: object
      additionalProperties: false
      required:
        - model
        - prompt
        - size
        - resolution
        - 'n'
      properties:
        model:
          type: string
          const: gpt-image-2
        prompt:
          $ref: '#/components/schemas/Prompt'
        size:
          $ref: '#/components/schemas/ImageAspectRatio'
        resolution:
          $ref: '#/components/schemas/ImageResolutionAPIMart'
        'n':
          type: integer
          const: 1
      description: >-
        The JSON body must be no larger than 256 KiB. Unknown fields are
        rejected.
    APIMartSubmitResponse:
      type: object
      additionalProperties: false
      required:
        - code
        - data
      properties:
        code:
          type: integer
          const: 200
        data:
          type: array
          minItems: 1
          maxItems: 1
          items:
            type: object
            additionalProperties: false
            required:
              - status
              - task_id
            properties:
              status:
                type: string
                const: submitted
              task_id:
                $ref: '#/components/schemas/PositiveTaskID'
    Prompt:
      type: string
      minLength: 1
      maxLength: 20000
      pattern: \S
      description: Non-blank Unicode text prompt
    ImageAspectRatio:
      type: string
      enum:
        - auto
        - '1:1'
        - '3:2'
        - '2:3'
        - '4:3'
        - '3:4'
        - '5:4'
        - '4:5'
        - '16:9'
        - '9:16'
        - '2:1'
        - '1:2'
        - '3:1'
        - '1:3'
        - '21:9'
        - '9:21'
      description: >-
        Some KIE resolution/aspect-ratio combinations are unsupported: auto
        requires 1K; 1:1 rejects 4K; 5:4, 4:5, 3:1, 1:3 and 9:21 require 1K.
    ImageResolutionAPIMart:
      type: string
      enum:
        - 1k
        - 2k
        - 4k
    PositiveTaskID:
      type: string
      pattern: ^[1-9][0-9]*$
      description: Positive decimal YIR task ID
    APIMartErrorResponse:
      type: object
      additionalProperties: false
      required:
        - code
        - error
      properties:
        code:
          type: integer
          description: HTTP status code
        error:
          type: object
          additionalProperties: false
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Stable YIR or admission reason code
            message:
              type: string
              description: Safe public error message
  responses:
    APIMartError:
      description: APIMart-compatible safe error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/APIMartErrorResponse'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: YIR_API_KEY
      description: >-
        Use Authorization: Bearer <YIR_API_KEY>. Upstream provider keys are not
        accepted.

````