---
title: "Create an image"
method: POST
path: "/images/generations"
tags: ["Images"]
---

# Create an image

`POST /images/generations`

Creates an image given a prompt using the OpenAI-compatible Images API.
The request returns one or more generated images as URLs or base64-encoded
JSON data.

Not every provider implements the Images API. Requests routed to a
provider that does not support it return `400 Bad Request` with an
explanatory error message; use `/chat/completions` for those providers.

## Query parameters

- `provider` 'ollama' | 'ollama_cloud' | 'groq' | 'llamacpp' | 'openai' | 'cloudflare' | 'cohere' | 'anthropic' | 'deepseek' | 'google' | 'mistral' | 'minimax' | 'moonshot' | 'nvidia' | 'zai'

## Request body

- CreateImageRequest — Request body for creating an image via the OpenAI-compatible Images API.
  - `prompt` string, required — A text description of the desired image.
  - `model` string — Model ID to use for image generation.
  - `n` integer — Number of images to generate.
  - `size` 'auto' | '256x256' | '512x512' | '1024x1024' | '1536x1024' | '1024x1536' | '1792x1024' | '1024x1792' — The size of the generated images. The GPT image models support `1024x1024`, `1536x1024`, `1024x1536`, and `auto`; `gpt-image-2` also accepts arbitrary `WIDTHxHEIGHT` values such as `1536x864`. `dall-e-2` supports `256x256`, `512x512`, and `1024x1024`; `dall-e-3` supports `1024x1024`, `1792x1024`, and `1024x1792`.
  - `quality` 'auto' | 'standard' | 'hd' | 'low' | 'medium' | 'high' — The quality of the image. `auto` selects the best quality for the model. The GPT image models support `low`, `medium`, and `high`; `dall-e-3` supports `standard` and `hd`; `dall-e-2` supports only `standard`.
  - `response_format` 'url' | 'b64_json' — The format in which the generated images are returned. Must be one of `url` or `b64_json`.

## Response `200`

Successful response

- ImagesResponse — Represents the result of an image generation request.
  - `created` integer, required — The Unix timestamp (in seconds) of when the image was created.
  - `data` Image[], required — The generated images.
    - `b64_json` string — The base64-encoded JSON of the generated image, if `response_format` is `b64_json`.
    - `url` string — The URL of the generated image, if `response_format` is `url` (default).
    - `revised_prompt` string — The prompt that was used to generate the image, if there was any revision to the prompt.
  - `usage` object — Usage statistics for the image generation request.
    - `total_tokens` integer — Total number of tokens used.
    - `input_tokens` integer — Number of input tokens.
    - `output_tokens` integer — Number of output tokens.
    - `input_tokens_details` object — A detailed breakdown of the input tokens.
      - `cached_tokens` integer — The number of tokens retrieved from the cache.

## Other responses

- `400` — The selected provider does not implement the Images API. The gateway returns this when a request is routed to a provider without Images support.
- `401` — Unauthorized
- `500` — Internal server error

## Changes

- **2026-07-31** `22669d27e4bb` — 2 breaking, 14 info
  - request property `quality` was restricted to a list of enum values
  - request property `size` was restricted to a list of enum values
  - added the new `1024x1024` enum value to the request property `size`
  - added the new `1024x1536` enum value to the request property `size`
  - …12 more
- **2026-07-31** `8f2868e30b5e` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/inference-gateway/apis/inference-gateway-api/changes/images/generations/post.md)

---

[API](https://skmtc.dev/inference-gateway/apis/inference-gateway-api.md) · [All operations](https://skmtc.dev/inference-gateway/apis/inference-gateway-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/inference-gateway/inference-gateway-api/revisions/fccc79b863aa/schema)
