{"record":{"id":"4908fe46fc5df470","repo":"vercel/ai","slug":"luma-ai-image-supports-up-to-4-reference-images-y","errorCode":null,"errorMessage":"Luma AI image supports up to 4 reference images. You provided ${files.length} images.","messagePattern":"Luma AI image supports up to 4 reference images\\. You provided (.+?) images\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/luma/src/luma-image-model.ts","lineNumber":269,"sourceCode":"            'Please provide image URLs using `prompt.images` with publicly accessible URLs. ' +\n            'Base64 and Uint8Array data are not supported.',\n        );\n      }\n    }\n\n    // Default weights per reference type\n    const defaultWeights: Record<LumaReferenceType, number> = {\n      image: 0.85,\n      style: 0.8,\n      character: 1.0, // Not used, but defined for completeness\n      modify_image: 1.0,\n    };\n\n    switch (referenceType) {\n      case 'image': {\n        // Supports up to 4 images\n        if (files.length > 4) {\n          throw new Error(\n            'Luma AI image supports up to 4 reference images. ' +\n              `You provided ${files.length} images.`,\n          );\n        }\n        options.image = files.map((file, index) => ({\n          url: (file as { type: 'url'; url: string }).url,\n          weight: imageConfigs[index]?.weight ?? defaultWeights.image,\n        }));\n        break;\n      }\n\n      case 'style': {\n        // Style ref accepts an array but typically uses one style image\n        options.style = files.map((file, index) => ({\n          url: (file as { type: 'url'; url: string }).url,\n          weight: imageConfigs[index]?.weight ?? defaultWeights.style,\n        }));\n        break;","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/luma/src/luma-image-model.ts#L251-L287","documentation":"Thrown by getEditingOptions when the 'image' reference type receives more than 4 files. Luma's image reference editing mode accepts at most 4 reference images, so the SDK enforces the limit client-side before calling the API.","triggerScenarios":"Calling generateImage with a luma image model using image references (e.g. referenceType 'image') and providing 5 or more images in prompt.images / the files array.","commonSituations":"Building mood-board style generations with many inspiration images; programmatically fanning out collections of assets as references without capping the count; migrating from providers with higher reference limits.","solutions":["Reduce the reference images to at most 4, prioritizing the most relevant ones.","Split the request into multiple generations with different reference subsets.","Combine/merge reference images into a single composite image before sending.","Use a provider with a higher multi-image reference limit if more than 4 is essential."],"exampleFix":"// before\nconst refs = allReferences; // 6 images\nawait generateImage({ model: luma.image('photon-flash-1'), prompt: { text: 'style match', images: refs, referenceType: 'image' } });\n// after\nconst refs = allReferences.slice(0, 4);\nawait generateImage({ model: luma.image('photon-flash-1'), prompt: { text: 'style match', images: refs, referenceType: 'image' } });","handlingStrategy":"validation","validationCode":"if ((images ?? []).length > 4) {\n  throw new Error(`Luma image references accept at most 4 images, got ${images.length}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await generateImage({ model: lumaImage, prompt: { ...prompt, images } });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('up to 4 reference images')) {\n    return generateImage({ model: lumaImage, prompt: { ...prompt, images: images.slice(0, 4) } });\n  }\n  throw e;\n}","preventionTips":["Cap reference selection UIs at 4 images when targeting Luma.","Slice/curate reference arrays defensively before submission.","Write unit tests asserting reference counts per provider mode.","Encode per-provider limits in a shared constants module."],"tags":["validation","image-limits","reference-images","luma"],"backgroundTag":"provider-limit-exceeded","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}