Skip to content

Images

Use POST /v1/images/generations for OpenAI-style image generation and POST /v1/images/edits for OpenAI-style image editing.

text
POST https://api.rout.my/v1/images/generations

Request

bash
curl https://api.rout.my/v1/images/generations \
  -H "Authorization: Bearer $ROUTMY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "provider/image-model-id",
    "prompt": "A clean product photo of a translucent blue cube on a white table",
    "n": 1,
    "image_config": {
      "aspect_ratio": "1:1",
      "image_size": "1K"
    }
  }'

Request fields

FieldTypeRequiredNotes
modelstringYesExact image model ID from /v1/models.
promptstringYesText description of the image.
nintegerNoNumber of images requested. Defaults to provider behavior when omitted.
sizestringNoOpenAI-style size value, when supported by the model.
qualitystringNoQuality hint, when supported by the model.
stylestringNoStyle hint, when supported by the model.
userstringNoAccepted for compatibility but stripped before upstream requests.
image_configobjectNoProvider-neutral image settings.

image_config

FieldTypeNotes
aspect_ratiostringCommon values include 1:1, 16:9, 9:16, 4:3, 3:4, 4:5, 5:4, and 21:9.
image_sizestringCommon values include 1K, 2K, and 4K. Values are forwarded to the provider when supported.

Response

The response follows an OpenAI-style image generation shape. Depending on the upstream provider, each image can contain a URL or base64 payload.

json
{
  "created": 1744000000,
  "data": [
    {
      "url": "https://example.com/generated-image.png",
      "revised_prompt": "A clean product photo of a translucent blue cube..."
    }
  ]
}

or:

json
{
  "created": 1744000000,
  "data": [
    {
      "b64_json": "iVBORw0KGgo..."
    }
  ]
}

Client code should handle both url and b64_json.

Image edits

Use POST /v1/images/edits when the model should transform one or more input images.

text
POST https://api.rout.my/v1/images/edits

JSON requests should use images as an array. Multipart requests can use OpenAI-style image file fields.

bash
curl https://api.rout.my/v1/images/edits \
  -H "Authorization: Bearer $ROUTMY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "provider/image-edit-model-id",
    "prompt": "Keep the product, replace the background with a clean studio gradient",
    "images": [
      {
        "image_url": "https://example.com/input.png"
      }
    ],
    "n": 1,
    "size": "1024x1024"
  }'

Common edit fields include model, prompt, images, image, mask, n, size, quality, background, input_fidelity, moderation, output_compression, output_format, partial_images, and stream. The user field is accepted for compatibility but stripped before upstream requests.

Quota accounting

Image generation and image edits deduct quota from the number of output images, multiplied by the model's token_multiplier:

Requested sizeBase quota units per image
empty, 1K, 2K, or other non-4K values5,000
4K12,500

Provider-reported usage.total_tokens can also be used internally when available, but it cannot reduce the billable base below the output-image floor. The effective base is:

text
max(provider_usage.total_tokens, output_images * base_quota_units_per_image)

For /v1/images/edits, the default floor is 5,000 quota units per output image. The public response can include provider usage when the upstream returns it, but private billing metadata is not exposed.

Chat image generation

Some image-capable chat models use /v1/chat/completions with modalities: ["image", "text"]. See Chat Completions for that request shape.

API documentation for rout.my.