Comfy-Org/ComfyUI · error · ValueError

Up to {CLAUDE_MAX_IMAGES} images are supported per request.

Error message

Up to {CLAUDE_MAX_IMAGES} images are supported per request.

What it means

ClaudeNode validates that the total image count across all connected image inputs does not exceed CLAUDE_MAX_IMAGES before calling the Anthropic Messages API. Image tensors may be batches, so the count is computed with get_number_of_images per tensor, not per connection.

Source

Thrown at comfy_api_nodes/nodes_anthropic.py:284

        output_cfg: AnthropicOutputConfig | None = None
        if always_thinking:
            output_cfg = AnthropicOutputConfig(effort=reasoning_effort)
        elif thinking_enabled:
            if model_label in _ADAPTIVE_THINKING_MODELS:
                # Adaptive mode - Anthropic chooses the budget based on effort hint
                thinking_cfg = AnthropicThinkingConfig(type="adaptive")
                output_cfg = AnthropicOutputConfig(effort=reasoning_effort)
            else:
                # Budget mode (Sonnet 4.5). Leave at least 1024 tokens for the actual response
                budget = _REASONING_BUDGET[reasoning_effort]
                budget = min(budget, max(1024, max_tokens - 1024))
                thinking_cfg = AnthropicThinkingConfig(type="enabled", budget_tokens=budget)
        elif model_label in _EXPLICIT_THINKING_OFF_MODELS:
            thinking_cfg = AnthropicThinkingConfig(type="disabled")

        image_tensors: list[Input.Image] = [t for t in (images or {}).values() if t is not None]
        if sum(get_number_of_images(t) for t in image_tensors) > CLAUDE_MAX_IMAGES:
            raise ValueError(f"Up to {CLAUDE_MAX_IMAGES} images are supported per request.")

        content: list[AnthropicTextContent | AnthropicImageContent] = []
        if image_tensors:
            content.extend(await _build_image_content_blocks(cls, image_tensors))
        content.append(AnthropicTextContent(text=prompt))

        response = await sync_op(
            cls,
            ApiEndpoint(path=ANTHROPIC_MESSAGES_ENDPOINT, method="POST"),
            response_model=AnthropicMessagesResponse,
            data=AnthropicMessagesRequest(
                model=CLAUDE_MODELS[model_label],
                max_tokens=max_tokens,
                messages=[AnthropicMessage(role=AnthropicRole.user, content=content)],
                system=system_prompt or None,
                temperature=temperature,
                thinking=thinking_cfg,
                output_config=output_cfg,

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Reduce the number of images: slice the batch tensor before the node (images[:limit]) or connect fewer inputs.
  2. Split the request into multiple Claude node calls, each within the limit.
  3. If you intended a single image, check upstream nodes that silently produce batches (e.g. video frame extraction) and index one frame.

Example fix

# before
images = load_image_batch(...)  # 30-frame batch -> ValueError

# after
images = images[:CLAUDE_MAX_IMAGES]  # or pick a single frame
images = images[0]
Defensive patterns

Strategy: validation

Validate before calling

from comfy_api_nodes.apis.anthropic import CLAUDE_MAX_IMAGES
n = sum(get_number_of_images(t) for t in (images or {}).values() if t is not None)
assert n <= CLAUDE_MAX_IMAGES, f"{n} images > limit {CLAUDE_MAX_IMAGES}"

Type guard

def within_claude_image_limit(image_tensors: list) -> bool:
    return sum(get_number_of_images(t) for t in image_tensors if t is not None) <= CLAUDE_MAX_IMAGES

Try / catch

try:
    out = await claude_node(...)
except ValueError as e:
    if "images are supported" in str(e):
        out = await claude_node(..., images=slice_to_limit(images, CLAUDE_MAX_IMAGES))

Prevention

When it happens

Trigger: Calling the Claude node with one or more image inputs whose summed batch sizes (get_number_of_images) exceed CLAUDE_MAX_IMAGES, including a single input connected to a batched image tensor.

Common situations: Feeding a LoadImage batch or video-frame batch straight into the Claude node; chaining multiple image outputs and forgetting they each carry N frames; assuming the limit counts sockets, not frames.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/055971204ee92596. Report an issue: GitHub.