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

  1. Pass exactly one image when using modify_image.
  2. If you need multiple references, switch the reference type to 'image' (supports up to 4).
  3. Composite the multiple source images into one image before modifying.
  4. 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

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


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/9232306a666a3d77. Report an issue: GitHub.