Nodes/ComfyUI-LLMLink/LLM Chat (LLMLink)
ComfyUI Node

LLM Chat (LLMLink)

The zero-dependency way to put an LLM in your ComfyUI graph

By leafiy·Created about a month ago·Updated about a month ago· 2
LLM Chat (LLMLink)
  • image
  • text
providerollama
base_urlhttp://127.0.0.1:11434
api_key
model
presetnatural
custom_prompt
temperature0.70
max_tokens1024
seed0
timeout120

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 - ollama or openai. Ollama uses its native /api/chat; openai means any OpenAI-compatible /chat/completions endpoint, local or cloud.
  • base_url - defaults to http://127.0.0.1:11434. Point it at https://api.openai.com/v1, an LM Studio or llama.cpp server, or a proxy.- model - free text like qwen2.5vl:7b or gpt-4o-mini. Leave it blank and the node asks the endpoint (/api/tags or /models) and takes the first model listed.
  • preset - natural (default) writes a flowing paragraph prompt suited to Flux/SDXL; tags writes booru-style tags for the SD1.5 anime lineage; none sends 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 404 from /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 left model blank and nothing is pulled. ollama pull something.
  • An empty prompt with preset=none and 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.

CategoryLLMLink

Inputs (11)

NameTypeDefaultDescription
providerCOMBOollama2 options: ollama, openai
base_urlSTRINGhttp://127.0.0.1:11434
api_keySTRING
modelSTRING留空 = 自动选用端点上的第一个可用模型 / empty = auto-pick the first model the endpoint lists
presetCOMBOnatural3 options: natural, tags, none
custom_promptSTRING
temperatureFLOAT0.700–2
max_tokensINT10241–65536
seedINT00–2147483647
timeoutINT1201–3600
imageoptIMAGE

Outputs (1)

NameTypeDescription
textSTRING