POST once, the server holds the connection open while the job runs, and you get back a final response with a direct URL to the asset. If the job needs longer than the wait window, you GET the same id with another wait — no client-side polling cadence to manage.
At a glance
- One resource.
POST /v1/generationsfor every image and video model. - Server-side long-polling.
wait="auto"(default) blocks for up to 60s — most short jobs return ascompletedin a single round-trip. - Strict input. Unknown fields are rejected, so typos surface immediately.
- Stable error codes. Branch on
error.code, never onerror.message.
Quickstart
Create a generation
POST /v1/generations accepts a strict JSON body. Unknown top-level or nested keys are rejected with invalid_input.
Request
Model ID (e.g.
flux-1.1-pro, veo-3, runway-gen4). Use the model ID
exactly as listed on llm-stats.com.Inputs to the generation. See Input fields.
Server-side long-poll window in seconds (0–60). Pass
0 for fire-and-forget
(returns immediately with status: "queued"). "auto" picks a sensible
default per modality.Input fields
All input fields live underinput and are optional unless noted.
Explicit pixel size (e.g.
"1024x1024"). Models that don’t accept size
ignore this; pick aspect_ratio instead.Response
Both endpoints return the sameGenerationResponse shape — a single resource you can poll, store, and re-fetch.
Lifecycle state.
queued and running are non-terminal; the rest are
terminal.One entry per produced asset. See MediaArtifact.
Present on
status === "failed". { code, message } — see
Error codes.MediaArtifact
Example response (completed image)
Example response (still running)
Ifwait elapses without a terminal status, you get the same shape with
status: "running" and a Retry-After header. Re-fetch the same id:
Fetch a generation
Optional long-poll window (0–60s). Passing
wait lets you GET once and
block until the job is terminal, mirroring the POST ergonomics.POST shape. Terminal responses are safe to
cache (Cache-Control: private, max-age=60); non-terminal responses are
returned with Cache-Control: no-store.
How wait actually works
wait: "auto"(default). The server picks per modality — long for image jobs (which usually finish quickly), short for video (which usually doesn’t).wait: 0. Fire-and-forget. The response always returns immediately; poll the resource yourself when you’re ready.wait: N(1–60). Server holds the connection up toNseconds. The cap is below typical proxy idle timeouts, so you won’t hit gateway 504s.
Error codes
Errors share the unified envelope. Generation-specific codes you’ll see most:Patterns and tips
Always use the resource id, never poll a wall clock
Always use the resource id, never poll a wall clock
Persist
job.id immediately after POST. If your worker crashes or your
user closes the tab, you can resume by re-fetching the same id — even
hours later — and you’ll get the final state, including the signed URL.Set realistic outer timeouts
Set realistic outer timeouts
wait caps a single request at 60s. Apply your own outer deadline (e.g.
5 minutes for image, 10 minutes for video) and bail out cleanly with the
last id so the user can be notified later.Image-to-image / image-to-video
Image-to-image / image-to-video
Pass reference URLs in
input.images (max 8). The first reference is the
primary input for single-reference models.Reproducibility
Reproducibility
Set
input.seed for deterministic outputs on supported models. Same model- same provider + same seed + same prompt → same image.