Images
Both endpoints follow OpenAI’s Images API. Images are always returned as base64 in data[].b64_json; we never return a URL.
Generating images
Section titled “Generating images”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"]))'import base64, osfrom openai import OpenAI
client = OpenAI( base_url="https://api.indorouter.ai/v1", api_key=os.environ["INDOROUTER_API_KEY"],)
result = client.images.generate( model="openai/gpt-image-2", prompt="A red bicycle against a white wall", size="1024x1024",)open("bike.png", "wb").write(base64.b64decode(result.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.
Editing images
Section titled “Editing images”Send the pictures and the prompt as multipart/form-data:
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.
Response
Section titled “Response”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.
Models and billing
Section titled “Models and billing”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 thepromptrate and the picture’s output tokens at theimage_outputrate.units.image_output_tokens_by_optionshows how many tokens each size or quality produces.images: a fixed price per image, theimage_output_imagesrate 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.