# GPT-Image · Introduction

GPT-Image image generation, text-to-image and image-to-image. `model` is required: gpt-image-1 / gpt-image-1.5 / gpt-image-2 / gpt-image-2.5-flare / gpt-image-2.5-sunburst. For size, prefer official pixel sizes (default 1024x1024, up to 4K); `quality` is low / medium / high / auto.

The two capabilities on this page use the asynchronous form of `POST /v1/images/generations`: the request must carry `"async": true`, one image per request (`n` can only be 1), then poll `GET /v1/images/generations/{id}`. A gpt-image request without `async` goes to the synchronous OpenAI Images route (it returns `url` or `b64_json`); see "Synchronous call".

> This page uses the unified API: generate with `POST /v1/images/generations` (synchronous by default: it returns once the image is ready; add `"async": true` to get a task back immediately and poll `GET /v1/images/generations/{id}`), authenticate with `Authorization: Bearer <key>`; errors use the OpenAI format. General notes are in the Images guide.

## How to call
1. Generate: `POST /v1/images/generations`
2. Poll (async, or after a sync timeout): `GET /v1/images/generations/{id}`

Synchronous (default): the server waits for the image and answers 200 with `data[].url`; if it is still not done after 110 seconds it answers 202 with the task object and a `Location` header. The task keeps running, so do not resubmit (there is no double charge); fetch the result with `GET /v1/images/generations/{id}`. Asynchronous (`"async": true` or the `Prefer: respond-async` header): answers 202 with the task object right away (`status: queued`, `Retry-After: 3`); poll with GET until `status` is `completed` or `failed`.

## Capability map
- **Text to Image** — Generate an image from text.
- **Image to Image** — Generate a new image from a reference + text.
- **Synchronous call (GPT-Image)** — Generate an image synchronously via the OpenAI Images protocol — a single request returns the image (url or b64_json), no polling.

## Common errors
| Status | code | When |
| --- | --- | --- |
| 400 | `invalid_request` | Validation failed (`n` above the model limit, missing `prompt`, `images` not http(s) URLs, an edit / image-to-image model without a reference image, `response_format` other than `url`, …); the reason is in `message`. Rejected before submission, nothing is charged. |
| 400 | `content_policy_violation` | The prompt or inputs were blocked by content rules. |
| 401 | `invalid_api_key` | The key is missing or invalid. |
| 402 | `insufficient_quota` | Insufficient balance. |
| 403 | `model_not_allowed` | The model is not on the key allowlist. |
| 404 | `model_not_found` | Not a supported model. |
| 404 | `not_found` | The task id does not exist or belongs to another account (only the key owner can read a task). |
| 429 | `task_limit_reached` | The concurrent task limit was reached. |
| 502 | `image_generation_failed` | The task failed during a synchronous request. |

A task that fails after submission: when polling, `status: failed` with `error` (`code` is `image_generation_failed`); a synchronous request answers 502 with the same code. Pre-deducted credits are refunded automatically.
