LM Studio Query
Turn your local LLM into a prompt-writer and image captioner, no API key required
- images
- generated_texts
- model_ref
Want an LLM inside your workflow without paying for an API? LM Studio Query talks to a local LM Studio server - which is just your own GPU running an OpenAI-compatible endpoint at http://localhost:1234 - and can do two genuinely useful things. First, pure text generation: feed it a template prompt and it writes a finished prompt for your sampler. Second, vision: attach images and it describes them, which makes it a batch captioner for training data or a "what did it actually generate" inspector. No key, no cloud, no monthly bill.
How it works
The node hits LM Studio's /v1/models endpoint to list what's loaded and available, then sends your system_prompt and user_prompt to the chat completions endpoint. If you give model_name (full or partial), it loads that model first; leave it blank and it uses whatever's currently loaded. Images get base64-encoded and sent along, so a vision-capable model can describe them. prompts_number runs the query multiple times with different seeds - handy for getting several prompt drafts to pick from - and unload_after_use frees the model from memory when done.
The inputs that matter
- system_prompt / user_prompt - the usual LLM pair. The defaults (
"You are a helpful assistant."/"Describe this image in detail.") are fine starting points. - server_url -
http://localhost:1234unless you changed LM Studio's port. - model_name - leave empty for the loaded model; otherwise a name or substring to load.
- temperature, top_p, max_tokens, seed - standard sampling knobs. 0.7 / 0.9 / 256 defaults are sensible.
- prompts_number - how many generations (1–10).
- images - optional
IMAGEinput; supports batches, so you can caption several images in one run.
Outputs: generated_texts (the responses, as a list if you asked for more than one) and model_ref (the model that actually ran - handy if you want to feed it into the unload node).
Installing it
Install the pack, and make sure LM Studio is actually serving:
cd ComfyUI/custom_nodes
git clone https://github.com/Pirog17000/Pirogs-Nodes
pip install -r Pirogs-Nodes/requirements.txt
In LM Studio: enable the local server (Settings → Server, default port 1234) and load a model. The lmstudio package in requirements.txt is technically only needed for unloading; the query node itself just needs requests.
Gotchas
Most failures here are "LM Studio isn't actually running" - the node errors out if it can't reach /v1/models in a couple of seconds. If you specified a model name and it's not in the server's list, you get a "not found" error. Vision queries silently degrade if your model isn't multimodal, so check which model you loaded. And remember the output is text: you still need to wire generated_texts into your prompt or a text-encode node - this node writes prompts, it doesn't apply them.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| system_prompt | STRING | You are a helpful assistant. | System prompt to set the AI's behavior and role |
| user_prompt | STRING | Describe this image in detail. | User prompt for the query. Use with images for descriptions or standalone for text generation. |
| model_name | STRING | Model name or partial name to search for. Leave empty to use currently loaded model. | |
| server_url | STRING | http://localhost:1234 | LM Studio server URL |
| temperature | FLOAT | 0.700–2 | Sampling temperature (0.0 = deterministic, 2.0 = very random) |
| max_tokens | INT | 2561–4096 | Maximum number of tokens to generate |
| top_p | FLOAT | 0.900–1 | Nucleus sampling parameter |
| seed | INT | 00–18446744073709550000 | Random seed for reproducible results. 0 = random each time. |
| prompts_number | INT | 11–10 | Number of prompts to generate with different seeds |
| unload_after_use | BOOLEAN | false | Unload the model after processing to free memory |
| imagesopt | IMAGE | Optional images for visual queries (batch processing supported) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| generated_texts | STRING | Array of generated text responses |
| model_ref | STRING | Reference to the loaded model name |