vercel/ai · error · Error
Luma AI modify_image only supports a single input image. You
Error message
Luma AI modify_image only supports a single input image. You provided ${files.length} images. What it means
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.
Source
Thrown at packages/luma/src/luma-image-model.ts:321
for (const [identityId, images] of Object.entries(identities)) {
if (images.length > 4) {
throw new Error(
`Luma AI character supports up to 4 images per identity. ` +
`Identity '${identityId}' has ${images.length} images.`,
);
}
}
options.character = Object.fromEntries(
Object.entries(identities).map(([id, images]) => [id, { images }]),
);
break;
}
case 'modify_image': {
// Only supports a single image
if (files.length > 1) {
throw new Error(
'Luma AI modify_image only supports a single input image. ' +
`You provided ${files.length} images.`,
);
}
options.modify_image = {
url: (files[0] as { type: 'url'; url: string }).url,
weight: imageConfigs[0]?.weight ?? defaultWeights.modify_image,
};
break;
}
}
return options;
}
private getLumaGenerationsUrl(generationId?: string) {
return `${this.config.baseURL}/dream-machine/v1/generations/${
generationId ?? 'image'View on GitHub (pinned to 69428b1f8b)
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.
Example fix
// before
prompt: { text: 'colorize', images: [imgA, imgB], referenceType: 'modify_image' }
// after
prompt: { text: 'colorize', images: [imgA], referenceType: 'modify_image' } Defensive patterns
Strategy: validation
Validate before calling
if (mode === 'modify_image' && (images ?? []).length !== 1) {
throw new Error('modify_image requires exactly one input image');
} Try / catch
try {
await generateImage({ model: lumaImage, prompt });
} catch (e) {
if (e instanceof Error && e.message.includes('modify_image only supports a single input image')) {
return generateImage({ model: lumaImage, prompt: { ...prompt, images: prompt.images.slice(0, 1) } });
}
throw e;
} Prevention
- 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.
When it happens
Trigger: Calling generateImage with a luma image model with referenceType/modify_image set and passing 2 or more images in prompt.images.
Common situations: 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.
Related errors
- Luma AI image supports up to 4 reference images. You provide
- Luma AI character supports up to 4 images per identity. Iden
- maxEmbeddingsPerCall must be greater than 0
- maxInputBytesPerCall must be greater than 0
- No image generated.
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/9232306a666a3d77.
Report an issue: GitHub.