LM Studio (Text Gen)
Ask a local LLM to write your prompts for you, right inside the graph
- Generated Text
This is the node for the era we're actually in: LLM-assisted prompting stopped being an experiment and became routine. Prompt-enhancer mentions on the reddit side went from a dozen in 2023 to a couple hundred a year by 2025, and the community's settled take is simple - if writing a good prompt for an LLM-encoded model is hard, have another LLM do it. The Text Gen node is that, minus the browser tab. It's a plain text-in, text-out call to a language model running locally in LM Studio, and you wire its output straight into a CLIP Text Encode.
The mechanism is unglamorous in the best way. You give it a prompt and a system_prompt, it builds a chat with the LM Studio server over the official lmstudio SDK, streams the response, and hands you the finished text. No image involved, no API key, nothing leaves your machine. Because the model lives in LM Studio, you get to pick the quality/VRAM trade - the default gemma-3-4b-it-qat is small enough to run on a modest card, but nothing stops you from pointing it at a bigger instruct model you've downloaded.
What to set
prompt- your instruction. Default is "Generate a creative story:", but the workflows people actually build feed this from another node (prompt templates, subject lines, randomizers) so the whole graph composes.system_prompt- how the model should behave. Default "You are a helpful AI assistant." For prompt-writing you'll want to override it: tell it the checkpoint's tag style, the{this|that}wildcard syntax, or that it should emit comma-separated booru tags for tag-based models.model_key- the LM Studio identifier of the model to use. Defaultgemma-3-4b-it-qat.seed- -1 for random, any other value for reproducible output.max_tokens(1000, max 4096) andtemperature(0.7) - the usual dials; lower temperature if you want the model to stop improvising and follow the system prompt closely.strip_thinking- on by default, and worth leaving on. It cuts<think>...</think>reasoning blocks out of the reply, which you do not want going into your text encoder.auto_unload/unload_delay- same VRAM management as the rest of the pack.unload_delay0 unloads right after each response; a TTL of a few hundred seconds keeps the model warm during a batch.
timeout_seconds (default 300) is the one that'll bite you if you run slow hardware on a big model - generation that exceeds it returns an error string instead of text.
Output is a single Generated Text (STRING). That's the whole interface. Wire it to CLIP Text Encode, into a ShowText node to read it, or back into another Text Gen node if you want a chain.
Install and gotchas
Same story as the rest of the pack: ComfyUI Manager (search "LM Studio"), or git clone https://github.com/mattjohnpowell/comfyui-lmstudio-image-to-text-node into custom_nodes, then make sure lmstudio is installed (the pack auto-installs it at load if it's missing) and restart ComfyUI. LM Studio needs to be running with the Server started and a model loaded - the SDK connects automatically to localhost:1234, so there's no port to configure unless you're using the legacy ip_address/port inputs from an old workflow.
If you get an empty or error output: flip debug on and read the ComfyUI console, confirm the model_key exists in your LM Studio library, and check that the server is actually up. And if the error message name-drops bosToken, your SDK is older than your LM Studio app - pip install lmstudio --upgrade (or run upgrade_lmstudio.py), then restart ComfyUI fully. That mismatch is the single most reported failure mode for this pack, and the fix is always the same.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Generate a creative story: | — |
| system_prompt | STRING | You are a helpful AI assistant. | — |
| model_key | STRING | gemma-3-4b-it-qat | — |
| auto_unload | COMBO | True | 2 options: True, False |
| unload_delay | INT | 00–3600 | — |
| seed | INT | -1-1–18446744073709550000 | — |
| max_tokensopt | INT | 10001–4096 | — |
| temperatureopt | FLOAT | 0.700–2 | — |
| debugopt | BOOLEAN | false | — |
| timeout_secondsopt | INT | 30010–3600 | — |
| strip_thinkingopt | BOOLEAN | true | Strip <think>...</think> reasoning blocks from the response (for models with thinking mode enabled). |
| modelopt | STRING | — | |
| ip_addressopt | STRING | — | |
| portopt | INT | 00–65535 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Generated Text | STRING | — |