GuidesWhat Are Video Generation API Best Practices for Retries and Polling?
Makernice Team · ·
Prices as of December 3, 2026 (price list v18).
A reliable integration with the Makernice generation API comes down to five habits: one Idempotency-Key per job, a fresh quote right before you create, polling that honours Retry-After, cancelling only queued jobs, and copying outputs before they expire. The five habits apply to every video and image model, including Seedance 2.5 and Wan 3.0, because all of them share the same async REST flow.
How do you retry a video generation API request without being charged twice?
A Makernice retry is safe when it reuses the same Idempotency-Key: the server returns 200 with the original generation instead of creating and charging a second one. Three rules keep keys safe:
- POST /v1/generations requires an Idempotency-Key header of 1 to 200 printable ASCII characters, no spaces, unique within your account.
- Generate one key per logical job, store it before you send the request, and reuse it on every retry. A retry returns 200 with the original generation instead of creating a second one.
- Reusing a key with a different quote or different price-affecting parameters returns 422 idempotency_conflict, so never recycle keys across jobs.

How long is a quote valid, and when should you request it?
A Makernice quote from POST /v1/generations/quote is valid for 12 minutes and can be used once. Request it immediately before creating, not when a user first opens a form. If you change the model, mode, resolution or duration after quoting, create returns 422 quote_mismatch, so quote the final input.
How do you poll a video generation API task correctly?
Poll a Makernice video generation with GET /v1/generations/{id} every few seconds, which is plenty since generations take a while, and stop on a final status: succeeded, failed or canceled. The checking status means we are confirming the result and the amount stays held, so keep polling.
How do you fix 429 Too Many Requests on the video generation API?
A Makernice 429 means wait, then repeat the same call: every endpoint can answer 429 rate_limited with a Retry-After header in seconds, so wait that long before the next call. Create can also return 429 concurrency_limit_reached when your account already has its maximum number of generations in progress, across all of its keys, so queue work on your side instead of firing everything at once, or contact support to raise the limit. Rate limits are counted per minute; the rate limits section of the docs has the details. The loop below polls one generation and waits out Retry-After:
// Poll one generation until it reaches a final status
const POLL_INTERVAL_MS = 5000;
const REQUEST_TIMEOUT_MS = 30000;
const FINAL = new Set(["succeeded", "failed", "canceled"]);
async function waitFor(id) {
for (;;) {
const res = await fetch(API_BASE + "/generations/" + id, { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
headers: { Authorization: "Bearer " + API_KEY },
});
if (res.status === 429) {
// Honour the server's Retry-After (seconds) before trying again
const retry_after_s = Number(res.headers.get("Retry-After") ?? "5");
await new Promise((r) => setTimeout(r, retry_after_s * 1000));
continue;
}
if (!res.ok) throw new Error("poll failed: " + res.status);
const gen = await res.json();
if (FINAL.has(gen.status)) return gen;
await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
}
}How do you handle timeouts while waiting for an AI video generation?
An AI video generation on Makernice is asynchronous, so no client has to hold one long HTTP call open: POST /v1/generations returns 202 with the generation right away, and you then poll or wait for a webhook. Give each poll request its own timeout (the example uses 30 seconds) and treat a timed-out poll like a network error by sending the same GET again. Size the overall wait to the maximum runtime, 60 minutes for a video and 15 minutes for an image; a run that goes past it fails and its hold is released in full. Note: if a finished output is blocked by output moderation for a policy violation, the run is still charged.
Should you use webhooks or polling with a video generation API?
Use a Makernice webhook when you can receive HTTPS POST requests, and poll when you can't. A video generation can take a few minutes, longer for long or high-resolution clips. If a run goes past its maximum runtime, it fails and the hold is released in full. Use a webhook when you have an HTTPS endpoint that can receive our POST requests: set callback_url when you create the generation, or set an account webhook address in console settings, and we POST the generation when it reaches a final status. Without one, poll GET /v1/generations/{id} as above. A failed delivery is retried after 1 min, 5 min, 30 min, 2 h, 6 h, 12 h (7 attempts in total) and then marked failed, so keep the ids of the generations you are waiting on: if no final event arrives, GET /v1/generations/{id} still returns the result. Recent deliveries and their last response are shown in console settings.
Which video generation API errors should you retry, and which should you fix?
Retry a Makernice error only when the same call, or the same call with a new quote, can succeed; fix everything else first. Branch on error.code with this table, and see the error reference for every code:
| Status | Error code | Retry? | What to do |
|---|---|---|---|
| 500 | internal_error | Yes, with backoff | Repeat with the same Idempotency-Key; log request_id |
| 429 | rate_limited, concurrency_limit_reached | Yes | Wait Retry-After seconds, then repeat the same call |
| 410 | quote_expired | With a new quote | Quote again, then create |
| 409 | quote_already_used | With a new quote | Check the job reused its key, then quote again |
| 422 | quote_mismatch | With a new quote | Quote the final input |
| 422 | idempotency_conflict | No | Use a new key only for a genuinely new job |
| 400 | invalid_request | No | Fix the input; check the mode in GET /v1/models |
| 402 | insufficient_balance | No | Top up in the console |
| 409 | not_cancelable | No | GET the generation to see its status |
| 410 | output_expired | No | Serve the copy in your own storage |
| 404 | task_not_found | No | Check the generation id and the account |
Other codes on create are worth surfacing to a person rather than retrying: 402 key_spend_limit_reached and 402 daily_spend_limit_reached, 403 org_frozen and 404 quote_not_found. Every error body carries error.code, error.message and usually a request_id; branch on the code, not the message, and log the request_id.
Should you retry a 500 or 503 error from the video generation API?
Retry a Makernice 500 internal_error with exponential backoff and a capped number of attempts, and include the request_id if you contact support; treat any other 5xx status the same way. On POST /v1/generations, resend with the same Idempotency-Key, so a create that actually went through is replayed with 200 instead of creating a second generation.
Why does polling a video generation API task return 404?
A Makernice 404 task_not_found means the generation id doesn't exist in your account, so check the id you stored at create time and the key you poll with, which must belong to the same account. Retrying the same id won't change the answer. After a crash, GET /v1/generations?status=queued,generating lists the jobs still in flight, which recovers lost ids.
What causes a 400 invalid_request on the video generation API?
A Makernice 400 invalid_request means the body, query or a header is invalid, and the error's details list each field and the problem. Common causes are a field the model doesn't accept in that mode (aspect_ratio in image-to-video on most models, resolution on fixed-tier models), a duration outside the model's range, or last_image_url sent outside flf mode. Fix the request instead of retrying it; GET /v1/models shows what each model accepts.
When can you cancel a generation?
A Makernice generation can be canceled with POST /v1/generations/{id}/cancel only while the status is queued, and the cancel releases the hold in full. Once a generation is generating, cancel returns 409 not_cancelable. Repeating a cancel that already succeeded also returns 409, so check the status with a GET before deciding what went wrong.
How long do video generation API outputs last, and how should you store them?
Makernice outputs last until their expiresAt, after which GET /v1/generations/{id}/outputs/{n} returns 410 output_expired, so copy every result into your own storage as soon as a generation succeeds. Request GET /v1/generations/{id}/outputs/{n} with your key; it only works once the generation has succeeded and answers with a 302 to a short-lived signed URL. Ask again whenever you need the file rather than storing the redirect target, and add download=1 if you want an attachment. Stored outputs carry an expiresAt (it is null while a file has not been stored yet), and after that the endpoint returns 410 output_expired, so copy results into your own storage as soon as a generation succeeds.
What should you log for every generation?
Log three Makernice identifiers for every generation: the quote id, the idempotency key and the generation id. Together they let you reconstruct what happened: GET /v1/generations/{id} shows the current state, and GET /v1/generations/{id}/events returns a timeline of codes such as created, generating, delivered and failed_refunded, each with a timestamp. After a crash, GET /v1/generations?status=queued,generating lists the jobs still in flight. The same identifiers also make support requests much faster to resolve.
New to the API? Start with the quickstart for the four basic calls, then add these habits; the same flow runs Seedance 2.5 and Wan 3.0. For live prices, call GET /v1/pricing or request a quote with your exact input.
Frequently asked questions
What does the checking status mean in the Makernice API?
Can I reuse an Idempotency-Key for a different generation?
Should I store the URL that outputs/0 redirects to?
Is the Retry-After header in seconds or milliseconds?
How do you measure how long a Makernice generation really takes?
Models in this post
VideoSeedance 2.5
ByteDance's flagship for long takes: up to 30 seconds, 480p to 4K, and up to 16 reference images to keep every shot on-model. Audio is on by default.
VideoWan 3.0
-21%The widest duration range on Makernice — 2 to 30 seconds — at 480p, 720p or 1080p, with every input mode and up to 10 references.