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 listRequest parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Image model ID. |
prompt | string | Yes | Image generation prompt. |
provider | string | No | Specify provider preferences. |
routing | object | No | Routing preference, such as provider or strategy tags. |
background | string | No | Background mode; supported values depend on the model. |
images | string[] | No | Reference image URL or data URL list. |
image_url | string | No | Single reference image URL. |
image_size | string | No | Provider-style image size alias. |
input_fidelity | string | No | Reference image fidelity. |
mask_url | string | No | Mask URL for partial editing. |
size | string | No | Output size, such as 1024x1024. |
aspect_ratio | string | No | Aspect ratio, such as 1:1, 16:9, or 9:16. |
resolution | string | No | Resolution tier; supported values depend on the model. |
n | integer | No | Number of images to generate. |
output_compression | integer | No | Output compression quality from 0 to 100. |
output_format | string | No | Output format, such as png, jpeg, or webp. |
response_format | string | No | Return url or b64_json, depending on model capability. |
quality | string | No | Quality tier; supported values depend on the model. |
style | string | No | Style parameter; supported values depend on the model. |
seed | integer | No | Random seed. |
payload | string | No | Raw payload marker or content passed through to a compatible provider. |
callback_url | string | No | Async callback URL when supported by the provider. |
sr | object | No | Super Resolution post-processing config, including provider, mode, and resolution. |
user | string | No | Application-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
| Field | Type | Required | Description |
|---|---|---|---|
created | integer | No | Creation timestamp. |
data | array | Yes | Image artifact list. |
data[].url | string | No | Image artifact URL. |
data[].original_url | string | No | Original image URL when SR is enabled. |
data[].sr | object | No | Processing summary when SR is enabled. |
data[].sr.output_url | string | No | SR-enhanced image URL. |
usage | object | No | Usage and billing information. |
Response example
{
"created": 1716283200,
"data": [
{ "url": "https://assets.example.test/image.png" }
],
"usage": { "total_cost": "0.012" }
}Errors
| HTTP | Code | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Missing or invalid Authorization Bearer token. |
| 403 | FORBIDDEN | The current API key is not allowed to call this scope or model. |
| 429 | RATE_LIMITED | Requests 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.