Nodes/ComfyUI LM Studio/LM Studio Connection
ComfyUI Node

LM Studio Connection

The Boring Node That Makes Local Captioning Work

By Winnougan·Created 2 months ago·Updated 2 months ago· 3
LM Studio Connection
    • connection
    base_urlhttp://localhost:1234/v1
    model
    api_keylm-studio
    timeout120

    LM Studio Connection is the least glamorous node in this pack - one URL box, a connection output, and nothing to look at while it runs. It's also the load-bearing half of the whole thing. It plays the role of CLIPLoader in the built-in CLIPLoader → TextGenerate pair this pack replaces, except instead of loading a model from disk, it just remembers where your LM Studio server is running and which model to ask. No model, no weights, no API key. Without it, LMStudioGenerateText has nothing to talk to.

    How it works

    The node doesn't run a model, and it doesn't call any cloud API. On each run it does two things: it pings {base_url}/models to confirm the server is alive, then it stashes a small dict - base_url, model, api_key, timeout - and hands it to the generate node as an LM_STUDIO_CONNECTION. That ping is the smart part: you get a clear "Could not reach LM Studio server" error at the start of the run instead of a cryptic failure halfway through a batch. If you've typed a model name that isn't loaded, it prints a warning rather than dying, because LM Studio can JIT-load an unloaded model on demand if that's enabled.

    This is the "external server" pattern, same shape as an Ollama setup - the node is a thin HTTP client and LM Studio is a second process on your machine. That's a real trade to be aware of: you're budgeting VRAM for two things at once (see llm-in-comfyui.md on GGUF and local LLMs). In exchange you get LM Studio's model manager, its JIT loading, and per-model settings. Given the ecosystem's history with malicious "LLM vision" nodes, it's also worth saying this is the least alarming shape a network-touching node can take: by default it talks to localhost:1234 and holds no credential.

    The inputs that matter

    Three of the four you can safely leave alone:

    • base_url - the one you'll actually set. Must match the port shown in LM Studio under Developer → Start Server. Default http://localhost:1234/v1; keep the /v1 on the end.
    • model - the exact model id from LM Studio's Developer tab (e.g. gemma-3-12b-it). Leave it blank to use whatever is currently loaded, which is honestly the better default for most people.
    • api_key - a lie that must stay non-empty. LM Studio ignores it, but the OpenAI-style client needs the header. The default lm-studio is fine; don't paste a real key here.
    • timeout (optional) - seconds per request, default 120. Raise it if you're captioning with a slow reasoning model.

    The single output, connection, wires straight into LMStudioGenerateText's connection input - same relationship as CLIP feeding TextGenerate.

    Install and first run

    Easiest path: ComfyUI Manager → search "LM Studio" (or comfyui-lmstudio) → install, then restart. Manual path:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Winnougan/comfyui-lmstudio
    

    Restart ComfyUI and the two nodes appear under the LM Studio category. The dependencies (requests, Pillow, numpy) are already ComfyUI dependencies, so pip is usually a no-op - and unlike many node packs, nothing downloads model files. You load the model yourself inside LM Studio, which is exactly what you want.

    Troubleshooting

    • "Could not reach LM Studio server at …" - LM Studio isn't running, or the port in base_url doesn't match the one Developer shows. Start the server, or fix the port.
    • WARNING about the model not being loaded - harmless if LM Studio JIT-loads; fatal if not, in which case load the model or blank the field.
    • Wrong model id - copy it from the Developer tab / GET /v1/models, not from memory; some ids include an org prefix like google/gemma-3-12b.

    Boring, but it turns the "is my server up and wired right" failure mode into a two-second fix instead of a ruined batch.

    CategoryLM Studio

    Inputs (4)

    NameTypeDefaultDescription
    base_urlSTRINGhttp://localhost:1234/v1
    modelSTRINGExact model id as shown by LM Studio (GET /v1/models), e.g. gemma-3-12b-it or google/gemma-3-12b. Leave blank to use whatever model is currently loaded in LM Studio.
    api_keySTRINGlm-studioLM Studio ignores this, but the field must be non-empty for OpenAI-style clients.
    timeoutoptINT1201–3600

    Outputs (1)

    NameTypeDescription
    connectionLM_STUDIO_CONNECTION