GRGlobalRouter Docs
Console

Images / POST

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 list

Request parameters

FieldTypeRequiredDescription
modelstringYesGlobalRouter model ID that supports image generation.
promptstringYesImage generation prompt.
aspect_ratiostringNoAspect ratio, such as 1:1, 16:9, 9:16, or auto. Do not send together with size.
backgroundstringNoBackground mode: auto, transparent, or opaque.
input_referencesobject[]NoReference 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[].typestringNoReference image type; must be image_url when supplied.
input_references[].image_url.urlstringYesReference image URL; accepts an HTTP(S) URL or a data:image/ Base64 data URL.
nintegerNoNumber of images to generate, from 1 to 10.
output_compressionintegerNoOutput compression quality from 0 to 100.
output_formatstringNoArtifact format: png, jpeg, webp, or svg.
providerobjectNoProvider selection and provider-specific options.
provider.provider_idstringNoProvider ID used to route the request, for example doubao.
provider.optionsobjectNoProvider-keyed options, for example { doubao: { ... } }.
provider.options.doubao.watermarkbooleanNoSeedream visible image watermark toggle; the upstream default is true.
provider.options.doubao.sequential_image_generationstringNoSeedream 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_imagesintegerNoMaximum 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.toolsobject[]NoSeedream 5.0 Lite web-search tools, for example [{ type: "web_search" }].
provider.options.doubao.optimize_prompt_optionsobjectNoSeedream 4.0 prompt-optimization options, for example { mode: "fast" }.
qualitystringNoQuality level: auto, low, medium, or high.
resolutionstringNoResolution tier: 512, 1K, 2K, or 4K. Do not send together with size.
response_formatstringNoResponse format. Allowed values: `url`, `b64_json`. Default: `b64_json`.
seedintegerNoRandom seed.
sizestringNoImage size or tier. Do not send together with resolution or aspect_ratio.
streambooleanNoWhether 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

FieldTypeRequiredDescription
createdintegerYesCreation timestamp.
dataobject[]YesImage results. Each entry contains url or b64_json according to response_format, and may include media_type.
data[].b64_jsonstringNoBase64 image content without a data URL prefix.
data[].urlstringNoAccessible HTTP(S) image URL.
data[].media_typestringNoImage MIME type; omitted when it cannot be reliably determined.
usageobjectNoUsage summary, which may include cost, cost_details, and other fields.

Response example

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

HTTPCodeDescription
400ROUTER_IMAGE_SIZE_CONFLICTsize was provided together with resolution or aspect_ratio.
400ROUTER_IMAGE_REFERENCE_INVALIDInvalid 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.