Developer reference
GPT Image 2.6 API documentation
Create an API key, submit a generation request, then query the task to retrieve your image.
Create your API key
Sign in and create a key in your account. Set GPT_IMAGE_API_KEY to that key in your server environment before running the examples below.
Manage API keysKeep your key on your server. Both endpoints use Authorization: Bearer with your user API key and require no browser cookie.
Generation requests use credits from your account. Flare and Sunburst have the same credit cost for the same settings. See current image costs
Submit a generation request
POST /api/generate
Save the JSON below as request.json. This example creates an image from text. To edit with reference images, add the images array described below.
Request body: request.json
{
"model": "gpt-image-2.6",
"variant": "flare",
"prompt": "A blue ceramic cup on a wooden table against a warm paper background.",
"quality": "medium",
"resolution": "1k",
"complexity": "high",
"output_format": "png"
}Send from your server
curl --request POST https://gptimage-26.com/api/generate \
--header "Authorization: Bearer $GPT_IMAGE_API_KEY" \
--header "Content-Type: application/json" \
--data @request.jsonA successful submission returns code 200, data.task_id, data.status set to IN_PROGRESS, and data.consumed_credits. Save data.task_id for the status query.
Request fields
| Field | Meaning and accepted values |
|---|---|
model | Use gpt-image-2.6. This is also the default when omitted. |
variant | Optional: flare, sunburst. Default: flare. Set sunburst to use Sunburst. |
prompt | Required text, from 1 to 20000 characters after trimming surrounding whitespace. |
quality | Optional: low, medium, high, xhigh, max. Default: medium. |
resolution | Optional: 1k, 2k, 4k. Default: 1k. |
complexity | Composition planning, optional: low, medium, high. Default: high. |
output_format | Optional: png, jpeg, webp. Default: png. |
images | Optional array of up to 16 HTTP(S) image URLs. At least one reference image selects editing; omit this field for text-to-image generation. |
Query the task
GET /api/status
Set TASK_ID to the returned data.task_id. Send it as the task_id query parameter, with the same user API key.
curl --get https://gptimage-26.com/api/status \
--header "Authorization: Bearer $GPT_IMAGE_API_KEY" \
--data-urlencode "task_id=$TASK_ID"PENDING / IN_PROGRESS- The task is still running. Query this endpoint again to check its progress.
SUCCESS- Read the generated image URLs from the data.response array.
FAILED- Read data.error_message for the failure details before deciding whether to submit another request.
Example of a completed task
{
"code": 200,
"message": "success",
"data": {
"task_id": "<TASK_ID>",
"status": "SUCCESS",
"response": [
"<IMAGE_URL>"
],
"error_message": null
}
}Values in angle brackets are placeholders for the task ID and image URL returned by your request.