deniz.in

Markets

Weather

Loading weather

· via Vercel blog

Vercel AI Gateway adds async video generation to avoid request timeouts

Vercel's AI Gateway can now run video generation as background jobs, adding webhook, polling, and start-and-retrieve workflows so long renders no longer break on HTTP timeouts.

Vercel AI Gateway adds async video generation to avoid request timeouts

Vercel has added asynchronous video generation to AI Gateway, its unified API for calling hosted AI models. According to the company's changelog post published on August 25, the change tackles a structural problem: the AI SDK's generateVideo function normally keeps a single HTTP request to the gateway open until the finished video comes back, and because rendering a clip can take anywhere from seconds to minutes, that request can outlive the timeout limits of the servers, proxies, and platforms sitting in the request path.

Three asynchronous workflows

Vercel now describes four supported modes: the original blocking call plus three asynchronous alternatives. Existing generateVideo invocations keep working unchanged, every mode handles text-to-video, image-to-video, reference-to-video, and other video inputs, and the right choice depends on whether the calling process can stay alive and whether the application can receive webhooks.

The first option attaches a webhook to generateVideo. AI Gateway emits an event when the render finishes or fails; the SDK waits for it, downloads the resulting clips, and resolves the original call. Vercel notes that the caller and the webhook receiver need a shared token and store to match a delivery to the correct generation, and that this particular flow does not expose the webhook signing secret — the full receiver pattern lives in separate documentation.

The second option is polling. Adding a poll object to generateVideo starts an async job and then has the SDK fire a short status request at a chosen interval — five seconds by default — until the video is ready or a limit is reached, ten minutes by default. The calling process still has to stay alive until the promise resolves, but no individual request to the gateway stays open for the whole render.

The third splits the work across requests entirely. startVideo submits the job and immediately returns an operation handle, which getVideoStatus can query later — from the same process or a different one. The operation is JSON-serializable, so it can be persisted in a database or routed through a queue, and there is no built-in timeout because the application decides how long to keep checking. startVideo also accepts a webhookUrl, and in that flow the start response does include the signing secret needed to verify deliveries. One caveat: getVideoStatus does not download hosted files. It returns provider URLs or inline bytes, and hosted URLs can expire, so anything worth keeping should be downloaded.

The code samples in the post demonstrate the workflows against models such as klingai/kling-v3.0-t2v, spacexai/grok-imagine-video-1.5, and bytedance/seedance-2.5.

Observability

Every asynchronous generation appears on the AI Gateway Logs page as soon as it starts, listed as Running and updated when the job completes or fails. A Request Mode filter narrows the view to async jobs only, and opening an entry shows the job ID and request details. Standard synchronous calls still show up as a single completed request once the video is ready.

To use the new modes, developers need to install the latest versions of the ai and @ai-sdk/gateway packages.

Why it matters

Video generation times sit awkwardly between a slow API call and a batch job, and neither a browser nor a typical server timeout is comfortable holding a connection open for minutes. By offering webhooks, short-interval polling, and durable operation handles that survive across processes, Vercel is handing developers the same patterns they already use for other long-running work — which matters most on ephemeral, per-request compute where a process may not outlive the render. The JSON-serializable operation is the most flexible of the three: it fits naturally into queues and databases, letting a job started by one request be claimed and finished by another. The remaining sharp edge is asset lifetime — provider-hosted URLs can expire — so applications still need their own download-and-store step for anything they intend to keep.

  • #ai-gateway
  • #vercel
  • #video-generation
  • #ai-sdk
  • #webhooks

Related posts