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

# Generate Images

> Creates an image given a prompt. [Learn more](https://developers.openai.com/api/docs/guides/images).



## OpenAPI

````yaml /openapi.json post /v1/images/generations
openapi: 3.1.0
info:
  title: AIHubMix Gateway API
  description: |
    Unified multi-protocol gateway. Exposes three native shapes side-by-side:
      - OpenAI (`/v1/chat/completions`, `/v1/responses`, ...)
      - Anthropic (`/v1/messages`)
      - Gemini (`/v1beta/models/{model}:generateContent`)
    Each vendor's native SDK connects directly. Gateway-only fields are
    marked with `x-source.authority: gateway`.
  contact:
    name: AIHubMix Team
  version: 2.1.1
  x-upstream:
    vendorSpecs:
      packageVersion: 0.1.1
      installedFrom: npm
    sources:
      openai/official:
        version: '2026-05-31'
        hash: >-
          sha256:a203971a0bc0cd3b903b9488e3ac40eaa161a274dfaf172c1da73eee029147a8
      anthropic/official:
        version: '2026-05-31'
        hash: >-
          sha256:f9d488f9290d78a081bed62fa0c040476b5d009f3db92c06c8e279e69df73fc9
    layers:
      - role: L0-base
        source: avs://openai/official
        protocol: openai
        authority: official
      - role: L0-base
        source: avs://anthropic/official
        protocol: anthropic
        authority: official
      - role: gateway-other
        source: gateway/anthropic-mappings.yml
        protocol: all
        authority: gateway
      - role: horizontal-auth
        source: gateway/auth.yml
        protocol: all
        authority: gateway
      - role: horizontal-errors
        source: gateway/errors.yml
        protocol: all
        authority: gateway
      - role: L3-gateway
        source: gateway/openai-gateway.yml
        protocol: openai
        authority: gateway
      - role: gateway-other
        source: gateway/openai-image-mappings.yml
        protocol: all
        authority: gateway
      - role: gateway-other
        source: gateway/openai-mappings.yml
        protocol: all
        authority: gateway
      - role: L2-passthrough
        source: gateway/openai-passthrough.yml
        protocol: openai
        authority: gateway
servers:
  - url: https://aihubmix.com
    description: Production
  - url: https://api.inferera.com
    description: Backup (use when the primary domain is unreachable)
security:
  - gatewayBearer: []
tags:
  - name: OpenAI Compatible
    description: >-
      OpenAI-compatible endpoints (chat, completions, embeddings, images, audio,
      videos, moderations).
  - name: Anthropic Compatible
    description: Anthropic-native endpoints (messages with Anthropic protocol).
  - name: Google Vertex AI Compatible
    description: Google Gemini / Vertex AI endpoints.
paths:
  /v1/images/generations:
    post:
      tags:
        - OpenAI Compatible
      summary: Generate Images
      description: >-
        Creates an image given a prompt. [Learn
        more](https://developers.openai.com/api/docs/guides/images).
      operationId: createImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateImageRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImagesResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ImageGenStreamEvent'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        '403':
          description: Permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        5XX:
          description: Server / upstream error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
components:
  schemas:
    CreateImageRequest:
      type: object
      properties:
        prompt:
          description: >-
            A text description of the desired image(s). The maximum length is
            32000 characters for the GPT image models, 1000 characters for
            `dall-e-2` and 4000 characters for `dall-e-3`.
          type: string
          example: A cute baby sea otter
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        model:
          anyOf:
            - type: string
            - type: string
              enum:
                - gpt-image-1.5
                - dall-e-2
                - dall-e-3
                - gpt-image-1
                - gpt-image-1-mini
          default: dall-e-2
          example: gpt-image-1.5
          nullable: true
          description: >-
            The model to use for image generation. One of `dall-e-2`,
            `dall-e-3`, or a GPT image model (`gpt-image-1`, `gpt-image-1-mini`,
            `gpt-image-1.5`). Defaults to `dall-e-2` unless a parameter specific
            to the GPT image models is used.
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        'n':
          type: integer
          minimum: 1
          maximum: 10
          default: 1
          example: 1
          nullable: true
          description: >-
            The number of images to generate. Must be between 1 and 10. For
            `dall-e-3`, only `n=1` is supported.
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        quality:
          type: string
          enum:
            - standard
            - hd
            - low
            - medium
            - high
            - auto
          default: auto
          example: medium
          nullable: true
          description: >
            The quality of the image that will be generated.


            - `auto` (default value) will automatically select the best quality
            for the given model.

            - `high`, `medium` and `low` are supported for the GPT image models.

            - `hd` and `standard` are supported for `dall-e-3`.

            - `standard` is the only option for `dall-e-2`.
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        response_format:
          type: string
          enum:
            - url
            - b64_json
          default: url
          example: url
          nullable: true
          description: >-
            The format in which generated images with `dall-e-2` and `dall-e-3`
            are returned. Must be one of `url` or `b64_json`. URLs are only
            valid for 60 minutes after the image has been generated. This
            parameter isn't supported for the GPT image models, which always
            return base64-encoded images.
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        output_format:
          type: string
          enum:
            - png
            - jpeg
            - webp
          default: png
          example: png
          nullable: true
          description: >-
            The format in which the generated images are returned. This
            parameter is only supported for the GPT image models. Must be one of
            `png`, `jpeg`, or `webp`.
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        output_compression:
          type: integer
          default: 100
          example: 100
          nullable: true
          description: >-
            The compression level (0-100%) for the generated images. This
            parameter is only supported for the GPT image models with the `webp`
            or `jpeg` output formats, and defaults to 100.
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        stream:
          type: boolean
          default: false
          example: false
          nullable: true
          description: >
            Generate the image in streaming mode. Defaults to `false`. See the

            [Image generation
            guide](https://developers.openai.com/api/docs/guides/image-generation)
            for more information.

            This parameter is only supported for the GPT image models.
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        partial_images:
          $ref: '#/components/schemas/PartialImages'
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        size:
          anyOf:
            - type: string
            - type: string
              enum:
                - auto
                - 1024x1024
                - 1536x1024
                - 1024x1536
                - 256x256
                - 512x512
                - 1792x1024
                - 1024x1792
          default: auto
          example: 1024x1024
          nullable: true
          description: >-
            The size of the generated images. For `gpt-image-2` and
            `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as
            `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height
            must both be divisible by 16 and the requested aspect ratio must be
            between 1:3 and 3:1. Resolutions above `2560x1440` are experimental,
            and the maximum supported resolution is `3840x2160`. The requested
            size must also satisfy the model's current pixel and edge limits.
            The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are
            supported by the GPT image models; `auto` is supported for models
            that allow automatic sizing. For `dall-e-2`, use one of `256x256`,
            `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`,
            `1792x1024`, or `1024x1792`.
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        moderation:
          type: string
          enum:
            - low
            - auto
          default: auto
          example: low
          nullable: true
          description: >-
            Control the content-moderation level for images generated by the GPT
            image models. Must be either `low` for less restrictive filtering or
            `auto` (default value).
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        background:
          type: string
          enum:
            - transparent
            - opaque
            - auto
          default: auto
          example: transparent
          nullable: true
          description: >
            Allows to set transparency for the background of the generated
            image(s).

            This parameter is only supported for the GPT image models. Must be
            one of

            `transparent`, `opaque` or `auto` (default value). When `auto` is
            used, the

            model will automatically determine the best background for the
            image.


            If `transparent`, the output format needs to support transparency,
            so it

            should be set to either `png` (default value) or `webp`.
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        style:
          type: string
          enum:
            - vivid
            - natural
          default: vivid
          example: vivid
          nullable: true
          description: >-
            The style of the generated images. This parameter is only supported
            for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes
            the model to lean towards generating hyper-real and dramatic images.
            Natural causes the model to produce more natural, less hyper-real
            looking images.
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
        user:
          type: string
          example: user-1234
          description: >
            A unique identifier representing your end-user, which can help
            OpenAI to monitor and detect abuse. [Learn
            more](https://developers.openai.com/api/docs/guides/safety-best-practices#end-user-ids).
          x-providers-default: drop
          x-providers:
            openai: {}
            azure: {}
      required:
        - prompt
      x-source:
        from: avs://openai/official
        authority: official
    ImagesResponse:
      type: object
      title: Image generation response
      description: The response from the image generation endpoint.
      properties:
        created:
          type: integer
          format: unixtime
          description: The Unix timestamp (in seconds) of when the image was created.
        data:
          type: array
          description: The list of generated images.
          items:
            $ref: '#/components/schemas/Image'
        background:
          type: string
          description: >-
            The background parameter used for the image generation. Either
            `transparent` or `opaque`.
          enum:
            - transparent
            - opaque
        output_format:
          type: string
          description: >-
            The output format of the image generation. Either `png`, `webp`, or
            `jpeg`.
          enum:
            - png
            - webp
            - jpeg
        size:
          type: string
          description: >-
            The size of the image generated. Either `1024x1024`, `1024x1536`, or
            `1536x1024`.
          enum:
            - 1024x1024
            - 1024x1536
            - 1536x1024
        quality:
          type: string
          description: >-
            The quality of the image generated. Either `low`, `medium`, or
            `high`.
          enum:
            - low
            - medium
            - high
        usage:
          $ref: '#/components/schemas/ImageGenUsage'
      required:
        - created
      x-source:
        from: avs://openai/official
        authority: official
    ImageGenStreamEvent:
      anyOf:
        - $ref: '#/components/schemas/ImageGenPartialImageEvent'
        - $ref: '#/components/schemas/ImageGenCompletedEvent'
      discriminator:
        propertyName: type
      x-source:
        from: avs://openai/official
        authority: official
    GatewayError:
      type: object
      description: |
        OpenAI-compatible error envelope. Top-level `error` object carrying
        `message` / `type` / `param` / `code`. `request_id` lives in the
        `X-Request-Id` response header, not in the body. The legacy `upstream`
        field is no longer emitted.
      x-source:
        from: gateway
        authority: gateway
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
          properties:
            message:
              type: string
              description: Human-readable error message.
            type:
              type: string
              nullable: true
              description: >
                Error category. OpenAI-compatible values include

                invalid_request_error / authentication_error / permission_error
                /

                not_found_error / rate_limit_error, etc. The upstream value is

                passed through verbatim; the enum is not fixed.
            param:
              type: string
              nullable: true
              description: Name of the offending field, when applicable.
            code:
              nullable: true
              description: |
                Sub-error code. May be a string or integer (the gateway treats
                `code` as an arbitrary type).
    PartialImages:
      anyOf:
        - type: integer
          maximum: 3
          minimum: 0
          default: 0
          example: 1
          description: >
            The number of partial images to generate. This parameter is used for

            streaming responses that return partial images. Value must be
            between 0 and 3.

            When set to 0, the response will be a single image sent in one
            streaming event.


            Note that the final image may be sent before the full number of
            partial images

            are generated if the full image is generated more quickly.
        - type: 'null'
      x-source:
        from: avs://openai/official
        authority: official
    Image:
      type: object
      description: >-
        Represents the content or the URL of an image generated by the OpenAI
        API.
      properties:
        b64_json:
          type: string
          description: >-
            The base64-encoded JSON of the generated image. Returned by default
            for the GPT image models, and only present if `response_format` is
            set to `b64_json` for `dall-e-2` and `dall-e-3`.
        url:
          type: string
          format: uri
          description: >-
            When using `dall-e-2` or `dall-e-3`, the URL of the generated image
            if `response_format` is set to `url` (default value). Unsupported
            for the GPT image models.
        revised_prompt:
          type: string
          description: >-
            For `dall-e-3` only, the revised prompt that was used to generate
            the image.
      x-source:
        from: avs://openai/official
        authority: official
    ImageGenUsage:
      properties:
        input_tokens:
          type: integer
          description: The number of tokens (images and text) in the input prompt.
        total_tokens:
          type: integer
          description: >-
            The total number of tokens (images and text) used for the image
            generation.
        output_tokens:
          type: integer
          description: The number of output tokens generated by the model.
        output_tokens_details:
          $ref: '#/components/schemas/ImageGenOutputTokensDetails'
        input_tokens_details:
          $ref: '#/components/schemas/ImageGenInputUsageDetails'
      type: object
      required:
        - input_tokens
        - total_tokens
        - output_tokens
        - input_tokens_details
      title: Image generation usage
      description: >-
        For `gpt-image-1` only, the token usage information for the image
        generation.
      x-source:
        from: avs://openai/official
        authority: official
    ImageGenPartialImageEvent:
      type: object
      description: >
        Emitted when a partial image is available during image generation
        streaming.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `image_generation.partial_image`.
          enum:
            - image_generation.partial_image
        b64_json:
          type: string
          description: >
            Base64-encoded partial image data, suitable for rendering as an
            image.
        created_at:
          type: integer
          format: unixtime
          description: |
            The Unix timestamp when the event was created.
        size:
          type: string
          description: |
            The size of the requested image.
          enum:
            - 1024x1024
            - 1024x1536
            - 1536x1024
            - auto
        quality:
          type: string
          description: |
            The quality setting for the requested image.
          enum:
            - low
            - medium
            - high
            - auto
        background:
          type: string
          description: |
            The background setting for the requested image.
          enum:
            - transparent
            - opaque
            - auto
        output_format:
          type: string
          description: |
            The output format for the requested image.
          enum:
            - png
            - webp
            - jpeg
        partial_image_index:
          type: integer
          description: |
            0-based index for the partial image (streaming).
      required:
        - type
        - b64_json
        - created_at
        - size
        - quality
        - background
        - output_format
        - partial_image_index
      x-source:
        from: avs://openai/official
        authority: official
    ImageGenCompletedEvent:
      type: object
      description: >
        Emitted when image generation has completed and the final image is
        available.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `image_generation.completed`.
          enum:
            - image_generation.completed
        b64_json:
          type: string
          description: |
            Base64-encoded image data, suitable for rendering as an image.
        created_at:
          type: integer
          format: unixtime
          description: |
            The Unix timestamp when the event was created.
        size:
          type: string
          description: |
            The size of the generated image.
          enum:
            - 1024x1024
            - 1024x1536
            - 1536x1024
            - auto
        quality:
          type: string
          description: |
            The quality setting for the generated image.
          enum:
            - low
            - medium
            - high
            - auto
        background:
          type: string
          description: |
            The background setting for the generated image.
          enum:
            - transparent
            - opaque
            - auto
        output_format:
          type: string
          description: |
            The output format for the generated image.
          enum:
            - png
            - webp
            - jpeg
        usage:
          $ref: '#/components/schemas/ImagesUsage'
      required:
        - type
        - b64_json
        - created_at
        - size
        - quality
        - background
        - output_format
        - usage
      x-source:
        from: avs://openai/official
        authority: official
    ImageGenOutputTokensDetails:
      properties:
        image_tokens:
          type: integer
          description: The number of image output tokens generated by the model.
        text_tokens:
          type: integer
          description: The number of text output tokens generated by the model.
      type: object
      required:
        - image_tokens
        - text_tokens
      title: Image generation output token details
      description: The output token details for the image generation.
      x-source:
        from: avs://openai/official
        authority: official
    ImageGenInputUsageDetails:
      properties:
        text_tokens:
          type: integer
          description: The number of text tokens in the input prompt.
        image_tokens:
          type: integer
          description: The number of image tokens in the input prompt.
      type: object
      required:
        - text_tokens
        - image_tokens
      title: Input usage details
      description: The input tokens detailed information for the image generation.
      x-source:
        from: avs://openai/official
        authority: official
    ImagesUsage:
      type: object
      description: >
        For the GPT image models only, the token usage information for the image
        generation.
      required:
        - total_tokens
        - input_tokens
        - output_tokens
        - input_tokens_details
      properties:
        total_tokens:
          type: integer
          description: >
            The total number of tokens (images and text) used for the image
            generation.
        input_tokens:
          type: integer
          description: The number of tokens (images and text) in the input prompt.
        output_tokens:
          type: integer
          description: The number of image tokens in the output image.
        input_tokens_details:
          type: object
          description: The input tokens detailed information for the image generation.
          required:
            - text_tokens
            - image_tokens
          properties:
            text_tokens:
              type: integer
              description: The number of text tokens in the input prompt.
            image_tokens:
              type: integer
              description: The number of image tokens in the input prompt.
      x-source:
        from: avs://openai/official
        authority: official
  securitySchemes:
    gatewayBearer:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        Gateway-issued API key, formatted as `sk-gateway-xxxxxxxx`.
        Used by OpenAI-shaped endpoints (/v1/chat/completions, etc.).
      x-source:
        from: gateway
        authority: gateway

````