Repository Public
1# Images23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45## Create image variation67**post** `/images/variations`89Creates a variation of a given image. This endpoint only supports `dall-e-2`.1011### Returns1213- `ImagesResponse object { created, background, data, 4 more }`1415 The response from the image generation endpoint.1617 - `created: number`1819 The Unix timestamp (in seconds) of when the image was created.2021 - `background: optional "transparent" or "opaque"`2223 The background parameter used for the image generation. Either `transparent` or `opaque`.2425 - `"transparent"`2627 - `"opaque"`2829 - `data: optional array of Image`3031 The list of generated images.3233 - `b64_json: optional string`3435 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`.3637 - `revised_prompt: optional string`3839 For `dall-e-3` only, the revised prompt that was used to generate the image.4041 - `url: optional string`4243 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.4445 - `output_format: optional "png" or "webp" or "jpeg"`4647 The output format of the image generation. Either `png`, `webp`, or `jpeg`.4849 - `"png"`5051 - `"webp"`5253 - `"jpeg"`5455 - `quality: optional "low" or "medium" or "high" or 2 more`5657 The quality of the image generated. One of `low`, `medium`, `high`, `xhigh`, or `max`.5859 - `"low"`6061 - `"medium"`6263 - `"high"`6465 - `"xhigh"`6667 - `"max"`6869 - `size: optional string or "1024x1024" or "1024x1536" or "1536x1024"`7071 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.7273 - `string`7475 - `"1024x1024" or "1024x1536" or "1536x1024"`7677 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.7879 - `"1024x1024"`8081 - `"1024x1536"`8283 - `"1536x1024"`8485 - `usage: optional object { input_tokens, input_tokens_details, output_tokens, 2 more }`8687 For `gpt-image-1` only, the token usage information for the image generation.8889 - `input_tokens: number`9091 The number of tokens (images and text) in the input prompt.9293 - `input_tokens_details: object { image_tokens, text_tokens }`9495 The input tokens detailed information for the image generation.9697 - `image_tokens: number`9899 The number of image tokens in the input prompt.100101 - `text_tokens: number`102103 The number of text tokens in the input prompt.104105 - `output_tokens: number`106107 The number of output tokens generated by the model.108109 - `total_tokens: number`110111 The total number of tokens (images and text) used for the image generation.112113 - `output_tokens_details: optional object { image_tokens, text_tokens }`114115 The output token details for the image generation.116117 - `image_tokens: number`118119 The number of image output tokens generated by the model.120121 - `text_tokens: number`122123 The number of text output tokens generated by the model.124125### Example126127```http128curl https://api.openai.com/v1/images/variations \129 -H 'Content-Type: multipart/form-data' \130 -H "Authorization: Bearer $OPENAI_API_KEY" \131 -F 'image=@/path/to/image' \132 -F n=1 \133 -F response_format=url \134 -F size=1024x1024 \135 -F user=user-1234136```137138#### Response139140```json141{142 "created": 0,143 "background": "transparent",144 "data": [145 {146 "b64_json": "b64_json",147 "revised_prompt": "revised_prompt",148 "url": "https://example.com"149 }150 ],151 "output_format": "png",152 "quality": "low",153 "size": "1024x1024",154 "usage": {155 "input_tokens": 0,156 "input_tokens_details": {157 "image_tokens": 0,158 "text_tokens": 0159 },160 "output_tokens": 0,161 "total_tokens": 0,162 "output_tokens_details": {163 "image_tokens": 0,164 "text_tokens": 0165 }166 }167}168```169170### Example171172```http173curl https://api.openai.com/v1/images/variations \174 -H "Authorization: Bearer $OPENAI_API_KEY" \175 -F image="@otter.png" \176 -F n=2 \177 -F size="1024x1024"178```179180#### Response181182```json183{184 "created": 1589478378,185 "data": [186 {187 "url": "https://..."188 },189 {190 "url": "https://..."191 }192 ]193}194```195196## Create image edit197198**post** `/images/edits`199200Creates an edited or extended image given one or more source images and a prompt. This endpoint supports GPT Image models and `dall-e-2`.201202### Body Parameters203204- `images: array of object { file_id, image_url }`205206 Input image references to edit.207 For GPT image models, you can provide up to 16 images.208209 - `file_id: optional string`210211 The File API ID of an uploaded image to use as input.212213 - `image_url: optional string`214215 A fully qualified URL or base64-encoded data URL.216217- `prompt: string`218219 A text description of the desired image edit.220221- `background: optional "transparent" or "opaque" or "auto" or null`222223 Set the background of the generated image output. `gpt-image-2.5-sunburst` and `gpt-image-2.5-flare`, including their `2026-09-08` snapshots, support `opaque` and `transparent` backgrounds. Transparent backgrounds are available for supported GPT Image models. For `gpt-image-2` and `gpt-image-2-2026-04-21`, this support is in preview. When using `transparent`, set the output format to `png` or `webp`.224225 - `"transparent"`226227 - `"opaque"`228229 - `"auto"`230231- `input_fidelity: optional "high" or "low" or null`232233 Controls fidelity to the original input image(s).234235 - `"high"`236237 - `"low"`238239- `mask: optional object { file_id, image_url }`240241 Reference an input image by either URL or uploaded file ID.242 Provide exactly one of `image_url` or `file_id`.243244 - `file_id: optional string`245246 The File API ID of an uploaded image to use as input.247248 - `image_url: optional string`249250 A fully qualified URL or base64-encoded data URL.251252- `model: optional string or "gpt-image-1.5" or "gpt-image-2" or "gpt-image-2-2026-04-21" or 7 more or null`253254 The GPT image model to use for image editing, including `gpt-image-2`, its dated snapshot `gpt-image-2-2026-04-21`, `gpt-image-2.5-sunburst`, `gpt-image-2.5-sunburst-2026-09-08`, `gpt-image-2.5-flare`, and `gpt-image-2.5-flare-2026-09-08`.255256 - `string`257258 - `"gpt-image-1.5" or "gpt-image-2" or "gpt-image-2-2026-04-21" or 7 more`259260 The GPT image model to use for image editing, including `gpt-image-2`, its dated snapshot `gpt-image-2-2026-04-21`, `gpt-image-2.5-sunburst`, `gpt-image-2.5-sunburst-2026-09-08`, `gpt-image-2.5-flare`, and `gpt-image-2.5-flare-2026-09-08`.261262 - `"gpt-image-1.5"`263264 - `"gpt-image-2"`265266 - `"gpt-image-2-2026-04-21"`267268 - `"gpt-image-2.5-sunburst"`269270 - `"gpt-image-2.5-sunburst-2026-09-08"`271272 - `"gpt-image-2.5-flare"`273274 - `"gpt-image-2.5-flare-2026-09-08"`275276 - `"gpt-image-1"`277278 - `"gpt-image-1-mini"`279280 - `"chatgpt-image-latest"`281282- `moderation: optional "low" or "auto" or null`283284 Moderation level for GPT image models.285286 - `"low"`287288 - `"auto"`289290- `n: optional number or null`291292 The number of edited images to generate.293294- `output_compression: optional number or null`295296 Compression level for `jpeg` or `webp` output.297298- `output_format: optional "png" or "jpeg" or "webp" or null`299300 Output image format. Supported for GPT image models.301302 - `"png"`303304 - `"jpeg"`305306 - `"webp"`307308- `partial_images: optional number or null`309310 The number of partial images to generate. This parameter is used for311 streaming responses that return partial images. Value must be between 0 and 3.312 When set to 0, the response will be a single image sent in one streaming event.313314 Note that the final image may be sent before the full number of partial images315 are generated if the full image is generated more quickly.316317- `quality: optional "low" or "medium" or "high" or 3 more or null`318319 Output quality for GPT image models. The GPT image models support `low`, `medium`,320 and `high`. `gpt-image-2.5-sunburst` and `gpt-image-2.5-flare`, including their321 `2026-09-08` snapshots, also support `xhigh` and `max`. Defaults to `auto`.322323 - `"low"`324325 - `"medium"`326327 - `"high"`328329 - `"xhigh"`330331 - `"max"`332333 - `"auto"`334335- `size: optional string or "auto" or "1024x1024" or "1536x1024" or "1024x1536" or null`336337 The size of the generated images. For `gpt-image-2`, `gpt-image-2-2026-04-21`, `gpt-image-2.5-sunburst`, `gpt-image-2.5-sunburst-2026-09-08`, `gpt-image-2.5-flare`, and `gpt-image-2.5-flare-2026-09-08`, 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.338339 - `string`340341 - `"auto" or "1024x1024" or "1536x1024" or "1024x1536"`342343 The size of the generated images. For `gpt-image-2`, `gpt-image-2-2026-04-21`, `gpt-image-2.5-sunburst`, `gpt-image-2.5-sunburst-2026-09-08`, `gpt-image-2.5-flare`, and `gpt-image-2.5-flare-2026-09-08`, 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.344345 - `"auto"`346347 - `"1024x1024"`348349 - `"1536x1024"`350351 - `"1024x1536"`352353- `stream: optional boolean or null`354355 Stream partial image results as events.356357- `user: optional string`358359 A unique identifier representing your end-user, which can help OpenAI360 monitor and detect abuse.361362### Returns363364- `ImagesResponse object { created, background, data, 4 more }`365366 The response from the image generation endpoint.367368 - `created: number`369370 The Unix timestamp (in seconds) of when the image was created.371372 - `background: optional "transparent" or "opaque"`373374 The background parameter used for the image generation. Either `transparent` or `opaque`.375376 - `"transparent"`377378 - `"opaque"`379380 - `data: optional array of Image`381382 The list of generated images.383384 - `b64_json: optional string`385386 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`.387388 - `revised_prompt: optional string`389390 For `dall-e-3` only, the revised prompt that was used to generate the image.391392 - `url: optional string`393394 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.395396 - `output_format: optional "png" or "webp" or "jpeg"`397398 The output format of the image generation. Either `png`, `webp`, or `jpeg`.399400 - `"png"`401402 - `"webp"`403404 - `"jpeg"`405406 - `quality: optional "low" or "medium" or "high" or 2 more`407408 The quality of the image generated. One of `low`, `medium`, `high`, `xhigh`, or `max`.409410 - `"low"`411412 - `"medium"`413414 - `"high"`415416 - `"xhigh"`417418 - `"max"`419420 - `size: optional string or "1024x1024" or "1024x1536" or "1536x1024"`421422 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.423424 - `string`425426 - `"1024x1024" or "1024x1536" or "1536x1024"`427428 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.429430 - `"1024x1024"`431432 - `"1024x1536"`433434 - `"1536x1024"`435436 - `usage: optional object { input_tokens, input_tokens_details, output_tokens, 2 more }`437438 For `gpt-image-1` only, the token usage information for the image generation.439440 - `input_tokens: number`441442 The number of tokens (images and text) in the input prompt.443444 - `input_tokens_details: object { image_tokens, text_tokens }`445446 The input tokens detailed information for the image generation.447448 - `image_tokens: number`449450 The number of image tokens in the input prompt.451452 - `text_tokens: number`453454 The number of text tokens in the input prompt.455456 - `output_tokens: number`457458 The number of output tokens generated by the model.459460 - `total_tokens: number`461462 The total number of tokens (images and text) used for the image generation.463464 - `output_tokens_details: optional object { image_tokens, text_tokens }`465466 The output token details for the image generation.467468 - `image_tokens: number`469470 The number of image output tokens generated by the model.471472 - `text_tokens: number`473474 The number of text output tokens generated by the model.475476### Example477478```http479curl https://api.openai.com/v1/images/edits \480 -H 'Content-Type: application/json' \481 -H "Authorization: Bearer $OPENAI_API_KEY" \482 -d '{483 "images": [484 {485 "image_url": "https://example.com/source-image.png"486 }487 ],488 "prompt": "Add a watercolor effect to this image",489 "model": "gpt-image-1.5",490 "quality": "high",491 "size": "1024x1024"492 }'493```494495#### Response496497```json498{499 "created": 0,500 "background": "transparent",501 "data": [502 {503 "b64_json": "b64_json",504 "revised_prompt": "revised_prompt",505 "url": "https://example.com"506 }507 ],508 "output_format": "png",509 "quality": "low",510 "size": "1024x1024",511 "usage": {512 "input_tokens": 0,513 "input_tokens_details": {514 "image_tokens": 0,515 "text_tokens": 0516 },517 "output_tokens": 0,518 "total_tokens": 0,519 "output_tokens_details": {520 "image_tokens": 0,521 "text_tokens": 0522 }523 }524}525```526527### Edit image528529```http530curl -s -D >(grep -i x-request-id >&2) \531 -o >(jq -r '.data[0].b64_json' | base64 --decode > gift-basket.png) \532 -X POST "https://api.openai.com/v1/images/edits" \533 -H "Authorization: Bearer $OPENAI_API_KEY" \534 -F "model=gpt-image-1.5" \535 -F "image[]=@body-lotion.png" \536 -F "image[]=@bath-bomb.png" \537 -F "image[]=@incense-kit.png" \538 -F "image[]=@soap.png" \539 -F 'prompt=Create a lovely gift basket with these four items in it'540```541542### Streaming543544```http545curl -s -N -X POST "https://api.openai.com/v1/images/edits" \546 -H "Authorization: Bearer $OPENAI_API_KEY" \547 -F "model=gpt-image-1.5" \548 -F "image[]=@body-lotion.png" \549 -F "image[]=@bath-bomb.png" \550 -F "image[]=@incense-kit.png" \551 -F "image[]=@soap.png" \552 -F 'prompt=Create a lovely gift basket with these four items in it' \553 -F "stream=true"554```555556#### Response557558```json559event: image_edit.partial_image560data: {"type":"image_edit.partial_image","b64_json":"...","partial_image_index":0}561562event: image_edit.completed563data: {"type":"image_edit.completed","b64_json":"...","usage":{"total_tokens":100,"input_tokens":50,"output_tokens":50,"input_tokens_details":{"text_tokens":10,"image_tokens":40}}}564```565566## Create image567568**post** `/images/generations`569570Creates an image given a prompt. [Learn more](/api/docs/guides/images-vision).571572### Body Parameters573574- `prompt: string`575576 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`.577578- `background: optional "transparent" or "opaque" or "auto" or null`579580 Set the background of the generated image(s). This parameter is only supported for581 the GPT image models. Must be one of `transparent`, `opaque`, or `auto` (default582 value). When `auto` is used, the model will automatically determine the best583 background for the image.584585 `gpt-image-2.5-sunburst` and `gpt-image-2.5-flare`, including their `2026-09-08`586 snapshots, support `opaque` and `transparent` backgrounds. Transparent backgrounds587 are available for supported GPT Image models. For `gpt-image-2` and588 `gpt-image-2-2026-04-21`, this support is in preview. When using `transparent`,589 set the output format to `png` or `webp`.590591 - `"transparent"`592593 - `"opaque"`594595 - `"auto"`596597- `model: optional string or ImageModel or null`598599 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`, `gpt-image-2`, `gpt-image-2-2026-04-21`, `gpt-image-2.5-sunburst`, `gpt-image-2.5-sunburst-2026-09-08`, `gpt-image-2.5-flare`, `gpt-image-2.5-flare-2026-09-08`). Defaults to `dall-e-2` unless a parameter specific to the GPT image models is used.600601 - `string`602603 - `ImageModel = "gpt-image-1.5" or "gpt-image-2" or "gpt-image-2-2026-04-21" or 8 more`604605 - `"gpt-image-1.5"`606607 - `"gpt-image-2"`608609 - `"gpt-image-2-2026-04-21"`610611 - `"gpt-image-2.5-sunburst"`612613 - `"gpt-image-2.5-sunburst-2026-09-08"`614615 - `"gpt-image-2.5-flare"`616617 - `"gpt-image-2.5-flare-2026-09-08"`618619 - `"dall-e-2"`620621 - `"dall-e-3"`622623 - `"gpt-image-1"`624625 - `"gpt-image-1-mini"`626627- `moderation: optional "low" or "auto" or null`628629 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).630631 - `"low"`632633 - `"auto"`634635- `n: optional number or null`636637 The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported.638639- `output_compression: optional number or null`640641 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.642643- `output_format: optional "png" or "jpeg" or "webp" or null`644645 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`.646647 - `"png"`648649 - `"jpeg"`650651 - `"webp"`652653- `partial_images: optional number or null`654655 The number of partial images to generate. This parameter is used for656 streaming responses that return partial images. Value must be between 0 and 3.657 When set to 0, the response will be a single image sent in one streaming event.658659 Note that the final image may be sent before the full number of partial images660 are generated if the full image is generated more quickly.661662- `quality: optional "standard" or "hd" or "low" or 5 more or null`663664 The quality of the image that will be generated.665666 - `auto` (default value) will automatically select the best quality for the given667 model.668 - `high`, `medium` and `low` are supported for the GPT image models.669 - `gpt-image-2.5-sunburst` and `gpt-image-2.5-flare`, including their `2026-09-08`670 snapshots, also support `xhigh` and `max`.671 - `hd` and `standard` are supported for `dall-e-3`.672 - `standard` is the only option for `dall-e-2`.673674 - `"standard"`675676 - `"hd"`677678 - `"low"`679680 - `"medium"`681682 - `"high"`683684 - `"xhigh"`685686 - `"max"`687688 - `"auto"`689690- `response_format: optional "url" or "b64_json" or null`691692 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.693694 - `"url"`695696 - `"b64_json"`697698- `size: optional string or "auto" or "1024x1024" or "1536x1024" or 5 more or null`699700 The size of the generated images. For `gpt-image-2`, `gpt-image-2-2026-04-21`, `gpt-image-2.5-sunburst`, `gpt-image-2.5-sunburst-2026-09-08`, `gpt-image-2.5-flare`, and `gpt-image-2.5-flare-2026-09-08`, 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`.701702 - `string`703704 - `"auto" or "1024x1024" or "1536x1024" or 5 more`705706 The size of the generated images. For `gpt-image-2`, `gpt-image-2-2026-04-21`, `gpt-image-2.5-sunburst`, `gpt-image-2.5-sunburst-2026-09-08`, `gpt-image-2.5-flare`, and `gpt-image-2.5-flare-2026-09-08`, 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`.707708 - `"auto"`709710 - `"1024x1024"`711712 - `"1536x1024"`713714 - `"1024x1536"`715716 - `"256x256"`717718 - `"512x512"`719720 - `"1792x1024"`721722 - `"1024x1792"`723724- `stream: optional boolean or null`725726 Generate the image in streaming mode. Defaults to `false`. See the727 [Image generation guide](/api/docs/guides/image-generation) for more information.728 This parameter is only supported for the GPT image models.729730- `style: optional "vivid" or "natural" or null`731732 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.733734 - `"vivid"`735736 - `"natural"`737738- `user: optional string`739740 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/api/docs/guides/safety-best-practices#implement-safety-identifiers).741742### Returns743744- `ImagesResponse object { created, background, data, 4 more }`745746 The response from the image generation endpoint.747748 - `created: number`749750 The Unix timestamp (in seconds) of when the image was created.751752 - `background: optional "transparent" or "opaque"`753754 The background parameter used for the image generation. Either `transparent` or `opaque`.755756 - `"transparent"`757758 - `"opaque"`759760 - `data: optional array of Image`761762 The list of generated images.763764 - `b64_json: optional string`765766 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`.767768 - `revised_prompt: optional string`769770 For `dall-e-3` only, the revised prompt that was used to generate the image.771772 - `url: optional string`773774 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.775776 - `output_format: optional "png" or "webp" or "jpeg"`777778 The output format of the image generation. Either `png`, `webp`, or `jpeg`.779780 - `"png"`781782 - `"webp"`783784 - `"jpeg"`785786 - `quality: optional "low" or "medium" or "high" or 2 more`787788 The quality of the image generated. One of `low`, `medium`, `high`, `xhigh`, or `max`.789790 - `"low"`791792 - `"medium"`793794 - `"high"`795796 - `"xhigh"`797798 - `"max"`799800 - `size: optional string or "1024x1024" or "1024x1536" or "1536x1024"`801802 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.803804 - `string`805806 - `"1024x1024" or "1024x1536" or "1536x1024"`807808 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.809810 - `"1024x1024"`811812 - `"1024x1536"`813814 - `"1536x1024"`815816 - `usage: optional object { input_tokens, input_tokens_details, output_tokens, 2 more }`817818 For `gpt-image-1` only, the token usage information for the image generation.819820 - `input_tokens: number`821822 The number of tokens (images and text) in the input prompt.823824 - `input_tokens_details: object { image_tokens, text_tokens }`825826 The input tokens detailed information for the image generation.827828 - `image_tokens: number`829830 The number of image tokens in the input prompt.831832 - `text_tokens: number`833834 The number of text tokens in the input prompt.835836 - `output_tokens: number`837838 The number of output tokens generated by the model.839840 - `total_tokens: number`841842 The total number of tokens (images and text) used for the image generation.843844 - `output_tokens_details: optional object { image_tokens, text_tokens }`845846 The output token details for the image generation.847848 - `image_tokens: number`849850 The number of image output tokens generated by the model.851852 - `text_tokens: number`853854 The number of text output tokens generated by the model.855856### Example857858```http859curl https://api.openai.com/v1/images/generations \860 -H 'Content-Type: application/json' \861 -H "Authorization: Bearer $OPENAI_API_KEY" \862 -d '{863 "prompt": "A cute baby sea otter",864 "background": "transparent",865 "moderation": "low",866 "n": 1,867 "output_compression": 100,868 "output_format": "png",869 "partial_images": 1,870 "quality": "medium",871 "response_format": "url",872 "style": "vivid",873 "user": "user-1234"874 }'875```876877#### Response878879```json880{881 "created": 0,882 "background": "transparent",883 "data": [884 {885 "b64_json": "b64_json",886 "revised_prompt": "revised_prompt",887 "url": "https://example.com"888 }889 ],890 "output_format": "png",891 "quality": "low",892 "size": "1024x1024",893 "usage": {894 "input_tokens": 0,895 "input_tokens_details": {896 "image_tokens": 0,897 "text_tokens": 0898 },899 "output_tokens": 0,900 "total_tokens": 0,901 "output_tokens_details": {902 "image_tokens": 0,903 "text_tokens": 0904 }905 }906}907```908909### Generate image910911```http912curl https://api.openai.com/v1/images/generations \913 -H "Content-Type: application/json" \914 -H "Authorization: Bearer $OPENAI_API_KEY" \915 -d '{916 "model": "gpt-image-2.5-flare",917 "prompt": "A cute baby sea otter",918 "n": 1,919 "size": "1024x1024"920 }'921```922923#### Response924925```json926{927 "created": 1713833628,928 "data": [929 {930 "b64_json": "..."931 }932 ],933 "usage": {934 "total_tokens": 100,935 "input_tokens": 50,936 "output_tokens": 50,937 "input_tokens_details": {938 "text_tokens": 10,939 "image_tokens": 40940 }941 }942}943```944945### Streaming946947```http948curl https://api.openai.com/v1/images/generations \949 -H "Content-Type: application/json" \950 -H "Authorization: Bearer $OPENAI_API_KEY" \951 -d '{952 "model": "gpt-image-2.5-flare",953 "prompt": "A cute baby sea otter",954 "n": 1,955 "size": "1024x1024",956 "stream": true957 }' \958 --no-buffer959```960961#### Response962963```json964event: image_generation.partial_image965data: {"type":"image_generation.partial_image","b64_json":"...","partial_image_index":0}966967event: image_generation.completed968data: {"type":"image_generation.completed","b64_json":"...","usage":{"total_tokens":100,"input_tokens":50,"output_tokens":50,"input_tokens_details":{"text_tokens":10,"image_tokens":40}}}969```970971## Domain Types972973### Image974975- `Image object { b64_json, revised_prompt, url }`976977 Represents the content or the URL of an image generated by the OpenAI API.978979 - `b64_json: optional string`980981 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`.982983 - `revised_prompt: optional string`984985 For `dall-e-3` only, the revised prompt that was used to generate the image.986987 - `url: optional string`988989 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.990991### Image Edit Completed Event992993- `ImageEditCompletedEvent object { b64_json, background, created_at, 5 more }`994995 Emitted when image editing has completed and the final image is available.996997 - `b64_json: string`998999 Base64-encoded final edited image data, suitable for rendering as an image.10001001 - `background: "transparent" or "opaque" or "auto"`10021003 The background setting for the edited image.10041005 - `"transparent"`10061007 - `"opaque"`10081009 - `"auto"`10101011 - `created_at: number`10121013 The Unix timestamp when the event was created.10141015 - `output_format: "png" or "webp" or "jpeg"`10161017 The output format for the edited image.10181019 - `"png"`10201021 - `"webp"`10221023 - `"jpeg"`10241025 - `quality: "low" or "medium" or "high" or 3 more`10261027 The quality setting for the edited image.10281029 - `"low"`10301031 - `"medium"`10321033 - `"high"`10341035 - `"xhigh"`10361037 - `"max"`10381039 - `"auto"`10401041 - `size: string or "1024x1024" or "1024x1536" or "1536x1024" or "auto"`10421043 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.10441045 - `string`10461047 - `"1024x1024" or "1024x1536" or "1536x1024" or "auto"`10481049 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.10501051 - `"1024x1024"`10521053 - `"1024x1536"`10541055 - `"1536x1024"`10561057 - `"auto"`10581059 - `type: "image_edit.completed"`10601061 The type of the event. Always `image_edit.completed`.10621063 - `"image_edit.completed"`10641065 - `usage: object { input_tokens, input_tokens_details, output_tokens, total_tokens }`10661067 For the GPT image models only, the token usage information for the image generation.10681069 - `input_tokens: number`10701071 The number of tokens (images and text) in the input prompt.10721073 - `input_tokens_details: object { image_tokens, text_tokens }`10741075 The input tokens detailed information for the image generation.10761077 - `image_tokens: number`10781079 The number of image tokens in the input prompt.10801081 - `text_tokens: number`10821083 The number of text tokens in the input prompt.10841085 - `output_tokens: number`10861087 The number of image tokens in the output image.10881089 - `total_tokens: number`10901091 The total number of tokens (images and text) used for the image generation.10921093### Image Edit Partial Image Event10941095- `ImageEditPartialImageEvent object { b64_json, background, created_at, 5 more }`10961097 Emitted when a partial image is available during image editing streaming.10981099 - `b64_json: string`11001101 Base64-encoded partial image data, suitable for rendering as an image.11021103 - `background: "transparent" or "opaque" or "auto"`11041105 The background setting for the requested edited image.11061107 - `"transparent"`11081109 - `"opaque"`11101111 - `"auto"`11121113 - `created_at: number`11141115 The Unix timestamp when the event was created.11161117 - `output_format: "png" or "webp" or "jpeg"`11181119 The output format for the requested edited image.11201121 - `"png"`11221123 - `"webp"`11241125 - `"jpeg"`11261127 - `partial_image_index: number`11281129 0-based index for the partial image (streaming).11301131 - `quality: "low" or "medium" or "high" or 3 more`11321133 The quality setting for the requested edited image.11341135 - `"low"`11361137 - `"medium"`11381139 - `"high"`11401141 - `"xhigh"`11421143 - `"max"`11441145 - `"auto"`11461147 - `size: string or "1024x1024" or "1024x1536" or "1536x1024" or "auto"`11481149 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.11501151 - `string`11521153 - `"1024x1024" or "1024x1536" or "1536x1024" or "auto"`11541155 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.11561157 - `"1024x1024"`11581159 - `"1024x1536"`11601161 - `"1536x1024"`11621163 - `"auto"`11641165 - `type: "image_edit.partial_image"`11661167 The type of the event. Always `image_edit.partial_image`.11681169 - `"image_edit.partial_image"`11701171### Image Edit Stream Event11721173- `ImageEditStreamEvent = ImageEditPartialImageEvent or ImageEditCompletedEvent`11741175 Emitted when a partial image is available during image editing streaming.11761177 - `ImageEditPartialImageEvent object { b64_json, background, created_at, 5 more }`11781179 Emitted when a partial image is available during image editing streaming.11801181 - `b64_json: string`11821183 Base64-encoded partial image data, suitable for rendering as an image.11841185 - `background: "transparent" or "opaque" or "auto"`11861187 The background setting for the requested edited image.11881189 - `"transparent"`11901191 - `"opaque"`11921193 - `"auto"`11941195 - `created_at: number`11961197 The Unix timestamp when the event was created.11981199 - `output_format: "png" or "webp" or "jpeg"`12001201 The output format for the requested edited image.12021203 - `"png"`12041205 - `"webp"`12061207 - `"jpeg"`12081209 - `partial_image_index: number`12101211 0-based index for the partial image (streaming).12121213 - `quality: "low" or "medium" or "high" or 3 more`12141215 The quality setting for the requested edited image.12161217 - `"low"`12181219 - `"medium"`12201221 - `"high"`12221223 - `"xhigh"`12241225 - `"max"`12261227 - `"auto"`12281229 - `size: string or "1024x1024" or "1024x1536" or "1536x1024" or "auto"`12301231 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.12321233 - `string`12341235 - `"1024x1024" or "1024x1536" or "1536x1024" or "auto"`12361237 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.12381239 - `"1024x1024"`12401241 - `"1024x1536"`12421243 - `"1536x1024"`12441245 - `"auto"`12461247 - `type: "image_edit.partial_image"`12481249 The type of the event. Always `image_edit.partial_image`.12501251 - `"image_edit.partial_image"`12521253 - `ImageEditCompletedEvent object { b64_json, background, created_at, 5 more }`12541255 Emitted when image editing has completed and the final image is available.12561257 - `b64_json: string`12581259 Base64-encoded final edited image data, suitable for rendering as an image.12601261 - `background: "transparent" or "opaque" or "auto"`12621263 The background setting for the edited image.12641265 - `"transparent"`12661267 - `"opaque"`12681269 - `"auto"`12701271 - `created_at: number`12721273 The Unix timestamp when the event was created.12741275 - `output_format: "png" or "webp" or "jpeg"`12761277 The output format for the edited image.12781279 - `"png"`12801281 - `"webp"`12821283 - `"jpeg"`12841285 - `quality: "low" or "medium" or "high" or 3 more`12861287 The quality setting for the edited image.12881289 - `"low"`12901291 - `"medium"`12921293 - `"high"`12941295 - `"xhigh"`12961297 - `"max"`12981299 - `"auto"`13001301 - `size: string or "1024x1024" or "1024x1536" or "1536x1024" or "auto"`13021303 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.13041305 - `string`13061307 - `"1024x1024" or "1024x1536" or "1536x1024" or "auto"`13081309 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.13101311 - `"1024x1024"`13121313 - `"1024x1536"`13141315 - `"1536x1024"`13161317 - `"auto"`13181319 - `type: "image_edit.completed"`13201321 The type of the event. Always `image_edit.completed`.13221323 - `"image_edit.completed"`13241325 - `usage: object { input_tokens, input_tokens_details, output_tokens, total_tokens }`13261327 For the GPT image models only, the token usage information for the image generation.13281329 - `input_tokens: number`13301331 The number of tokens (images and text) in the input prompt.13321333 - `input_tokens_details: object { image_tokens, text_tokens }`13341335 The input tokens detailed information for the image generation.13361337 - `image_tokens: number`13381339 The number of image tokens in the input prompt.13401341 - `text_tokens: number`13421343 The number of text tokens in the input prompt.13441345 - `output_tokens: number`13461347 The number of image tokens in the output image.13481349 - `total_tokens: number`13501351 The total number of tokens (images and text) used for the image generation.13521353### Image Gen Completed Event13541355- `ImageGenCompletedEvent object { b64_json, background, created_at, 5 more }`13561357 Emitted when image generation has completed and the final image is available.13581359 - `b64_json: string`13601361 Base64-encoded image data, suitable for rendering as an image.13621363 - `background: "transparent" or "opaque" or "auto"`13641365 The background setting for the generated image.13661367 - `"transparent"`13681369 - `"opaque"`13701371 - `"auto"`13721373 - `created_at: number`13741375 The Unix timestamp when the event was created.13761377 - `output_format: "png" or "webp" or "jpeg"`13781379 The output format for the generated image.13801381 - `"png"`13821383 - `"webp"`13841385 - `"jpeg"`13861387 - `quality: "low" or "medium" or "high" or 3 more`13881389 The quality setting for the generated image.13901391 - `"low"`13921393 - `"medium"`13941395 - `"high"`13961397 - `"xhigh"`13981399 - `"max"`14001401 - `"auto"`14021403 - `size: string or "1024x1024" or "1024x1536" or "1536x1024" or "auto"`14041405 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.14061407 - `string`14081409 - `"1024x1024" or "1024x1536" or "1536x1024" or "auto"`14101411 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.14121413 - `"1024x1024"`14141415 - `"1024x1536"`14161417 - `"1536x1024"`14181419 - `"auto"`14201421 - `type: "image_generation.completed"`14221423 The type of the event. Always `image_generation.completed`.14241425 - `"image_generation.completed"`14261427 - `usage: object { input_tokens, input_tokens_details, output_tokens, total_tokens }`14281429 For the GPT image models only, the token usage information for the image generation.14301431 - `input_tokens: number`14321433 The number of tokens (images and text) in the input prompt.14341435 - `input_tokens_details: object { image_tokens, text_tokens }`14361437 The input tokens detailed information for the image generation.14381439 - `image_tokens: number`14401441 The number of image tokens in the input prompt.14421443 - `text_tokens: number`14441445 The number of text tokens in the input prompt.14461447 - `output_tokens: number`14481449 The number of image tokens in the output image.14501451 - `total_tokens: number`14521453 The total number of tokens (images and text) used for the image generation.14541455### Image Gen Partial Image Event14561457- `ImageGenPartialImageEvent object { b64_json, background, created_at, 5 more }`14581459 Emitted when a partial image is available during image generation streaming.14601461 - `b64_json: string`14621463 Base64-encoded partial image data, suitable for rendering as an image.14641465 - `background: "transparent" or "opaque" or "auto"`14661467 The background setting for the requested image.14681469 - `"transparent"`14701471 - `"opaque"`14721473 - `"auto"`14741475 - `created_at: number`14761477 The Unix timestamp when the event was created.14781479 - `output_format: "png" or "webp" or "jpeg"`14801481 The output format for the requested image.14821483 - `"png"`14841485 - `"webp"`14861487 - `"jpeg"`14881489 - `partial_image_index: number`14901491 0-based index for the partial image (streaming).14921493 - `quality: "low" or "medium" or "high" or 3 more`14941495 The quality setting for the requested image.14961497 - `"low"`14981499 - `"medium"`15001501 - `"high"`15021503 - `"xhigh"`15041505 - `"max"`15061507 - `"auto"`15081509 - `size: string or "1024x1024" or "1024x1536" or "1536x1024" or "auto"`15101511 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.15121513 - `string`15141515 - `"1024x1024" or "1024x1536" or "1536x1024" or "auto"`15161517 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.15181519 - `"1024x1024"`15201521 - `"1024x1536"`15221523 - `"1536x1024"`15241525 - `"auto"`15261527 - `type: "image_generation.partial_image"`15281529 The type of the event. Always `image_generation.partial_image`.15301531 - `"image_generation.partial_image"`15321533### Image Gen Stream Event15341535- `ImageGenStreamEvent = ImageGenPartialImageEvent or ImageGenCompletedEvent`15361537 Emitted when a partial image is available during image generation streaming.15381539 - `ImageGenPartialImageEvent object { b64_json, background, created_at, 5 more }`15401541 Emitted when a partial image is available during image generation streaming.15421543 - `b64_json: string`15441545 Base64-encoded partial image data, suitable for rendering as an image.15461547 - `background: "transparent" or "opaque" or "auto"`15481549 The background setting for the requested image.15501551 - `"transparent"`15521553 - `"opaque"`15541555 - `"auto"`15561557 - `created_at: number`15581559 The Unix timestamp when the event was created.15601561 - `output_format: "png" or "webp" or "jpeg"`15621563 The output format for the requested image.15641565 - `"png"`15661567 - `"webp"`15681569 - `"jpeg"`15701571 - `partial_image_index: number`15721573 0-based index for the partial image (streaming).15741575 - `quality: "low" or "medium" or "high" or 3 more`15761577 The quality setting for the requested image.15781579 - `"low"`15801581 - `"medium"`15821583 - `"high"`15841585 - `"xhigh"`15861587 - `"max"`15881589 - `"auto"`15901591 - `size: string or "1024x1024" or "1024x1536" or "1536x1024" or "auto"`15921593 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.15941595 - `string`15961597 - `"1024x1024" or "1024x1536" or "1536x1024" or "auto"`15981599 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.16001601 - `"1024x1024"`16021603 - `"1024x1536"`16041605 - `"1536x1024"`16061607 - `"auto"`16081609 - `type: "image_generation.partial_image"`16101611 The type of the event. Always `image_generation.partial_image`.16121613 - `"image_generation.partial_image"`16141615 - `ImageGenCompletedEvent object { b64_json, background, created_at, 5 more }`16161617 Emitted when image generation has completed and the final image is available.16181619 - `b64_json: string`16201621 Base64-encoded image data, suitable for rendering as an image.16221623 - `background: "transparent" or "opaque" or "auto"`16241625 The background setting for the generated image.16261627 - `"transparent"`16281629 - `"opaque"`16301631 - `"auto"`16321633 - `created_at: number`16341635 The Unix timestamp when the event was created.16361637 - `output_format: "png" or "webp" or "jpeg"`16381639 The output format for the generated image.16401641 - `"png"`16421643 - `"webp"`16441645 - `"jpeg"`16461647 - `quality: "low" or "medium" or "high" or 3 more`16481649 The quality setting for the generated image.16501651 - `"low"`16521653 - `"medium"`16541655 - `"high"`16561657 - `"xhigh"`16581659 - `"max"`16601661 - `"auto"`16621663 - `size: string or "1024x1024" or "1024x1536" or "1536x1024" or "auto"`16641665 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.16661667 - `string`16681669 - `"1024x1024" or "1024x1536" or "1536x1024" or "auto"`16701671 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.16721673 - `"1024x1024"`16741675 - `"1024x1536"`16761677 - `"1536x1024"`16781679 - `"auto"`16801681 - `type: "image_generation.completed"`16821683 The type of the event. Always `image_generation.completed`.16841685 - `"image_generation.completed"`16861687 - `usage: object { input_tokens, input_tokens_details, output_tokens, total_tokens }`16881689 For the GPT image models only, the token usage information for the image generation.16901691 - `input_tokens: number`16921693 The number of tokens (images and text) in the input prompt.16941695 - `input_tokens_details: object { image_tokens, text_tokens }`16961697 The input tokens detailed information for the image generation.16981699 - `image_tokens: number`17001701 The number of image tokens in the input prompt.17021703 - `text_tokens: number`17041705 The number of text tokens in the input prompt.17061707 - `output_tokens: number`17081709 The number of image tokens in the output image.17101711 - `total_tokens: number`17121713 The total number of tokens (images and text) used for the image generation.17141715### Image Model17161717- `ImageModel = "gpt-image-1.5" or "gpt-image-2" or "gpt-image-2-2026-04-21" or 8 more`17181719 - `"gpt-image-1.5"`17201721 - `"gpt-image-2"`17221723 - `"gpt-image-2-2026-04-21"`17241725 - `"gpt-image-2.5-sunburst"`17261727 - `"gpt-image-2.5-sunburst-2026-09-08"`17281729 - `"gpt-image-2.5-flare"`17301731 - `"gpt-image-2.5-flare-2026-09-08"`17321733 - `"dall-e-2"`17341735 - `"dall-e-3"`17361737 - `"gpt-image-1"`17381739 - `"gpt-image-1-mini"`17401741### Images Response17421743- `ImagesResponse object { created, background, data, 4 more }`17441745 The response from the image generation endpoint.17461747 - `created: number`17481749 The Unix timestamp (in seconds) of when the image was created.17501751 - `background: optional "transparent" or "opaque"`17521753 The background parameter used for the image generation. Either `transparent` or `opaque`.17541755 - `"transparent"`17561757 - `"opaque"`17581759 - `data: optional array of Image`17601761 The list of generated images.17621763 - `b64_json: optional string`17641765 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`.17661767 - `revised_prompt: optional string`17681769 For `dall-e-3` only, the revised prompt that was used to generate the image.17701771 - `url: optional string`17721773 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.17741775 - `output_format: optional "png" or "webp" or "jpeg"`17761777 The output format of the image generation. Either `png`, `webp`, or `jpeg`.17781779 - `"png"`17801781 - `"webp"`17821783 - `"jpeg"`17841785 - `quality: optional "low" or "medium" or "high" or 2 more`17861787 The quality of the image generated. One of `low`, `medium`, `high`, `xhigh`, or `max`.17881789 - `"low"`17901791 - `"medium"`17921793 - `"high"`17941795 - `"xhigh"`17961797 - `"max"`17981799 - `size: optional string or "1024x1024" or "1024x1536" or "1536x1024"`18001801 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.18021803 - `string`18041805 - `"1024x1024" or "1024x1536" or "1536x1024"`18061807 The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.18081809 - `"1024x1024"`18101811 - `"1024x1536"`18121813 - `"1536x1024"`18141815 - `usage: optional object { input_tokens, input_tokens_details, output_tokens, 2 more }`18161817 For `gpt-image-1` only, the token usage information for the image generation.18181819 - `input_tokens: number`18201821 The number of tokens (images and text) in the input prompt.18221823 - `input_tokens_details: object { image_tokens, text_tokens }`18241825 The input tokens detailed information for the image generation.18261827 - `image_tokens: number`18281829 The number of image tokens in the input prompt.18301831 - `text_tokens: number`18321833 The number of text tokens in the input prompt.18341835 - `output_tokens: number`18361837 The number of output tokens generated by the model.18381839 - `total_tokens: number`18401841 The total number of tokens (images and text) used for the image generation.18421843 - `output_tokens_details: optional object { image_tokens, text_tokens }`18441845 The output token details for the image generation.18461847 - `image_tokens: number`18481849 The number of image output tokens generated by the model.18501851 - `text_tokens: number`18521853 The number of text output tokens generated by the model.1854