{"record":{"id":"0fa243cbfb5b3eef","repo":"Comfy-Org/ComfyUI","slug":"the-maximum-number-of-reference-images-allowed-wit","errorCode":null,"errorMessage":"The maximum number of reference images allowed with a video input is 4.","messagePattern":"The maximum number of reference images allowed with a video input is 4\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_kling.py","lineNumber":1217,"sourceCode":"        model_name: str,\n        prompt: str,\n        aspect_ratio: str,\n        duration: int,\n        reference_video: Input.Video,\n        keep_original_sound: bool,\n        reference_images: Input.Image | None = None,\n        resolution: str = \"1080p\",\n        seed: int = 0,\n    ) -> IO.NodeOutput:\n        _ = seed\n        prompt = normalize_omni_prompt_references(prompt)\n        validate_string(prompt, min_length=1, max_length=2500)\n        validate_video_duration(reference_video, min_duration=3.0, max_duration=10.05)\n        validate_video_dimensions(reference_video, min_width=720, min_height=720, max_width=2160, max_height=2160)\n        image_list: list[OmniParamImage] = []\n        if reference_images is not None:\n            if get_number_of_images(reference_images) > 4:\n                raise ValueError(\"The maximum number of reference images allowed with a video input is 4.\")\n            for i in reference_images:\n                validate_image_dimensions(i, min_width=300, min_height=300)\n                validate_image_aspect_ratio(i, (1, 2.5), (2.5, 1))\n            for i in await upload_images_to_comfyapi(cls, reference_images, wait_label=\"Uploading reference image\"):\n                image_list.append(OmniParamImage(image_url=i))\n        video_list = [\n            OmniParamVideo(\n                video_url=await upload_video_to_comfyapi(cls, reference_video, wait_label=\"Uploading reference video\"),\n                refer_type=\"feature\",\n                keep_original_sound=\"yes\" if keep_original_sound else \"no\",\n            )\n        ]\n        response = await sync_op(\n            cls,\n            ApiEndpoint(path=\"/proxy/kling/v1/videos/omni-video\", method=\"POST\"),\n            response_model=TaskStatusResponse,\n            data=OmniProReferences2VideoRequest(\n                model_name=model_name,","sourceCodeStart":1199,"sourceCodeEnd":1235,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_kling.py#L1199-L1235","documentation":"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.","triggerScenarios":"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.","commonSituations":"Reusing a 6-image reference set that worked on the image-to-video node on the video-driven variant, which has the lower cap.","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"],"exampleFix":"# before\nreference_images = character_refs.images  # 6 images\nreference_video = load_ref_video.output\n\n# after\nreference_images = character_refs.images[:4]  # <= 4 with video input\nreference_video = load_ref_video.output","handlingStrategy":"validation","validationCode":"def reference_count_ok_with_video(reference_images) -> bool:\n    return reference_images is None or get_number_of_images(reference_images) <= 4","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["kling","video","reference-images","video-input","limit","api-nodes"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}