LLM API
A Real Cloud LLM Call, Right Inside Your Graph
- image
- response
Every once in a while a node is exactly what its name says, and this is one of them. LLM API doesn't run a model, download weights, or touch your VRAM. You type a prompt, it phones an OpenAI-compatible endpoint like OpenRouter, and the reply drops back into your graph as plain text. That's the whole job - and honestly, that's a feature.
Why you'd reach for it
This is the API path in the local-vs-cloud decision that the whole LLM-in-ComfyUI conversation keeps coming back to. A local GGUF model behind an Ollama node buys you free, offline, uncensored calls - but it also eats VRAM that your diffusion model wants, and an 8B is not writing frontier-quality prose. If you want genuine Gemini/Claude/GPT-level text and you don't care about local or NSFW, calling out beats running local.
Concretely it's a text-and-vision workhorse for three jobs: describing an image (the classic "Describe this image:" default prompt), rewriting a rough idea into a structured, model-appropriate prompt to feed your encoder, and captioning a reference image to seed an img2img or video pass. All of it sits upstream of the sampler.
How it works
Under the hood it's a single requests.post() to the base_url you give it, speaking the standard OpenAI chat-completions wire format. Wire in an image and it converts the tensor to a PNG, base64-encodes it, and sends it as a data URL alongside your text - that's the multimodal path. It then grabs choices[0].message.content and hands you the string. Failures don't crash the graph: they come back as an Error: ... string in the output, with the full details printed to the ComfyUI console.
The inputs that matter
- base_url - default points at OpenRouter's chat completions endpoint. Because it's free text, the node isn't locked to any one provider: OpenAI, Gemini's OpenAI-compatible endpoint, a local LM Studio/Ollama server, vLLM, whatever speaks the same format. This is the node's real superpower.
- model - free text too, and that matters. The LLM-API nodes of old hard-coded their model lists and rotted when providers retired them (people were still stuck on
claude-3-sonnetlong after it was dead). Here you type the exact provider ID; default isgoogle/gemini-2.0-flash-001. - api_key - paste it in, or leave it blank and it loads from the
OPENAI_API_KEYenvironment variable via dotenv. - temperature - a 0–2.0 slider, default 0.7. Standard knob.
- prompt - multiline, where the instruction lives. image (optional) - any IMAGE tensor.
Output is a single response STRING. Wire it into ShowText, a text-preview node, or straight into a CLIP Text Encode - anything that takes a string.
Installing it
ComfyUI Manager, search for ComfyUI LLM API Nodes and hit install. Or the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/perfectspr/comfyui_llm_api
Restart ComfyUI. That's it - there are no model files to download and the real dependencies (requests, python-dotenv, pydantic) are light. The "heavy" cost here is billed by the API provider, not your GPU.
Where people get burned
- It's a single-shot call. No conversation history, no system prompt, no streaming, no retries. Feed it one message, get one reply. Multi-turn chat isn't this node's job.
- Error strings flow back into the graph. A failed call hands you
Error: API call failed with status 404...as a string, and it's easy to pipe that into your prompt enhancer without noticing. Glance at the console. - Only the first frame of an image batch is sent - it takes
image[0], so a batch of 4 means frames 1–3 silently vanish. And everything ships as base64 PNG, so downscale big images or a multimodal provider may reject the payload with a 400. - Wrong model name = model not found. OpenRouter's IDs are
provider/model; a typo or an ID that's not behind your key gives a clean 404. - It holds a credential and phones home by design - the exact shape of node that got weaponized once in this ecosystem. This one is MIT, open, and only a couple dozen lines, so reading it before first run takes five minutes. Do that, and don't paste a key into a workflow you plan to share; it gets saved with the JSON.
Honest sizing: it's alpha (0.0.3), a single node out of a cookiecutter scaffold, and there's basically no community chatter around it yet. If you want a feature-rich LLM suite with history and streaming, look elsewhere. If you want one clean, provider-agnostic API call inside a graph - this is the lean one I'd grab.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Describe this image: | — |
| base_url | STRING | https://openrouter.ai/api/v1/chat/completions | — |
| api_key | STRING | — | |
| model | STRING | google/gemini-2.0-flash-001 | — |
| temperature | FLOAT | 0.70–2 | — |
| imageopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| response | STRING | — |