GRGlobalRouter Docs
Console

Images / POST

Create image

Creates an OpenAI-compatible image generation request.

POST /v1/images/generations

Used to migrate OpenAI-style image generation calls. GlobalRouter handles model availability, tenant permissions, and billing rules.

Back to Images endpoint list

Request parameters

FieldTypeRequiredDescription
modelstringYesImage model ID.
promptstringYesImage generation prompt.
providerstringNoSpecify provider preferences.
routingobjectNoRouting preference, such as provider or strategy tags.
backgroundstringNoBackground mode; supported values depend on the model.
imagesstring[]NoReference image URL or data URL list.
image_urlstringNoSingle reference image URL.
image_sizestringNoProvider-style image size alias.
input_fidelitystringNoReference image fidelity.
mask_urlstringNoMask URL for partial editing.
sizestringNoOutput size, such as 1024x1024.
aspect_ratiostringNoAspect ratio, such as 1:1, 16:9, or 9:16.
resolutionstringNoResolution tier; supported values depend on the model.
nintegerNoNumber of images to generate.
output_compressionintegerNoOutput compression quality from 0 to 100.
output_formatstringNoOutput format, such as png, jpeg, or webp.
response_formatstringNoReturn url or b64_json, depending on model capability.
qualitystringNoQuality tier; supported values depend on the model.
stylestringNoStyle parameter; supported values depend on the model.
seedintegerNoRandom seed.
payloadstringNoRaw payload marker or content passed through to a compatible provider.
callback_urlstringNoAsync callback URL when supported by the provider.
srobjectNoSuper Resolution post-processing config, including provider, mode, and resolution.
userstringNoApplication-side user identifier.

Request examples

curl "https://api.globalrouter.com/v1/images/generations" \
  -H "Authorization: Bearer $GR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedream-image",
    "prompt": "一张清爽的 AI 模型聚合平台产品插图",
    "provider": "doubao",
    "routing": { "provider": "doubao" },
    "background": "transparent",
    "images": ["https://example.com/reference-a.png"],
    "image_url": "https://example.com/reference-b.png",
    "image_size": "1024x1024",
    "input_fidelity": "high",
    "mask_url": "https://example.com/mask.png",
    "size": "1024x1024",
    "aspect_ratio": "1:1",
    "resolution": "1080p",
    "n": 1,
    "output_compression": 90,
    "output_format": "png",
    "response_format": "url",
    "quality": "standard",
    "style": "natural",
    "seed": 42,
    "payload": "provider-specific-payload",
    "callback_url": "https://example.com/webhooks/gr-image",
    "sr": { "provider": "auto", "mode": "auto", "resolution": "1080p" },
    "user": "user_123"
  }'

Response fields

FieldTypeRequiredDescription
createdintegerNoCreation timestamp.
dataarrayYesImage artifact list.
data[].urlstringNoImage artifact URL.
data[].original_urlstringNoOriginal image URL when SR is enabled.
data[].srobjectNoProcessing summary when SR is enabled.
data[].sr.output_urlstringNoSR-enhanced image URL.
usageobjectNoUsage and billing information.

Response example

Response example
{
  "created": 1716283200,
  "data": [
    { "url": "https://assets.example.test/image.png" }
  ],
  "usage": { "total_cost": "0.012" }
}

Errors

HTTPCodeDescription
401UNAUTHORIZEDMissing or invalid Authorization Bearer token.
403FORBIDDENThe current API key is not allowed to call this scope or model.
429RATE_LIMITEDRequests are too frequent or the asynchronous task queue is full; reduce concurrency or retry later.

Notes

  • Image URLs should be treated as short-lived artifact addresses. Download or transfer them in your application when long-term retention is required.