{"record":{"id":"5643fe7684a6f890","repo":"Comfy-Org/ComfyUI","slug":"the-current-maximum-number-of-supported-images-is-5643fe","errorCode":null,"errorMessage":"The current maximum number of supported images is 14.","messagePattern":"The current maximum number of supported images is 14\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_gemini.py","lineNumber":1125,"sourceCode":"        model: str,\n        seed: int,\n        aspect_ratio: str,\n        resolution: str,\n        response_modalities: str,\n        images: Input.Image | None = None,\n        files: list[GeminiPart] | None = None,\n        system_prompt: str = \"\",\n    ) -> IO.NodeOutput:\n        validate_string(prompt, strip_whitespace=True, min_length=1)\n        if model == \"Nano Banana 2 (Gemini 3.1 Flash Image)\":\n            model = \"gemini-3.1-flash-image\"\n        elif model == \"gemini-3-pro-image-preview\":\n            model = \"gemini-3-pro-image\"\n\n        parts: list[GeminiPart] = [GeminiPart(text=prompt)]\n        if images is not None:\n            if get_number_of_images(images) > 14:\n                raise ValueError(\"The current maximum number of supported images is 14.\")\n            parts.extend(await create_image_parts(cls, images))\n        if files is not None:\n            parts.extend(files)\n\n        image_config = GeminiImageConfig(imageSize=resolution)\n        if aspect_ratio != \"auto\":\n            image_config.aspectRatio = aspect_ratio\n\n        gemini_system_prompt = None\n        if system_prompt:\n            gemini_system_prompt = GeminiSystemInstructionContent(parts=[GeminiTextPart(text=system_prompt)], role=None)\n\n        response = await sync_op(\n            cls,\n            ApiEndpoint(path=f\"/proxy/vertexai/gemini/{model}\", method=\"POST\"),\n            data=GeminiImageGenerateContentRequest(\n                contents=[\n                    GeminiContent(role=GeminiRole.user, parts=parts),","sourceCodeStart":1107,"sourceCodeEnd":1143,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_gemini.py#L1107-L1143","documentation":"Client-side validation in the Gemini image generation node (single-input variant): the connected image input batch contains more than 14 images, which is the API's current maximum number of reference images for image generation/editing. The count is computed with get_number_of_images, so a batched tensor of N images counts as N. It fails before any network call.","triggerScenarios":"Executing GeminiImageGenerator-style node with an images input where get_number_of_images(images) > 14 — e.g. one batched tensor of 15+ frames or several tensors whose total exceeds 14.","commonSituations":"Feeding a video frame batch or image grid directly into the reference image input; chaining a load-image-folder node that emits 20 images; iterating workflows where batch size was tuned for a different model's higher limit.","solutions":["Split the input into batches of at most 14 images and run the node multiple times.","Trim the source list/tensor to the 14 most relevant images before connecting it.","If using a batched tensor, slice it: images[:14]."],"exampleFix":"# before\nawait generate(prompt, images=all_frames)  # all_frames has 20 images -> raises\n\n# after\nawait generate(prompt, images=all_frames[:14])","handlingStrategy":"validation","validationCode":"from comfy_api_nodes.nodes_gemini import get_number_of_images  # conceptually\nn = get_number_of_images(images)\nassert n <= 14, f\"{n} images connected; Gemini allows at most 14\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Slice batched image tensors to <=14 before connecting.","Build workflows with a visible image-count node when batches vary.","Remember the cap counts every image in a batch, not each connected wire."],"tags":["gemini","image-generation","input-validation","limit","comfy-api-nodes"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}