Nodes/ComfyUI Ollama Model Manager/Ollama Chat Completion
ComfyUI Node

Ollama Chat Completion

This is the node that makes the LLM talk

By darth-veitcher·Created 10 months ago·Updated 10 months ago· 2
Ollama Chat Completion
  • client
  • history
  • options
  • image
  • response
  • history
model
prompt
system_prompt
formatnone

Ollama Chat Completion is the heart of this pack - the node that actually sends your prompt to a local model and gets text back. If you've seen people make ComfyUI write things - enriching a prompt before the image gen, auto-captioning a video frame, extracting structured data out of a scene - this is the piece doing the writing. It's a full local-LLM call wrapped in a ComfyUI node, and it's genuinely useful once you stop thinking of ComfyUI as "only images."

How it works

The node calls Ollama's /api/chat endpoint with streaming off and assembles the message list itself: it takes any history you feed in, inserts your system_prompt as the first message if it isn't already there, then appends your prompt as the user turn. Whatever generation options you chained in (temperature, seed, top_k - all the OllamaOption* nodes) get passed as Ollama's options object. The response text comes back on response, and a fresh copy of the whole conversation comes back on history so you can hand it to the next chat node and get multi-turn memory for free.

There's a smart caching quirk worth knowing. If your options include a seed, the node behaves like a normal ComfyUI node - identical inputs get cached, so re-running the workflow doesn't re-bill your local GPU. If there's no seed, it deliberately re-executes every time (it returns NaN for the change hash) so you always get a fresh, non-deterministic answer. That's the difference between "iterate on this workflow forever" and "I need a new answer every run."

Inputs and outputs that matter

Required:

  • client - the OLLAMA_CLIENT connection from an Ollama Client or Model Selector.
  • model - model name, auto-populated by the selector. Leave it to the selector; typing it by hand is how you get "Model name cannot be empty."
  • prompt - your user message. Multiline.

Optional, and all worth using:

  • system_prompt - sets behavior ("You are a prompt engineer…").
  • history - previous turns from another Chat Completion's history output.
  • options - the merged OLLAMA_OPTIONS dict from the option nodes.
  • format - none (plain text) or json (forces structured JSON out of the model, great for parsing downstream).
  • image - an IMAGE tensor; for vision models like llava, this gets base64-encoded and attached to the prompt.

Outputs are response (STRING - wire it into anything that eats text, including your image prompt) and history (OLLAMA_HISTORY).

Installing it

Same as every node in this pack: ComfyUI Manager → search "Ollama Manager" → Install → restart, or git clone https://github.com/darth-veitcher/comfyui-ollama-model-manager into ComfyUI/custom_nodes and run python install.py. Python 3.12+, and the pack installs httpx, loguru, rich on its own. The model itself comes from Ollama - ollama pull llama3.2 before you start - and Ollama must be running at http://localhost:11434.

Where people get burned

The classic beginner wall is the empty model list: the node errors with something like "Invalid model selected … Available models: []" because Ollama isn't running or you haven't pulled any models yet. curl http://localhost:11434/api/tags will tell you in one shot. Second: the prompt-crafting loop people actually run - LLM writes the prompt, image gen renders it - is only as good as the model you picked; a tiny 3B model will give you bland prompts fast, so it's worth pulling something with real writing ability if you're going to lean on it.

CategoryOllama

Inputs (8)

NameTypeDefaultDescription
clientOLLAMA_CLIENTOllama client connection from OllamaClient or OllamaModelSelector node
modelSTRINGModel name to use for generation (auto-populated from selector)
promptSTRINGUser prompt or question to send to the model
system_promptoptSTRINGSystem instructions to guide model behavior (optional)
historyoptOLLAMA_HISTORYConversation history from previous chat turns (optional)
optionsoptOLLAMA_OPTIONSGeneration parameters like temperature, seed, etc. (optional)
formatoptCOMBOnoneOutput format: 'none' for text, 'json' for structured JSON response
imageoptIMAGEImage input for vision models (optional)

Outputs (2)

NameTypeDescription
responseSTRING
historyOLLAMA_HISTORY