Docs / Image Series / GPT Image / Async
GPT Image Web Image Generation
Asynchronous image generation on the GPT Image Web channel using the model name gpt-image-web, supporting basic text-to-image, image-to-image, and size parameters.
Real-time success rate (--:--:--)
GPT Image Web (gpt-image-web) is an image generation model on the Web channel that supports basic text-to-image and image-to-image. This endpoint uses an asynchronous task mode: submission immediately returns a task ID, which you then poll through the query endpoint.
- Asynchronous mode uses a dedicated endpoint,POST /v1/images/async-generations, which returns atask_idon submission. Use the task query endpoint to fetch the result. - Generated image links are pre-signed URLs valid for about 24 hours; save them promptly.
Authentication#
All endpoints require Bearer token authentication. Create your key on the API Key management page and add it to the request header:
Authorization: Bearer YOUR_API_KEYCreate a task#
POST /v1/images/async-generations
Request parameters#
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | gpt-image-web | Model name, fixed as gpt-image-web |
prompt | string | Yes | — | The prompt describing the image to generate or edit. Up to 32,000 characters |
image_urls | array | No | — | List of reference image URLs for image-to-image/image editing. 1-16 images, each < 20MB |
size | string | No | auto | Image size, in ratio format (e.g. 16:9) or pixel format (e.g. 1024x1024); output is capped at 2K — larger sizes are downscaled to 2K |
callback_url | string | No | — | HTTPS callback URL invoked when the task completes |
size#
The default value is auto. You can pass a ratio or an explicit pixel size.
Ratio format:
| Ratio | Description |
|---|---|
1:1 | Square |
2:3 / 3:2 | Photo ratio (portrait / landscape) |
3:4 / 4:3 | Classic display ratio (portrait / landscape) |
4:5 / 5:4 | Social post ratio (portrait / landscape) |
9:16 / 16:9 | Video frame ratio (portrait / landscape) |
9:21 / 21:9 | Ultrawide ratio (portrait / landscape) |
1:2 / 2:1 | Elongated ratio (portrait / landscape) |
1:3 / 3:1 | Very elongated ratio (portrait / landscape) |
Pixel format: WIDTHxHEIGHT, e.g. 1024x1024, 1536x1024, 1920x1080. Width and height must be multiples of 16, each side within 16–3840, and the aspect ratio must not exceed 3:1.
Resolution cap: Generated images are output at up to 2K resolution. Passing a larger size (e.g. 3840x2160) does not error; it is automatically downscaled to at most 2K.
Request examples#
The request body has the same structure as the synchronous OpenAI Images API. Minimal text-to-image needs only model and prompt:
{
"model": "gpt-image-web",
"prompt": "A beautiful, colorful sunset over the sea"
}Image-to-image / image editing (with reference images):
{
"model": "gpt-image-web",
"prompt": "Add a cute kitten next to her",
"size": "1:1",
"image_urls": ["https://example.com/input.png"],
"callback_url": "https://your-domain.com/webhook/image-done"
}Create task response#
On successful submission, task information is returned immediately (HTTP 200):
{
"id": "task_V1StGXR8_Z5jdHi6B",
"object": "image.generation.task",
"type": "image",
"status": "queued",
"progress": 0,
"created": 1757156493,
"model": "gpt-image-web",
"task_info": {
"can_cancel": true,
"estimated_time": 100
}
}id is the task identifier (task_ prefix), used for subsequent queries.
Query a task#
GET /v1/tasks/{id}
curl 'https://api.apimax.ai/v1/tasks/task_V1StGXR8_Z5jdHi6B' \
--header 'Authorization: Bearer <token>'Poll every 2-5 seconds until status becomes completed or failed.
The generated result is determined by what data actually returns: individual images may fail to generate, in which case the task still ends as completed, returning only the successful images, billed by the number of successfully generated images.
Completed (`completed`):
{
"id": "task_V1StGXR8_Z5jdHi6B",
"object": "image.generation.task",
"type": "image",
"status": "completed",
"progress": 100,
"created": 1757156493,
"completed_at": 1757156593,
"model": "gpt-image-web",
"data": [
{
"url": "https://cdn.example.com/img/.../0.png?X-Amz-Signature=...",
"url_expires_at": 1757160193
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 4160,
"total_tokens": 4172
}
}The pre-signed URL is re-signed on every query, so polling effectively "refreshes" expired links.
Failed (`failed`):
{
"id": "task_V1StGXR8_Z5jdHi6B",
"object": "image.generation.task",
"type": "image",
"status": "failed",
"failed_at": 1757156593,
"model": "gpt-image-web",
"error": {
"code": "upstream_error",
"message": "openai returned 400: content_policy_violation"
}
}status#
| Status | Meaning |
|---|---|
queued | Queued, waiting to execute |
in_progress | Generating |
completed | Generation completed; data contains the image links |
failed | Generation failed; see error |
error.code error codes#
| Code | Meaning |
|---|---|
upstream_error | Upstream returned 4xx (content policy / invalid prompt) |
upstream_unavailable | Upstream still returned 5xx after multiple retries |
storage_error | Failed to upload the result to cloud storage |
internal_error | Internal gateway exception |
If a task fails, the pre-deducted quota is automatically refunded.
Error codes (HTTP)#
| Status code | code | Meaning |
|---|---|---|
| 400 | invalid_request | Missing prompt/model, or incorrectly formatted parameters |
| 400 | model_not_supported | Model is not in the gpt-image-* series |
| 401 | unauthorized | Token is invalid or expired |
| 403 | insufficient_user_quota | Insufficient quota; please top up |
| 403 | (empty string) | Token does not have access to this model |
| 429 | rate_limit_exceeded | Too many requests |
| 500 | internal_error | Internal server error |
Callback (callback_url)#
When callback_url is set, the gateway POSTs a callback whenever the task completes / fails / is canceled. The callback body has the same format as the task query endpoint.
- Only HTTPS is supported, callbacks to internal IPs are blocked, and the URL must be no more than 2048 characters
- 10-second timeout; failed deliveries are retried up to 3 times (after 1s / 2s / 4s)
- A 2xx callback response counts as success; any other status code triggers a retry

