Nodes/Ninode Utils/OpenAI Compatible Chat
ComfyUI Node

OpenAI Compatible Chat

The chat node that talks to any LLM server — no wrapper lock-in

By iGavroche·Created 11 months ago·Updated 11 months ago· 1
OpenAI Compatible Chat
  • images
  • files
  • advanced_options
  • STRING
prompt
api_urlhttp://127.0.0.1:8000/api/v1/chat/completions
modelgpt-4o-mini
api_key
persist_contexttrue
max_tokens1000
temperature0.7
top_p1.00
system_message

If you've ever wanted an LLM inside a ComfyUI workflow but bounced off chat nodes that only talk to one service, this is the un-locked version. OpenAI Compatible Chat is a thin client for any endpoint that speaks OpenAI's /v1/chat/completions format. Ollama, LM Studio, AMD's Lemonade Server (that's the default URL it ships with), the actual OpenAI API, or some random server on localhost - if it serves that endpoint, this node will talk to it. It's sold as a drop-in replacement for the classic ChatGPT node: same interface, way more backends.

How it works

There's nothing clever under the hood, and that's the point. The node builds a messages array, POSTs JSON to your api_url with aiohttp, and pulls choices[0].message.content out of the response. stream is hardcoded to false, so replies come back whole. No models on your disk, no weights to download - the heavy lifting happens wherever your server is.

Two things it does that are genuinely useful:

  • Multi-turn context. With persist_context on, it keeps your conversation history in memory (keyed by a session id, plus the last response id) so follow-up prompts see earlier turns. Flip it off and every call is stateless. It's in-memory, so a ComfyUI restart wipes the conversation.
  • Vision + files. Drop an IMAGE into images and it's converted to a PNG base64 data URL in the request - works with any vision model on the endpoint. The files and advanced_options inputs take dedicated types (OPENAI_INPUT_FILES, OPENAI_CHAT_CONFIG) from the pack's companion nodes, so you can pipe in documents or a prebuilt config object.

The inputs that actually matter

  • api_url - the full endpoint, e.g. http://localhost:11434/v1/chat/completions for Ollama. This is the field that decides everything.
  • model - must match what your server serves (llama3.2, gpt-4o-mini, whatever). A name the server doesn't know is a 400/404 waiting to happen.
  • api_key - leave empty for local servers. The name is a hint, not a requirement.
  • prompt - your text. persist_context - the multi-turn switch, on by default.

Worth a quick note on temperature (0–2) and top_p (0–1): they map straight onto the same-named OpenAI parameters, so treat them like you would in any API call. system_message sets the assistant's personality. The output is a single STRING - the model's reply - which you can wire into a prompt text box, a string into CLIP, or anywhere else that eats text.

Install

Through ComfyUI Manager, search for "Ninode Utils" and install, or the manual way:

cd ComfyUI/custom_nodes
git clone https://github.com/iGavroche/ComfyUI-Ninode-Utils.git
cd ComfyUI-Ninode-Utils
pip install -r requirements.txt

Then restart ComfyUI. The actual requirements.txt pulls aiohttp, torch, Pillow, numpy, and torchaudio - the torch pin is the only heavyweight and you already have it if you're running ComfyUI. The node appears under the Ninode Utils/Chat category.

Common issues

The most common failure is out-of-the-box and not really your fault: the default api_url points at Lemonade Server on 127.0.0.1:8000 while the default model is gpt-4o-mini. If you don't run Lemonade, the first run fails with a connection error. Set both fields to match the server you actually have.

  • Connection refused - your local server isn't running, or the port is wrong.
  • 401 unauthorized - key mismatch; empty key against a server that wants one, or vice versa.
  • Model not found - the name doesn't match what the server serves; check with ollama list or your server's UI.

One more thing, and it's the part I'd actually worry about. Your api_key lives in the workflow JSON, and ComfyUI happily embeds that JSON into output PNG metadata. Sharing a workflow image can share your key. And whatever you feed this node - prompts, full images - goes to whatever endpoint you point it at. After the ComfyUI_LLMVISION malware incident, the community rule is simple: only connect to endpoints you run or genuinely trust.

CategoryNinode Utils/Chat

Inputs (12)

NameTypeDefaultDescription
promptSTRINGText inputs to the model, used to generate a response.
api_urlSTRINGhttp://127.0.0.1:8000/api/v1/chat/completionsOpenAI-compatible API endpoint URL (e.g., http://127.0.0.1:8000/api/v1/chat/completions for Lemonade Server, or http://localhost:11434/v1/chat/completions for Ollama)
modelSTRINGgpt-4o-miniModel name to use (e.g., gpt-4o-mini, llama3.2, etc.)
api_keySTRINGAPI key for authentication (leave empty if not required)
persist_contextBOOLEANtruePersist chat context between calls (multi-turn conversation)
imagesoptIMAGEOptional image(s) to use as context for the model. To include multiple images, you can use the Batch Images node.
filesoptOPENAI_INPUT_FILESOptional file(s) to use as context for the model. Accepts inputs from the OpenAI Chat Input Files node.
advanced_optionsoptOPENAI_CHAT_CONFIGOptional configuration for the model. Accepts inputs from the OpenAI Chat Advanced Options node.
max_tokensoptINT10001–100000Maximum number of tokens to generate
temperatureoptFLOAT0.70–2Controls randomness in the response (0.0 = deterministic, 2.0 = very random)
top_poptFLOAT1.000–1Controls diversity via nucleus sampling (0.0 = only most likely tokens, 1.0 = all tokens)
system_messageoptSTRINGOptional system message to set the behavior of the assistant

Outputs (1)

NameTypeDescription
STRINGSTRING