Comfy-Org/ComfyUI · error · ValueError
Maximum {max_count} reference images are allowed.
Error message
Maximum {max_count} reference images are allowed. What it means
Raised by _luma2_upload_image_refs (comfy_api_nodes/nodes_luma.py:695) when more reference images are supplied than the target Luma 2 / Ray endpoint allows (max_count, e.g. 9 for image refs). Note the check runs after every ref has already been uploaded, so the error also wastes upload time and bandwidth.
Source
Thrown at comfy_api_nodes/nodes_luma.py:695
optional=True,
tooltip=f"Up to {max_image_refs} reference images for style/content guidance.",
),
]
async def _luma2_upload_image_refs(
cls: type[IO.ComfyNode],
refs: dict | None,
max_count: int,
) -> list[Luma2ImageRef] | None:
if not refs:
return None
out: list[Luma2ImageRef] = []
for key in refs:
url = await upload_image_to_comfyapi(cls, refs[key])
out.append(Luma2ImageRef(url=url))
if len(out) > max_count:
raise ValueError(f"Maximum {max_count} reference images are allowed.")
return out or None
async def _luma2_submit_and_poll(
cls: type[IO.ComfyNode],
request: Luma2GenerationRequest,
*,
estimated_duration: int | None = None,
) -> Luma2Generation:
"""Submit a Luma Agents generation and poll until done; returns the completed generation."""
initial = await sync_op(
cls,
ApiEndpoint(path="/proxy/luma_2/generations", method="POST"),
response_model=Luma2Generation,
data=request,
)
if not initial.id:
raise RuntimeError("Luma API did not return a generation id.")View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Count the chained image-ref nodes and reduce them to at most max_count (9 for Luma image refs).
- Remove duplicate or lowest-value reference images from the chain.
- If you hit this often, pre-validate len(refs) in your own wrapper node before executing.
Defensive patterns
Strategy: validation
Validate before calling
MAX_REFS = 9
if refs and len(refs) > MAX_REFS:
raise ValueError(f"Too many Luma image refs: {len(refs)} > {MAX_REFS}; trim the chain before executing") Prevention
- Count chained image-ref nodes before queueing; the limit (max_count) varies by node, 9 for Luma image refs.
- Note the node uploads all refs before checking, so catching it early also saves upload bandwidth.
When it happens
Trigger: Passing a refs dict (image_ref chain input) with more entries than max_count — e.g. 10+ Luma image-reference nodes chained into LumaImageNode2's image_ref input.
Common situations: Users chain many reference-image nodes believing more refs improve style fidelity; a workflow copied from a different node with a higher limit; duplicates accidentally added while editing a chain.
Related errors
- At least one of first_image and last_image requires an input
- 'manga' style requires a portrait aspect ratio ({allowed_man
- Looping is only available with 5s duration on Ray 3.2.
- Provide at least one of start_frame / end_frame.
- Looping is not available when an end_frame is set.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/bfe403afbb748c6e.
Report an issue: GitHub.