GRGlobalRouter Docs
Console

Images / POST

Create image task

Create an asynchronous image generation task and poll polling_url for completion.

POST /api/v1/image-tasks

For long-running tasks such as Jimeng image generation. Creation persists the task in the local queue and returns a virtual task ID; background workers submit, poll, store results, and finalize billing. Use Create images for immediate image responses.

Back to Images endpoint list

Request parameters

FieldTypeRequiredDescription
modelstringYesGlobalRouter image model ID, such as jimeng_t2i_v31.
promptstringYesImage generation prompt.
input_referencesobject[]NoReference image list; each entry contains type=image_url and image_url.url.
nintegerNoNumber of images, defaulting to 1; the maximum depends on model capability configuration.
sizestringNoImage dimensions in WxH format or a supported model tier, such as 2K for Seedream. Do not combine with resolution or aspect_ratio; see notes below for GHYZ dimensions.
aspect_ratiostringNoAspect ratio: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 16:9, or 9:16.
resolutionstringNoResolution tier: 1K, 2K, or 4K; send with aspect_ratio. See the notes below for supported sizes.
qualitystringNoQuality level, such as auto, low, medium, or high.
seedintegerNoRandom seed.
output_formatstringNoOutput format, such as png, jpeg, or webp.
response_formatstringNoReturn url or b64_json.
provider.provider_idstringNoSelect a provider, such as doubao_gr. Once selected at creation, the same provider is used for submission and polling.
provider.optionsobjectNoThe current asynchronous endpoint does not forward this object. Use the synchronous endpoint for advanced Seedream options. Do not include AK/SK.
webhook_urlstringNoHTTPS webhook URL. Completion and failure notifications are delivered through the background outbox.
metadataobjectNoClient metadata. Omit req_key; the server derives it from model + provider_model_id.

Request examples

curl "https://api.globalrouter.com/api/v1/image-tasks" \
  -H "Authorization: Bearer $GR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "生成一张 16:9 的模型网关控制台产品插图,白色背景,简洁科技风,画面中有一块显示实时延迟曲线的面板。",
    "provider": { "provider_id": "ghyz" },
    "size": "2048x1152",
    "n": 1,
    "response_format": "url",
    "quality": "high"
  }'

Response fields

FieldTypeRequiredDescription
idstringYesGR virtual image task ID, such as imgtask_xxx.
objectstringYesAlways image.task.
statusstringYesStatus such as queued, submitting, submitted, in_progress, completed, failed, or expired.
modelstringYesRequested model.
providerstringYesProvider fixed at creation.
polling_urlstringYesRelative URL for polling task status.
dataobject[]NoImage details returned after completed.
data[].urlstringNoImage URL.
data[].b64_jsonstringNoBase64 image content.
usageobjectNoUsage summary after the background polling worker finalizes billing.
errorobjectNoFailure reason.

Response example

Response example
{
  "id": "imgtask_xxx",
  "object": "image.task",
  "status": "queued",
  "model": "gpt-image-2",
  "provider": "ghyz",
  "polling_url": "/api/v1/image-tasks/imgtask_xxx",
  "created_at": 1770000000,
  "updated_at": 1770000000,
  "data": [],
  "usage": {
    "billing_status": "unreserved"
  },
  "metadata": {
    "client_request_id": "client-001"
  }
}

Errors

HTTPCodeDescription
400ROUTER_IMAGE_TASK_PROVIDER_RELATION_NOT_FOUNDThe model has no available provider binding, or provider_model_id/req_key is missing.
429ROUTER_IMAGE_TASK_QUEUE_FULLThe tenant or API key asynchronous image queue is full.
503ROUTER_IMAGE_TASK_QUEUE_DISABLEDThe asynchronous image task queue is disabled.

Notes

  • The server derives req_key from model and provider_model_id; normal clients do not need to supply it.
  • The task provider is fixed in image_tasks.provider_id; polling does not reroute by model.
  • The following sizes apply to GHYZ asynchronous image-to-image (model=gpt-image-2); other models use their capability configuration.
  • 1K (9 sizes): 1:1 1024x1024, 2:3 1024x1536, 3:2 1536x1024, 3:4 1152x1536, 4:3 1536x1152, 4:5 1216x1520, 5:4 1520x1216, 16:9 1536x864, 9:16 864x1536.
  • 2K (9 sizes): 1:1 2048x2048, 2:3 1344x2016, 3:2 2016x1344, 3:4 1536x2048, 4:3 2048x1536, 4:5 1600x2000, 5:4 2000x1600, 16:9 2048x1152, 9:16 1152x2048.
  • 4K (9 sizes): 1:1 2880x2880, 2:3 2336x3504, 3:2 3504x2336, 3:4 2448x3264, 4:3 3264x2448, 4:5 2560x3200, 5:4 3200x2560, 16:9 3840x2160, 9:16 2160x3840.
  • You may send only resolution and aspect_ratio: resolution is 1K, 2K, or 4K; aspect_ratio is 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 16:9, or 9:16. The server calculates the size (for example, resolution=2K + aspect_ratio=16:9 yields 2048x1152). With size=auto, the upstream provider determines the size.
  • Size constraints: dimensions must be multiples of 16, the longest side must not exceed 3840, the aspect ratio must not exceed 3:1, and total pixels must be between 655360 and 8294400. Requests exceeding these limits fail during upstream submission, with final task status failed.
  • Billing has two output-pixel tiers: up to 2360000 pixels and above 2360000 pixels. For example, 2048x1152 (2359296 pixels) and 2048x2048 (4194304 pixels) fall into different tiers.