Nodes/EA_LMStudio/EA LM Studio
ComfyUI Node

EA LM Studio

The LM Studio node that treats ComfyUI like a chat client

By EnragedAntelope·Created 8 months ago·Updated 7 days ago· 21
EA LM Studio
  • image1
  • image2
  • image3
  • image4
  • response
  • reasoning
  • troubleshooting
system_messageYou are a helpful assistant.
prompt
model_selection-- Custom (enter below) --
custom_model_name
max_tokens1024
temperature0.70
seed0
top_p1.00
top_k0
repeat_penalty1.00
min_p0.00
stop_strings
context_overflowTruncate middle
output_formatText
json_schema
reasoning_modeAuto-detect (recommended)
custom_open_tag<think>
custom_close_tag</think>
image_resizeMedium (768px)
draft_model_selection-- Custom (enter below) --
custom_draft_model
unload_llmtrue
unload_comfy_modelsfalse
refresh_modelsfalse

You already know the workflow: you're building a prompt-enhancement chain for Flux or Qwen-Image, you want a VLM to describe an image into a prompt, or you just want an LLM to draft options you then steer by hand. You also already have LM Studio sitting on your machine with a Qwen3 or DeepSeek loaded. EA LM Studio is the bridge - a single node that turns ComfyUI into a chat client for whatever model is loaded in your local LM Studio server. No cloud API, no key, no per-token billing. The model stays in your machine's RAM.

The name trips people up once: this node does call an "API," but it's LM Studio's own local server on 127.0.0.1:1234 - nothing leaves your box. That's exactly the right posture for an LLM node, given how the ecosystem got burned. The ComfyUI_LLMVISION debacle (an LLM-vision node that shipped infostealer wheels and eventually landed its author 15 months federal) is the reason to prefer open-source nodes like this one that only talk to your own server. Read the code if you're nervous; it's small enough.

How it works

Under the hood it uses the official lmstudio Python SDK to talk to the local server. Models are discovered automatically at ComfyUI startup - the dropdown populates from LM Studio's model list, so you pick by name instead of typing a path. A refresh_models toggle re-fetches instantly if you loaded a new model after ComfyUI started.

The clever bit is reasoning extraction. For thinking models like DeepSeek R1, Qwen3, and QwQ, the node splits <think>...</think> content off into a separate reasoning output, so your downstream nodes never choke on chain-of-thought. It even handles GPT-OSS's "harmony" channel markers (<|channel|>, <|message|>, <|end|>, <|return|>) and cleans up partially-leaked tags.

The inputs that matter

Most of the node is boilerplate sampling knobs you can ignore. You actually set these:

  • system_message and prompt - your role definition and your request. The two you'll touch every run.
  • model_selection / custom_model_name - pick a discovered model, or choose "Custom" and type an identifier from LM Studio's /v1/models list.
  • max_tokens - output length only; the input side is governed by the context window you set in LM Studio itself.
  • temperature - 0.7 default, drop toward 0.1 for deterministic work.

Two footguns worth knowing. seed looks like it should make runs reproducible - it can't. The LM Studio SDK has no inference-time seeding, so the seed is purely a re-roll control: changing it tells ComfyUI the node is dirty and should run again. Don't chase reproducibility through it. And if output turns repetitive, reach for repeat_penalty (1.1–1.3) or presence_penalty (0.3–0.8); min_p at 0.05–0.1 is the modern, less finicky alternative to top_p.

For vision models, wire image1 through image4 and set image_resize - the auto-resize exists precisely to stop multi-image VLMs from OOMing. For Qwen3 and friends, enable_thinking forces thinking on hybrid models without the /think prompt hack, and reasoning_mode controls how thinking gets split out. unload_llm (on by default) frees VRAM after generation so your diffusion models can load back.

Outputs

Three strings: response (the cleaned answer), reasoning (the extracted thinking), and troubleshooting - status messages plus real stats like tokens/sec, time to first token, and stop reason. Wire response into a text display or straight into another node's prompt input; that's the whole point.

Installing it

ComfyUI Manager: search "EA_LMStudio". Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/EnragedAntelope/EA_LMStudio.git
pip install -r EA_LMStudio/requirements.txt

Dependencies are light - the lmstudio SDK, requests, Pillow, numpy - but the SDK needs Python 3.10+, and you need LM Studio running with its server enabled (validated against 0.4.17). Server host/port and model-exclusion patterns live in lms_config/user_config.json.

Common issues

Models not showing? LM Studio must be running before ComfyUI starts, then toggle refresh_models. Context errors? Raise the context length in LM Studio settings, not max_tokens. enable_thinking doing nothing? The toggle sets an enableThinking flag that only works when the model's chat template honors it - many community finetunes ignore it, so fix it in LM Studio by editing the Jinja template or its reasoning-parsing delimiters. VLM failing on multi-image? Drop to one image or a smaller image_resize. And keep both LM Studio and the SDK updated: older backends silently ignore newer sampling params like min_p rather than erroring, so stale versions quietly no-op half your settings.

CategoryEA/LMStudio

Inputs (28)

NameTypeDefaultDescription
system_messageSTRINGYou are a helpful assistant.System prompt that defines the LLM's role and behavior. Sets the context for all responses.
promptSTRINGThe user prompt to send to the LLM. This is your main request or question.
model_selectionCOMBO-- Custom (enter below) --Select a model from LM Studio. Models are fetched at ComfyUI startup. Select 'Custom' to manually enter a model identifier.
custom_model_nameSTRINGManual model identifier. Only used when 'Custom' is selected above. Find identifiers in LM Studio's model list.
max_tokensINT10241–131072Maximum OUTPUT tokens for the response (default 1024). Limits reply length, not input. Raise for longer replies; lower to cap length/speed up. The model's context window (input+output) is set in LM Studio when loading and must exceed max_tokens for full output.
temperatureFLOAT0.700–2Controls randomness (default 0.7). Lower (0.1-0.3) = more focused/deterministic; higher (0.7-1.2) = more creative/varied. 0.0 = greedy/most deterministic.
seedINT00–18446744073709550000Re-roll control only. LM Studio has no inference-time seed, so this does NOT make output reproducible - changing it simply tells ComfyUI the node is dirty so it generates again instead of reusing the cached response. Set control_after_generate to 'randomize' for a fresh answer every queue, or 'fixed' to keep the cached one.
top_poptFLOAT1.000–1Nucleus sampling: only consider tokens within cumulative probability top_p (default 1.0 = disabled). Lowering (e.g. 0.9-0.95) = more focused/coherent; raising toward 1.0 = more diverse.
top_koptINT00–500Top-K sampling: only consider the K most likely tokens (default 0 = disabled). Lowering (e.g. 20-40) = more focused; raising = more diverse. Recommended 20-40 for thinking models.
repeat_penaltyoptFLOAT1.000–2Penalizes tokens that already appeared, scaled by how often (default 1.0 = disabled). Raising (1.1-1.3) reduces repetition/loops; too high can hurt coherence. Below 1.0 encourages repetition. LM Studio has no presence or frequency penalty - this and min_p are the repetition controls it offers.
min_poptFLOAT0.000–1Min-P sampling: drop tokens below this fraction of the top token's probability (default 0.0 = disabled). Raising (e.g. 0.05-0.1) = more focused/coherent; lowering toward 0 = more diverse. A modern alternative to top_p.
stop_stringsoptSTRINGStop generation when any of these strings appears. One per line; blank lines ignored. Leading/trailing spaces are kept, and \n \r \t \\ are expanded - so a line of '\nUser:' stops at a newline followed by 'User:'. Empty = no stop strings. Useful to stop a chatty model running on past the answer.
context_overflowoptCOMBOTruncate middleWhat LM Studio does when prompt + response exceed the model's context window. 'Truncate middle' (default) silently drops the middle of the conversation. 'Rolling window' drops from the start. 'Stop at limit (error)' fails loudly instead - pick it if a silently shortened prompt would be worse than no answer.
output_formatoptCOMBOText'Text' = normal prose. 'JSON (schema below)' constrains decoding to the schema in json_schema and is the reliable choice when a downstream node must parse the response. 'JSON (no schema)' only asks for JSON - it does NOT constrain decoding, and many models answer with a ```json fenced block (which is unwrapped automatically when the contents are valid JSON). Structured output and thinking models mix poorly.
json_schemaoptSTRINGJSON Schema object, used only when output_format is 'JSON (schema below)'. Example: {"type": "object", "properties": {"caption": {"type": "string"}}, "required": ["caption"]}
reasoning_modeoptCOMBOAuto-detect (recommended)How to split thinking from the final answer. When LM Studio's own Reasoning Parsing is configured for the model, its tagging is used directly and this setting is not needed. Otherwise Auto-detect handles DeepSeek, Qwen, QwQ, GLM, GPT-OSS and similar tag formats. Models don't always think for simple queries.
custom_open_tagoptSTRING<think>Custom opening tag for reasoning extraction. Only used when reasoning_mode is 'Custom tags'.
custom_close_tagoptSTRING</think>Custom closing tag for reasoning extraction. Only used when reasoning_mode is 'Custom tags'.
image_resizeoptCOMBOMedium (768px)Resize images before processing. Smaller = faster inference. 'No Resize' keeps original size. Only applies when images are connected.
image1optIMAGEFirst image input for vision models (VLMs). Leave unconnected for text-only inference.
image2optIMAGESecond image input for multi-image VLMs. Not all VLMs support multiple images.
image3optIMAGEThird image input for multi-image VLMs. Not all VLMs support multiple images.
image4optIMAGEFourth image input for multi-image VLMs. Not all VLMs support multiple images.
draft_model_selectionoptCOMBO-- Custom (enter below) --Optional draft model for speculative decoding (faster inference). Must share a tokenizer with the main model. Leave on 'Custom' with an empty box to disable. Acceptance stats are reported in troubleshooting.
custom_draft_modeloptSTRINGManual draft model identifier. Only used when draft 'Custom' is selected. Leave empty to disable.
unload_llmoptBOOLEANtrueUnload the LLM from LM Studio after generation. Recommended to free VRAM for image generation. Turn off to keep the model warm across runs (this also unloads a model you loaded by hand in LM Studio).
unload_comfy_modelsoptBOOLEANfalseUnload ComfyUI models (SD, VAE, etc.) before LLM inference. Frees VRAM for larger LLMs.
refresh_modelsoptBOOLEANfalseToggle ON to re-fetch the model list from LM Studio and update the dropdowns instantly. Automatically toggles back off.

Outputs (3)

NameTypeDescription
responseSTRING
reasoningSTRING
troubleshootingSTRING