{"record":{"id":"561bb997334efb08","repo":"Comfy-Org/ComfyUI","slug":"a-maximum-of-3-input-images-is-supported","errorCode":null,"errorMessage":"A maximum of 3 input images is supported.","messagePattern":"A maximum of 3 input images is supported\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_grok.py","lineNumber":447,"sourceCode":"        )\n\n    @classmethod\n    async def execute(\n        cls,\n        model: str,\n        image: Input.Image,\n        prompt: str,\n        resolution: str,\n        number_of_images: int,\n        seed: int,\n        aspect_ratio: str = \"auto\",\n    ) -> IO.NodeOutput:\n        validate_string(prompt, strip_whitespace=True, min_length=1)\n        if model == \"grok-imagine-image-pro\":\n            if get_number_of_images(image) > 1:\n                raise ValueError(\"The pro model supports only 1 input image.\")\n        elif get_number_of_images(image) > 3:\n            raise ValueError(\"A maximum of 3 input images is supported.\")\n        if aspect_ratio != \"auto\" and get_number_of_images(image) == 1:\n            raise ValueError(\n                \"Custom aspect ratio is only allowed when multiple images are connected to the image input.\"\n            )\n        response = await sync_op(\n            cls,\n            ApiEndpoint(path=\"/proxy/xai/v1/images/edits\", method=\"POST\"),\n            data=ImageEditRequest(\n                model=model,\n                images=[InputUrlObject(url=f\"data:image/png;base64,{tensor_to_base64_string(i)}\") for i in image],\n                prompt=prompt,\n                resolution=resolution.lower(),\n                n=number_of_images,\n                seed=seed,\n                aspect_ratio=None if aspect_ratio == \"auto\" else aspect_ratio,\n            ),\n            response_model=ImageGenerationResponse,\n        )","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_grok.py#L429-L465","documentation":"Grok image edit validation for non-pro models: at most 3 input images are supported. Applies to every model other than grok-imagine-image-pro in this execute path (which itself has the stricter 1-image rule). Counted via get_number_of_images, so batched tensors count per image.","triggerScenarios":"Calling grok image edit with a non-pro model and get_number_of_images(image) > 3 — e.g. a 4-frame batch tensor or 4 separate images combined into one input.","commonSituations":"Frame-grid or multi-reference workflows ported from other providers (e.g. Gemini's 14-image allowance); upscaled batches accidentally left connected; assuming the limit is per-run output count rather than input count.","solutions":["Trim inputs to at most 3 images (slice batched tensors).","Choose the most relevant reference images and drop the rest.","Run multiple edits and composite results downstream if more references are truly needed."],"exampleFix":"# before\nawait grok_image_edit(model='grok-imagine-image', image=batch5)  # raises\n\n# after\nawait grok_image_edit(model='grok-imagine-image', image=batch5[:3])","handlingStrategy":"validation","validationCode":"assert get_number_of_images(image) <= 3, \"grok image edit accepts at most 3 images\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap reference images at 3 for non-pro grok edit models.","Slice batches: image = image[:3].","Do not port Gemini's 14-image workflows to grok unmodified."],"tags":["grok","xai","image-editing","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"}