Comfy-Org/ComfyUI · error · ValueError
The maximum number of reference images allowed with a video
Error message
The maximum number of reference images allowed with a video input is 4.
What it means
Raised by OmniProVideoToVideoNode.execute when more than 4 reference images accompany a reference video. With a video input the Kling omni API tightens the image reference cap from 7 to 4; the check runs after video duration/dimension validation and before uploads.
Source
Thrown at comfy_api_nodes/nodes_kling.py:1217
model_name: str,
prompt: str,
aspect_ratio: str,
duration: int,
reference_video: Input.Video,
keep_original_sound: bool,
reference_images: Input.Image | None = None,
resolution: str = "1080p",
seed: int = 0,
) -> IO.NodeOutput:
_ = seed
prompt = normalize_omni_prompt_references(prompt)
validate_string(prompt, min_length=1, max_length=2500)
validate_video_duration(reference_video, min_duration=3.0, max_duration=10.05)
validate_video_dimensions(reference_video, min_width=720, min_height=720, max_width=2160, max_height=2160)
image_list: list[OmniParamImage] = []
if reference_images is not None:
if get_number_of_images(reference_images) > 4:
raise ValueError("The maximum number of reference images allowed with a video input is 4.")
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))
for i in await upload_images_to_comfyapi(cls, reference_images, wait_label="Uploading reference image"):
image_list.append(OmniParamImage(image_url=i))
video_list = [
OmniParamVideo(
video_url=await upload_video_to_comfyapi(cls, reference_video, wait_label="Uploading reference video"),
refer_type="feature",
keep_original_sound="yes" if keep_original_sound else "no",
)
]
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
- Trim reference_images to at most 4 when a reference video is connected
- Move subject/style cues from extra images into the prompt or the reference video itself
Example fix
# before reference_images = character_refs.images # 6 images reference_video = load_ref_video.output # after reference_images = character_refs.images[:4] # <= 4 with video input reference_video = load_ref_video.output
Defensive patterns
Strategy: validation
Validate before calling
def reference_count_ok_with_video(reference_images) -> bool:
return reference_images is None or get_number_of_images(reference_images) <= 4 Prevention
- When a reference video is connected, re-slice image references to 4
- Keep a table of per-node reference caps next to your workflow notes
When it happens
Trigger: reference_video connected (3.0-10.05s, 720-2160px) plus a reference_images batch of 5 or more on the video-to-video omni node.
Common situations: Reusing a 6-image reference set that worked on the image-to-video node on the video-driven variant, which has the lower cap.
Related errors
- The maximum number of reference images allowed is 6.
- The maximum number of reference images is 7.
- The maximum number of reference images is 10.
- The 'end_frame' input cannot be used simultaneously with 're
- The 'end_frame' input cannot be used simultaneously with sto
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/0fa243cbfb5b3eef.
Report an issue: GitHub.