ComfyUI Node

Chat Once

One-shot LLM calls inside your ComfyUI graph, no key required

By zaknak·Created 6 months ago·Updated 6 months ago· 0
Chat Once
  • endpoint
  • text
  • response_json
  • finish_reason
  • usage_json
system_prompt
user_prompt
max_tokens10240
seed0
extra_body_toml
strict_finish_reasontrue
strip_think_tagsfalse
timeout_seconds60.0

Want a local LLM to write your prompt, evaluate your output, or clean up your tags - all inside a ComfyUI workflow? This is the node for that. Chat Once sends a single text prompt to an OpenAI-compatible API server and returns the reply as a plain string you can wire into anything.

The name is a clue about the design: one request per run, no conversation memory, no streaming. If you need multi-turn, this pack doesn't do it - by design. But for "LLM as a step in the graph," stateless is actually the right shape, because every run of your workflow is a fresh generation anyway.

How it works

It needs an endpoint - the custom connection object from Compatible Endpoint. Under the hood it builds a standard chat-completions payload (model, messages, max_tokens, seed) and POSTs it to {base_url}/chat/completions using Python's standard urllib - no openai SDK, no API key required for local servers, and no extra package to compromise. It then reads choices[0].message.content and hands you the text plus the raw response.

Two switches are worth knowing before you hit a confusing error:

  • strict_finish_reason (default true) - the run errors out unless the API reports finish_reason == "stop". That's great for catching truncated output, but if your server routinely truncates (small max_tokens), turn it off.
  • strip_think_tags (default false) - removes <think>...</think> reasoning sections from the returned text, for models that emit chain-of-thought. The raw response_json output always keeps the original.

The inputs and outputs that matter

  • endpoint - required; from Compatible Endpoint.
  • system_prompt / user_prompt - at least one must be non-empty.
  • max_tokens (10240) - 0 omits it from the payload entirely.
  • extra_body_toml - a TOML block merged into the request body, which is how you set temperature, top_p, response_format, or anything else the node doesn't expose as a widget:
temperature = 0.7
top_p = 0.9

[response_format]
type = "json_object"

Outputs: text (the reply), response_json (full API response, for debugging), finish_reason, and usage_json (token counts).

Install

Part of ComfyUi_zaknak_nodes - ComfyUI Manager, or git clone https://github.com/zaknak/ComfyUi_zaknak_nodes into ComfyUI/custom_nodes, then restart. It talks to an external server; you run LM Studio (the default http://127.0.0.1:1234/v1 is its address), llama.cpp, Ollama's /v1, or vLLM yourself. No model runs inside ComfyUI.

Troubleshooting

  • "connection refused" / timeout: your server isn't up, or base_url doesn't point at it. The default targets LM Studio's port; Ollama's /v1 lives on a different port, so update base_url accordingly.
  • Error like finish_reason must be 'stop', got: 'length': that's strict_finish_reason doing its job - the model ran out of tokens. Raise max_tokens or flip the switch.
  • "at least one of system_prompt or user_prompt must be provided": both were empty. Obvious, but easy to hit when you bypass Prompt Preset and wire nothing in.
  • extra_body_toml errors: you can't override the reserved keys (model, messages, max_tokens, seed), and TOML dates/times aren't convertible to JSON. Both fail explicitly.
  • No conversation memory: expected. If your workflow needs context, feed the previous reply back into user_prompt yourself.
Categoryzaknak/llm

Inputs (9)

NameTypeDefaultDescription
endpointCOMPATIBLE_ENDPOINT
system_promptSTRING
user_promptSTRING
max_tokensINT102400–65535
seedINT00–2147483647
extra_body_tomlSTRING
strict_finish_reasonBOOLEANtrue
strip_think_tagsBOOLEANfalse
timeout_secondsFLOAT60.00.1–300

Outputs (4)

NameTypeDescription
textSTRING
response_jsonSTRING
finish_reasonSTRING
usage_jsonSTRING