Create image
Generate images from a text prompt.
/model/v1/images/generations● SupportedRequest body
modelstring必填Image model id; list candidates with listModels?type=image. Router support (supported): Verified to take effect.
Verified to take effect.
response_formatstring可选◐ Partially supportedImage response encoding. Only b64_json is accepted; url returns 400.
gpt-image-2 supports b64_json; url returns 400.
promptstring必填Text description of the image to generate. Router support (supported): Verified to take effect.
Verified to take effect.
ninteger可选Number of images to generate, from 1 to 10; defaults to 1. Router support (supported): Controls image count; zero returns 400 and values 1–10 are accepted.
Controls image count; zero returns 400 and values 1–10 are accepted.
sizestring可选◐ Partially supportedSize of the generated images. Router support (partial): gpt-image-2 supports tested 1024x1024 and 1024x1536 sizes; 512x512 returns 400.
gpt-image-2 supports tested 1024x1024 and 1024x1536 sizes; 512x512 returns 400.
qualitystring可选Quality of the generated images. Router support (supported): Verified to take effect.
Verified to take effect.
backgroundstring可选transparent returns a transparent PNG on gpt-image-2.
output_formatstring可选jpeg returns JPEG on gpt-image-2.
Returns
200
Platform errors (auth, rate limits, validation) and OCR errors use problem+json; other model call errors follow the endpoint's own format (OpenAI or Anthropic) — see error codes
Response
HTTP 200
Image generation response
application/json
| Name | Type | Description |
|---|---|---|
| created | integer | Unix time in seconds at which the images were created. |
| data | array<object> | Generated images. |
| data[].url | string | URL of the image; present when response_format is `url`. |
| data[].b64_json | string | Base64-encoded image; present when response_format is `b64_json`. |
| data[].revised_prompt | string | Prompt after the image model rewrote it, when the model reports it. |