Video generation on AI Gateway can now run asynchronously.
By default, generateVideo
keeps one HTTP request to AI Gateway open until the result is ready. Because video generation can take seconds or minutes, that request can exceed request timeouts.
With asynchronous generation, your application can receive a webhook, poll for completion, or start a generation and retrieve the result in a later request.
Choose an option based on whether your process can keep running and whether your application can receive webhooks:
Existing generateVideo
calls continue to work as before. All four options support text-to-video, image-to-video, reference-to-video, and other video inputs.
Install the latest versions of the AI SDK and AI Gateway provider:
generateVideo
Pass webhook
to generateVideo
to wait for a completion event without polling. AI Gateway sends an event when the job completes or fails. The SDK waits for that event, fetches the generated videos, and resolves the original generateVideo
call.
The calling process and webhook handler need a shared token and store so the delivery can be matched to the correct generation. generateVideo
does not expose the signing secret for this workflow. See the webhook verification documentation for the complete receiver pattern.
Both the polling and webhook options for generateVideo
return result.videos
as GeneratedFile
objects. The SDK downloads provider-hosted videos, making uint8Array
, base64
, and mediaType
available in either workflow.
generateVideo
Add poll
to an existing generateVideo
call:
AI Gateway starts an asynchronous job, and the SDK sends a short status request at each interval until the job finishes. The calling process must remain running until generateVideo
resolves, but no individual request to AI Gateway stays open for the full generation.
startVideo
returns an operation as soon as AI Gateway accepts the job, without waiting for rendering to finish. Store that operation and pass it to getVideoStatus
later from the same process or another one:
The operation is JSON-serializable, so it can be stored in a database or passed through a queue. Your application controls how long to keep checking the job because this workflow has no built-in timeout.
You can also pass webhookUrl
to startVideo
to receive a completion event instead of checking the status. The start response includes the signing secret needed to verify the webhook.
Unlike generateVideo
, getVideoStatus
does not download hosted videos. It returns provider URLs or inline bytes. Hosted URLs can expire, so download any videos you need to keep.
Every asynchronous generation appears on the AI Gateway Logs page as soon as it starts. Jobs show as Running while generation is in progress and update when they complete or fail.
Under Request Mode, select Async to show only asynchronous jobs. Opening an entry shows the job ID and the request details.
Only asynchronous workflows create jobs. A standard generateVideo
call appears as a single completed request after the video is ready.
For size limits, idempotency for retried job starts, webhook delivery retries, and other operational details, read the asynchronous video generation documentation or browse all video models.