vercel/ai · error · InvalidResponseDataError

Image generation failed.

Error message

Image generation failed.

What it means

When Luma reports the generation state as 'failed', pollForImageUrl throws InvalidResponseDataError with the message 'Image generation failed.' and the full statusResponse as data. This is the library surfacing a server-side generation failure to the caller in a typed, inspectable way.

Source

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

        abortSignal,
        fetch: this.config.fetch,
        failedResponseHandler: this.createLumaErrorHandler(),
        successfulResponseHandler: createJsonResponseHandler(
          lumaGenerationResponseSchema,
        ),
      });

      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',
    });

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Read error.data (statusResponse) / Luma dashboard for the failure_reason of the generation id
  2. Adjust the prompt or generation options (aspect ratio, model id) that may have triggered rejection
  3. Retry the generation — some failures are transient capacity issues
  4. Verify account quota/billing status with Luma
  5. Upgrade @ai-sdk/luma in case failure payload parsing changed

Example fix

// before
const { image } = await generateImage({ model: luma.image('photon-1'), prompt: 'cat' }); // state: failed
// after
try {
  const { image } = await generateImage({ model: luma.image('photon-1'), prompt: 'a cat sitting on a windowsill' });
} catch (e) {
  if (InvalidResponseDataError.isInstance(e)) console.log(e.data.state, e.data.failure_reason);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: keep prompts within Luma content policy and supported options
const safePrompt = prompt.trim();
if (safePrompt.length === 0) throw new Error('Prompt required');
// avoid unsupported aspect ratios / model ids for your Luma account

Type guard

function isFailedGeneration(r: unknown): r is { state: 'failed'; failure_reason?: string } {
  return (r as any)?.state === 'failed';
}

Try / catch

try {
  const { image } = await generateImage({ model: luma.image('photon-1'), prompt });
} catch (e) {
  if (InvalidResponseDataError.isInstance(e) && e.data?.state === 'failed') {
    console.warn('Luma generation failed:', e.data.failure_reason); // adjust prompt/params and retry
  } else throw e;
}

Prevention

When it happens

Trigger: Polling a Luma image generation whose status response has state 'failed' — the provider rejected or aborted the job (unsafe prompt, capacity issues, invalid params).

Common situations: Prompts rejected by Luma's safety filters, unsupported aspect ratio/model options, transient Luma capacity failures, or account/quota problems.

Related errors


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