Claude Prompt Generator
An LLM that writes your prompts, billed per call
- STRING
This node is exactly what it sounds like: you type a vague idea, it pings Anthropic's Claude, and the model's written prompt comes back as a string you can wire into your sampler. No local model, no VRAM, no checkpoints to download. The heavy lifting happens on Anthropic's servers, and - the part nobody screenshots - you pay for it per call.
Reach for it when you're stuck staring at an empty positive-prompt box, or when you're feeding one of the new LLM-encoded checkpoints (Z-Image, Flux 2 Klein, Anima) where your prompt is an instruction, not a tag list. Per the community's prompting lore, those models genuinely respond to a well-worded sentence. For SDXL-lineage models with a 77-token CLIP encoder, Claude's verbose prose mostly gets chopped at the boundary - so this is a tool for modern checkpoints, not your Illustrious comfort zone.
How it works
Look at the source and there's not much to it. The node builds a two-message conversation - your system_prompt as the system instruction, your user_input as the user message - and calls the messages.create() endpoint with the model hardcoded to claude-3-opus-20240229, temperature=0, max_tokens=1000. It grabs the first text block from the response, strips it, and hands it back. Errors are caught and re-raised as readable RuntimeErrors, so rate limits and connection failures show up in the ComfyUI console instead of silently failing.
The entire dependency list is one line: anthropic. No models, no model files, nothing to download beyond a pip package.
The inputs that matter
- system_prompt (required, multiline) - the instructions Claude follows. The default is "You are an AI art prompt generator. Reply only with a prompt for image generation, no explanations." That last clause matters: without it, Claude tends to explain the prompt instead of just handing it over.
- user_input (required, multiline) - what you want a prompt for. Default: "Generate a prompt for: space cat".
- api_key (optional) - paste your key here, or set the
ANTHROPIC_API_KEYenvironment variable and leave this blank. A field left empty falls back to the env var.
The single STRING output goes straight into a CLIP Text Encode node or any prompt-text input. In practice, run it through a Show Text / preview node first - you don't want a half-coherent generation eating a paid API call plus a sampler run.
Installing it
ComfyUI Manager → search "Claude Prompt Generator" → Install → restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/PauldeLavallaz/comfyui_claude_prompt_generator
pip install -r comfyui_claude_prompt_generator/requirements.txt
Restart ComfyUI and the node appears under "prompt generation". One trap: the README's own clone URL is literally a placeholder (tu_usuario = "your_user" in Spanish), so copy the real repo URL above, not the one from the docs. That tells you the maintenance level you're signing up for - this is a small, single-commit pack.
Where people get burned
The cost, mostly. claude-3-opus is Anthropic's flagship - their most expensive model - and this node lets you pick no other. Every queue-run of your workflow is a real money transaction against your API account, and the graph blocks while the HTTP call resolves. The 1000-token cap keeps each call bounded, but batch a grid of variations and watch your usage dashboard. If you're on the free tier, expect Rate limit exceeded errors and generous backoff between runs.
Also set expectations about the content policy: Anthropic's API has a real one. If your intended subject is adult, Claude will refuse or rewrite - that's API policy, not a node bug, and no local flag bypasses it. Keep this node for the SFW side of your workflow.
Troubleshooting
- "No API key provided" - set
ANTHROPIC_API_KEYor fill theapi_keyinput. On Windows CMD that'sset ANTHROPIC_API_KEY=sk-ant-...before launching ComfyUI from the same session. - "Rate limit exceeded" / "Connection error" - the API wrapper surfaces these. Slow down, check your plan's limits.
- Empty or weird output - your
system_promptis letting Claude editorialize. Tighten it to "reply only with the prompt."
Use it as a brainstorming layer, not a default. Let Claude draft, you curate, and the $0.075-or-so per call is money well spent instead of a recurring bill.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| system_prompt | STRING | You are an AI art prompt generator. Reply only with a prompt for image generation, no explanations. | — |
| user_input | STRING | Generate a prompt for: space cat | — |
| api_keyopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |