Back to timeline

AI Gateway now supports asynchronous video generation

Vercel News·Kevin Dawkins·

on AI Gateway can now run asynchronously. Video generation

By default, 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.generateVideo

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 calls continue to work as before. All four options support text-to-video, image-to-video, reference-to-video, and other video inputs.generateVideo

Install the latest versions of the AI SDK and AI Gateway provider:

Pass to 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 call.webhookgenerateVideogenerateVideo

The calling process and webhook handler need a shared token and store so the delivery can be matched to the correct generation. does not expose the signing secret for this workflow. See the for the complete receiver pattern.generateVideowebhook verification documentation

Both the polling and webhook options for return as objects. The SDK downloads provider-hosted videos, making , , and available in either workflow.generateVideoresult.videosGeneratedFileuint8Arraybase64mediaType

Add to an existing call:pollgenerateVideo

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 resolves, but no individual request to AI Gateway stays open for the full generation.generateVideo

returns an operation as soon as AI Gateway accepts the job, without waiting for rendering to finish. Store that operation and pass it to later from the same process or another one:startVideogetVideoStatus

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 to to receive a completion event instead of checking the status. The start response includes the signing secret needed to verify the webhook.webhookUrlstartVideo

Unlike , does not download hosted videos. It returns provider URLs or inline bytes. Hosted URLs can expire, so download any videos you need to keep.generateVideogetVideoStatus

Every asynchronous generation appears on the as soon as it starts. Jobs show as Running while generation is in progress and update when they complete or fail.AI Gateway Logs page

Under , select to show only asynchronous jobs. Opening an entry shows the job ID and the request details.Request ModeAsync

Only asynchronous workflows create jobs. A standard call appears as a single completed request after the video is ready.generateVideo

For size limits, idempotency for retried job starts, webhook delivery retries, and other operational details, read the or .asynchronous video generation documentationbrowse all video models

Read more

Upgrade the SDK

Use asynchronous video generation

Monitor asynchronous jobs

Use a webhook with generateVideo

Poll with generateVideo

Start a job and retrieve it later