{"record":{"id":"9232306a666a3d77","repo":"vercel/ai","slug":"luma-ai-modify-image-only-supports-a-single-input","errorCode":null,"errorMessage":"Luma AI modify_image only supports a single input image. You provided ${files.length} images.","messagePattern":"Luma AI modify_image only supports a single input image\\. You provided (.+?) images\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/luma/src/luma-image-model.ts","lineNumber":321,"sourceCode":"        for (const [identityId, images] of Object.entries(identities)) {\n          if (images.length > 4) {\n            throw new Error(\n              `Luma AI character supports up to 4 images per identity. ` +\n                `Identity '${identityId}' has ${images.length} images.`,\n            );\n          }\n        }\n\n        options.character = Object.fromEntries(\n          Object.entries(identities).map(([id, images]) => [id, { images }]),\n        );\n        break;\n      }\n\n      case 'modify_image': {\n        // Only supports a single image\n        if (files.length > 1) {\n          throw new Error(\n            'Luma AI modify_image only supports a single input image. ' +\n              `You provided ${files.length} images.`,\n          );\n        }\n        options.modify_image = {\n          url: (files[0] as { type: 'url'; url: string }).url,\n          weight: imageConfigs[0]?.weight ?? defaultWeights.modify_image,\n        };\n        break;\n      }\n    }\n\n    return options;\n  }\n\n  private getLumaGenerationsUrl(generationId?: string) {\n    return `${this.config.baseURL}/dream-machine/v1/generations/${\n      generationId ?? 'image'","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/luma/src/luma-image-model.ts#L303-L339","documentation":"Thrown by getEditingOptions when the 'modify_image' reference type receives more than one input image. Luma's modify_image mode operates on exactly one source image, so the SDK rejects multi-image requests client-side before hitting the API.","triggerScenarios":"Calling generateImage with a luma image model with referenceType/modify_image set and passing 2 or more images in prompt.images.","commonSituations":"Reusing the same images array across modes and forgetting to trim it for modify_image; switching from 'image' reference mode (up to 4) to 'modify_image' without adjusting the input count.","solutions":["Pass exactly one image when using modify_image.","If you need multiple references, switch the reference type to 'image' (supports up to 4).","Composite the multiple source images into one image before modifying.","Validate prompt.images.length === 1 in your app code before calling modify_image."],"exampleFix":"// before\nprompt: { text: 'colorize', images: [imgA, imgB], referenceType: 'modify_image' }\n// after\nprompt: { text: 'colorize', images: [imgA], referenceType: 'modify_image' }","handlingStrategy":"validation","validationCode":"if (mode === 'modify_image' && (images ?? []).length !== 1) {\n  throw new Error('modify_image requires exactly one input image');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await generateImage({ model: lumaImage, prompt });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('modify_image only supports a single input image')) {\n    return generateImage({ model: lumaImage, prompt: { ...prompt, images: prompt.images.slice(0, 1) } });\n  }\n  throw e;\n}","preventionTips":["Trim the images array to exactly one entry whenever referenceType is modify_image.","Switch to the 'image' reference type when multiple references are needed.","Add a form/UI constraint preventing multi-select in modify_image mode.","Cover each reference mode's count rules in unit tests."],"tags":["validation","image-limits","modify-image","luma"],"backgroundTag":"provider-limit-exceeded","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}