Add an LLM prompt node to ComfyUI, powered by any catalog model.
Updated 2026-07-16
Your diffusion models keep running locally. The one thing worth calling out for is the text: an OpenAI-compatible LLM node rewrites terse prompts into detailed ones before they hit the sampler. Point it at one endpoint and Claude, Gemini, or DeepSeek does the rewriting under a single key.
Quick answer: two maintained node routes.
The simplest route is a dedicated compatible-endpoint node such as the community OpenAI Compatible LLM node: its inputs are prompt, endpoint, api_token, and optional model, max_tokens, temperature, and an image input for multimodal calls. Its endpoint field takes the full completions URL, so for APIsRouter that is https://api.apisrouter.com/v1/chat/completions, with the model field carrying any catalog id as a plain string. The richer route is Plush-for-ComfyUI's Advanced Prompt Enhancer, a long-maintained node pack built specifically for this job. It supports several connection types; the one for a gateway is the OpenAI API Connection (URL) type, which takes the base URL with the /v1 path, https://api.apisrouter.com/v1, reads the key from an environment variable, and lets you register model ids in an opt_models.txt file so they appear as a dropdown. Both routes install through ComfyUI Manager or a git clone into custom_nodes.
prompt: "a lighthouse at dusk"
endpoint: https://api.apisrouter.com/v1/chat/completions
api_token: sk-APIsRouter-...
model: claude-haiku-4-5-20251001
max_tokens: 300
-> STRING output wires into your CLIP Text Encode nodeWhat stays local and what calls out.
ComfyUI (comfyanonymous on GitHub, roughly 121K stars) is the node-graph interface for local image and video generation, and its economics are the opposite of a chat app: the expensive part, diffusion, runs on your own GPU and costs you electricity, not tokens. The LLM node changes none of that. Checkpoints, LoRAs, samplers, and VAE decoding never leave your machine. What leaves is text, and only when the graph reaches the LLM node: your short prompt goes out, an enriched prompt comes back, typically a few hundred tokens round trip. That asymmetry is why API-based prompt enhancement makes sense even for people who chose ComfyUI precisely to keep generation local, the token bill for a whole evening of enhanced generations usually amounts to a rounding error next to what image-generation APIs would have charged for the same session. The one genuine boundary decision is multimodal. Nodes with an image input can send a generated frame out for critique or captioning, which is powerful for iterate-on-look workflows, and it means that specific image does leave your machine as base64. Wire image inputs deliberately: prompt text out by default, frames out only when you connected them on purpose.
Full setup: Plush Advanced Prompt Enhancer.
Install Plush-for-ComfyUI through ComfyUI Manager, then do two things before starting ComfyUI. First, export the key: Plush reads remote-service keys from environment variables, with LLM_KEY as the documented name for open-source and remote compatible services, and a Custom API Key node available when you want a user-defined variable instead. Second, add your model ids to opt_models.txt in the Plush directory; the file is untracked so updates will not overwrite it, and its entries populate the model dropdown for connection types ending in (URL). In the node itself, choose the OpenAI API Connection (URL) type and enter https://api.apisrouter.com/v1 as the URL. Plush documents exactly this shape for gateway-style services, base URL with /v1 for the API connection type, or the full /v1/chat/completions path if you use the Direct Web Connection type instead. Pick one type and match its URL shape; mixing them is the most common misconfiguration. Wire the enhancer between your text input and the CLIP Text Encode node, so the enriched prompt is what the encoder sees. The node also takes a style instruction, which is where Plush earns its keep: the same terse subject line can be expanded photorealistic, painterly, or cinematic by swapping the style input rather than rewriting the prompt.
# key for remote compatible services (Plush reads env at startup)
export LLM_KEY=sk-APIsRouter-...
# register catalog ids for the model dropdown
cat >> custom_nodes/Plush-for-ComfyUI/opt_models.txt <<'EOF'
claude-haiku-4-5-20251001
claude-sonnet-4-6
gemini-3.5-flash
deepseek-v4-flash
EOFChoosing a model for prompt work.
The comparison that matters is visual: run the same seed and workflow with two different enhancer models and look at the images. Behind one endpoint that is a dropdown change, and the usage log prices each candidate's text step while the pictures argue for themselves.
- Prompt expansion is short, structured rewriting, the natural home of fast ids. claude-haiku-4-5-20251001, gemini-3.5-flash, and deepseek-v4-flash return in a beat and cost next to nothing per generation.
- Style-heavy expansion, where the model must hold a consistent aesthetic vocabulary across a batch, is where claude-sonnet-4-6 shows a visible quality step in the images that come out the other end.
- Batch pipelines that enhance hundreds of prompts per queue run are volume workloads; the fast tier keeps the text step invisible in the session cost.
- Critique loops that send a frame out for feedback need an id that accepts image input; test the round trip on one frame before wiring it into a loop.
- Negative-prompt generation and tag cleanup are the same class of work as expansion, and the same fast ids serve them.
Pay-as-you-go · transparent per-model pricing
Selected models are priced below official list prices. Exact input, output, cache, and per-request prices are shown for each model.
| Model | Official Price | Our Price |
|---|---|---|
| Claude Haiku 4.5 20251001 | $1.00 / $5.00 per M | $0.80 / $4.00 per M |
| Gemini 3.5 Flash | $1.50 / $9.00 per M | $1.20 / $7.20 per M |
| DeepSeek V4 Flash | $0.14 / $0.28 per M | $0.13 / $0.25 per M |
| Claude Sonnet 4.6 | $3.00 / $15.00 per M | $2.40 / $12.00 per M |
| GPT-5.4 Mini | $0.75 / $4.50 per M | $0.60 / $3.60 per M |
Failure modes specific to ComfyUI nodes.
URL shape is per connection type, and it is the top source of 404s. Plush's OpenAI API Connection (URL) type wants the base with /v1; its Direct Web Connection type wants the full /v1/chat/completions path; the simple compatible node's endpoint field also wants the full path. Read which field you are filling and match its expected shape rather than pasting one URL everywhere. Environment variables are read when ComfyUI starts. An LLM_KEY exported after launch, or exported in a different shell than the one that started ComfyUI, produces authentication failures that look like a wrong key. Desktop launchers are the classic trap, since they do not inherit your terminal's exports. The opt_models.txt list only feeds connection types ending in (URL), so a model id that works in one node type may be absent from another's dropdown; that is the documented scope, not a bug. Ids must match the gateway's /v1/models listing exactly. And a workflow that errors only when an image input is connected is a model mismatch: the text id you chose does not accept image input. Swap to a multimodal id for critique steps, or disconnect the image input for pure text enhancement.
Who wires ComfyUI to a gateway.
- Local-first generators who keep diffusion on their own GPU and want frontier-quality prompt writing without a vendor account per model family.
- Batch creators enhancing large prompt queues, where fast catalog ids make the text step a negligible line next to the GPU time.
- Workflow authors publishing graphs for others, since an endpoint plus env-var key is reproducible for every downloader in a way that personal vendor accounts are not.
- Iterate-on-look artists running critique loops, sending a frame out for feedback and regenerating, which needs a multimodal id behind the same endpoint.
- Developers without access to a given vendor's billing. Top-up based access with no card requirement removes the per-provider sign-up dependency.
Verify the endpoint and debug the first enhanced prompt.
Prove the endpoint with curl first, using the exact id you will select in the node. The LLM node is one of many things that can fail in a ComfyUI graph, and confirming the API half outside the graph cuts the search space before you queue anything. Then build the smallest graph that exercises the node: text input, LLM node, and a preview or show-text node on its STRING output, with no sampler attached. Queue it once. A 401 is the key or the env var timing; a 404 is the URL shape for that connection type; a model error is the id spelling; an empty output with no error usually means the node is fine and your prompt template asked for nothing. Only after the text round trip works should you wire the output into CLIP Text Encode and the full generation graph. Once it flows, the APIsRouter console shows per-request model, token counts, and spend. Prompt enhancement is genuinely small traffic, a few hundred tokens per generation, and the usage log is where you confirm that the text step costs what this page says it does, on your own workflow rather than anyone's estimate.
curl -s https://api.apisrouter.com/v1/chat/completions \
-H "Authorization: Bearer $APISROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"claude-haiku-4-5-20251001",
"messages":[{"role":"user","content":
"Expand into a detailed image prompt: a lighthouse at dusk"}]}'FAQ
Which ComfyUI node connects to an OpenAI-compatible endpoint?
Two maintained routes: a dedicated compatible-endpoint node whose fields are prompt, endpoint, api_token, and model, taking the full /v1/chat/completions URL; and Plush-for-ComfyUI's Advanced Prompt Enhancer, whose OpenAI API Connection (URL) type takes the base URL with /v1 and reads the key from an environment variable.
Does my image generation leave my machine?
No. Diffusion, checkpoints, LoRAs, and sampling all run locally exactly as before. Only the text passing through the LLM node calls out, and an image only leaves if you deliberately wire a frame into a multimodal node input for critique or captioning.
Should the URL include /v1 or the full /chat/completions path?
It depends on the field. Plush's OpenAI API Connection (URL) type wants https://api.apisrouter.com/v1; its Direct Web Connection type and the simple node's endpoint field want https://api.apisrouter.com/v1/chat/completions. Matching the shape to the connection type resolves most 404s.
Where does the API key go for Plush?
In an environment variable read at ComfyUI startup: LLM_KEY is the documented name for remote compatible services, and a Custom API Key node supports user-defined variable names. Export it in the same environment that launches ComfyUI, then restart.
Can Claude or Gemini write my prompts through one endpoint?
Yes. The model field is forwarded as a plain string to the endpoint, so any catalog id works: claude-haiku-4-5-20251001 for fast expansion, claude-sonnet-4-6 for style-heavy batches, gemini-3.5-flash for quick iterations, all through the same key.
What does prompt enhancement cost per image?
A typical round trip is a few hundred tokens, which on fast catalog ids amounts to a small fraction of a cent per generation. The APIsRouter usage log shows the exact per-request spend, so a session's text cost is a number you can read rather than estimate.