Nodes/LF Nodes/Local chat completions
ComfyUI Node

Local chat completions

An LLM in your graph with no API key

By lucafoscili·Created 2 years ago·Updated 23 days ago· 36
Local chat completions
  • image
  • ui_widget
  • text
  • response_json
◄prompt►
◄urlhttp://127.0.0.1:1234/v1/chat/completions►
◄system_message►
◄model►
◄temperature0.2►
◄max_tokens4096►
◄timeout120►
◄reasoningauto►

The name is the honest version of what a dozen "AI assistant" nodes do badly: it calls a chat completions endpoint running on your machine. No key, no credits, no account, no phone-home. Point it at LM Studio (or anything OpenAI-compatible - llama.cpp's server, KoboldCpp, text-generation-webui) and you have a text generator sitting in the middle of your graph.

What people actually use it for: rewrite a rough idea into a structured prompt for whatever base model they're running, caption an image with a vision model, or pull a field out of a blob of text. It's the general-purpose member of the pack's LLM group - where LF_H3PromptMaker is opinionated about H3 video prompts, this one is just "talk to the model".

How it works

It builds a chat request, and it'll speak two dialects depending on the URL you give it. The default is LM Studio's native route (http://127.0.0.1:1234/api/v1/chat), which is the one that supports reasoning control and blank-model discovery. Point it at http://127.0.0.1:1234/v1/chat/completions instead and you get the OpenAI-compatible shape, which works with a much wider set of servers - at the cost of the native extras.

The reasoning input is the tell: auto works anywhere, but off and on require the native route. If you set a reasoning mode and get an error, that's why.

There's a real gotcha in the temperature limits. The schema offers 0 to 2, because OpenAI-compatible endpoints accept that range - but the native LM Studio route rejects anything above 1. So the same slider value works at 1.5 against llama.cpp and fails at 1.5 against LM Studio's native API. You'll hit it as a confusing error unless you know the two paths differ.

The inputs and outputs that matter

  • prompt - what you're asking. Multiline; the user turn.
  • url - the endpoint. This is the input that decides everything about the dialect above.
  • system_message (optional) - your instruction, sent before the prompt. This is where you put the actual job description ("output only the prompt, no preamble").
  • image (optional) - one or more reference images for a vision-capable model. If your model has no vision, don't wire this.
  • model (optional) - leave it blank on LM Studio's native route and the node resolves whichever LLM instance is currently loaded. Specify it if you keep more than one loaded.
  • temperature - default 0.2, range 0–2. Low is right for structured output; the classic enhancer mistake is cranking this and getting creative drift instead of better prompts.
  • max_tokens - default 4096, and note the tooltip: the budget includes the model's reasoning tokens. A thinking model that spends 3,900 tokens reasoning has 196 left for your answer, and truncation looks like the node failing.
  • timeout - default 120 seconds.

Outputs: text (the answer string, exactly as returned - wire it into a CLIP Text Encode) and response_json (the whole endpoint response, for finish reasons, token counts, and the case where text came back empty).

How to install it

ComfyUI Manager → search LF Nodes → install → restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/lucafoscili/lf-nodes
python -m pip install -r lf-nodes/requirements.txt

Pip with ComfyUI's interpreter - the pack lists openai and requests, which is what the transport uses. You also need a server running locally; LM Studio with its server enabled and a model loaded is the tested path (the pack's notes mention KoboldCpp, which is what the author used). And as always with this suite: lucafoscili/comfyui-lf is the archived repo, lf-nodes is current.

Common issues & troubleshooting

Connection refused / empty response. The server isn't running, the port is wrong, or the model name matches nothing loaded. Check response_json before you change the node.

"Temperature must be between 0 and 1 when using LM Studio /api/v1/chat." You slid past the native route's limit. Drop to ≤1, or switch the URL to the OpenAI-compatible endpoint.

The answer includes the model's chatter. "Here's your enhanced prompt:" bleeding into your conditioning is the single most common failure of local prompting nodes, and it's a prompting problem, not a node problem: constrain system_message hard ("reply with the prompt only, nothing else"), keep temperature low, and remember the model's conversational habits land in your prompt tokens if you don't.

Your text is truncated mid-sentence. max_tokens ran out, and reasoning tokens counted against it. Raise the budget or turn reasoning off where the endpoint supports it. The truncation is visible in response_json.

It's slow. Local inference is slow, and a big model on a card that's also holding a diffusion model is slower. That's the honest cost of "no API key", and it's why people run small models for prompt work.

The response is empty but nothing errored. A vision request to a non-vision model, or a model that answered entirely in its reasoning channel. Check response_json.

Category✨ LF Nodes/LLM

Inputs (10)

NameTypeDefaultDescription
promptSTRINGUser prompt sent to the local chat-completions endpoint.
urlSTRINGhttp://127.0.0.1:1234/v1/chat/completionsLocal OpenAI-compatible /v1/chat/completions or LM Studio native /api/v1/chat endpoint.
system_messageoptSTRINGOptional system instruction sent before the user prompt.
imageoptIMAGEOptional ordered reference images for a vision-capable model.
modeloptSTRINGOptional. Blank LM Studio native chat requests use the sole loaded LLM instance.
temperatureoptFLOAT0.20–2Controls response randomness.
max_tokensoptINT4096Response token budget, including any model reasoning.
timeoutoptINT120Request timeout in seconds.
ui_widgetoptLF_CODE—
reasoningoptCOMBOautoLM Studio native reasoning control. auto uses the model default; off/on require /api/v1/chat.

Outputs (2)

NameTypeDescription
textSTRINGExact answer text returned by the local model.
response_jsonJSONComplete JSON response returned by the endpoint.