Guides
Generations
How async generations work: queued, running, succeeded, failed and canceled statuses, polling best practices, outputs and cancellation.
Video and image models take from a few seconds to several minutes, so every request is asynchronous. Submitting returns a generation immediately; you then poll it or receive a webhook when it reaches a final state. One generation object describes the whole job — its input, status, output, error and cost.
Lifecycle#
queued if no capacity accepts it. Failed and canceled jobs are refunded in full.| Status | Final? | Meaning |
|---|---|---|
queued | No | Accepted, not started yet: waiting in your account's queue (past your concurrency limit) or for capacity. The price is held from your balance. You can still cancel. |
running | No | The model is generating. started_at is set. It can no longer be canceled. |
succeeded | Yes | Finished. output holds the media URLs and the held amount becomes the final charge. |
failed | Yes | Could not be completed. error explains why and the full hold has been refunded. |
canceled | Yes | You canceled it while it was queued. The full hold has been refunded. |
succeeded, failed and canceled are final: a generation never changes after reaching one of them. Treat any other value as "still in progress" so your code keeps working if we add intermediate states.
1. Submit#
POST /api/v1/run/{endpoint} with the model's inputs as the JSON body. The endpoint ID combines the model and the task, e.g. bytedance/seedance-2.0-fast/text-to-video. Find every endpoint and its fields on the Models page.
We validate the input, compute the price, hold it from your balance and queue the job. The response is 202 Accepted with the generation, plus urls.get and urls.cancel for convenience:
{
"id": "gen_8c2QmX1nq0k4Lw7Z",
"object": "generation",
"model": "bytedance/seedance-2.0-fast",
"endpoint": "bytedance/seedance-2.0-fast/text-to-video",
"mode": "text-to-video",
"status": "queued",
"input": {
"prompt": "A slow dolly-in on a ceramicist shaping a vase at golden hour, dust in the light, shallow depth of field",
"aspect_ratio": "16:9",
"resolution": "720p",
"duration": 5,
"generate_audio": true
},
"output": null,
"error": null,
"cost": {
"amount_usd": 0.4494,
"currency": "usd",
"estimated": true
},
"source": "api",
"created_at": "2026-10-15T09:21:04.512Z",
"started_at": null,
"completed_at": null,
"retention": "1d",
"expires_at": null,
"purged_at": null,
"urls": {
"get": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4Lw7Z",
"cancel": "https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4Lw7Z/cancel"
}
}Reference images, videos and audio#
reference-to-video modes take up to three kinds of references, each a list of HTTPS URLs (public links, or URLs from uploads): reference_image_urls for characters, products and scenes, reference_video_urls for motion, camera moves and effects, and reference_audio_urls for voice, music and sound.
Point at them in the prompt by position: @Image1 is the first URL in reference_image_urls, @Video1 the first in reference_video_urls, @Audio2 the second audio clip, and so on. Mentions are case-insensitive and normalized to @Image1. A mention with no matching reference (say @Video2 with one video attached) is rejected with 400 invalid_request (param: "prompt") before anything is charged.
{
"prompt": "@Image1 dances on a rooftop, copying the choreography and camera move of @Video1, in sync with @Audio1",
"reference_image_urls": [
"https://example.com/dancer.jpg"
],
"reference_video_urls": [
"https://example.com/choreo.mp4"
],
"reference_audio_urls": [
"https://example.com/beat.mp3"
],
"resolution": "720p",
"duration": 8
}We download the start of every reference video and audio file when you submit and check its real duration, size, resolution and frame rate against the model's limits. Anything out of range — a 20-second clip, a 1080p video for a model that takes 720p, an M4A where MP3 or WAV is required, a URL that doesn't answer — returns 400 invalid_request with param set to the field (for example reference_video_urls) and a message naming the clip, before anything is charged. Reference videos add billed seconds; see Billing.
| Model | Images | Videos | Audio | Rules |
|---|---|---|---|---|
| Seedance 2.0 | ≤ 9 | ≤ 3 · MP4/MOV · 2–15 s each, 15 s total · ≤ 50 MB total · 24–60 fps | ≤ 3 · MP3/WAV · 2–15 s each, 15 s total · ≤ 15 MB each | ≤ 12 files in total; needs an image or video |
| Seedance 2.5 | ≤ 30 | ≤ 10 · MP4/MOV · 2–30 s each, 30 s total · ≤ 200 MB each · 24–60 fps | ≤ 10 · MP3/WAV · 2–30 s each, 30 s total · ≤ 15 MB each | ≤ 50 files in total; needs at least one reference |
| Seedance 2.0 Fast | ≤ 9 | ≤ 3 · MP4/MOV · 2–15 s each, 15 s total · ≤ 50 MB total · 24–60 fps | ≤ 3 · MP3/WAV · 2–15 s each, 15 s total · ≤ 15 MB each | ≤ 12 files in total; needs an image or video |
| Seedance 2.0 Mini | ≤ 9 | ≤ 3 · MP4/MOV · 2–15 s each, 15 s total · ≤ 50 MB total · 480p–720p only · 24–60 fps | ≤ 3 · MP3/WAV · 2–15 s each, 15 s total · ≤ 15 MB each | ≤ 12 files in total; needs an image or video |
| Kling 4.0 | ≤ 10 | ≤ 5 · MP4/MOV · 3–30 s each, 30 s total · ≤ 200 MB each | — | needs an image or video |
| Wan 3.0 | ≤ 4 | ≤ 5 · MP4/MOV · 1–15 s each, 15 s total · ≤ 100 MB each · 16+ fps · reference + output ≤ 30 s | ≤ 5 · MP3/WAV · 1–15 s each, 15 s total · ≤ 15 MB each | needs at least one reference |
| Wan 3.0 Prime | ≤ 4 | ≤ 5 · MP4/MOV · 1–15 s each, 15 s total · ≤ 100 MB each · 16+ fps · reference + output ≤ 30 s | ≤ 5 · MP3/WAV · 1–15 s each, 15 s total · ≤ 15 MB each | needs at least one reference |
| MiniMax H3 | ≤ 5 | ≤ 3 · MP4/MOV · 2–15 s each, 15 s total · ≤ 50 MB each · 24–60 fps | ≤ 3 · MP3/WAV · 2–15 s each, 15 s total · ≤ 15 MB each | ≤ 12 files in total; needs an image or video |
| MiniMax H3 Fast | ≤ 9 | ≤ 3 · MP4/MOV · 2–15 s each, 15 s total · ≤ 50 MB each · 24–60 fps | ≤ 3 · MP3/WAV · 2–15 s each, 15 s total · ≤ 15 MB each | ≤ 15 files in total; needs an image or video |
| MAGI-2 | ≤ 10 | ≤ 5 · MP4/MOV · 2–30 s each, 30 s total | ≤ 5 · MP3/WAV · 2–30 s each, 30 s total | ≤ 20 files in total; needs at least one reference |
Videos must be H.264 or H.265 MP4/MOV. Limits are the strictest of the capacity each model runs on, so a request that passes here is accepted upstream. Reference images and audio don't change the price.
Some models also limit input images: MiniMax H3 and H3 Max take 256–5760 px on each side and a width ÷ height of 0.4–2.5, up to 30 MB; Seedance 2.0, 2.5, Fast and Mini take a width ÷ height of 0.4–2.5. Each such field lists its limits in the model's input schema as x-image-limits. We read the start of each image when you submit, and an image outside the limits, or a video, audio file or PDF sent as an image, returns 400 invalid_request that names it, before anything is charged.
2. Poll for the result#
GET /api/v1/generations/{id} returns the current state. Reading a generation also nudges it forward: if a status check is due, we check before answering, so polling never returns data more than a few seconds old.
const API = "https://cheapergen.com/api/v1";
const headers = { Authorization: `Bearer ${process.env.CHEAPERGEN_API_KEY}` };
const FINAL = new Set(["succeeded", "failed", "canceled"]);
export async function wait(id, timeoutMs = 15 * 60_000) {
let delay = 2000;
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
const gen = await fetch(`${API}/generations/${id}`, { headers }).then((r) => r.json());
if (FINAL.has(gen.status)) return gen;
await new Promise((r) => setTimeout(r, delay));
delay = Math.min(delay * 1.5, 10_000); // back off to every 10 s
}
// Giving up: cancel it first, or it still runs and is charged when it finishes (once running it can't be: 409).
await fetch(`${API}/generations/${id}/cancel`, { method: "POST", headers }).catch(() => {});
throw new Error(`Timed out waiting for ${id}`);
}Recommended polling intervals#
- Images: every 1–2 seconds. Most finish in under 30 seconds.
- Video: every 3–5 seconds at first, backing off to 10 seconds. A 5-second clip typically takes one to three minutes, longer at high resolutions.
- Polling counts toward your rate limit. If you run many jobs at once, prefer webhooks.
3. Use the output#
On success, output holds HTTPS URLs to the generated media. Video models return one file:
{
"output": {
"video": {
"url": "https://cdn.cheapergen.com/outputs/gen_8c2QmX1nq0k4Lw7Z.mp4",
"content_type": "video/mp4"
}
}
}Image models return a list, one entry per generated image:
{
"output": {
"images": [
{
"url": "https://cdn.cheapergen.com/outputs/gen_8c2QmX1nq0k4Lw7Z.png",
"content_type": "image/png"
}
]
}
}Store what you want to keep
Output URLs are served from our CDN until the generation's content expires — 1 day after it finishes for API generations by default (see Data retention). Copy outputs you want to keep into your own storage when the job succeeds.Failures and refunds#
When a generation fails, status is failed, error says why and what to do, and cost.amount_usd drops to 0 — the full hold has been returned to your balance. Outages and model errors are retried automatically on every other eligible route before a job is marked failed. A safety-filter rejection or an input the model can't take is not: it would be rejected the same way again. When the model can't download one of your input files, we usually download it ourselves and retry with our copy, at the same price; input_unreachable mostly means it couldn't be downloaded at all.
{
"status": "failed",
"error": {
"code": "generation_failed",
"message": "ByteDance's safety review for Seedance 2.0 Fast rejected the prompt.",
"reason": "content_blocked",
"hint": "Describe the character's look instead of naming a copyrighted character or real person, keep it non-explicit, or try another model.",
"retryable": false,
"refunded": true,
"detail": "Your request did not pass content safety review. Please adjust your prompt and try again."
},
"cost": {
"amount_usd": 0,
"currency": "usd",
"estimated": false
}
}code— the broad class, unchanged since launch:generation_failed(the input was rejected or couldn't be completed),upstream_error,timeoutormodel_unavailable.reason— exactly why, from the table below. Branch on this for new integrations; new reasons may be added.message— what happened, in words you can show your users. When a safety filter rejected it, it names whose (the model's vendor).hint— what to change or do next.retryable—truewhen sending the same request again may succeed;falsewhen it would fail the same way.refunded—truewhen the hold was returned. Failed generations are never charged.param— the input field to change, when we can tell (e.g.image_url,duration).detail— more detail from the model, when there is any.
| error.reason | error.code | What happened | What to do | Resend as is? |
|---|---|---|---|---|
content_blocked | generation_failed | The model vendor's safety filter rejected the prompt, an input file or the generated result (for example a named copyrighted character, a real person, or explicit content). The message names whose filter it was. | Rephrase the prompt (describe the look instead of naming a character, brand or real person), use other input files, or try a model from another vendor. Sending it unchanged fails the same way. | No — change it first |
invalid_input | generation_failed | The model could not accept one of the inputs or settings: a file too large, in an unsupported format, with the wrong dimensions or aspect ratio, too long, or a value it doesn't take. param names the field when we can tell. | Fix the named field (see the model's limits on its API page) and resubmit, or try another model. | No — change it first |
input_unreachable | generation_failed | An input URL could not be downloaded: it needs a sign-in, its signed link expired, it doesn't point straight at the file, or the host refused the request. When the model can't fetch a file, we usually download it ourselves and retry with our copy, so this mostly means the file couldn't be downloaded at all. | Use a public, direct file URL (or upload the file with POST /api/v1/uploads) and resubmit. | No — change it first |
upstream_unavailable | upstream_error | The model was down, overloaded or at capacity on every route we could use. | Retry in a minute or two, or use another model. | Yes |
upstream_error | upstream_error | The model hit an internal error on every route we tried. | Retry; these errors are usually temporary. If it keeps failing, try another model. | Yes |
timeout | timeout | The generation did not finish in time (the model's own time limit, or ours of 40 minutes). | Retry. Shorter or lower-resolution clips finish sooner. | Yes |
output_unavailable | upstream_error | The model finished but returned no usable file, or the result could not be downloaded and stored. | Retry. | Yes |
model_unavailable | model_unavailable | The model, or this mode of it, stopped being served while the generation was in progress. | Pick another model, or retry later. | No — change it first |
canceled | upstream_error | The service canceled or expired the job before it finished. (A generation you cancel yourself has status canceled and no error.) | Retry. | Yes |
generation_failed | generation_failed | The model stopped without a result and gave no reason. | Retry once; if it fails again, simplify the prompt or inputs, or try another model. | Yes |
Generations that failed before reason existed keep their original code; reason and hint are filled in for them too.
Quotes and spending limits#
Quote the exact inputs before generating. Set max_cost_usd to your approved USD limit. Requests above that limit are refused without a charge.
allow_fallback_price defaults to true. Set it to false to refuse requests that require a price adjustment. Failed jobs are refunded. Your approved max_cost_usd limit still applies.
If the final price is reduced, the difference is refunded. Your generation shows the amount charged and any adjustment. Previously accepted jobs retain their original settlement terms.
Accounts with a contract price keep their agreed pricing terms. Requests that cannot complete under those terms are refused; failed jobs are refunded.
Safety checker#
enable_safety_checker defaults to true. You may send false over the API; it is always on in the Studio and on the model pages. What it does depends on the model:
- Closed models (Seedance, Kling, Veo, MiniMax H3, Wan 3.0…) carry their lab's own moderation, which no one can turn off. They accept
trueandfalse, and neither changes anything — so the option isn't listed in their schema. MiniMax H3 Max is the exception: it supports switching the filter off, so it lists the option. Those requests use their own safety configuration — quote the selected setting before generating. - Seedream 5.0 Pro support this setting. The quoted prices are Seedream 5.0 Pro $0.0378 per image (1K) · $0.0756 per image (2K) . Send
enable_safety_checker: falseto/quoteto get the price for your inputs. If the setting is unavailable,503 model_unavailableis returned; useenable_safety_checker: truefor the standard filter. - Open-weights models list it. Where a generation runs on capacity without a filter of its own, our checker reads the prompt and input images first: with the switch on it blocks sexual, graphically violent and self-harm content; with it off, still anything sexual involving minors. Where the capacity has a switchable filter of its own, the switch is passed to it as you sent it; with it off, our checker still blocks anything sexual involving minors.
false on a mode that doesn't list the option (and can't turn its checker off) returns 400 invalid_request. Turning it off doesn't allow anything our Acceptable Use Policy prohibits.
Data retention#
API generations are kept for 1 day by default, counted from when they finish. After that we delete the prompt, input media, outputs and their files automatically. The generation itself stays, with its model, the parameters that set the price, cost and timestamps, so your usage history and invoices remain accurate: output becomes null, purged_at is set and content_expired explains why. A failed generation also keeps why it failed (the error with any quoted prompt and links removed, whether each input file was uploaded or linked and its type, size and dimensions, and the length of each text input), never the prompt, the files or their links. Download outputs you want to keep before expires_at.
retention | Content is deleted |
|---|---|
immediate | 10 minutes after the result is delivered — your webhook accepted it, or you read the finished generation with GET — so you can still download the files. Never later than 1 hour after it finishes. |
1h | 1 hour after it finishes. |
1d | 1 day after it finishes. The default. |
7d, 30d | 7 or 30 days after it finishes. Enterprise accounts only. |
Pass retention in the request body to choose per generation. Any account can shorten it (or ask for up to 1d); 7d and 30d need an account-level retention setting — contact sales. A request for a longer period than your account allows returns 400 invalid_request with param: "retention".
{
"prompt": "A paper boat drifting down a rain-soaked street",
"resolution": "720p",
"duration": 5,
"retention": "immediate",
"webhook_url": "https://example.com/hooks/cheapergen"
}Studio and playground generations are kept until you delete them. Uploads live as long as a kept generation uses them; files that no generation uses are deleted after 1 day. Deleting your account deletes all of your generations and files. Where a model provider lets us choose, we also ask it to keep as little as possible on its side.
Deleting a generation#
Delete any finished generation with DELETE /api/v1/generations/{id}, from the generations list in the dashboard, or from the Studio viewer; through the API a queued one too, while it can still be canceled (it is canceled first and its hold refunded in full). Its files, prompt and inputs are removed right away and it disappears from lists; the charge stays in your billing history. See the API reference.
Canceling#
POST /api/v1/generations/{id}/cancel cancels a generation that is still queued and refunds the hold. Once a job is running the model is already working on it, so canceling returns 409 conflict and the job completes (and is billed) normally. Some models can't be canceled once queued; those also return 409.
curl -X POST https://cheapergen.com/api/v1/generations/gen_8c2QmX1nq0k4Lw7Z/cancel \
-H "Authorization: Bearer $CHEAPERGEN_API_KEY"Listing generations#
GET /api/v1/generations lists your generations, newest first, with cursor pagination. Filter by status, model or source (playground, api, mcp); pass the returned next_cursor as cursor to get the next page. Details in the API reference.
curl "https://cheapergen.com/api/v1/generations?status=succeeded&limit=50" \
-H "Authorization: Bearer $CHEAPERGEN_API_KEY"Generations from the Studio and model-page playgrounds appear here too, with source: "playground"; API requests have source: "api".
Something unclear or missing? Email support@cheapergen.com — we read everything.