LM Studio Bridge
Give ComfyUI a brain — a local LLM, no API key, nothing leaves your machine
- image
- Generated Text
So you want an LLM to write your prompts, caption your images, or second-guess your composition - without shipping every prompt to a cloud API or wrestling a dependency-heavy node pack. That's the gap LM Studio Bridge fills. It's a single node that talks to LM Studio, the local LLM desktop app, and hands you back plain text - a literal bridge to LM Studio's local server.
One clarification up front: LM Studio is not a text encoder, and this node doesn't replace CLIP or the T5 in your Flux workflow. It's just an LLM - you feed it a prompt, it returns a string, and that string still goes through the encoder your diffusion model needs. What people actually do with it is prompt enhancement - write "moody cyberpunk street at night, rain" and let a decent LLM turn that into a full positive prompt - or image captioning with a vision model. It slots into a workflow wherever you'd otherwise paste text by hand.
How it works
The node doesn't run any model itself. LM Studio loads the GGUF, does the GPU offloading, keeps the KV cache warm - and the node just makes HTTP calls to LM Studio's native REST API at http://localhost:1234 (endpoint /api/v1/chat, not the OpenAI-compatible one). ComfyUI gets a thin, fast client; the heavy lifting happens in the app. A few behaviors are worth knowing:
- Auto model detection. Leave
model_keyempty and it queries/api/v1/models, grabs the first model with a loaded instance, and uses that. Swap models in LM Studio and the node follows. - Image optimization. Feed it an image and it resizes anything over 1536px, drops an opaque alpha channel, and saves as compressed PNG before base64-encoding. Vision models burn tokens per image, so this matters on slower hardware.
- Keep-alive session and
IS_CHANGED. It reuses one HTTP session instead of reconnecting every run, and it hashes every input - including the image data - so ComfyUI re-runs it when your image changes. A detail most LLM nodes forget.
The inputs that matter
Most of these you'll set once and forget. The ones you actually touch:
prompt- your instruction to the LLM. The default is a prompt-enhancer style ("Make the ready-to-use prompt with the image description:"), which tells you what the author had in mind.system_prompt- the assistant's frame. This is where you get leverage; a good system prompt matters more than the prompt itself.max_output_tokens(default 2000) andtemperature(default 0.6) - dial temperature down toward 0.3–0.4 when you want a caption that doesn't hallucinate, up when you want creative prompt expansion.model_key- leave empty for auto-detect, or pin a specific model ID when you have several loaded and the auto-pick grabs the wrong one.image- optional, wire a Load Image into it if you're using a vision model.
The one output is Generated Text (a STRING). It feeds a Show Text node, a positive prompt, or whatever consumes text next. One gotcha: errors are returned as the output string, not thrown. If your result reads "Error: Cannot connect to LM Studio server at localhost:1234", that's the node politely handing you its own failure message - check the ComfyUI console too, and turn on debug for the full picture.
Install and setup
Via ComfyUI Manager, search "LM Studio Bridge". Or the manual way:
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/caradat/comfyui-lmstudio-bridge.git comfyui-lmstudio-bridge
The requirements are just requests, Pillow, and numpy - all things ComfyUI already ships, so you usually don't need to pip anything extra. Restart and the node appears under ComfyExpo/REST. Given the ecosystem's history with "LLM vision" nodes as a malware vector, it's genuinely reassuring that this pack's dependency list is this boring: local server, no API keys, no fake OpenAI wheels.
Then the part people miss: install LM Studio, download a model (a vision model like a Qwen-VL variant if you want image input), load it, and start the server in the Developer tab - port 1234 by default. The node is dead weight until that server is running.
Where it burns you
- "Server accessible, but no models are known." You started the server before loading a model. Load one first, then start.
- Timeouts on big models. Large GGUFs are slow on the first token. Raise
timeout_seconds(default 300) instead of blaming the node. - VRAM thrash. LM Studio and ComfyUI fight over the same GPU - a 32B model next to SDXL means swapping. Keep the LLM small or accept the hit.
- Auto-detect picks the wrong model. Pin
model_keywhen you have several loaded.
It's a light, single-purpose node, and that's its charm: one dependency-free bridge, and whichever GGUF you've got loaded in LM Studio opens up inside your workflow.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Make the ready-to-use prompt with the image description: | — |
| system_prompt | STRING | You are a helpful AI assistant. | — |
| host | STRING | localhost | — |
| port | INT | 12341–65535 | — |
| max_output_tokens | INT | 20001–4096 | — |
| temperature | FLOAT | 0.60–2 | — |
| imageopt | IMAGE | — | |
| model_keyopt | STRING | — | |
| debugopt | BOOLEAN | false | — |
| timeout_secondsopt | INT | 30010–3600 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Generated Text | STRING | — |