Nodes/Comfy DV Nodes/Chat Completion
ComfyUI Node

Chat Completion

The node that makes ComfyUI actually talk to a local LLM

By darth-veitcher·Created 2 years ago·Updated about a month ago· 2
Chat Completion
  • client
  • history
  • options
  • image
  • response
  • updated_history
  • model_name
  • seed_used
model
prompt
system
timeout_secs300
structured_outputfalse
output_schema{"type": "object", "properties": {"output": {"type": "string"}}, "required": ["output"]}
max_retries2

This is the node that actually does the thing. Everything else in comfydv's LLM section - the client, the selector, the load/unload nodes, all those option widgets - exists to feed this one. You wire it a prompt, it sends it to a local Ollama or llama.cpp server, and the response comes back as an output socket you can pipe into a Format String node, save to a file, or feed into the next step of an image workflow.

Why would you bother? Prompt enrichment before a generation, auto-captioning a frame or a batch, rewriting a caption into something a token-hungry model like Flux's T5 understands, or extracting structured JSON out of a scene description. It's ComfyUI doing "text in, text out" with no Python needed on your end.

How it works

You give it a client (the LLM_CLIENT socket from an Ollama Client or LlamaCpp Client node), a model name, and a prompt. It doesn't care which backend you picked - the pack's whole design is that both clients emit the same socket type and every downstream node works identically. Under the hood the Ollama path talks to Ollama's native /api/chat; the llama.cpp path uses llama-server's OpenAI-compatible endpoint. The response renders inline in the node body (it's an output node) and also comes out of the response socket, so the rest of your graph can consume it.

Inputs that matter

  • client - wire from Ollama Client or LlamaCpp Client. This is what makes backend-swapping a one-node change.
  • model - type a name or wire one in from LLM Model Selector / LLM Load Model. Leave it empty and you get a clear "model cannot be empty" error, not a silent failure.
  • prompt - your message. Multiline.
  • system (optional) - a system prompt prepended to the conversation.
  • history (optional) - an OLLAMA_HISTORY list. Feed the updated_history output back into here and you get multi-turn conversation.
  • options (optional) - where the Ollama Option - nodes chain in (temperature, seed, top p, and the rest).
  • structured_output / output_schema (optional) - flip this on and the response is validated against a JSON schema and returned as parsed fields, with bounded retries (max_retries, default 2). Handy when you're feeding a prompt builder and need reliable JSON, not prose.
  • timeout_secs - the call times out if the model is still grinding after this (default 300s, max 3600).

Outputs: response (the text), updated_history (the conversation so far, including this turn), and model_name (echoes the model back - useful for chaining into an LLM Unload Model later).

Install and gotchas

Install the pack via ComfyUI Manager (search "comfydv") or git clone https://github.com/darth-veitcher/comfydv.git into custom_nodes, then restart. The LLM nodes are useless without a local backend: install Ollama (ollama serve, then ollama pull qwen2.5:latest) or run llama.cpp's llama-server --models-dir ./models -c 8192.

Three things catch people:

  • The rename. This node used to be called OllamaChatCompletion. If you open an old saved workflow and it complains about a missing node type, the behavior is unchanged - just delete and re-add it, and rewire.
  • Structured output against a "thinking" model can eat the whole token budget on chain-of-thought before producing JSON. If you see token-limit validation errors, drop the thinking model or disable its reasoning.
  • Keep it local. This is a node that makes network calls; comfydv's own README and the wider community history (the ComfyUI_LLMVISION incident) are a strong reminder to only point it at a server you control, not some random endpoint from a stranger's workflow.
Categorydv/ollama

Inputs (11)

NameTypeDefaultDescription
clientLLM_CLIENT
modelSTRING
promptSTRING
systemoptSTRING
historyoptOLLAMA_HISTORY
optionsoptOLLAMA_OPTIONS
imageoptIMAGEOptional image(s) for a vision-capable model. Requires a multimodal model on the connected server (Ollama multimodal model, or llama.cpp launched with --mmproj). A batch is sent as multiple images on the turn.
timeout_secsoptINT30030–3600
structured_outputoptBOOLEANfalse
output_schemaoptSTRING{"type": "object", "properties": {"output": {"type": "string"}}, "required": ["output"]}
max_retriesoptINT20–5

Outputs (4)

NameTypeDescription
responseSTRING
updated_historyOLLAMA_HISTORY
model_nameSTRING
seed_usedINT