vercel/ai · error

Video generation timed out after ${timeoutMs}ms.

Error message

Video generation timed out after ${timeoutMs}ms.

What it means

In the start/status (polling) flow of experimental_generateVideo, the SDK polls model.doStatus until the operation completes; if the elapsed time since the operation started reaches timeoutMs before completion, it throws 'Video generation timed out after {timeoutMs}ms'. Video generation is slow and asynchronous, so the SDK bounds polling with the caller-provided (or default) timeout.

Source

Thrown at packages/ai/src/generate-video/generate-video.ts:555

  const delay = pollConfig?.delay ?? defaultDelay;
  const startTime = Date.now();

  if (webhookReceived != null) {
    // 3a. Webhook flow: wait for webhook, then get final status
    await waitForWebhook({
      received: webhookReceived,
      timeoutMs,
      abortSignal: callOptions.abortSignal,
      delay,
    });
  }

  while (true) {
    if (webhookReceived == null) {
      // 3b. Polling flow (also used when webhooks are not supported)
      const elapsedMs = Date.now() - startTime;
      if (elapsedMs >= timeoutMs) {
        throw new Error(`Video generation timed out after ${timeoutMs}ms.`);
      }
      await delay(Math.min(intervalMs, timeoutMs - elapsedMs), {
        abortSignal: callOptions.abortSignal,
      });
      if (Date.now() - startTime >= timeoutMs) {
        throw new Error(`Video generation timed out after ${timeoutMs}ms.`);
      }
    }

    const statusResult = await retry(() =>
      model.doStatus!({
        operation: startResult.operation,
        abortSignal: callOptions.abortSignal,
        headers: callOptions.headers,
      }),
    );

    if (statusResult.status === 'error') {

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Increase the timeout option passed to experimental_generateVideo to cover realistic generation times (minutes, not seconds).
  2. Check the provider dashboard/logs to see if the operation actually failed or is queued.
  3. Retry the generation; a fresh operation may complete faster.
  4. Verify the timeout unit is milliseconds.
  5. Wrap the call in try/catch and re-submit with a larger timeout on timeout errors.

Example fix

// before
await experimental_generateVideo({ model, prompt, poll: { timeoutMs: 10_000 } });

// after
await experimental_generateVideo({ model, prompt, poll: { timeoutMs: 600_000 } }); // allow 10 minutes
Defensive patterns

Strategy: retry

Validate before calling

const MIN_VIDEO_TIMEOUT_MS = 5 * 60_000;
if (poll?.timeoutMs != null && poll.timeoutMs < MIN_VIDEO_TIMEOUT_MS) {
  console.warn(`timeoutMs ${poll.timeoutMs} is likely too small for video generation`);
}

Type guard

null

Try / catch

try {
  const result = await experimental_generateVideo({ model, prompt, poll: { timeoutMs: 600_000, intervalMs: 10_000 } });
} catch (error) {
  if (error instanceof Error && /Video generation timed out/.test(error.message)) {
    // check provider operation status, then resubmit with a larger timeout
  } else throw error;
}

Prevention

When it happens

Trigger: The provider operation stays pending longer than timeoutMs — very long generations, a stuck/failed provider operation that never changes status, or an explicitly low timeoutMs passed via poll/timeout options.

Common situations: Setting timeoutMs too small for a slow video model; provider incidents where status never leaves 'pending'; queuing delays at the provider during peak load; passing timeoutMs in the wrong unit (seconds vs milliseconds).

Understand the failure class

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/859e15c43ddf020d. Report an issue: GitHub.