Generate images (OpenAI-compatible)
The billing unit depends on the model — the catalogue shows whether it prices per image or per token. Requesting several images bills each image separately either way. A request can also be served by a backup model if the primary upstream is down; the response headers name the model that actually answered.
Per-model limits (openai/gpt-image-2.5-sunburst, openai/gpt-image-2.5-flare, openai/gpt-image-2):
- Standard
size:auto(default),1024x1024,1536x1024,1024x1536. Output is about 1.5 MP;sizeonly sets the aspect ratio andqualitydoes not change the output or the price. Other sizes return 400. n: up to 4 foropenai/gpt-image-2; 1 for flare and sunburst.- The response is always
{created, data:[{b64_json}]}(base64 PNG);response_formathas no effect. openai/gpt-image-2.5-sunburst2K / 4K:2048x2048,2560x1440,1440x2560or"2K"= 2K at $0.08 per image;3840x2160,2160x3840or"4K"= 4K at $0.12 per image (standard is $0.0186). 2K / 4K requiresn= 1, ignoresquality, does not supportmask, and is never retried or served by a backup model. Unlisted sizes return 400 and are not charged.
xai/grok-imagine-image-2.0: quality is low (default; auto means low) or medium; resolution is 1k (default), 1.5k or 2k; aspect_ratio sets the frame; n up to 4. Priced per image by quality × resolution, see the model page. Other quality or resolution values return 400 and are not charged.
See Images: Parameters vs. OpenAI for the full list of supported and unsupported parameters.
Authorization
bearerAuth Authorization: Bearer <your RouteMux API key>.
Create keys at https://routemux.com/console/keys. New keys use the sk- prefix;
the legacy rmx_live_ prefix is still accepted.
The Anthropic SDK's x-api-key and the Google SDK's x-goog-api-key are accepted too.
Sending several key headers with different values returns 400 AUTH_AMBIGUOUS_API_KEY.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Request and response bodies match the upstream provider's official format verbatim —
RouteMux passes them through untouched. See the provider's own docs for field definitions;
the gateway itself only reads model and stream.
Response Body
application/json
application/json
application/json
curl -X POST "https://example.com/v1/images/generations" \ -H "Content-Type: application/json" \ -d '{ "model": "xai/grok-imagine-image-2.0", "prompt": "A watercolor lighthouse on a cliff", "quality": "medium", "resolution": "2k", "aspect_ratio": "16:9" }'{ "model": "string", "stream": true}