Chat Once
One-shot LLM calls inside your ComfyUI graph, no key required
- endpoint
- text
- response_json
- finish_reason
- usage_json
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 reportsfinish_reason == "stop". That's great for catching truncated output, but if your server routinely truncates (smallmax_tokens), turn it off.strip_think_tags(default false) - removes<think>...</think>reasoning sections from the returnedtext, for models that emit chain-of-thought. The rawresponse_jsonoutput always keeps the original.
The inputs and outputs that matter
endpoint- required; fromCompatible Endpoint.system_prompt/user_prompt- at least one must be non-empty.max_tokens(10240) -0omits it from the payload entirely.extra_body_toml- a TOML block merged into the request body, which is how you settemperature,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_urldoesn't point at it. The default targets LM Studio's port; Ollama's/v1lives on a different port, so updatebase_urlaccordingly. - Error like
finish_reason must be 'stop', got: 'length': that'sstrict_finish_reasondoing its job - the model ran out of tokens. Raisemax_tokensor 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_tomlerrors: 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_promptyourself.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| endpoint | COMPATIBLE_ENDPOINT | — | |
| system_prompt | STRING | — | |
| user_prompt | STRING | — | |
| max_tokens | INT | 102400–65535 | — |
| seed | INT | 00–2147483647 | — |
| extra_body_toml | STRING | — | |
| strict_finish_reason | BOOLEAN | true | — |
| strip_think_tags | BOOLEAN | false | — |
| timeout_seconds | FLOAT | 60.00.1–300 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| response_json | STRING | — |
| finish_reason | STRING | — |
| usage_json | STRING | — |