{"record":{"id":"cb5c845404c1cd1b","repo":"vercel/ai","slug":"image-generation-failed","errorCode":null,"errorMessage":"Image generation failed.","messagePattern":"Image generation failed\\.","errorType":"exception","errorClass":"InvalidResponseDataError","httpStatus":null,"severity":"error","filePath":"packages/luma/src/luma-image-model.ts","lineNumber":204,"sourceCode":"        abortSignal,\n        fetch: this.config.fetch,\n        failedResponseHandler: this.createLumaErrorHandler(),\n        successfulResponseHandler: createJsonResponseHandler(\n          lumaGenerationResponseSchema,\n        ),\n      });\n\n      switch (statusResponse.state) {\n        case 'completed':\n          if (!statusResponse.assets?.image) {\n            throw new InvalidResponseDataError({\n              data: statusResponse,\n              message: `Image generation completed but no image was found.`,\n            });\n          }\n          return statusResponse.assets.image;\n        case 'failed':\n          throw new InvalidResponseDataError({\n            data: statusResponse,\n            message: `Image generation failed.`,\n          });\n      }\n      await delay(pollIntervalMillis);\n    }\n\n    throw new Error(\n      `Image generation timed out after ${this.maxPollAttempts} attempts.`,\n    );\n  }\n\n  private createLumaErrorHandler() {\n    return createJsonErrorResponseHandler({\n      errorSchema: lumaErrorSchema,\n      errorToMessage: (error: LumaErrorData) =>\n        error.detail[0].msg ?? 'Unknown error',\n    });","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/luma/src/luma-image-model.ts#L186-L222","documentation":"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.","triggerScenarios":"Polling a Luma image generation whose status response has state 'failed' — the provider rejected or aborted the job (unsafe prompt, capacity issues, invalid params).","commonSituations":"Prompts rejected by Luma's safety filters, unsupported aspect ratio/model options, transient Luma capacity failures, or account/quota problems.","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"],"exampleFix":"// before\nconst { image } = await generateImage({ model: luma.image('photon-1'), prompt: 'cat' }); // state: failed\n// after\ntry {\n  const { image } = await generateImage({ model: luma.image('photon-1'), prompt: 'a cat sitting on a windowsill' });\n} catch (e) {\n  if (InvalidResponseDataError.isInstance(e)) console.log(e.data.state, e.data.failure_reason);\n}","handlingStrategy":"try-catch","validationCode":"// pre-flight: keep prompts within Luma content policy and supported options\nconst safePrompt = prompt.trim();\nif (safePrompt.length === 0) throw new Error('Prompt required');\n// avoid unsupported aspect ratios / model ids for your Luma account","typeGuard":"function isFailedGeneration(r: unknown): r is { state: 'failed'; failure_reason?: string } {\n  return (r as any)?.state === 'failed';\n}","tryCatchPattern":"try {\n  const { image } = await generateImage({ model: luma.image('photon-1'), prompt });\n} catch (e) {\n  if (InvalidResponseDataError.isInstance(e) && e.data?.state === 'failed') {\n    console.warn('Luma generation failed:', e.data.failure_reason); // adjust prompt/params and retry\n  } else throw e;\n}","preventionTips":["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"],"tags":["image","generation-failed","polling","invalid-data"],"backgroundTag":"image-generation-failed","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}