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
- Read error.data (statusResponse) / Luma dashboard for the failure_reason of the generation id
- Adjust the prompt or generation options (aspect ratio, model id) that may have triggered rejection
- Retry the generation — some failures are transient capacity issues
- Verify account quota/billing status with Luma
- 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
- Check failure_reason in e.data before retrying — do not blind-retry policy rejections
- Keep prompts compliant with Luma content policy
- Use supported aspect ratios/model ids for your Luma plan
- Add bounded retries for transient capacity failures
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
- Image generation completed but no image was found.
- Video generation timed out after ${timeoutMs}ms.
- Unsupported image mime type: ${mimeType}, expected one of: $
- Transcription request was aborted
- Transcription failed: ${transcript.error ?? 'Unknown error'}
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/cb5c845404c1cd1b.
Report an issue: GitHub.