๐ผ> LMStudio
Let a real LLM write your prompts โ local, free, no API key
- image
- Extended Prompt
- Reasoning
The name is a half-lie, in the good way: this node doesn't call any cloud API and needs no key. It's the bridge between LM Studio - the local, ChatGPT-style app that runs GGUF models on your own GPU - and ComfyUI. You feed it a rough idea, it sends that to the LLM sitting inside LM Studio, and hands back a rewritten, expanded prompt plus whatever "reasoning" the model did along the way. Think of it as an on-call prompt engineer that never sends your text anywhere.
Why you'd want an LLM in your prompt path
Prompt expansion has quietly become a legitimate workflow instead of a gimmick. Modern LLM-encoded models read your prompt like an instruction, not a bag of tags, so a well-structured paragraph genuinely beats a comma list. A local Qwen-class instruct model can take "cyberpunk detective in the rain" and hand back a vivid, structured scene description. There's even real-world proof: someone on r/StableDiffusion was running Qwen3.6 through LM Studio and this node to generate JSON-structured prompts for 17MP Ideogram generations.
How it works
LM Studio needs its local server running first (Developer tab โ Start Server, default port 1234). The node connects to ip:port via the official lmstudio Python SDK, which wraps that HTTP API. It then:
- Sends your
promptto the loaded model using thesystem_messageas instructions - the default ships with a prompt-expander persona you should absolutely edit to taste. - Passes along
temperature,max_tokens, and an optionaldraft_modelfor speculative decoding. - If the model writes its thinking inside
<reasoning_tag>blocks (defaultthink), the node strips them: the clean answer goes to Extended Prompt, the thinking goes to Reasoning as a separate output. Handy when you want to see the model's reasoning before committing. - If the first request fails (typically a chat-template mismatch the README calls "400 errors"), it silently retries with the system message flattened into the user prompt. Most of the time you'll never know it happened.
Two behaviors worth knowing. If you attach the optional image input, the node checks the model is actually vision-capable (it raises "The loaded model is not vision enabled" if not), encodes your image to a temp JPEG, and sends it - real multimodal prompting. Quirk: in that path the two STRING outputs are identical, and system_message isn't used. And seed is accepted as an input but the code never forwards it, so don't expect reproducible generations from it.
The inputs that matter
prompt- your rough idea; it'sforceInput, so it expects a connection from a text node or another node.model_identifier- the exact model ID as shown in LM Studio's dropdown (fully qualified, likeQwen3.6-35B-A3B-Instruct). An empty string won't find anything.system_message- the personality. The default is a decent prompt-expander, but this is where you tune the whole behavior.reasoning_tag- must match what your model actually emits, or nothing gets split out.ip/port-localhost:1234unless LM Studio runs elsewhere on your LAN.unload_comfy_models- frees VRAM (unloads diffusion models + empties cache) before the LLM call. Your friend on a single 8-16 GB card.unload_llm- unloads the LLM from LM Studio's memory afterward, mainly useful for remote sessions.
Outputs: Extended Prompt (STRING) wires into the prompt input of your LLM-encoded checkpoint's conditioning. Reasoning (STRING) is optional - route it to a text preview or just ignore it.
Installing
Two ways: ComfyUI Manager (search "YANC_LMStudio"), or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/ALatentPlace/YANC_LMStudio.git
cd YANC_LMStudio
pip install -r requirements.txt
requirements.txt is just lmstudio and msgspec - no heavy deps, no model files to download. The LLM itself lives inside LM Studio, which is the whole point: you pick and load the model there. Restart ComfyUI and you'll find the nodes under the YANC โ LMStudio submenu (the author's own node-collection naming).
Troubleshooting
- Connection refused - LM Studio's server isn't running. Start it, check port 1234.
- Empty output -
model_identifierdoesn't match LM Studio exactly; copy it from the model dropdown instead of typing. - VRAM OOM - enable
unload_comfy_modelsso diffusion models get kicked out before the LLM loads. - Vision errors - you loaded a text-only model. Switch to a Qwen-VL / vision-capable variant.
One honest caveat: like all custom nodes, this runs arbitrary Python inside your ComfyUI process. The whole source is one ~170-line file - after the LLMVISION malware episode in this ecosystem, reading a node's source before trusting it is a habit worth keeping. I looked; this one's clean and boring, in the good way.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | โ | |
| model_identifier | STRING | โ | |
| draft_model | STRING | โ | |
| system_message | STRING | You are an AI assistant specialized in generating detailed and creative image prompts for AI image generation. Your task is to expand a given user prompt into a well-structured, vivid, and highly descriptive prompt while ensuring that all terms from the original prompt are included. Enhance the visual quality and artistic impact by adding relevant details, but do not omit or alter any key elements provided by the user. Follow the given instructions or guidelines and respond only with the refined prompt. | โ |
| reasoning_tag | STRING | think | โ |
| seed | INT | 00โ18446744073709550000 | โ |
| ip | STRING | localhost | โ |
| port | INT | 1234 | โ |
| temperature | FLOAT | 0.700.01โ1 | โ |
| max_tokens | INT | 600-1โ18446744073709550000 | โ |
| unload_llm | BOOLEAN | false | โ |
| unload_comfy_models | BOOLEAN | false | โ |
| imageopt | IMAGE | โ |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| Extended Prompt | STRING | โ |
| Reasoning | STRING | โ |