ComfyUI Node

Claude API

Anthropic's models for captions and prompt-writing in ComfyUI

By al-swaiti·Created 2 years ago·Updated 2 months ago· 185
Claude API
  • image1
  • image2
  • image3
  • image4
  • image5
  • text
promptWhat is the meaning of life?
model
max_tokens1024
structure_outputfalse
prompt_structureCustom
structure_formatReturn only the prompt text itself. No explanations or formatting.
output_formatraw_text
api_key

This node puts Anthropic's Claude models inside a ComfyUI graph. Same shape as the pack's OpenAI, Gemini, Qwen, and Ollama nodes: text and images in, a string out. You'd reach for it for the two things a language model is good at here - reading images (captioning renders and references, building dataset captions) and writing text (expanding a scrappy idea into a well-formed prompt for whatever model you're about to run). Claude has a reputation as a strong, careful writer, which is exactly the trait that makes it pleasant for prompt-crafting.

The two jobs in one node

Vision. Wire a picture into one of the image1image5 slots and Claude will describe or analyze it. Multiple image slots mean you can ask it to compare or combine references in one call.

Prompt optimization. This is the useful part. Turn structure_output on, choose a prompt_structure template - FLUX.1-dev, SDXL, Imagen4, HunyuanVideo, Wan2.1, FLUXKontext, GeminiNanaBananaEdit - and Claude rewrites your input into a prompt shaped for that specific target. That's not busywork: prompting in 2026 is encoder-specific. SDXL-lineage models want comma-separated tags; FLUX and the newer LLM-encoded models want a plain-language instruction. Picking the wrong dialect is the single biggest source of bad results, so having a capable model translate your intent into the right one is a real win. The whole "LLM writes your prompt" pattern went from a curiosity to standard equipment for exactly this reason.

The inputs and outputs that matter

  • prompt - your instruction or the idea to expand.
  • model - six choices across the Claude 3.x line: claude-3-7-sonnet, the 3-5-sonnet builds, 3-opus, plus the faster 3-5-haiku and 3-haiku. Haiku is cheap and quick and fine for captions; Sonnet is the balanced default for prompt-writing; Opus is overkill for this.
  • structure_output + prompt_structure - the optimizer switch and the target-model template.
  • structure_format - governs the output; the default "Return only the prompt text itself. No explanations or formatting" keeps Claude from prefacing your prompt with a friendly sentence. Leave it unless you have a reason.
  • api_key (optional) - paste directly, or leave blank to read from the pack config.

The one output is text, a string - into a CLIP Text Encode, a Save Text node, or the next node in line.

Installing it and the key

ComfyUI Manager: search ComfyUI-OllamaGemini, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/al-swaiti/ComfyUI-OllamaGemini
pip install -r requirements.txt

then restart. Get a key from console.anthropic.com - this is a paid API, so you'll load credit - and store it in the pack's config as ANTHROPIC_API_KEY, or paste it into the api_key input.

Where people get burned

The trust one is not optional reading here. Your Anthropic key sits in a plaintext config file that any custom node in your install can read, and every custom node is arbitrary Python with full access to your machine. This pack is open and MIT-licensed and there's no reason to think otherwise of it - but the ecosystem's defining incident is on-point: in 2024 the ComfyUI_LLMVISION malware hid an infostealer inside fake builds of the openai and anthropic libraries, the very SDKs a Claude node depends on. Install from the real repo, keep it updated, and be ready to rotate any key you paste in.

Practical stuff: this node bills per call, so watch batch captioning; and if the optimizer hands back explanation instead of a clean prompt, someone changed structure_format - put the default line back. If the node never shows after install, it's usually a failed dependency taking the whole pack down on import, so read the startup console before blaming the menu.

CategoryAI API/Claude

Inputs (13)

NameTypeDefaultDescription
promptSTRINGWhat is the meaning of life?
modelCOMBO6 options: claude-3-7-sonnet-20250219, claude-3-5-haiku-20241022, claude-3-opus-20240229, claude-3-5-sonnet-20241022, claude-3-5-sonnet-20240620, claude-3-haiku-20240307
max_tokensINT10241–4096
structure_outputBOOLEANfalse
prompt_structureCOMBOCustom8 options: Custom, HunyuanVideo, Wan2.1, FLUX.1-dev, SDXL, FLUXKontext, +2
structure_formatSTRINGReturn only the prompt text itself. No explanations or formatting.
output_formatCOMBOraw_text2 options: raw_text, json
api_keyoptSTRING
image1optIMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE
image5optIMAGE

Outputs (1)

NameTypeDescription
textSTRING