LM Studio Unified (URL + API Key)
Ask a local LLM to look at your image — straight from the graph
- image
- generated_text
So you've got a local LLM running in LM Studio and a ComfyUI graph full of images, and you'd like the two to talk. Maybe you want a caption for a generated image, a critique, a rewritten prompt, or a decision ("pick the best frame") that feeds back into the graph. The pieces all exist, but wiring a custom HTTP call into ComfyUI by hand is a small project of its own.
LM Studio Unified (URL + API Key) is that wiring, done for you. It calls LM Studio's OpenAI-compatible chat endpoint with text, an image, or both, and hands back the model's reply as a generated_text string.
How it works
Everything goes through LM Studio's /v1/chat/completions API. The node builds a chat message from your system_prompt and prompt, and if you connect an image, each frame of the batch is encoded to a JPEG data URL and sent as a separate image_url content part (capped by max_images). So vision-capable models actually see your image; text-only models can still use it as a pure text chat node.
It's intentionally dependency-free - plain urllib, no openai SDK, no pip installs. Request details go to the ComfyUI console when debug is on, and IS_CHANGED hashes all inputs so the node re-runs when anything changes and doesn't rerun when nothing does.
The inputs that matter
base_url- the endpoint. Defaults tohttp://127.0.0.1:1234/v1, the standard local LM Studio address. It also acceptshttps://host,/v1-style paths, or a full/v1/chat/completionsURL, so it works against remote/Cloudflare-fronted routes too.model- the model id from LM Studio's/v1/modelslist. Must match what you loaded in the app.prompt/system_prompt- the user and system messages.image(optional) - the IMAGE batch to send.api_key/api_key_env_var- optional. A blankapi_keyfalls back to the env var (defaultLMSTUDIO_API_KEY), which on Windows also checks User/Machine registry values.seed,max_tokens,temperature,timeout_seconds,user_agent,debug- the rest of the knobs.user_agentmatters for routes behind Cloudflare that block Python's default urllib signature; there's a browser-like one preloaded.
Output: generated_text, the model's reply as a STRING.
Install
Part of the Enviral Design Node Pack. ComfyUI Manager: search "Enviral Design Node Pack". Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/EnviralDesign/comfyUI-enviral-design-node-pack
then restart. No extra dependencies, and no LM Studio install required by the node itself - you just need an endpoint reachable.
Gotchas worth knowing
The single most common failure is a model id that doesn't match anything loaded in LM Studio - check the app's model list, not your memory of the filename. For local use, 127.0.0.1:1234 with no key is the zero-config path; if you've pointed it at a remote route, set the key (or env var) and make sure the server's CORS/auth accepts browser-like traffic. And remember the model you're asking must be vision-capable to describe images - a text-only model will politely ignore the image parts. Debug mode is your friend here: it prints exactly what's being sent.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| base_url | STRING | http://127.0.0.1:1234/v1 | LM Studio OpenAI-compatible base URL. Accepts https://host, https://host/v1, or full /v1/chat/completions URL. |
| api_key | STRING | Optional LM Studio API key. Sent as Authorization: Bearer <key> when provided. | |
| model | STRING | gemma-4-e4b-uncensored-hauhaucs-aggressive | Model id from LM Studio /v1/models. |
| prompt | STRING | Describe this image in detail. | User prompt. Can be used with an image input or by itself. |
| system_prompt | STRING | You are a helpful AI assistant. | — |
| seed | INT | -1-1–18446744073709550000 | — |
| imageopt | IMAGE | — | |
| api_key_env_varopt | STRING | LMSTUDIO_API_KEY | Optional environment variable to read the API key from when api_key is blank. |
| max_tokensopt | INT | 10001–32768 | — |
| temperatureopt | FLOAT | 0.700–2 | — |
| timeout_secondsopt | INT | 30010–3600 | — |
| max_imagesopt | INT | 201–200 | Maximum number of images from the input IMAGE batch to send as separate image_url parts. |
| user_agentopt | STRING | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 | HTTP User-Agent sent to LM Studio. Useful when Cloudflare blocks Python's default urllib signature. |
| debugopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| generated_text | STRING | — |