Images

GetRouter exposes separate endpoints for image generation and image editing.

POST https://getrouter.ai/v1/images/generations
POST https://getrouter.ai/v1/images/edits

Choose an image model from Models and review its price and supported options before sending a request.

Generate an image

curl https://getrouter.ai/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "prompt": "A minimal black-and-white illustration of an API router",
    "n": 1,
    "size": "1024x1024",
    "response_format": "url"
  }'

The response contains a data array. Depending on the request and model, each item can contain a hosted URL or Base64-encoded image data.

Python

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://getrouter.ai/v1",
)

response = client.images.generate(
    model="MODEL_ID",
    prompt="A minimal black-and-white illustration of an API router",
    size="1024x1024",
    n=1,
)

print(response.data[0].url or response.data[0].b64_json)

Edit an image

Image edits use multipart form data:

curl https://getrouter.ai/v1/images/edits \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "model=MODEL_ID" \
  -F "prompt=Replace the background with a clean studio wall" \
  -F "[email protected]" \
  -F "n=1"

A compatible model may also accept a mask and additional model-specific fields.

Common fields

FieldPurpose
modelImage model ID
promptDescription or edit instruction
nNumber of requested images
sizeOutput dimensions supported by the model
qualityModel-specific quality mode
styleModel-specific style mode
response_formatCommon values include url and b64_json

The API also supports provider-specific image payloads for some models. When a model requires a different body shape, use the schema and example shown in the API Reference.

Warning

Image count, dimensions, quality, and edit support vary by model and directly affect cost. Check Pricing before generating batches.

Handle output safely

  • Download hosted URLs before they expire.
  • Decode b64_json before writing it to a file.
  • Validate the output MIME type in applications that serve generated files.
  • Avoid retrying a successful generation just because the client failed to save the response.

Next steps