{"record":{"id":"f16fc1e16c2a8390","repo":"vercel/ai","slug":"luma-ai-does-not-support-mask-based-image-editing","errorCode":null,"errorMessage":"Luma AI does not support mask-based image editing. Use the prompt to describe the changes you want to make, along with `prompt.images` containing the source image URL.","messagePattern":"Luma AI does not support mask-based image editing\\. Use the prompt to describe the changes you want to make, along with `prompt\\.images` containing the source image URL\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/luma/src/luma-image-model.ts","lineNumber":235,"sourceCode":"  private createLumaErrorHandler() {\n    return createJsonErrorResponseHandler({\n      errorSchema: lumaErrorSchema,\n      errorToMessage: (error: LumaErrorData) =>\n        error.detail[0].msg ?? 'Unknown error',\n    });\n  }\n\n  private getEditingOptions(\n    files: ImageModelV4File[] | undefined,\n    mask: ImageModelV4File | undefined,\n    referenceType: LumaReferenceType = 'image',\n    imageConfigs: Array<{ weight?: number | null; id?: string | null }> = [],\n  ): Record<string, unknown> {\n    const options: Record<string, unknown> = {};\n\n    // Luma does not support mask-based inpainting\n    if (mask != null) {\n      throw new Error(\n        'Luma AI does not support mask-based image editing. ' +\n          'Use the prompt to describe the changes you want to make, along with ' +\n          '`prompt.images` containing the source image URL.',\n      );\n    }\n\n    if (files == null || files.length === 0) {\n      return options;\n    }\n\n    // Validate all files are URL-based\n    for (const file of files) {\n      if (file.type !== 'url') {\n        throw new Error(\n          'Luma AI only supports URL-based images. ' +\n            'Please provide image URLs using `prompt.images` with publicly accessible URLs. ' +\n            'Base64 and Uint8Array data are not supported.',\n        );","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/luma/src/luma-image-model.ts#L217-L253","documentation":"Thrown by getEditingOptions when an image editing request includes a mask. Luma's image API does not support mask-based inpainting, so the SDK rejects masks up front instead of sending an unsupported parameter to the API. The guidance is to express edits via the prompt and supply the source image through prompt.images.","triggerScenarios":"Calling generateImage with a luma image model and passing a mask (e.g. images array item with mask, or edit options carrying a mask) alongside the source image.","commonSituations":"Migrating code from OpenAI's DALL·E image edit (which requires a mask) to Luma; building a provider-agnostic pipeline that always includes masks for 'erase object' style edits.","solutions":["Remove the mask from the request entirely.","Describe the desired edit in the prompt text (e.g. 'replace the sky with a sunset').","Pass the source image via prompt.images as a publicly accessible URL.","If mask-based inpainting is a hard requirement, use a provider that supports it (e.g. OpenAI) instead of Luma."],"exampleFix":"// before\nawait generateImage({\n  model: luma.image('photon-flash-1'),\n  prompt: { text: 'remove the car', images: [{ type: 'url', url: src }], mask: maskUrl },\n});\n// after\nawait generateImage({\n  model: luma.image('photon-flash-1'),\n  prompt: { text: 'remove the car', images: [{ type: 'url', url: src }] },\n});","handlingStrategy":"validation","validationCode":"function assertNoMask(images) {\n  if (images && images.some(i => 'mask' in i && i.mask != null)) {\n    throw new Error('Luma does not support masks; describe edits in the prompt instead');\n  }\n}","typeGuard":"function hasMask(p: { images?: Array<{ mask?: unknown }> }): boolean {\n  return p.images?.some(i => i.mask != null) ?? false;\n}","tryCatchPattern":"try {\n  await generateImage({ model: lumaImage, prompt });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('mask-based image editing')) {\n    // fall back: strip mask and rely on prompt-only editing\n    const { mask, ...rest } = prompt;\n    return generateImage({ model: lumaImage, prompt: rest });\n  }\n  throw e;\n}","preventionTips":["Never send masks to provider-agnostic image pipelines targeting Luma.","Design edit features prompt-first so they degrade gracefully across providers.","Add a pre-flight capability check when a provider switch can occur at runtime.","Keep a provider-feature matrix in tests to catch mask usage early."],"tags":["unsupported-feature","image-editing","mask","luma"],"backgroundTag":"unsupported-provider-feature","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}