LLM Chat (LLMLink)
The zero-dependency way to put an LLM in your ComfyUI graph
- image
- text
The name is a slight lie in your favor: it says "LLM Link," and then it turns out to need exactly one dependency - none. LLMLinkChat is a chat node that talks to Ollama or any OpenAI-compatible endpoint over plain HTTP, using only the Python standard library plus the numpy/Pillow ComfyUI already ships. No pip install openai, no Ollama SDK, no runtime sidecar. If you already run Ollama and want its replies inside a workflow - prompt reverse-engineering, booru-tag captioning, structured prompt rewriting - this is the least-friction way to get there. Most LLM-in-the-graph nodes drag in heavy SDKs; a few have actively misbehaved (more on that below). One whose whole install step is git clone and a restart is the good shape for this category.
What it actually does
The mechanism is refreshingly boring. You type a prompt, optionally connect an image, and the node POSTs a JSON body. Images become base64 PNGs - every frame in a batch goes along, so an 8-frame batch is one request carrying 8 images. Ollama gets its native /api/chat; the openai path gets /chat/completions. No streaming, no websocket, just urllib. That plainness is the feature: fewer moving parts, and you can read the whole thing in one file.
The clever bit is the cache. Every input that shapes the reply - including image pixels and seed - goes into a hash, and an identical request returns the cached answer instead of burning another API call or GPU pass. It's a process-wide LRU capped at 100 entries, errors are never cached, and it logs [LLMLink] cache hit/miss to the console. When a node seems to "do nothing," change seed - it's part of the key - and it re-runs. Unplugged from any image, this is a plain text LLM: write an instruction in custom_prompt and it answers. Plug an image in and it becomes a VLM captioner - the reason most people install it.
The inputs that matter
The list is short enough that you'll set most of it once:
- provider -
ollamaoropenai. Ollama uses its native/api/chat;openaimeans any OpenAI-compatible/chat/completionsendpoint, local or cloud. - base_url - defaults to
http://127.0.0.1:11434. Point it athttps://api.openai.com/v1, an LM Studio or llama.cpp server, or a proxy.- model - free text likeqwen2.5vl:7borgpt-4o-mini. Leave it blank and the node asks the endpoint (/api/tagsor/models) and takes the first model listed. - preset -
natural(default) writes a flowing paragraph prompt suited to Flux/SDXL;tagswrites booru-style tags for the SD1.5 anime lineage;nonesends nothing. - custom_prompt - when non-empty, it completely replaces the preset. This is how you turn the node from a captioner into a text tool.
- image (optional) - connect an IMAGE and it's a VLM; leave it unplugged and it's text-only.
Output is a single text STRING. Wire it into the text input of a CLIP Text Encode and you've got image-to-prompt; feed it to any text slot and it's a rewrite step. temperature, max_tokens, seed, and timeout are what they look like - leave them alone at first.
Install
Two lines and a restart:
cd ComfyUI/custom_nodes
git clone https://github.com/leafiy/ComfyUI-LLMLink.git
Restart ComfyUI. No pip install step, no requirements.txt to resolve. (Or search "ComfyUI-LLMLink" in ComfyUI Manager.) What you do need is a backend: Ollama running with a model pulled - ollama pull qwen2.5vl:7b for vision, a plain llama3.2 for text - or an API key for the OpenAI path. The node downloads nothing itself.
Common issues
The errors are real HTTP responses, so they tell you what's wrong:
cannot reach http://127.0.0.1:11434- Ollama isn't running, or lives on another host/port. Start it, check the port.HTTP 404from/api/chat- usually an old Ollama build; update it. A 401/403 on the openai path is a bad or missing key.model is empty and Ollama has no models installed- you leftmodelblank and nothing is pulled.ollama pullsomething.- An empty prompt with
preset=noneand no image raises "nothing to send" instead of silently shipping garbage.
That last one is the design philosophy in miniature: failures abort the workflow rather than feeding error text into your sampler. A broken caption never quietly becomes a weird prompt.
Security, briefly
A key typed into the api_key widget gets saved into your workflow JSON, so clear it before sharing files. Cleaner: leave the widget empty and start ComfyUI with LLMLINK_API_KEY (both providers) or OPENAI_API_KEY (openai only) as environment variables. This is an LLM-in-the-graph node - the category that once shipped the ComfyUI_LLMVISION credential-stealing malware - so the stdlib-only design is reassuring: one plain HTTP call to the exact base_url you configured, no phone-home hidden in an SDK. It's still arbitrary Python that runs on import, so skim the single source file once, then use it happily.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| provider | COMBO | ollama | 2 options: ollama, openai |
| base_url | STRING | http://127.0.0.1:11434 | — |
| api_key | STRING | — | |
| model | STRING | 留空 = 自动选用端点上的第一个可用模型 / empty = auto-pick the first model the endpoint lists | |
| preset | COMBO | natural | 3 options: natural, tags, none |
| custom_prompt | STRING | — | |
| temperature | FLOAT | 0.700–2 | — |
| max_tokens | INT | 10241–65536 | — |
| seed | INT | 00–2147483647 | — |
| timeout | INT | 1201–3600 | — |
| imageopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |