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

# Generate an image

> POST /v1/images/generations — text-to-image generation.

```bash theme={null}
curl https://api.infery.ai/v1/images/generations \
  -H "Authorization: Bearer $INFERY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "An isometric dev dashboard, neon green accents, dark theme",
    "size": "1024x1024",
    "n": 1
  }'
```

### Sample output

<Frame>
  <img src="https://mintcdn.com/inferyai/5YDpMTITcUUspdCA/samples/image.png?fit=max&auto=format&n=5YDpMTITcUUspdCA&q=85&s=2f7c6a22252e41004c0e7d721f028888" alt="Generated image sample" width="1024" height="1024" data-path="samples/image.png" />
</Frame>

*Generated with `gemini-2.5-flash-image` (Nano Banana).*

## Response formats

* `response_format: "url"` (default) → provider-hosted URL, ephemeral (\~1 hour). Download within that window if you need to keep it.
* `response_format: "b64_json"` → inline base64 PNG.

To persist the image forever, upload the decoded bytes via `POST /v1/files`.

## Supported models

See [Models catalog](/models/catalog) filtered to image modality. OpenAI (DALL·E), Google (Imagen, Gemini Image), xAI (Grok Image), Alibaba (Qwen Image), Suno-music, FLUX (self-hosted) — all accessed by slug.

## Aspect ratios and sizes

Per-model; common values: `1024x1024`, `1792x1024`, `1024x1792`, `512x512`. Check a model's `allowedParams.supported_sizes` via `GET /v1/models/{slug}`.


## OpenAPI

````yaml openapi.json POST /v1/images/generations
openapi: 3.0.0
info:
  title: Infery Gateway
  description: >-
    Infery Inference Gateway — OpenAI-compatible API for LLMs, embeddings,
    images, audio, and video
  version: '1.0'
  contact: {}
servers:
  - url: https://api.infery.ai
    description: Production
  - url: http://localhost:3001
    description: Local
security: []
tags: []
paths:
  /v1/images/generations:
    post:
      tags:
        - Images
      summary: Create image generation
      operationId: createImageGeneration
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - prompt
              properties:
                model:
                  type: string
                  description: Model ID to use for generation
                prompt:
                  type: string
                  description: Text prompt describing the image to generate
                'n':
                  type: integer
                  description: >-
                    Number of images (model-specific max: DALL-E 3=1, Imagen=4,
                    GPT Image=4, DALL-E 2=10)
                  default: 1
                size:
                  type: string
                  description: >-
                    Image size. DALL-E: 256x256-1792x1024. GPT Image:
                    1024x1024/1024x1536/1536x1024/auto
                quality:
                  type: string
                  description: 'DALL-E: standard/hd. GPT Image: low/medium/high/auto'
                style:
                  type: string
                  enum:
                    - vivid
                    - natural
                  description: DALL-E only
                response_format:
                  type: string
                  enum:
                    - url
                    - b64_json
                  default: url
                  description: DALL-E only. GPT Image always returns b64_json
                aspect_ratio:
                  type: string
                  description: >-
                    Aspect ratio (Google models, see /v1/models for allowed
                    values)
                image_size:
                  type: string
                  description: >-
                    Output resolution: Imagen Standard/Ultra "1K"|"2K", Gemini 3
                    image "1K"|"2K"|"4K"
                person_generation:
                  type: string
                  enum:
                    - dont_allow
                    - allow_adult
                    - allow_all
                  description: Person generation policy (Google models)
                background:
                  type: string
                  enum:
                    - transparent
                    - opaque
                    - auto
                  description: Background type (GPT Image models only)
                output_format:
                  type: string
                  enum:
                    - png
                    - webp
                    - jpeg
                  description: Output file format (GPT Image models only)
                output_compression:
                  type: integer
                  description: Compression 0-100 (GPT Image, jpeg/webp only)
                input_fidelity:
                  type: string
                  enum:
                    - high
                    - low
                  description: Match style of input images (GPT Image 1/1.5 only)
                moderation:
                  type: string
                  enum:
                    - auto
                    - low
                  description: Content filter level (GPT Image only)
                negative_prompt:
                  type: string
                  description: What to exclude from the image (Imagen 4)
                seed:
                  type: integer
                  description: Seed for reproducibility (Imagen 4)
      responses:
        '200':
          description: >-
            Image generation result. When stream=true, returns SSE
            (text/event-stream) with progress events, then a final chunk with
            the result.
          content:
            application/json:
              schema:
                type: object
                properties:
                  created:
                    type: integer
                    example: 1713204900
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                          example: /samples/image.png
                          description: >-
                            Ephemeral provider-hosted URL. Download within ~1
                            hour.
                        b64_json:
                          type: string
                          description: >-
                            Inline base64-encoded PNG. Present when
                            response_format=b64_json.
                        revised_prompt:
                          type: string
                          description: Prompt rewritten by the model (DALL-E 3).
                    example:
                      - url: /samples/image.png
                        revised_prompt: >-
                          Isometric illustration of a glowing neon-green AI
                          control panel
                  credits_used:
                    type: integer
                    example: 40
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
        '401':
          description: Unauthorized — invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
        '404':
          description: Model not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
      security:
        - ApiKey: []
components:
  schemas:
    ErrorResponseDto:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetailDto'
      required:
        - error
    ErrorDetailDto:
      type: object
      properties:
        message:
          type: string
          example: Model not found
          description: Human-readable error message
        type:
          type: string
          example: invalid_request_error
          description: Error category
          enum:
            - invalid_request_error
            - authentication_error
            - permission_error
            - quota_exceeded
            - rate_limit_error
            - server_error
        code:
          type: object
          example: model_not_found
          nullable: true
          description: Stable machine-readable error code
        param:
          type: object
          example: model
          nullable: true
          description: >-
            Name of the request parameter that triggered the error, if
            applicable
      required:
        - message
        - type
        - code
        - param
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization
      description: 'API key in format: Bearer inf_***'

````