Comfy-Org/ComfyUI · error · ValueError
The current maximum number of supported images is 14.
Error message
The current maximum number of supported images is 14.
What it means
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.
Source
Thrown at comfy_api_nodes/nodes_gemini.py:1125
model: str,
seed: int,
aspect_ratio: str,
resolution: str,
response_modalities: str,
images: Input.Image | None = None,
files: list[GeminiPart] | None = None,
system_prompt: str = "",
) -> IO.NodeOutput:
validate_string(prompt, strip_whitespace=True, min_length=1)
if model == "Nano Banana 2 (Gemini 3.1 Flash Image)":
model = "gemini-3.1-flash-image"
elif model == "gemini-3-pro-image-preview":
model = "gemini-3-pro-image"
parts: list[GeminiPart] = [GeminiPart(text=prompt)]
if images is not None:
if get_number_of_images(images) > 14:
raise ValueError("The current maximum number of supported images is 14.")
parts.extend(await create_image_parts(cls, images))
if files is not None:
parts.extend(files)
image_config = GeminiImageConfig(imageSize=resolution)
if aspect_ratio != "auto":
image_config.aspectRatio = aspect_ratio
gemini_system_prompt = None
if system_prompt:
gemini_system_prompt = GeminiSystemInstructionContent(parts=[GeminiTextPart(text=system_prompt)], role=None)
response = await sync_op(
cls,
ApiEndpoint(path=f"/proxy/vertexai/gemini/{model}", method="POST"),
data=GeminiImageGenerateContentRequest(
contents=[
GeminiContent(role=GeminiRole.user, parts=parts),View on GitHub (pinned to 1c6d8d45b3)
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].
Example fix
# before await generate(prompt, images=all_frames) # all_frames has 20 images -> raises # after await generate(prompt, images=all_frames[:14])
Defensive patterns
Strategy: validation
Validate before calling
from comfy_api_nodes.nodes_gemini import get_number_of_images # conceptually
n = get_number_of_images(images)
assert n <= 14, f"{n} images connected; Gemini allows at most 14" Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The current maximum number of supported images is {OMNI_MAX_
- The current maximum number of supported videos is {OMNI_MAX_
- Gemini did not generate an image. Try rephrasing your prompt
- The pro model supports only 1 input image.
- A maximum of 3 input images is supported.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/5643fe7684a6f890.
Report an issue: GitHub.