Nodes/LiamUtil/OllamaApiChat @Liam
ComfyUI Node

OllamaApiChat @Liam

Free, local LLM chat inside ComfyUI

By ai-liam·Created 2 years ago·Updated 2 years ago· 2
OllamaApiChat @Liam
    • text
    • messages
    • session_history
    prompthi
    api_urlhttp://127.0.0.1:11434/api/chat
    modelllava:latest
    system_contentYou are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.
    context_size10
    keep_alive5
    topic_id1
    uid123

    Running a local LLM inside ComfyUI has become a whole genre of its own - prompt enhancers, captioners, and dialogue-driven workflows all want a chat model in the graph, and Ollama is the most popular way to get one without paying per token. This node is a thin client for Ollama's /api/chat endpoint: point it at your local Ollama server, give it a model name, and it returns the model's reply as a string you can wire into anything.

    The good news: unlike the pack's Azure node, this one has sane defaults. api_url points at http://127.0.0.1:11434/api/chat - the standard Ollama port - and model defaults to llava:latest, a vision-capable model. If you already run Ollama, this works the moment the pack is installed.

    How it works

    Every run, the node assembles a messages array from your system_content, the last context_size exchanges of per-uid history, and your prompt, then POSTs it to Ollama with stream off, temperature 0, and top_p 0.95. It grabs message.content from the JSON reply and returns it as text. Like the Azure node in the same pack, it keeps conversation history in Python memory keyed by uid, and switching topic_id resets the thread. keep_alive (in minutes) tells Ollama how long to hold the model in RAM after the call.

    The inputs that matter

    • model - the name of a model you've actually pulled (ollama pull llava or ollama pull llama3.2). llava:latest is only a sensible default if that model exists on your box; otherwise you'll get an error about an unknown model.
    • context_size - past messages sent with each call. Default 10, slider to 50. This is the dial that turns the node from single-shot into a real conversation.
    • api_url - leave it alone unless your Ollama isn't on the same machine. If ComfyUI runs in Docker, http://host.docker.internal:11434/api/chat is the usual fix.
    • uid and topic_id - identity plumbing for keeping multiple conversations separate and starting new ones.

    Outputs are text (the reply), messages (the exact payload sent), and session_history (the accumulated conversation as JSON) - useful for debugging what the model actually saw.

    Installing it

    It ships in LiamUtil (display name "OllamaApiChat @Liam"). ComfyUI Manager → search LiamUtil → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ai-liam/comfyui-liam
    pip install -r requirements.txt
    

    The only pip dependency is opencv-python, so this node itself is dependency-light. What you actually need is Ollama running separately:

    ollama pull llava      # or whichever model you want
    ollama serve
    

    Keep Ollama alive in a terminal or as a service while ComfyUI runs. No API keys, no cloud account - that's the whole appeal.

    Where people get burned

    Almost every failure is "Ollama isn't reachable." If the server isn't running, the requests.post raises a connection error and the node dies with a console traceback - so the first check when you see a red node is curl http://127.0.0.1:11434/api/tags. Second is model names: the dropdown-free model field is free text, and Ollama is picky - an unpulled model errors immediately. And remember the memory is in-process: restart ComfyUI and every conversation resets, which matters if you're building anything session-like. Temperature is also hardcoded to 0, so you can't dial creativity - fine for deterministic prompt work, less ideal if you wanted variety.

    CategoryLiam/LLM

    Inputs (8)

    NameTypeDefaultDescription
    promptSTRINGhi
    api_urlSTRINGhttp://127.0.0.1:11434/api/chat
    modelSTRINGllava:latest
    system_contentSTRINGYou are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.
    context_sizeINT100–50
    keep_aliveINT50–60
    topic_idSTRING1
    uidSTRING123

    Outputs (3)

    NameTypeDescription
    textSTRING
    messagesSTRING
    session_historySTRING