vercel/ai · error · Error

Image generation timed out after ${this.maxPollAttempts} att

Error message

Image generation timed out after ${this.maxPollAttempts} attempts.

What it means

Thrown by pollForImageUrl when the Luma image generation request did not reach a terminal state within maxPollAttempts polling cycles. Luma's generate API is asynchronous: the model polls the generation status until it succeeds or fails, and this generic Error signals the polling budget was exhausted. It does not indicate the image definitively failed — generation may still complete later on Luma's side.

Source

Thrown at packages/luma/src/luma-image-model.ts:212

      switch (statusResponse.state) {
        case 'completed':
          if (!statusResponse.assets?.image) {
            throw new InvalidResponseDataError({
              data: statusResponse,
              message: `Image generation completed but no image was found.`,
            });
          }
          return statusResponse.assets.image;
        case 'failed':
          throw new InvalidResponseDataError({
            data: statusResponse,
            message: `Image generation failed.`,
          });
      }
      await delay(pollIntervalMillis);
    }

    throw new Error(
      `Image generation timed out after ${this.maxPollAttempts} attempts.`,
    );
  }

  private createLumaErrorHandler() {
    return createJsonErrorResponseHandler({
      errorSchema: lumaErrorSchema,
      errorToMessage: (error: LumaErrorData) =>
        error.detail[0].msg ?? 'Unknown error',
    });
  }

  private getEditingOptions(
    files: ImageModelV4File[] | undefined,
    mask: ImageModelV4File | undefined,
    referenceType: LumaReferenceType = 'image',
    imageConfigs: Array<{ weight?: number | null; id?: string | null }> = [],
  ): Record<string, unknown> {

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Increase the maxPollAttempts provider option (e.g. to 30-60) when constructing the image model.
  2. Increase pollIntervalMillis so Luma has more wall-clock time between status checks.
  3. Retry the generation once; transient queue delays often resolve on a second attempt.
  4. If it persists, check Luma's status/queue conditions or reduce prompt complexity (fewer reference images, simpler aspect ratio).

Example fix

// before
const luma = createLuma({ apiKey });
const model = luma.image('photon-flash-1');
// after
const luma = createLuma({ apiKey });
const model = luma.image('photon-flash-1', {
  maxPollAttempts: 60,
  pollIntervalMillis: 2000,
});
Defensive patterns

Strategy: retry

Validate before calling

// Ensure generous polling budget before calling
const opts = { maxPollAttempts: 60, pollIntervalMillis: 2000 };
if ((opts.maxPollAttempts * opts.pollIntervalMillis) < 60000) {
  throw new Error('Polling budget under 60s; increase maxPollAttempts/pollIntervalMillis');
}

Try / catch

try {
  const { image } = await generateImage({ model: luma.image('photon-flash-1', { maxPollAttempts: 60 }), prompt });
} catch (e) {
  if (e instanceof Error && /timed out after \d+ attempts/.test(e.message)) {
    // retry once with a larger budget
    return generateImage({ model: luma.image('photon-flash-1', { maxPollAttempts: 120 }), prompt });
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling generateImage/doGenerate with a luma.imageModel(...) while the generation stays in a non-terminal state (e.g. 'queued'/'dreaming') for longer than maxPollAttempts × pollIntervalMillis. Typical with slow models, heavy queue times, or when maxPollAttempts/pollIntervalMillis provider options are set too low.

Common situations: Long Luma API queue during peak hours; developers passing a small maxPollAttempts (e.g. 10) with a short pollIntervalMillis; complex multi-reference requests that take longer to render; network latency making each poll slower than intended.

Understand the failure class

Related errors


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