Comfy-Org/ComfyUI · error · ValueError
The model supports at most input image ; are connected.
Error message
The {model_id} model supports at most {max_images} input image{'s' if max_images > 1 else ''}; {n_images} are connected. What it means
Per-model input image cap in the dict-driven Grok image edit node. _GROK_IMAGE_EDIT_MAX_IMAGES maps grok-imagine-image-pro to 1 and the other grok image models to 3 (fallback 3). The summed image count across all connected tensors is compared against the selected model's cap, and exceeding it reports both the cap and the connected count.
Solutions
- Trim connected images to the model's cap (1 for pro, 3 for others).
- Switch to a model whose cap fits your input count.
- Slice batched tensors so the summed count fits.
Example fix
# before: model_id='grok-imagine-image-pro', 2 images connected
await grok_edit_execute(model={'model': 'grok-imagine-image-pro', 'images': {'a': i1, 'b': i2}, ...}, seed=1) # raises
# after: keep only the primary reference
await grok_edit_execute(model={'model': 'grok-imagine-image-pro', 'images': {'a': i1}, ...}, seed=1) Defensive patterns
Strategy: validation
Validate before calling
CAPS = {"grok-imagine-image-2.0": 3, "grok-imagine-image-pro": 1,
"grok-imagine-image-quality": 3, "grok-imagine-image": 3}
n = sum(get_number_of_images(t) for t in tensors if t is not None)
assert n <= CAPS.get(model_id, 3), f"{n} images > cap {CAPS.get(model_id, 3)} for {model_id}" Prevention
- Re-validate image count whenever the model dropdown changes.
- Treat pro as a 1-image model in workflow validation logic.
- Count the batch dimension of every tensor, not just the number of wires.
When it happens
Trigger: n_images = sum(get_number_of_images(t)) over connected tensors exceeds _GROK_IMAGE_EDIT_MAX_IMAGES[model_id] — e.g. 2 images with pro (cap 1) or 4 images with grok-imagine-image (cap 3).
Common situations: Changing the model dropdown to pro without trimming inputs; batched tensors whose batch dimension silently multiplies the count; workflows shared between models with different caps.
Related errors
- A maximum of 3 input images is supported.
- The pro model supports only 1 input image.
- At least one image is required for editing.
- Custom aspect ratio is only allowed when multiple images…
- 1080p resolution is only available for…
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/610abdc54089f11d.
Report an issue: GitHub.
Appendix: source
Thrown at comfy_api_nodes/nodes_grok.py:586
cls,
prompt: str,
model: dict,
seed: int,
) -> IO.NodeOutput:
validate_string(prompt, strip_whitespace=True, min_length=1)
model_id = model["model"]
resolution = model["resolution"]
number_of_images = model["number_of_images"]
images_dict = model.get("images") or {}
aspect_ratio = model.get("aspect_ratio", "auto")
image_tensors: list[Input.Image] = [t for t in images_dict.values() if t is not None]
n_images = sum(get_number_of_images(t) for t in image_tensors)
max_images = _GROK_IMAGE_EDIT_MAX_IMAGES.get(model_id, 3)
if n_images < 1:
raise ValueError("At least one image is required for editing.")
if n_images > max_images:
raise ValueError(
f"The {model_id} model supports at most {max_images} input "
f"image{'s' if max_images > 1 else ''}; {n_images} are connected."
)
if aspect_ratio != "auto" and model_id in _GROK_IMAGE_EDIT_ASPECT_RATIO_NEEDS_MULTIPLE and n_images == 1:
raise ValueError(
"Custom aspect ratio is only allowed when multiple images are connected to the image input."
)
flat_tensors: list[torch.Tensor] = []
for tensor in image_tensors:
if len(tensor.shape) == 4:
flat_tensors.extend(tensor[i] for i in range(tensor.shape[0]))
else:
flat_tensors.append(tensor)
response = await sync_op(
cls,
ApiEndpoint(path="/proxy/xai/v1/images/edits", method="POST"),View on GitHub (pinned to 1c6d8d45b3)