APNext Claude Code
Ask Claude Code from inside ComfyUI — subscription seat, no API key
- image
- text
- session_id
- info
The name is a half-truth: this node doesn't call the Claude API at all. It runs your prompt through the Claude Code CLI installed on your machine, using its login and your subscription seat. That means no API key in ComfyUI, no per-call metering, and - the part that makes it actually interesting - the model can do things while it answers: search the web, read files, check details. If you already pay for a Claude plan, this is the cheapest way to get a real LLM into a ComfyUI workflow.
You'd reach for it over the plain claude: provider for two reasons. One is billing: usage counts against your plan's rolling window (the CLI reports it as rateLimitType: five_hour), not API spend. The other is capability: with enable_research on, it can fetch facts while it writes, so a prompt like "a 1930s Berlin rooftop at dusk" can quietly look up period-accurate wardrobe instead of guessing. The cost=$… in its info output is the CLI's estimate of equivalent API cost, not a charge - worth knowing so you don't panic.
How it works
Under the hood it speaks Claude Code's bidirectional streaming protocol (--input-format stream-json --output-format stream-json). Images go inline as base64 blocks, progress streams to the ComfyUI console, and cancelling the queue kills the CLI instead of letting it run against your quota. When use_subscription is on (the default) the node hides ANTHROPIC_API_KEY from the CLI so the call authenticates with your login. Your ~/.claude/CLAUDE.md, skills and hooks are deliberately ignored - a personal "always use Go best practices" rule has no business rewriting a video prompt.
Two honest caveats. It's slower than a plain API call - 5–30s typical, more with research on - because it's a full agent loop. And it carries Claude Code's tool preamble (~35k cached tokens), so each call costs more tokens than hitting the API directly. The subscription seat is the trade.
The inputs that matter
Most defaults are fine to leave alone. The ones you'll actually touch:
prompt- what to ask. Connectimagebelow it to have the frame described or used as reference.model-sonnet,opus,haiku,fable, ordefault(whatever the CLI is configured for).enable_research- reaches the internet. Grants WebSearch, WebFetch, Glob, Grep and Read. Off means it answers from the prompt alone.use_subscription- on uses your login; off bills the API key instead.resume_session_id- feed in a previous node'ssession_idto continue that conversation. This is how you chain refinement: node 1 writes, node 2 says "make shot 2 wilder, cut the dialogue" without re-sending any of it.
timeout_seconds defaults to 600 - give research runs room. seed has nothing to do with sampling (Claude Code has no seed); it only controls ComfyUI caching, and -1 re-runs every queue. Outputs are text (the answer), session_id, and info (model, duration, turns, cost). working_dir lets it read real files; empty uses a throwaway scratch folder, which is the safe default.
Install
Install the pack itself - ComfyUI Manager (search "comfyui_dagthomas") or:
cd ComfyUI/custom_nodes
git clone https://github.com/dagthomas/comfyui_dagthomas
cd comfyui_dagthomas
pip install -r requirements.txt
Then restart. The additional requirement is the Claude Code CLI itself - a separate install from this pack - and you must have run claude once to log in. If claude isn't on PATH, set CLAUDE_CODE_PATH to the binary. The node's model entries only appear when the CLI is found.
Common issues
- "claude not found" - the CLI isn't installed or isn't on PATH. Install it and log in once.
- Hits the rate limit - the
five_hourrolling window on your plan. Heavy batches will exhaust it; the node prints a clear warning. - Times out - a research run on a big prompt can exceed even 600s. Raise
timeout_seconds(up to 3600). - It's just slow - that's the agent loop, not a bug. Use
haikufor quick rewrites.
One ecosystem-level warning: this pack shells out to a real CLI and - like every custom node - runs arbitrary Python. After the ComfyUI LLM-vision malware incident, "review what you install and never expose ComfyUI to the internet unauthenticated" stopped being paranoia. This node is local-first and reads nothing outside the folders you point it at, but the habit is a good one.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | What to ask. Connect images below to have them described or used as reference. | |
| model | COMBO | sonnet | Claude Code model alias. `default` uses whatever the CLI is configured for. |
| enable_research | BOOLEAN | false | Let Claude Code search the web and read files while it answers (WebSearch, WebFetch, Glob, Grep, Read). Slower, and it reaches the internet. Off means it answers from the prompt alone. |
| use_subscription | BOOLEAN | true | Hide ANTHROPIC_API_KEY from the CLI so it uses your Claude Code login and subscription seat. Turn off to bill the API key instead. |
| timeout_seconds | INT | 60030–3600 | How long to wait before giving up. Research runs take longer. |
| seed | INT | -1-1–18446744073709550000 | Claude Code has no seed of its own - this only controls ComfyUI caching. -1 re-runs every queue; any other value reuses the cached answer until it changes. |
| imageopt | IMAGE | Reference frame(s), sent inline to the CLI as vision input. | |
| system_promptopt | STRING | You are a precise creative writing assistant working inside an image and video generation pipeline. Answer with the finished text only: no preamble, no commentary, no markdown fences, no offers to help further. | Replaces Claude Code's own system prompt. Long text is moved into the message automatically. |
| resume_session_idopt | STRING | Continue an earlier run by feeding it that node's session_id output. Lets a second node refine the first answer - 'make it wilder', 'shorten shot 2' - with the whole conversation still in context. | |
| working_diropt | STRING | Run inside this folder so Claude Code can read its files. Empty uses a throwaway scratch folder, which is the safe default. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| session_id | STRING | — |
| info | STRING | — |