Images
POST/v1/images
Parameters
promptstringRequired.modelstringOptional, default "gpt-image-1" (also the "auto" resolution). No auto-router for images yet — see Which models below.input_referencesarrayOptional. Image-to-image mode — [{"type":"image_url","image_url":{"url":...}}], URL or base64 data: URI. Only supported on chat-image and edit-capable models.nintegerOptional, default 1. Number of images to generate.aspect_ratio / resolutionstringOptional. Combine to request a size; ignored (default size used) if the model doesn't support the combination.sizestringOptional. Explicit "WxH" — overrides aspect_ratio/resolution when given.qualitystringOptional. OpenAI models only — ignored elsewhere.prompt_extendbooleanOptional — the model’s own prompt rewriting / expansion (Enhance prompt in the Studio). true lets the model rewrite and enrich your prompt; false uses it exactly as written. Supported on MiniMax H3 Image, Ideogram 4.0, FLUX.2 / Kontext / Pro 1.1, Qwen-Image 2.0 / 3.0, Wan 2.6 and z-image-spicy on the hosts that expose the switch; a request with it routes only to those rows, else 400 prompt_extend_not_supported. Omitted → the row’s own default.output_format / background / output_compression—Optional. OpenAI models only — ignored elsewhere.moderationstringOptional, "low" or "auto". OpenAI models only, and only in generation mode — the edit endpoint doesn't accept it; ignored elsewhere.input_fidelitystringOptional, "low" or "high". OpenAI models only, and only in image-to-image edit mode (requires input_references) — how much fine detail from the input image to preserve; ignored elsewhere.userstringOptional, your own stable end-user id, capped at 64 characters. Forwarded to OpenAI models for their own abuse monitoring; also recorded on every model as this platform's own advisory per-end-user attribution, visible via GET /api/usage/by-end-user.streambooleanNot supported — true is rejected with a 400, not silently ignored.max_wait_secnumberOptional, 10–270 (default 270). How long this request waits for a slow generation before on_timeout applies.on_timeoutstringOptional. "handoff" (default): past max_wait_sec return 202 + job id, charged only if it completes. "fallback" (needs max_wait_sec): start another host at that point and return whichever finishes first; the slow job is not cancelled and you are charged for it too if it completes — it is listed under pending_jobs so you can fetch it with GET /v1/images/{id}.Idempotency: send an Idempotency-Key header (any unique string up to 255 characters, one per request, reused when you retry) and a retry returns the original response instead of generating and billing again. A new key means a new request. Same rules as POST /v1/videos — see Idempotent retries.
Example response
{
"created": 1731430000,
"data": [{ "b64_json": "...", "url": null, "revised_prompt": "...", "media_type": "image/png" }],
"usage": { "prompt_tokens": 13, "completion_tokens": 1568, "total_tokens": 1581, "cost": 0.063 }
}
Some models (e.g. gpt-image-1) also echo background/output_format/quality/size at the top level, mirroring the provider's own response. A few Fal-hosted models return a real url instead of b64_json.
GET/v1/images/{id}
Unbilled. Result of a generation that outlived POST /v1/images's wait. When a single-image request is still running after about 4.5 minutes, the call returns 202 with {"id": "provider:job", "status": "processing", "retrieve_url": "/v1/images/..."} instead of an error — the job keeps running and you are charged only if it completes. Poll this endpoint (every ~15 s, see Retry-After) with the same API key.
200 status: "completed" — same data/usage shape as a direct POST /v1/images response. 202 "processing" — keep polling. 502 "failed" — the host reported the job failed; you are not charged. 404 — unknown id, or not yours. Requests with n > 1 keep the plain timeout error. Clients that cannot poll can send x-llmrouter-async: never to keep the timeout error.
Example response (completed)
{
"id": "wavespeed:0f3a9c...",
"object": "image.generation.job",
"status": "completed",
"created": 1731430000,
"data": [{ "url": "https://...", "media_type": "image/jpeg" }],
"usage": { "cost": 0.0523 }
}
GET/v1/images/models
Unbilled. Live list of every valid model slug for POST /v1/images — bare ids only, no price or capability breakdown (see /models for that).
Example response
{
"object": "list",
"data": [
{ "id": "gpt-image-1", "object": "model" },
{ "id": "imagen-4.0-generate-001", "object": "model" },
{ "id": "flux-1.1-pro", "object": "model" }
]
}