{"record":{"id":"055971204ee92596","repo":"Comfy-Org/ComfyUI","slug":"up-to-claude-max-images-images-are-supported-per","errorCode":null,"errorMessage":"Up to {CLAUDE_MAX_IMAGES} images are supported per request.","messagePattern":"Up to (.+?) images are supported per request\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_anthropic.py","lineNumber":284,"sourceCode":"        output_cfg: AnthropicOutputConfig | None = None\n        if always_thinking:\n            output_cfg = AnthropicOutputConfig(effort=reasoning_effort)\n        elif thinking_enabled:\n            if model_label in _ADAPTIVE_THINKING_MODELS:\n                # Adaptive mode - Anthropic chooses the budget based on effort hint\n                thinking_cfg = AnthropicThinkingConfig(type=\"adaptive\")\n                output_cfg = AnthropicOutputConfig(effort=reasoning_effort)\n            else:\n                # Budget mode (Sonnet 4.5). Leave at least 1024 tokens for the actual response\n                budget = _REASONING_BUDGET[reasoning_effort]\n                budget = min(budget, max(1024, max_tokens - 1024))\n                thinking_cfg = AnthropicThinkingConfig(type=\"enabled\", budget_tokens=budget)\n        elif model_label in _EXPLICIT_THINKING_OFF_MODELS:\n            thinking_cfg = AnthropicThinkingConfig(type=\"disabled\")\n\n        image_tensors: list[Input.Image] = [t for t in (images or {}).values() if t is not None]\n        if sum(get_number_of_images(t) for t in image_tensors) > CLAUDE_MAX_IMAGES:\n            raise ValueError(f\"Up to {CLAUDE_MAX_IMAGES} images are supported per request.\")\n\n        content: list[AnthropicTextContent | AnthropicImageContent] = []\n        if image_tensors:\n            content.extend(await _build_image_content_blocks(cls, image_tensors))\n        content.append(AnthropicTextContent(text=prompt))\n\n        response = await sync_op(\n            cls,\n            ApiEndpoint(path=ANTHROPIC_MESSAGES_ENDPOINT, method=\"POST\"),\n            response_model=AnthropicMessagesResponse,\n            data=AnthropicMessagesRequest(\n                model=CLAUDE_MODELS[model_label],\n                max_tokens=max_tokens,\n                messages=[AnthropicMessage(role=AnthropicRole.user, content=content)],\n                system=system_prompt or None,\n                temperature=temperature,\n                thinking=thinking_cfg,\n                output_config=output_cfg,","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_anthropic.py#L266-L302","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reduce the number of images: slice the batch tensor before the node (images[:limit]) or connect fewer inputs.","Split the request into multiple Claude node calls, each within the limit.","If you intended a single image, check upstream nodes that silently produce batches (e.g. video frame extraction) and index one frame."],"exampleFix":"# before\nimages = load_image_batch(...)  # 30-frame batch -> ValueError\n\n# after\nimages = images[:CLAUDE_MAX_IMAGES]  # or pick a single frame\nimages = images[0]","handlingStrategy":"validation","validationCode":"from comfy_api_nodes.apis.anthropic import CLAUDE_MAX_IMAGES\nn = sum(get_number_of_images(t) for t in (images or {}).values() if t is not None)\nassert n <= CLAUDE_MAX_IMAGES, f\"{n} images > limit {CLAUDE_MAX_IMAGES}\"","typeGuard":"def within_claude_image_limit(image_tensors: list) -> bool:\n    return sum(get_number_of_images(t) for t in image_tensors if t is not None) <= CLAUDE_MAX_IMAGES","tryCatchPattern":"try:\n    out = await claude_node(...)\nexcept ValueError as e:\n    if \"images are supported\" in str(e):\n        out = await claude_node(..., images=slice_to_limit(images, CLAUDE_MAX_IMAGES))","preventionTips":["Count frames with get_number_of_images, not sockets.","Slice batched image tensors before connecting them.","Keep a helper that chunks image lists at the model limit."],"tags":["anthropic","claude","vision","input-validation","batch"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}