Async Image Tasks
OpenAI-style async image generation and editing task APIs
Async image task APIs let you submit image generation or editing tasks and query results by task ID. Use them for long-running image generation requests.
Submit a Task
curl -X POST "https://api.routescope.ai/v1/aiart/openai/image/submit" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2", "prompt": "一只橘猫坐在霓虹灯下,电影感,细节丰富", "size": "1024x1024", "quality": "high", "n": 1, "output_format": "png" }'{
"request_id": "req_8f2b7c1a9d",
"job_id": "task_20260529123456_abcd1234"
}{
"code": "invalid_request",
"message": "prompt or images is required",
"data": null
}{
"code": "invalid_request",
"message": "prompt or images is required",
"data": null
}{
"code": "invalid_request",
"message": "prompt or images is required",
"data": null
}{
"code": "invalid_request",
"message": "prompt or images is required",
"data": null
}Authorization
BearerAuth
Model relay API authentication. Request header: Authorization: Bearer .
In: header
Request Body
application/json
Image generation or editing prompt. Required for text-to-image; can be used together with images for image-to-image or editing.
Model name. If omitted, the server defaults to gpt-image-2.
"gpt-image-2"Input reference image URL list. Used for image-to-image, image editing, or multi-image references; empty strings in the array are ignored.
Mask image URL. Used to limit the editing area; omitted when no mask is needed.
uriInput image fidelity control. Used during image editing to control how closely the result follows the input image; supported values depend on the upstream channel.
Output image size. Common format is width x height, for example 1024x1024; exact support depends on the upstream model.
Output image quality tier. Supported values depend on the upstream channel, such as low, medium, or high.
Background mode. Controls transparent or generated backgrounds; supported values depend on the upstream channel.
Number of images to generate. Currently only 1 image is supported.
1 <= value <= 1Output image format. Common values include png, jpeg, and webp; exact support depends on the upstream channel.
Output image compression quality. Usually applies to jpeg/webp formats; this field supports explicitly passing 0, which the server preserves and forwards upstream.
0 <= value <= 100Result return format. This endpoint submits asynchronous tasks and always returns job_id in the submit response; the field is forwarded as an upstream extension parameter.
Logo add switch. Usually 1 means add and 0 means do not add; this field supports explicitly passing 0.
0 | 1Logo parameters for adding a specified logo to generated images.
Extended request parameters. Use this to pass upstream extension fields or avoid top-level field conflicts.
Response Body
application/json
application/json
application/json
application/json
application/json
Query Task Result
curl -X POST "https://api.routescope.ai/v1/aiart/openai/image/query" \ -H "Content-Type: application/json" \ -d '{ "job_id": "task_20260529123456_abcd1234" }'{
"status": "WAIT",
"created": 1779993296
}{
"code": "invalid_request",
"message": "job_id is required",
"data": null
}{
"code": "invalid_request",
"message": "prompt or images is required",
"data": null
}{
"code": "invalid_request",
"message": "prompt or images is required",
"data": null
}Authorization
BearerAuth
Model relay API authentication. Request header: Authorization: Bearer .
In: header
Request Body
application/json
Public task ID returned by the submit endpoint. This field is required.
Response Body
application/json
application/json
application/json
application/json
Task Parameters
| Field | Endpoint | Type | Description |
|---|---|---|---|
model | Submit task | string | The example uses gpt-image-2. |
prompt | Submit task | string | Generation or editing prompt. At least one of prompt and images must be provided. |
images | Submit task | array | Reference images. At least one of prompt and images must be provided. |
job_id | Query result | string | Task ID returned when submitting the task. |
Task Flow
- Call
/v1/aiart/openai/image/submitto submit the task. - The server returns
job_id. - Use
/v1/aiart/openai/image/queryto query task status. - When status is
DONE, result image URLs are returned indata. When status isFAIL,error_messageusually contains the failure reason.
Example Code
Submit a Task
curl https://api.routescope.ai/v1/aiart/openai/image/submit \
-H "Authorization: Bearer $ROUTESCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "Generate a modern API documentation cover"
}'Query Result
curl https://api.routescope.ai/v1/aiart/openai/image/query \
-H "Authorization: Bearer $ROUTESCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"job_id": "your-job-id"
}'How is this guide?
Last updated on