Nodes/YANC_LMStudio/๐Ÿ˜ผ> LMStudio
ComfyUI Node

๐Ÿ˜ผ> LMStudio

Let a real LLM write your prompts โ€” local, free, no API key

By ALatentPlaceยทCreated about a year agoยทUpdated about a year agoยท 25
๐Ÿ˜ผ> LMStudio
  • image
  • Extended Prompt
  • Reasoning
โ—„promptโ€”โ–บ
โ—„model_identifierโ–บ
โ—„draft_modelโ–บ
โ—„system_messageYou 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_tagthinkโ–บ
โ—„seed0โ–บ
โ—„iplocalhostโ–บ
โ—„port1234โ–บ
โ—„temperature0.70โ–บ
โ—„max_tokens600โ–บ
โ—„unload_llmfalseโ–บ
โ—„unload_comfy_modelsfalseโ–บ

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 prompt to the loaded model using the system_message as instructions - the default ships with a prompt-expander persona you should absolutely edit to taste.
  • Passes along temperature, max_tokens, and an optional draft_model for speculative decoding.
  • If the model writes its thinking inside <reasoning_tag> blocks (default think), 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's forceInput, 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, like Qwen3.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:1234 unless 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_identifier doesn't match LM Studio exactly; copy it from the model dropdown instead of typing.
  • VRAM OOM - enable unload_comfy_models so 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.

CategoryYANC/๐Ÿ˜ผ LMStudio

Inputs (13)

NameTypeDefaultDescription
promptSTRINGโ€”
model_identifierSTRINGโ€”
draft_modelSTRINGโ€”
system_messageSTRINGYou 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_tagSTRINGthinkโ€”
seedINT00โ€“18446744073709550000โ€”
ipSTRINGlocalhostโ€”
portINT1234โ€”
temperatureFLOAT0.700.01โ€“1โ€”
max_tokensINT600-1โ€“18446744073709550000โ€”
unload_llmBOOLEANfalseโ€”
unload_comfy_modelsBOOLEANfalseโ€”
imageoptIMAGEโ€”

Outputs (2)

NameTypeDescription
Extended PromptSTRINGโ€”
ReasoningSTRINGโ€”