> Markdown copy of https://makernice.com/blog/api-integration-best-practices/ for AI tools. The HTML page is the canonical version.

[← All posts](https://makernice.com/blog/)

Guides

# What Are Video Generation API Best Practices for Retries and Polling?

Makernice Team · 2026-10-05 · Updated 2026-11-12

Prices as of December 3, 2026 (price list v18).

## Key takeaways

-   Every POST /v1/generations needs an Idempotency-Key of 1 to 200 printable ASCII characters, and a retry with the same key returns 200 with the original generation.
-   A quote is valid for 12 minutes and for one generation; 410 quote\_expired, 409 quote\_already\_used and 422 quote\_mismatch are all fixed by requesting a new quote.
-   On 429 rate\_limited or 429 concurrency\_limit\_reached, wait the number of seconds in the Retry-After header before the next call.
-   POST /v1/generations/{id}/cancel only works while the status is queued and releases the hold in full; otherwise it returns 409 not\_cancelable.
-   Output downloads return a 302 to a short-lived signed URL, and once a file has expired the endpoint returns 410 output\_expired.

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.

One idempotency key per job turns every retry into a safe replay instead of a second charge.

## 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](https://makernice.com/docs/#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](https://makernice.com/docs/#errors) 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](https://makernice.com/docs/#quickstart) for the four basic calls, then add these habits; the same flow runs [Seedance 2.5](https://makernice.com/models/seedance-2-5/) and [Wan 3.0](https://makernice.com/models/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?

checking means we are confirming a result before it is final. The amount stays held, so keep polling until you see succeeded, failed or canceled.

#### Can I reuse an Idempotency-Key for a different generation?

No. A key must be unique within your account. Sending it again with a different quote or different price-affecting parameters returns 422 idempotency\_conflict.

#### Should I store the URL that outputs/0 redirects to?

No. The redirect points to a short-lived signed URL. Request /v1/generations/{id}/outputs/0 again each time you need the file, or keep your own copy.

#### Is the Retry-After header in seconds or milliseconds?

Seconds. Every 429 response carries Retry-After as the number of seconds to wait before retrying.

#### How do you measure how long a Makernice generation really takes?

Read the timestamps in GET /v1/generations/{id}/events. The gap from created to submitted is how long the job waited before it reached the model, and the gap from submitted to delivered is the model's run plus the output check, since delivered appears only after that check finishes. The maximum runtime is 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.

## Models in this post

Video

### Seedance 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.

By ByteDanceFrom $0.1152/s

https://makernice.com/models/seedance-2-5/

Video

### Wan 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.

By AlibabaFrom $0.0394/s

https://makernice.com/models/wan-3-0/
