Comfy-Org/ComfyUI · error · ValueError
The maximum number of reference images is 7.
Error message
The maximum number of reference images is 7.
What it means
Raised by OmniProImageToVideoNode.execute when the reference_images batch exceeds 7 images. This node (first-frame driven image-to-video) allows up to 7 omni reference images; the count check happens before upload via get_number_of_images.
Source
Thrown at comfy_api_nodes/nodes_kling.py:1103
sb_prompt = storyboards[f"storyboard_{i}_prompt"]
sb_duration = storyboards[f"storyboard_{i}_duration"]
validate_string(sb_prompt, field_name=f"storyboard_{i}_prompt", min_length=1, max_length=512)
multi_prompt_list.append(
MultiPromptEntry(
index=i,
prompt=sb_prompt,
duration=str(sb_duration),
)
)
total_storyboard_duration = sum(int(e.duration) for e in multi_prompt_list)
if total_storyboard_duration != duration:
raise ValueError(
f"Total storyboard duration ({total_storyboard_duration}s) "
f"must equal the global duration ({duration}s)."
)
if get_number_of_images(reference_images) > 7:
raise ValueError("The maximum number of reference images is 7.")
for i in reference_images:
validate_image_dimensions(i, min_width=300, min_height=300)
validate_image_aspect_ratio(i, (1, 2.5), (2.5, 1))
image_list: list[OmniParamImage] = []
for i in await upload_images_to_comfyapi(cls, reference_images, wait_label="Uploading reference image"):
image_list.append(OmniParamImage(image_url=i))
if resolution == "4k":
mode = "4k"
elif resolution == "1080p":
mode = "pro"
else:
mode = "std"
response = await sync_op(
cls,
ApiEndpoint(path="/proxy/kling/v1/videos/omni-video", method="POST"),
response_model=TaskStatusResponse,
data=OmniProReferences2VideoRequest(
model_name=model_name,View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Slice the reference batch to at most 7 images
- Curate the reference set down to the most informative frames
- Check for stray/duplicate frames in the source folder feeding the batch
Example fix
# before reference_images = folder_batch.images # 12 images # after reference_images = folder_batch.images[:7] # <= 7
Defensive patterns
Strategy: validation
Validate before calling
def reference_count_ok_image2video(reference_images) -> bool:
return reference_images is None or get_number_of_images(reference_images) <= 7 Prevention
- Slice reference batches to 7 for the image-to-video omni node
- Note the per-node cap differences: 7 here, 6 on first/last-frame, 4 with video input
When it happens
Trigger: Connecting a batch of 8+ images to reference_images on the OmniPro image-to-video node.
Common situations: A folder loader or batch-concat node emits more frames than expected (hidden extra files, growing folder), pushing the count past 7.
Related errors
- The maximum number of reference images allowed is 6.
- The maximum number of reference images allowed with a video
- The maximum number of reference images is 10.
- Reference video {i} is too short: {dur:.1f}s. Minimum durati
- Total reference video duration is {total_video_duration:.1f}
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/6f35aa2cab630769.
Report an issue: GitHub.