vercel/ai · error

Black Forest Labs supports up to 10 input images.

Error message

Black Forest Labs supports up to 10 input images.

What it means

Black Forest Labs image models (FLUX) accept at most 10 input images for image-to-image / editing operations. getArgs counts the provided images and throws when more than 10 are supplied.

Source

Thrown at packages/black-forest-labs/src/black-forest-labs-image-model.ts:129

    });

    const [widthStr, heightStr] = size?.split('x') ?? [];

    const inputImages: string[] =
      files?.map(file => {
        if (file.type === 'url') {
          return file.url;
        }

        if (typeof file.data === 'string') {
          return file.data;
        }

        return Buffer.from(file.data).toString('base64');
      }) || [];

    if (inputImages.length > 10) {
      throw new Error('Black Forest Labs supports up to 10 input images.');
    }

    const inputImageField =
      this.modelId === 'flux-pro-1.0-fill' ? 'image' : 'input_image';
    const inputImagesObj: Record<string, string> = inputImages.reduce<
      Record<string, string>
    >((acc, img, index) => {
      acc[`${inputImageField}${index === 0 ? '' : `_${index + 1}`}`] = img;
      return acc;
    }, {});

    let maskValue: string | undefined;
    if (mask) {
      if (mask.type === 'url') {
        maskValue = mask.url;
      } else {
        if (typeof mask.data === 'string') {
          maskValue = mask.data;

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Limit the images array to 10 entries, batching the rest into separate requests.
  2. Pre-select the most relevant reference images instead of sending all.
  3. Split into multiple generateImage calls and merge results downstream.

Example fix

// before
await generateImage({ model: flux, images: allTwentyImages });
// after
for (const batch of chunk(allTwentyImages, 10)) {
  await generateImage({ model: flux, images: batch });
}
Defensive patterns

Strategy: validation

Validate before calling

if (images.length > 10) {
  throw new Error('FLUX accepts at most 10 input images; batch the rest');
}

Try / catch

try {
  await generateImage({ model: flux, images });
} catch (e) {
  if (e instanceof Error && e.message.includes('up to 10 input images')) {
    // re-run with images.slice(0, 10)
  }
}

Prevention

When it happens

Trigger: Calling generateImage with a flux model (e.g. flux-pro-1.0-fill or flux-kontext) and an images array containing 11 or more input images.

Common situations: Batch-editing many reference images at once; concatenating image sets without a cap; passing a folder's images in a loop.

Related errors


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