Claude Prompt Expander
An LLM prompt expander that keeps your Claude key out of every PNG
- text
If you've spent any time with a FLUX.2-era model, you know the blank-page problem. Klein and its siblings don't read prompt tag-soup - they read prose instructions like an LLM chat turn - so typing viking portrait and hoping is leaving most of the model on the table. Claude Prompt Expander fixes the boring, annoying part of that: you type the rough idea, it pays an Anthropic API call to turn it into a proper structured prompt, and hands you the text. No GPU work, no VRAM, no model download. Just one network round-trip and a string.
How it works
This is one of the smallest "LLM in the graph" nodes you'll find - about 70 lines, and the thing most worth knowing about it is in the Why section of the README. ComfyUI serialises widget values into the workflow JSON, and that JSON gets embedded in the metadata of every PNG it saves. An API key typed into a node widget therefore travels with every image you share. This node sidesteps the whole problem: there is no key widget. It reads your Anthropic key from a plain key.txt file sitting next to __init__.py, at call time.
Underneath it's just urllib POSTing to https://api.anthropic.com/v1/messages with your prompt as the user message and your system text as the system prompt, then pulling the text out of the response's content blocks. No requests, no Anthropic SDK, no dependencies at all beyond the standard library - which makes it trivially auditable, a real virtue in a category that's already been weaponized once. The returned prompt is also printed to the ComfyUI console, so you can see exactly what the node produced before it hits your encoder.
The inputs that matter
All five are widgets, and you'll mostly touch three of them:
- prompt - your short description, e.g.
viking portrait. - system - the instruction Claude follows. The default is tuned for FLUX.2: flowing prose, subject → setting → lighting → camera, material and texture detail, no style words without the visual meaning behind them. It's editable, so this is where you retarget the whole thing for any other model family.
- seed - this one does something unusual. ComfyUI caches nodes with identical inputs, so the author wired the seed through
IS_CHANGED: bump it and you force a genuinely fresh API call instead of getting yesterday's cached text back.
model defaults to claude-sonnet-4-6 (swap in any Anthropic model string you like), and max_tokens caps the response at 1000 by default. The single output, text, is a plain STRING - wire it into whatever consumes your prompt, which on an LLM-encoded base is usually just your text-encoder node.
Installing it
No dependencies, no model files - this is the easiest install in the ecosystem:
cd ComfyUI/custom_nodes
git clone https://github.com/IdarV/comfyui-claude-prompt-expander
Then create key.txt in the new comfyui-claude-prompt-expander folder (next to __init__.py) containing your Anthropic key:
sk-ant-...
Restart ComfyUI. ComfyUI Manager should find it by searching the pack title if you'd rather go that route.
Gotchas
- No
key.txt? You'll get aRuntimeErrorspelling out exactly that. Check the path - the file must sit next to__init__.py. - The API errors surface raw. HTTP failures come back as a
RuntimeErrorwith the status code and the response body, so a 401 means the key is wrong and a 429 means you're out of quota or hitting rate limits. - A response that comes back instantly with the same old text is the cache, not a bug. Change the seed.
- Claude filters content. This is the honest tradeoff of any API path: the frontier model writes lovely prose, but its safety policy refuses things a local abliterated LLM wouldn't blink at. If that matters to you, this node is the wrong tool - go local instead.
- The key is plaintext on disk. That's the deliberate design, but it means don't share the folder and don't commit
key.txt(the repo's.gitignorealready excludes it).
Because this pack is brand new and barely installed, the ecosystem's standing advice applies extra hard: read the source before first run. Here that's a five-minute job, and it pays off.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| system | STRING | Expand the input into a detailed image prompt for FLUX.2. Write flowing prose, not comma-separated tags. Order: subject first, then setting, then lighting, then camera and technical detail. Always state an explicit adult age for people. Include material and texture detail. Never use style words without describing what they mean visually. Output only the prompt, no preamble. | — |
| model | STRING | claude-sonnet-4-6 | — |
| max_tokens | INT | 100064–8192 | — |
| seed | INT | 00–4294967295 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |