Skip to content

Images

Both endpoints follow OpenAI’s Images API. Images are always returned as base64 in data[].b64_json; we never return a URL.

Terminal window
curl https://api.indorouter.ai/v1/images/generations \
-H "Authorization: Bearer $INDOROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-image-2",
"prompt": "A red bicycle against a white wall",
"size": "1024x1024"}' \
| python3 -c 'import sys, json, base64; open("bike.png", "wb").write(base64.b64decode(json.load(sys.stdin)["data"][0]["b64_json"]))'
Field Notes
model Required. An image model ID.
prompt Required, and not empty.
n Number of images. Each model has a maximum per request (indorouter.routes[].units.max_images_per_request in GET /v1/models). A higher n is refused, not lowered.
size, quality, output_format, output_compression, background, moderation Forwarded to the vendor unchanged. Supported values depend on the model.
response_format Leave it out. "url" is refused, because pictures only come back as b64_json.

The JSON body may be up to 1 MB. Streaming is not available.

Send the pictures and the prompt as multipart/form-data:

Terminal window
curl https://api.indorouter.ai/v1/images/edits \
-H "Authorization: Bearer $INDOROUTER_API_KEY" \
-F model=openai/gpt-image-2 \
-F image=@bike.png \
-F prompt="Make the bicycle blue"
Field Notes
image or image[] Required. One to 16 files, each PNG, WebP or JPEG.
mask Optional. A PNG file.
prompt Required, and not empty.
model, n As for generations.
size, quality, background, input_fidelity, output_format, output_compression, moderation Forwarded to the vendor unchanged.

Editing works on models whose route lists units.image_tokens_max in GET /v1/models, which today means OpenAI’s GPT Image models. Other image models refuse an edit before anything is charged.

The response uses the vendor’s format. We set created and model, return images in data[].b64_json and use the Images API’s field names for usage.

Image models are listed with GET /v1/models?output_modalities=image and on indorouter.ai/models. A route bills one of two ways, shown in units.image_billing:

  • tokens: your prompt at the prompt rate and the picture’s output tokens at the image_output rate. units.image_output_tokens_by_option shows how many tokens each size or quality produces.
  • images: a fixed price per image, the image_output_images rate divided by 1,000,000.

Before the request runs we reserve the cost of n pictures at the model’s largest size. You are charged what the vendor reports once the pictures are made. How billing works explains the reservation.

See Error codes for errors and how to handle them.