Routescope APIRoutescope API
Image ModelsOpenAI-Style Images

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

POST
/v1/aiart/openai/image/submit
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

AuthorizationBearer <token>

Model relay API authentication. Request header: Authorization: Bearer .

In: header

Request Body

application/json

prompt?string

Image generation or editing prompt. Required for text-to-image; can be used together with images for image-to-image or editing.

model?string

Model name. If omitted, the server defaults to gpt-image-2.

Default"gpt-image-2"
images?array<string>

Input reference image URL list. Used for image-to-image, image editing, or multi-image references; empty strings in the array are ignored.

mask?string

Mask image URL. Used to limit the editing area; omitted when no mask is needed.

Formaturi
input_fidelity?string

Input image fidelity control. Used during image editing to control how closely the result follows the input image; supported values depend on the upstream channel.

size?string

Output image size. Common format is width x height, for example 1024x1024; exact support depends on the upstream model.

quality?string

Output image quality tier. Supported values depend on the upstream channel, such as low, medium, or high.

background?string

Background mode. Controls transparent or generated backgrounds; supported values depend on the upstream channel.

n?integer

Number of images to generate. Currently only 1 image is supported.

Range1 <= value <= 1
output_format?string

Output image format. Common values include png, jpeg, and webp; exact support depends on the upstream channel.

output_compression?integer

Output image compression quality. Usually applies to jpeg/webp formats; this field supports explicitly passing 0, which the server preserves and forwards upstream.

Range0 <= value <= 100
response_format?string

Result 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?integer

Logo add switch. Usually 1 means add and 0 means do not add; this field supports explicitly passing 0.

Value in0 | 1
logo_param?

Logo parameters for adding a specified logo to generated images.

extra_body?

Extended request parameters. Use this to pass upstream extension fields or avoid top-level field conflicts.

[key: string]?never

Response Body

application/json

application/json

application/json

application/json

application/json

Query Task Result

POST
/v1/aiart/openai/image/query
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

AuthorizationBearer <token>

Model relay API authentication. Request header: Authorization: Bearer .

In: header

Request Body

application/json

job_id*string

Public task ID returned by the submit endpoint. This field is required.

[key: string]?never

Response Body

application/json

application/json

application/json

application/json

Task Parameters

FieldEndpointTypeDescription
modelSubmit taskstringThe example uses gpt-image-2.
promptSubmit taskstringGeneration or editing prompt. At least one of prompt and images must be provided.
imagesSubmit taskarrayReference images. At least one of prompt and images must be provided.
job_idQuery resultstringTask ID returned when submitting the task.

Task Flow

  1. Call /v1/aiart/openai/image/submit to submit the task.
  2. The server returns job_id.
  3. Use /v1/aiart/openai/image/query to query task status.
  4. When status is DONE, result image URLs are returned in data. When status is FAIL, error_message usually 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