Create images
Create images in OpenRouter format, returning a URL or b64_json.
POST /api/v1/images
For text-to-image, reference-image generation, or OpenRouter-compatible integrations requiring separate image parameters and response format controls.
Back to Images endpoint listRequest parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | GlobalRouter model ID that supports image generation. |
prompt | string | Yes | Image generation prompt. |
aspect_ratio | string | No | Aspect ratio, such as 1:1, 16:9, 9:16, or auto. Do not send together with size. |
background | string | No | Background mode: auto, transparent, or opaque. |
input_references | object[] | No | Reference images, each formatted as { type: "image_url", image_url: { url } }; legacy entries without type are supported. Accepts HTTP(S) URLs or data:image/ Base64 data URLs. |
input_references[].type | string | No | Reference image type; must be image_url when supplied. |
input_references[].image_url.url | string | Yes | Reference image URL; accepts an HTTP(S) URL or a data:image/ Base64 data URL. |
n | integer | No | Number of images to generate, from 1 to 10. |
output_compression | integer | No | Output compression quality from 0 to 100. |
output_format | string | No | Artifact format: png, jpeg, webp, or svg. |
provider | object | No | Provider selection and provider-specific options. |
provider.provider_id | string | No | Provider ID used to route the request, for example doubao. |
provider.options | object | No | Provider-keyed options, for example { doubao: { ... } }. |
provider.options.doubao.watermark | boolean | No | Seedream visible image watermark toggle; the upstream default is true. |
provider.options.doubao.sequential_image_generation | string | No | Seedream image-set mode: disabled for a single image, or auto for a model-generated set based on the prompt. |
provider.options.doubao.sequential_image_generation_options.max_images | integer | No | Maximum image-set output count. Combined with input references, it must not exceed 15; examples also set n within the platform limit of 10. |
provider.options.doubao.tools | object[] | No | Seedream 5.0 Lite web-search tools, for example [{ type: "web_search" }]. |
provider.options.doubao.optimize_prompt_options | object | No | Seedream 4.0 prompt-optimization options, for example { mode: "fast" }. |
quality | string | No | Quality level: auto, low, medium, or high. |
resolution | string | No | Resolution tier: 512, 1K, 2K, or 4K. Do not send together with size. |
response_format | string | No | Response format. Allowed values: `url`, `b64_json`. Default: `b64_json`. |
seed | integer | No | Random seed. |
size | string | No | Image size or tier. Do not send together with resolution or aspect_ratio. |
stream | boolean | No | Whether to stream when supported by the provider. The current Seedream adapter returns complete JSON only; use false. Native Volcengine SSE events are not supported. |
Request examples
curl "https://api.globalrouter.com/api/v1/images" \
-H "Authorization: Bearer $GR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "将图片1中的人物转为白色色块图,不需要描绘人物的面部,不需要描绘人物的服装,背景场景不变。",
"input_references": [
{
"type": "image_url",
"image_url": {
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_5_imageToimage.png"
}
}
],
"n": 1,
"response_format": "url",
"size": "1024x1024"
}'Response fields
| Field | Type | Required | Description |
|---|---|---|---|
created | integer | Yes | Creation timestamp. |
data | object[] | Yes | Image results. Each entry contains url or b64_json according to response_format, and may include media_type. |
data[].b64_json | string | No | Base64 image content without a data URL prefix. |
data[].url | string | No | Accessible HTTP(S) image URL. |
data[].media_type | string | No | Image MIME type; omitted when it cannot be reliably determined. |
usage | object | No | Usage summary, which may include cost, cost_details, and other fields. |
Response example
{
"created": 1748372400,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUg...",
"media_type": "image/png"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 4175,
"total_tokens": 4175,
"cost": 0.04
}
}Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | ROUTER_IMAGE_SIZE_CONFLICT | size was provided together with resolution or aspect_ratio. |
| 400 | ROUTER_IMAGE_REFERENCE_INVALID | Invalid input_references format or image_url.url. |
Notes
- Seedream examples are adapted from the official Volcengine image-generation documentation. Use a GlobalRouter API key, a public model ID and provider=doubao; replace the native image parameter with input_references.
- Image-set examples target Seedream 5.0 Lite. Do not apply them to Pro or Flash variants without image-set support. Input references and output images together must not exceed 15; the platform n range remains 1–10.
- The web-search example uses tools with Seedream 5.0 Lite. The fast prompt-optimization example uses optimize_prompt_options.mode=fast with Seedream 4.0; these models are not interchangeable.
- For single-image examples, set response_format to b64_json to receive Base64 results. Image-set and web-search examples use url. Only adapted generation scenarios are covered here, not native streaming events or layer decomposition.
- Use n for ordinary image generation. Seedream image sets also require sequential_image_generation=auto and max_images. Examples set n to the same limit; the actual output count is model-dependent.
- Keys in provider.options must match provider.provider_id; send only options supported by the selected provider.
- response_format defaults to b64_json. With url, the response includes the provider's original HTTP(S) URL or a signed URL from the existing TOS artifact flow.
- Both url and b64_json responses support optional media_type. It is omitted when uncertain; images are not downloaded solely to detect MIME type.
- Use Create image task for long-running generation, batch production, or background polling.