-
Notifications
You must be signed in to change notification settings - Fork 1
LLM Text Generator
Back to Wiki Home
The LLM Text Generator node connects to any OpenAI-compatible LLM service (Ollama, vLLM, llama.cpp, LocalAI, etc.) for text generation inside ComfyUI workflows. It supports multiple reference images, videos, and audio, and can display generated text in real time via streaming (SSE).
-
Class name:
zyd232 LLMGenerator -
Category:
zyd232 Nodes/LLM -
Outputs:
text(final answer),reasoning(thinking process)
- Config Preset System
- API Key & Environment Variables
- Model Selection
- Multimodal Inputs (Images / Videos / Audio)
- Streaming Text Display
- Lock Result
- Thinking / Reasoning Mode
- Other Parameters Quick Reference
Save all your settings (API URL, key, model, prompts, parameters) as named presets and switch between them with one click. Presets are stored in a single JSON file (presets/llm_text_generator_presets.json).
-
Configure the node — Fill in
base_url,api_key, choose a model, write your prompts, and set other parameters. - Name your preset — Type a name into the config_name field (e.g., "My Ollama", "GPT-4o"). Invalid file-system characters are automatically removed.
-
Save — Click 💾 Save Config & Hide API. All current settings are saved under that name, and your
api_keyis hidden as********for security. - Switch presets — Pick any saved preset from the config_select dropdown. All fields are filled in automatically (no separate "Load" button needed).
- Delete — Select a preset in the dropdown, then click 🗑 Delete. The built-in "Default" preset cannot be deleted.
- Refresh list — Click 🔄 Refresh Config List to reload the preset dropdown at any time.
- "Default" is always available as a fallback preset.
- After saving, your
api_keyshows as********but the real key is still used behind the scenes. - Create separate presets for different LLM backends (e.g., one for Ollama, one for vLLM) and switch instantly.
- The
api_keyfield accepts a plain key, orENV:var_nameto read the key from an environment variable at runtime. - If the widget shows the masked placeholder
********, the real key is loaded from the saved preset automatically. - As a last resort, the node falls back to the
api_keystored in the Default preset.
Two dropdown selectors are provided:
- model_select — Pick a vision model (used when an image/video/audio is connected). After picking, the dropdown resets to the placeholder.
- model_NoVision_select — Pick a text-only model (used when no media is connected). Resets after picking too.
You can also type model names directly into the model / model_NoVision text fields. Click 🔄 Refresh Model List to re-fetch available models from your API server.
When no image/video/audio input is connected, the node automatically uses model_NoVision. If that model fails, it falls back to model.
The node supports multiple reference images, videos, and audio via autogrow inputs:
| Input | Description | Max count |
|---|---|---|
| images | Reference images (image_0, image_1, …), converted to base64 PNG |
0–9 |
| videos | Reference videos (video_0, …); frames are sampled and sent as images |
0–3 |
| video_audios | Soundtrack of the same-numbered reference video (video_audio_0, …) |
0–3 |
| audios | Standalone reference audio (audio_0, …) |
0–5 |
The inputs follow the same pattern as MiniMax H3 Reference to Video: connect
image_0to revealimage_1, and so on.
-
video_fps — Frames per second sampled from each reference video (default
1.0). -
max_video_frames — Maximum number of frames sent per video to avoid exceeding the context length (default
16).
- enable_audio — Encode and send audio references to the API. Only enable if the model supports audio input. Audio is converted to base64 WAV.
The node shows the generated text in real time on a floating panel to the right of the node. As chunks arrive over WebSocket, the panel updates live while the model is still generating. The panel is a DOM overlay that follows the node when it is moved or the canvas is zoomed/panned, and it never overlaps the node's widgets.
The panel supports:
-
Collapse / Expand (
▼/▶) — hide or show the panel. -
Show / Hide Reasoning (
🧠/🚫) — toggle the reasoning block. -
Lock / Unlock Result (
🔒/🔓) — lock the current output so it is saved into the workflow and reused on the next run without calling the LLM again (see below). -
Clear (
✕) — clear the displayed text. Disabled while the result is locked (unlock first). -
Copy (
⧉) — copy the displayed text to the clipboard. - Auto-scroll — the panel stays scrolled to the bottom while streaming; scroll manually to pause auto-scroll.
When you finish a generation, you can lock the result so it is stored inside the workflow itself. This is useful when you want to save or share a workflow: other users (or a later re-run) will use the locked output directly and skip the LLM service call entirely.
- Run the node and wait for the generation to finish.
- Click the 🔒 Lock button on the Streaming Text panel's title bar. The current output (and reasoning, if shown) is saved into the workflow.
- Save the workflow as usual — the locked result is embedded in the workflow JSON.
- When the workflow is re-run (by you or anyone who loads the shared file), the node returns the locked text/reasoning directly without contacting the LLM server. Downstream nodes consume the locked result as normal.
- To generate fresh output again, click 🔓 Unlock and re-run.
- Hovering over the lock button shows a tooltip explaining its function.
- While locked, the Clear button is disabled so the locked result cannot be accidentally wiped; unlock first to clear.
- Locking an empty result is allowed (it simply locks an empty output).
- Unlocking changes the node's inputs, which invalidates ComfyUI's cache and forces the node to re-run the LLM on the next execution.
Enable thinking to separate the model's reasoning chain from its final answer. Uses custom tags (<think> / </think> by default). Reasoning goes to the reasoning output, the answer to the text output.
- thinking — Enable/disable thinking mode.
-
think_start_tag — Opening tag to mark the start of thinking content (default
<think>). -
think_end_tag — Closing tag to mark the end of thinking content (default
</think>).
| Parameter | What It Does | When to Enable |
|---|---|---|
| cache_prompt | Tells the server to cache prompts for faster repeated responses | Server supports caching (e.g., vLLM) |
| clean_comfy_vram_before_gen | Frees ComfyUI GPU memory before sending the LLM request | Limited VRAM |
| unload_after_gen | Sends an unload command to the server after generation | Using vLLM, Ollama, LocalAI, etc. |
| unload_endpoint | API endpoint path used for the general unload request | Custom server unload path |
| llama_cpp_unload | Unloads via llama.cpp-specific endpoint | Using a llama.cpp server |
| llama_endpoint | llama.cpp unload API endpoint path | Using a llama.cpp server |
| context_length | Context window size (num_ctx / n_ctx); -1/0 uses server default |
Control memory usage / context size |
| video_fps | Frames per second sampled from each reference video | Using video inputs |
| max_video_frames | Max frames sent per video (avoids exceeding context length) | Using video inputs |
| enable_audio | Encode and send audio references to the API | Model supports audio input |
| temperature | Randomness: higher is more creative, lower is more stable (default 0.7) |
Control output style |
| top_k | Pick next word from top K candidates (default 40) |
Control diversity |
| seed | Random seed for reproducibility; -1 for random (default -1) |
Reproducible output |
| timeout | Timeout in seconds for the LLM generation request (default 180) |
Long-running tasks |
Click the ⏹ Stop Generation button to interrupt the currently running request. The node uses streaming (SSE) generation; clicking Stop closes the active connection, which makes the server stop generating and the node return the text accumulated so far.
Back to Wiki Home