ComfyUI Node

LM Studio (Unified)

One node for text, images, or both — the lazy route to local LLMs

By mattjohnpowell·Created 2 years ago·Updated 3 months ago· 59
LM Studio (Unified)
  • image
  • Generated Text
text_inputgive me a prompt for an image generation
system_promptYou are a helpful AI assistant.
model_keygemma-3-4b-it-qat
auto_unloadTrue
unload_delay0
seed-1
max_tokens1000
temperature0.70
debugfalse
timeout_seconds300
strip_thinkingtrue

The Unified node is the "just talk to a model" option in this pack. Where its siblings specialize - Image to Text is vision-only, Text Gen is text-only - this one takes a text prompt, an image, or both, and returns a single generated text string. The default text_input is literally "give me a prompt for an image generation," which tells you what the author thinks you'll do with it: sit in front of a checkpoint with no idea what to type, and let a local LLM in LM Studio write your prompt for you.

And that genuinely is the killer use. LLM-assisted prompting has become routine in the ComfyUI world - prompt-enhancer mentions grew twentyfold between 2023 and 2026 - and the community's advice has settled into one sentence: if writing a prompt for a modern LLM-encoded model is hard, have an LLM translate what you want into a well-structured prompt following the model's own guide. Unified is that, as a node, with the option to throw in a reference image when your idea is visual rather than verbal.

How it works

Same machinery as the whole pack: an lmstudio SDK client connects to your local LM Studio server (localhost:1234, automatically - no key, no IP/port to type), builds a chat from system_prompt plus your input, streams the answer, and returns the finished text. The difference is what it accepts. An image input is optional, and so is text_input - just don't leave both empty, or the node has nothing to work with.

If you pass both, the image and text go into the same user message, which is the interesting combo: "Look at this image and give me a prompt for a scene like it, but at night." That's the workflow the other two nodes can't do in one shot.

Inputs worth touching

  • text_input - your instruction; defaults to the prompt-for-image-generation example above.
  • system_prompt - set this if you want the output to match a specific checkpoint's style (comma-separated tags, the {this|that} wildcard syntax, whatever the model guide recommends).
  • image - optional; requires a vision-capable model_key.
  • model_key - default gemma-3-4b-it-qat. Switch to something like qwen/qwen3-vl-8b if your input is image-based.
  • seed, max_tokens (1000), temperature (0.7), strip_thinking (on), auto_unload/unload_delay - all the standard dials from the pack. Lower the temperature for prompt-writing; leave strip_thinking alone.

The output is a single Generated Text (STRING) that feeds into CLIP Text Encode, a ShowText node, or back into another LLM node.

When to pick it over the others

Honest take: if you know you only need text-to-text, the Text Gen node is the cleaner choice - it's the same engine with fewer knobs to trip over. If you're doing vision-only captioning, use Image to Text. But if you're prototyping, sharing a workflow, or want text-plus-image in one call, Unified is the one that keeps your graph small. Its IS_CHANGED logic re-runs on any input change, so be aware it'll call the model whenever you tweak a widget - that's expected, not a bug.

Install and troubleshooting

ComfyUI Manager (search "LM Studio") or git clone https://github.com/mattjohnpowell/comfyui-lmstudio-image-to-text-node into custom_nodes, pip install lmstudio if needed (the pack auto-installs at load), restart ComfyUI. LM Studio must be running with the Server started and a model loaded.

The usual failure stack applies: server not running, model_key not in your library, or a non-vision model getting an image (which fails loudly). Flip debug on and read the console. Post-upgrade bosToken errors mean your SDK is behind your LM Studio app - pip install lmstudio --upgrade (or run upgrade_lmstudio.py) and restart ComfyUI completely.

CategoryComfyExpo/LMStudio

Inputs (12)

NameTypeDefaultDescription
text_inputSTRINGgive me a prompt for an image generation
system_promptSTRINGYou are a helpful AI assistant.
model_keySTRINGgemma-3-4b-it-qat
auto_unloadCOMBOTrue2 options: True, False
unload_delayINT00–3600
seedINT-1-1–18446744073709550000
imageoptIMAGE
max_tokensoptINT10001–4096
temperatureoptFLOAT0.700–2
debugoptBOOLEANfalse
timeout_secondsoptINT30010–3600
strip_thinkingoptBOOLEANtrueStrip <think>...</think> reasoning blocks from the response (for models with thinking mode enabled).

Outputs (1)

NameTypeDescription
Generated TextSTRING