GPT Image 2 Async Image API
ReachAPI provides a task-based image API for GPT Image 2. Use this endpoint when you want task status polling, callback delivery, and final image URLs in data[].url.
The async API uses the public model code gpt-image-2-async. This code is only for POST /v1/images/create. The OpenAI-compatible Image API continues to use gpt-image-2 on /v1/images/generations and /v1/images/edits.
1. Overview
- Submit a task:
POST https://direct.reachapi.ai/v1/images/create - Query a task:
GET https://direct.reachapi.ai/v1/tasks/{task_id} - Model code:
gpt-image-2-async - Execution mode: async task
- Result field:
data[].url
Request headers:
Authorization: Bearer YOUR_REACH_API_KEY
Content-Type: application/json2. Submit a Task
Request body:
{
"model": "gpt-image-2-async",
"callback_url": "https://your-domain.com/callback",
"input": {
"prompt": "A children's book drawing of a veterinarian using a stethoscope to listen to a small animal.",
"resolution": "1k",
"aspect_ratio": "2:3",
"quality": "medium",
"background": "auto",
"moderation": "auto",
"output_format": "png"
}
}2.1 Top-Level Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Must be gpt-image-2-async |
callback_url | string | No | HTTPS callback URL for terminal task status. Maximum length is 2048. Local, private-network, and localhost targets are rejected |
input | object | Yes | Image generation parameters |
2.2 input Parameters
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Text prompt for image generation or image editing |
image_urls | array<string> | No | Reference image URLs. Omit or send an empty array for text-to-image. Send one or more URLs for image editing. Maximum 14 images |
size | string | No | Exact output size, such as 1024x1536. If provided, it takes priority over resolution + aspect_ratio |
resolution | string | No | Standard resolution tier. Supported values: 1k, 2k, 4k. Defaults to 1k |
aspect_ratio | string | No | Standard aspect ratio. Supported values: 1:1, 3:2, 2:3. Defaults to 1:1 |
quality | string | No | Quality tier. Supported values: low, medium, high. Defaults to medium |
background | string | No | Background mode. Supported values: auto, opaque, transparent. gpt-image-2 does not support transparent |
moderation | string | No | Moderation mode. Supported values: auto, low |
output_format | string | No | Preferred output format. Supported values: png, jpeg, webp |
Notes:
input.sizetakes priority overresolution + aspect_ratio- For
input.size, maximum edge length must be less than or equal to3840px, both edges must be multiples of16px, long-edge to short-edge ratio must not exceed3:1, and total pixels must be at least655,360and no more than8,294,400 background=transparentcannot be used withoutput_format=jpeg- If you need local image input, upload it first and pass a reachable HTTPS URL in
input.image_urls
2.3 Standard Size Mapping
resolution + aspect_ratio | Output size |
|---|---|
1k + 1:1 | 1024x1024 |
1k + 3:2 | 1536x1024 |
1k + 2:3 | 1024x1536 |
2k + 1:1 | 2048x2048 |
2k + 3:2 | 2048x1152 |
4k + 3:2 | 3840x2160 |
4k + 2:3 | 2160x3840 |
If a combination is not listed, use input.size to request the exact output size.
3. Billing
The async task API is billed per request by normalized resolution + quality.
quality is case-insensitive and is normalized to low, medium, or high. If omitted, it defaults to medium.
quality | 1k | 2k | 4k |
|---|---|---|---|
low | $0.010 | $0.020 | $0.030 |
medium | $0.060 | $0.120 | $0.180 |
high | $0.220 | $0.440 | $0.660 |
Billing resolution is determined as follows:
- If
input.sizeis provided, its pixel dimensions are mapped to1k,2k, or4k - Otherwise,
input.resolutionis used; if omitted, it defaults to1k
4. Examples
4.1 Text to Image
curl -X POST "https://direct.reachapi.ai/v1/images/create" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-async",
"input": {
"prompt": "An editorial fashion photo of a silver handbag on a reflective pedestal, soft studio lighting",
"resolution": "4k",
"aspect_ratio": "2:3",
"quality": "high",
"output_format": "png"
}
}'4.2 Custom Size
curl -X POST "https://direct.reachapi.ai/v1/images/create" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-async",
"input": {
"prompt": "A fashion poster with a tall custom composition",
"size": "2336x3504",
"quality": "high",
"output_format": "png"
}
}'4.3 Image Editing
curl -X POST "https://direct.reachapi.ai/v1/images/create" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-async",
"input": {
"prompt": "Turn this sneaker photo into a premium e-commerce hero shot with a clean studio background",
"image_urls": [
"https://cdn.example.com/reference-1.png"
],
"resolution": "1k",
"aspect_ratio": "1:1",
"quality": "medium",
"output_format": "jpeg"
}
}'5. Submit Response
{
"code": 200,
"msg": "",
"status": "queued",
"task_id": "task_xxx",
"data": []
}| Field | Type | Description |
|---|---|---|
code | integer | Business status code |
msg | string | Status or error message |
status | string | Initial task status, usually queued |
task_id | string | Task ID for querying the result |
data | array | Empty at submit time |
6. Query a Task
Request:
curl -X GET "https://direct.reachapi.ai/v1/tasks/task_xxx" \
-H "Authorization: Bearer YOUR_REACH_API_KEY"Task statuses:
| Status | Description |
|---|---|
queued | Accepted and waiting to run |
generating | Generation in progress |
success | Generation completed |
failed | Generation failed |
Success response:
{
"code": 200,
"msg": "",
"status": "success",
"task_id": "task_xxx",
"data": [
{
"url": "https://cdn.example.com/generated/gpt-image-2.png",
"size": "1024x1536",
"revised_prompt": "A children's book illustration of a veterinarian using a stethoscope."
}
],
"cost": {
"spend": 0.12
}
}Failure response:
{
"code": 500,
"msg": "Model service request failed",
"status": "failed",
"task_id": "task_xxx",
"data": []
}7. Callback
If callback_url is provided when the task is submitted, ReachAPI sends a POST request when the task reaches success or failed. The callback body uses the same JSON structure as the task query response.
Callback constraints:
- HTTPS only
- Maximum length:
2048 localhost,.local, private-network, and local IP targets are rejected- Single delivery timeout:
10s - Failed delivery is retried up to 2 times, for a maximum of 3 delivery attempts
8. Constraints
promptis required and cannot be emptyimage_urlsmust contain server-accessible HTTPS URLsimage_urlssupports up to 14 imagesimage_base64sis not supportedn > 1is not supportedmaskis not supported on this async endpointoutput_compressionis not supporteduseris not supportedsizemust use pixel dimensions where the maximum edge is3840pxor less, both edges are multiples of16px, the long-edge to short-edge ratio is no more than3:1, and total pixels are between655,360and8,294,400resolutionsupports1k,2k, and4kaspect_ratiosupports1:1,3:2, and2:3in standard mapping mode- If
sizeis not provided,resolution + aspect_ratiomust match the standard mapping table qualitysupportslow,medium, andhighbackground,moderation, andoutput_formatmust use the documented enum valuesbackground=transparentdoes not supportoutput_format=jpeg