How to wait for a video-generation API task without burning
How to wait for a video-generation API task without burning your rate limit
A video-generation API usually does not return the MP4 in the create response. You get a task id, then you either wait for a signed webhook or poll a task endpoint until the job is completed, failed, or cancelled.
Polling works, but it is easy to overdo. Each poll is a request and typically counts against the same rate limits as create calls. A practical pattern from production docs is to poll every 5–10 seconds at first, then back off to about 30 seconds if the job is still running. Tight loops do not make the video finish faster; they just spend quota and can trip 429s.
Webhooks are usually the better default when you can expose an HTTPS endpoint. Prefer signed deliveries, and handle the terminal events you actually need: completed, failed, and cancelled. Keep the polling path as a fallback for missed deliveries, not as the primary wait loop.
Two other details are easy to miss. First, the output video URL is often temporary. If a provider keeps the file for a limited window (for example, seven days with an expires_at timestamp), download the MP4 to your own storage instead of hot-linking the temporary URL. Second, a credit balance in the billing console is not always the same as spendable credits. Some APIs hold credits when a task is created and only settle them when it completes; a 402 insufficient_credits error can appear even when the console still shows a larger total, because held credits are not spendable.
If you are wiring this for the first time, FiveAPI documents this shape as a prepaid video-generation REST API: Bearer-token auth, POST to create a text-to-video, image-to-video, reference-to-video, or video-extend task, then a signed webhook or GET /v1/tasks/{task_id}. Inputs are public HTTPS URLs (there is no upload endpoint in v1), and new production accounts may be reviewed before they can create keys. Do not expect an instant unrestricted key, unlimited generation, or unfiltered output; failed jobs can return a content-moderation error.
Start with one small task, log the request id, confirm the webhook signature, and download the MP4 before it expires. That path is slower to type than a tight poll loop, and it is much easier to run in production.