vercel/ai · error · AISDKError

BLACK_FOREST_LABS_VIDEO_GENERATION_TIMEOUT

BLACK_FOREST_LABS_VIDEO_GENERATION_TIMEOUT

Error message

Black Forest Labs video generation timed out after ${pollTimeoutMillis}ms. Request id: ${operation.requestId}

What it means

Thrown in doGenerate when the polling loop has waited longer than pollTimeoutMillis (Date.now() - startTime > pollTimeoutMillis) without the BFL video operation reaching a terminal state. AISDKError named BLACK_FOREST_LABS_VIDEO_GENERATION_TIMEOUT includes the configured timeout and the provider request id. Video generation can take minutes, so the default timeout may simply be too short for high resolutions/long durations.

Source

Thrown at packages/black-forest-labs/src/black-forest-labs-video-model.ts:714

    return { status: 'pending', response };
  }

  async doGenerate(
    options: BlackForestLabsVideoDoGenerateOptions,
  ): Promise<VideoModelV4Result> {
    const startResult = await this.doStart(options);
    const operation = startResult.operation as BlackForestLabsVideoOperation;
    const pollIntervalMillis =
      this.config.pollIntervalMillis ?? DEFAULT_POLL_INTERVAL_MILLIS;
    const pollTimeoutMillis =
      this.config.pollTimeoutMillis ?? DEFAULT_POLL_TIMEOUT_MILLIS;
    const startTime = Date.now();

    while (true) {
      await delay(pollIntervalMillis, { abortSignal: options.abortSignal });

      if (Date.now() - startTime > pollTimeoutMillis) {
        throw new AISDKError({
          name: 'BLACK_FOREST_LABS_VIDEO_GENERATION_TIMEOUT',
          message:
            `Black Forest Labs video generation timed out after ${pollTimeoutMillis}ms. ` +
            `Request id: ${operation.requestId}`,
        });
      }

      const statusResult = await this.doStatus({
        operation,
        headers: options.headers,
        abortSignal: options.abortSignal,
      });

      if (statusResult.status === 'pending') {
        continue;
      }

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

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Increase the poll timeout option (pollTimeoutMillis / provider timeout setting) for long or high-resolution generations.
  2. Retry the request; if it persists, check BFL status/queue conditions and the request id.
  3. Use the start-then-poll API (doStart + doStatus) so your own scheduler controls the wait instead of the SDK's fixed timeout.
  4. Verify the abortSignal is not cutting the polling loop short in a way that leaves it pending.

Example fix

// before
await generateVideo({ model: bfl.video('flux-3'), prompt });
// after
await generateVideo({ model: bfl.video('flux-3'), prompt, pollTimeoutMillis: 600000 });
Defensive patterns

Strategy: retry

Try / catch

try {
  const video = await generateVideo({ model, prompt, pollTimeoutMillis: 600000 });
} catch (e) {
  if (AISDKError.isInstance(e) && e.name === 'BLACK_FOREST_LABS_VIDEO_GENERATION_TIMEOUT') {
    // retry with a longer timeout or fall back to doStart + manual doStatus polling
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling generateVideo on a BFL video model where the operation stays pending past pollTimeoutMillis of the polling loop (delay + status checks).

Common situations: Generating long (up to 20s) or high-resolution videos that exceed the default timeout; BFL API congestion or incidents leaving jobs queued; using doStart + doStatus yourself with a short custom timeout.

Understand the failure class

Related errors


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