vercel/ai · error · Error

Luma AI only supports URL-based images. Please provide image

Error message

Luma AI only supports URL-based images. Please provide image URLs using `prompt.images` with publicly accessible URLs. Base64 and Uint8Array data are not supported.

What it means

Thrown by getEditingOptions when any provided input image is not URL-based (base64 or Uint8Array data). Luma's image editing API only accepts publicly accessible image URLs, so the SDK validates file types before the request and rejects binary image data with this error.

Source

Thrown at packages/luma/src/luma-image-model.ts:249

    const options: Record<string, unknown> = {};

    // Luma does not support mask-based inpainting
    if (mask != null) {
      throw new Error(
        '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.',
      );
    }

    if (files == null || files.length === 0) {
      return options;
    }

    // Validate all files are URL-based
    for (const file of files) {
      if (file.type !== 'url') {
        throw new Error(
          'Luma AI only supports URL-based images. ' +
            'Please provide image URLs using `prompt.images` with publicly accessible URLs. ' +
            'Base64 and Uint8Array data are not supported.',
        );
      }
    }

    // Default weights per reference type
    const defaultWeights: Record<LumaReferenceType, number> = {
      image: 0.85,
      style: 0.8,
      character: 1.0, // Not used, but defined for completeness
      modify_image: 1.0,
    };

    switch (referenceType) {
      case 'image': {
        // Supports up to 4 images

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Host the image at a publicly accessible URL (S3, GCS, Vercel Blob, etc.) and pass that URL in prompt.images.
  2. If the image comes from a previous generation, use the returned image's hosted URL instead of the raw bytes.
  3. Convert binary data to a URL by uploading via a storage presign flow before calling the model.
  4. Switch to a provider that accepts binary image input if URL-only is not workable.

Example fix

// before
const bytes = await fs.readFile('source.png');
await generateImage({ model: luma.image('photon-flash-1'), prompt: { text: 'make it night', images: [{ type: 'binary', data: bytes }] } });
// after
const { url } = await put('source.png', await fs.readFile('source.png'));
await generateImage({ model: luma.image('photon-flash-1'), prompt: { text: 'make it night', images: [{ type: 'url', url }] } });
Defensive patterns

Strategy: validation

Validate before calling

function assertUrlImages(images) {
  for (const img of images ?? []) {
    if (img.type !== 'url' || typeof img.url !== 'string' || !img.url.startsWith('http')) {
      throw new Error('Luma requires publicly accessible image URLs for prompt.images');
    }
  }
}

Type guard

function isUrlImage(img: { type: string }): img is { type: 'url'; url: string } {
  return img.type === 'url' && typeof (img as { url?: unknown }).url === 'string';
}

Try / catch

try {
  await generateImage({ model: lumaImage, prompt });
} catch (e) {
  if (e instanceof Error && e.message.includes('only supports URL-based images')) {
    const hosted = await Promise.all(prompt.images.map(uploadAndGetUrl));
    return generateImage({ model: lumaImage, prompt: { ...prompt, images: hosted } });
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling generateImage with a luma image model where prompt.images (or editing input files) contains a data-URI/base64 image or a Uint8Array/binary File instead of a { type: 'url', url } entry.

Common situations: Passing a locally uploaded file or Buffer read from disk directly into the edit request; reusing code written for OpenAI-style APIs that accept binary image data; images generated in-memory from a previous step being fed straight back in.

Related errors


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