Create image
Creates an image given a prompt using a GPT Image model. Learn more.
Body ParametersJSON
Number of frames for GIF output. Accepts integers from 2 through 16. Defaults to 9 when omitted. Only supported with output_format=gif. The requested size must satisfy the selected model’s GIF size limits. GIF output does not support streaming, partial images, masks, or custom output compression. Requires access to the GIF preview for the selected model.
Requested delay per GIF frame, in milliseconds. Defaults to 200 when omitted. GIF output rounds to the nearest 10 ms and caps the encoded delay at 655,350 ms per frame. Only supported with output_format=gif.
The number of images to generate. Must be between 1 and 10.
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.
The number of partial images to generate. This parameter is used for streaming responses that return partial images. Value must be between 0 and 3. When set to 0, the response will be a single image sent in one streaming event.
Note that the final image may be sent before the full number of partial images are generated if the full image is generated more quickly.
A stable identifier for an end user in your organization, used for safety monitoring and abuse detection. Hash a username or email address to avoid sending identifying information. A non-empty value takes precedence over the deprecated user parameter. If omitted, null, or empty, the API uses user when available. Learn more.
Generate the image in streaming mode. Defaults to false. See the
Image generation guide for more information.
This parameter is only supported for the GPT image models.
Deprecated: use safety_identifier instead. This parameter remains accepted for backward compatibility and is used when safety_identifier is omitted, null, or empty. Learn more.
Create image
curl https://api.openai.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-image-2.5-flare",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024"
}'
{
"created": 1713833628,
"data": [
{
"b64_json": "..."
}
],
"usage": {
"total_tokens": 100,
"input_tokens": 50,
"output_tokens": 50,
"input_tokens_details": {
"text_tokens": 10,
"image_tokens": 40
}
}
}
Create image
curl https://api.openai.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-image-2.5-flare",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024",
"stream": true
}' \
--no-buffer
event: image_generation.partial_image
data: {"type":"image_generation.partial_image","b64_json":"...","partial_image_index":0}
event: image_generation.completed
data: {"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}}}
Returns Examples
{
"created": 0,
"background": "transparent",
"data": [
{
"b64_json": "b64_json",
"revised_prompt": "revised_prompt",
"url": "https://example.com"
}
],
"output_format": "png",
"quality": "low",
"safety_identifier": "safety_identifier",
"size": "1024x1024",
"svg_usage": {
"input_tokens": 0,
"model": "model",
"output_tokens": 0,
"reasoning_tokens": 0,
"total_tokens": 0
},
"usage": {
"input_tokens": 0,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 0
},
"output_tokens": 0,
"total_tokens": 0,
"output_tokens_details": {
"image_tokens": 0,
"text_tokens": 0
}
}
}