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

# OpenAI Images Generations

Create images from a text prompt using OpenAI-compatible image models. The endpoint follows the official OpenAI Images API request and response shape for `POST /v1/images/generations`.

Documentation translated from the <a href="https://developers.openai.com/api/reference/resources/images/methods/generate" target="_blank">official documentation</a>.

Supported models include `gpt-image-2`, `gpt-image-1.5`, `gpt-image-1`, `dall-e-2`, and `dall-e-3`.

<Note>
  Since OpenAI image generation is a synchronous response and takes a relatively long time, it is recommended to use the **[https://api.ttapi.org](https://api.ttapi.org)** gateway.
</Note>


## OpenAPI

````yaml openapi/en/openai.json POST /v1/images/generations
openapi: 3.1.0
info:
  title: Open AI API DOCS
  version: 1.0.0
  description: TTAPI OpenAI API service
servers:
  - url: https://api.ttapi.io
security: []
paths:
  /v1/images/generations:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerationsRequest'
      responses:
        '200':
          description: >-
            Request successful, returns image generation results (supports
            url/base64 formats)
          content:
            application/json:
              schema:
                type: object
                properties:
                  created:
                    type: integer
                    description: Generation timestamp (seconds)
                    example: 1745818538
                  data:
                    type: array
                    items:
                      oneOf:
                        - title: URL format
                          type: object
                          properties:
                            url:
                              type: string
                              description: >-
                                CDN URL of generated image. Validity: see
                                [Storage and Persistence](/grids/en/faq/storage)
                              example: >-
                                https://filesystem.site/cdn/20250428/5LsFMT0Def02RVVUkwJ4v7IslleMzo.webp
                            revised_prompt:
                              type: string
                              description: Optimized prompt
                              example: >-
                                A cute fluffy cat with big, bright eyes, soft
                                fur, and a playful expression. It has a light
                                gray coat with hints of white on its paws and
                                tail. The cat is sitting in a cozy setting,
                                surrounded by soft cushions, with its tail
                                wrapped around its paws. Its ears are perked up,
                                and it's looking directly at the viewer, exuding
                                a sense of curiosity and warmth.
                          required:
                            - url
                        - title: Base64 format
                          type: object
                          properties:
                            b64_json:
                              type: string
                              description: Base64 encoded string of generated image
                              example: iVBORw0KGgoAAAANSUhE...
                          required:
                            - b64_json
                    description: Image generation result list
                  usage:
                    type: object
                    properties:
                      input_tokens:
                        type: integer
                        description: Input token count
                        example: 9
                      input_tokens_details:
                        type: object
                        properties:
                          image_tokens:
                            type: integer
                            description: Image token count
                            example: 0
                          text_tokens:
                            type: integer
                            description: Text token count
                            example: 9
                        required:
                          - image_tokens
                          - text_tokens
                      output_tokens:
                        type: integer
                        description: Output token count
                        example: 4160
                      total_tokens:
                        type: integer
                        description: Total token count
                        example: 4169
                    required:
                      - input_tokens
                      - input_tokens_details
                      - output_tokens
                      - total_tokens
                required:
                  - created
                  - data
                examples:
                  URL Format:
                    summary: Return image in URL format
                    value:
                      data:
                        - url: >-
                            https://filesystem.site/cdn/20250428/5LsFMT0Def02RVVUkwJ4v7IslleMzo.webp
                          revised_prompt: >-
                            A cute fluffy cat with big, bright eyes, soft fur,
                            and a playful expression. It has a light gray coat
                            with hints of white on its paws and tail. The cat is
                            sitting in a cozy setting, surrounded by soft
                            cushions, with its tail wrapped around its paws. Its
                            ears are perked up, and it's looking directly at the
                            viewer, exuding a sense of curiosity and warmth.
                      created: 1745818538
                  Base64 Format:
                    summary: Return image in Base64 format
                    value:
                      created: 1745818890
                      data:
                        - b64_json: iVBORw0KGgoAAAANSUhE...
                      usage:
                        input_tokens: 9
                        input_tokens_details:
                          image_tokens: 0
                          text_tokens: 9
                        output_tokens: 4160
                        total_tokens: 4169
        '400':
          $ref: '#/components/responses/400Response'
        '401':
          $ref: '#/components/responses/401Response'
      security:
        - CustomApiKey: []
components:
  schemas:
    GenerationsRequest:
      type: object
      properties:
        prompt:
          type: string
          description: >-
            Text description of the image. `gpt-image-1.5`, `gpt-image-1`, and
            `gpt-image-2` support up to 32,000 characters; `dall-e-2` supports
            up to 1,000 characters; `dall-e-3` supports up to 4,000 characters.
        background:
          type: string
          description: >-
            Sets the transparency of generated image backgrounds. Applies only
            to GPT Image models. Choose `transparent`, `opaque`, or `auto`
            (default). When set to `transparent`, `output_format` must support
            transparency; use `png` or `webp`.
          enum:
            - transparent
            - opaque
            - auto
          default: auto
        model:
          type: string
          description: The model to use for image generation.
          enum:
            - gpt-image-2
            - gpt-image-1.5
            - gpt-image-1
            - dall-e-2
            - dall-e-3
          default: dall-e-2
        moderation:
          type: string
          description: >-
            Controls the content moderation level for images generated by GPT
            Image models. Choose `low` for less restrictive filtering or `auto`
            (default).
          enum:
            - low
            - auto
          default: auto
        'n':
          type: integer
          description: >-
            Number of images to generate, default 1. Available range `1-10`;
            `dall-e-3` is fixed at 1.
        output_compression:
          type: integer
          description: >-
            Compression level for generated images (0-100). Applies only to GPT
            Image models with `output_format` set to `webp` or `jpeg`; defaults
            to 100.
          default: 100
        output_format:
          type: string
          description: >-
            Return format for generated images. Applies only to GPT Image
            models. Choose `png` (default), `jpeg`, or `webp`.
          enum:
            - png
            - jpeg
            - webp
          default: png
        partial_images:
          type: integer
          description: >-
            Number of partial images to return in the streaming response, from
            `0` to `3`; defaults to 0. Available only when `stream` is `true`.
          default: 0
        quality:
          type: string
          description: >-
            Image quality. `auto` (default) automatically selects the best
            quality for the model. 


            GPT Image models support `high`, `medium`, and `low`; 


            `dall-e-3` supports `hd` and `standard`; 


            `dall-e-2` only supports `standard`.
          default: auto
        response_format:
          type: string
          description: >-
            Return data format. Only `dall-e-2` and `dall-e-3` support `url` or
            `b64_json`; URLs are valid for 60 minutes. GPT Image models always
            return `b64_json`.
          enum:
            - url
            - b64_json
        size:
          type: string
          description: >-
            Image size. 


            GPT Image models support `1024x1024`, `1536x1024`, `1024x1536`, and
            `auto` (default). 


            `gpt-image-2` support arbitrary `WIDTHxHEIGHT` resolution strings
            where both dimensions are divisible by 16 and the aspect ratio is
            between 1:3 and 3:1. 


            `dall-e-2` supports `256x256`, `512x512`, `1024x1024`; 


            `dall-e-3` supports `1024x1024`, `1792x1024`, `1024x1792`.
          default: auto
        stream:
          type: boolean
          description: >-
            Whether to stream generation progress. When enabled, use
            `partial_images` to receive partial image events.
          default: false
        style:
          type: string
          description: Style of generated image. Applies only to `dall-e-3`.
          enum:
            - vivid
            - natural
        user:
          type: string
          description: >-
            A unique identifier representing your end-user, which can help
            OpenAI monitor and detect abuse.
      required:
        - prompt
        - model
  responses:
    400Response:
      description: Parameter error
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: '"prompt" cannot be empty.'
              data:
                type: object
            required:
              - status
              - message
    401Response:
      description: Authorization failed
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: Wrong TT-API-KEY or email is not activated.
            required:
              - status
              - message
  securitySchemes:
    CustomApiKey:
      type: apiKey
      in: header
      name: TT-API-KEY
      description: >-
        You can obtain your API key from the <a
        href='https://dashboard.ttapi.io' target='_blank'>TTAPI Dashboard</a>.

````