GPT Image 2.6 API
Use GPT Image 2.6 to generate images from text or edit them using reference images. First select a public model, then connect using the same image API.
¶ Select a Model
| Model | Selection and Access |
|---|---|
gpt-image-2.6-flare |
Flare model; see the corresponding model page for capabilities, pricing, and minimum request requirements |
gpt-image-2.6-sunburst |
Sunburst model; see the corresponding model page for capabilities, pricing, and minimum request requirements |
:official and :reverse variants |
Model ID suffixes are part of the public API names; see each model page for variant pricing and supported parameters |
¶ Prepare an Image Generation Request
Open a general-purpose application in the application list and click the copy button to the right of API KEY. Next, use this key to generate an image. If you use a restricted key, make sure it permits image generation; editing reference images also requires image editing permission.
¶ Generate Your First Image
export ACEDATACLOUD_API_KEY="YOUR_API_KEY"
curl --fail-with-body 'https://api.acedata.cloud/openai/images/generations' \
--header "Authorization: Bearer $ACEDATACLOUD_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2.6-flare",
"prompt": "A white ceramic coffee mug on a blue table, soft morning light, no text.",
"size": "1024x1024",
"n": 1,
"response_format": "url"
}'
¶ Response JSON
The following excerpt from an existing Images response shows where the task ID, model, and image URL appear. The model you selected and the image address are determined by the values returned by this request.
{
"success": true,
"task_id": "49848451-c624-4df9-9dc2-494018daaf4c",
"trace_id": "5ac021c2-2891-4eed-bfcf-4c6668ac1be1",
"created": 1788831893,
"data": [
{
"url": "https://cdn.acedata.cloud/assets/examples/gpt-image/49848451-c624-4df9-9dc2-494018daaf4c_0-b6d780a732ca.png"
}
]
}
After the synchronous response is returned, read the generated image from data[].url. To adjust the aspect ratio, quality, or output format, see the image generation guide. If you select the b64_json response format, decode the corresponding result according to the guide.
¶ Edit a Reference Image
Replace YOUR_IMAGE_URL with an accessible reference image URL, then describe what you want to change.
curl --fail-with-body 'https://api.acedata.cloud/openai/images/edits' \
--header "Authorization: Bearer $ACEDATACLOUD_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2.6-flare",
"image": "YOUR_IMAGE_URL",
"prompt": "Change the mug to dark green and keep the composition.",
"n": 1,
"response_format": "url"
}'
¶ Response JSON
The following excerpt from an existing Images response shows where the task ID, model, and image URL appear. The model you selected and the image address are determined by the values returned by this request.
{
"success": true,
"task_id": "49848451-c624-4df9-9dc2-494018daaf4c",
"trace_id": "5ac021c2-2891-4eed-bfcf-4c6668ac1be1",
"created": 1788831893,
"data": [
{
"url": "https://cdn.acedata.cloud/assets/examples/gpt-image/49848451-c624-4df9-9dc2-494018daaf4c_0-b6d780a732ca.png"
}
]
}
The edited image is also read from data[].url. See the image editing guide for input requirements for multiple images, masks, sizes, and formats.
¶ Long-Running Tasks and Error Recovery
When you need an asynchronous approach, set async=true according to the image API documentation and save the returned task ID. Use OpenAI task query to obtain the final result of the original task and avoid submitting it again while waiting. Handle authentication, balance, and parameter errors according to the error in the response, and retain the trace_id for troubleshooting.
See OpenAIAPI for complete call examples and access to more capabilities.
