EasyRAG - LM Studio API (Advanced)
Fully local, uncensored RAG chat that won't eat your VRAM
- rag_index
- image
- answer
- context_used
- raw_response
If the External API node is EasyRAG's cloud path, this is the one you want when nothing leaves your machine. EasyRAG - LM Studio API (Advanced) is a RAG-capable chat node that talks to LM Studio running as a local server - your LLM, your documents, your GPU, no API key, no data sent anywhere. It's the node that makes the phrase "local RAG" mean something: a GGUF model in LM Studio, a FAISS index you built, and ComfyUI sitting in between. For anything private, uncensored, or just "I don't want to pay per call," this is the node from the pack I'd actually reach for.
How it works
The node assumes LM Studio is already up with its Local Server toggle on (default http://127.0.0.1:1234, per the README). It talks to the server over the OpenAI-compatible API: it lists models from /api/v1/models (falling back to /v1/models), sends your request to /v1/responses, and falls back to /v1/chat/completions if the first call fails - so it works across LM Studio's API versions without you caring which one you're on.
The RAG part mirrors the External node exactly: if you wire in a RAG_INDEX, it loads the embedding model, searches the top top_k chunks on CPU, and unloads the embedder before the LLM ever runs. Images work too - connect IMAGE sockets and they get sent as base64 data URLs, in order, as more sockets appear when you connect them.
Then the part that makes this node worth writing about: unload_model_after_response (default on). After the answer streams back, the node tells LM Studio to unload the model via its /api/v1/models/unload endpoint. So the LLM exists in VRAM only while it's answering, then it's gone - which matters because you're presumably running this inside an image-generation workflow that wants that VRAM back for SDXL or FLUX. The KB's llm-in-comfyui.md is blunt about why this pattern matters: you're budgeting VRAM for two models at once, and the good nodes do automatic unload rather than holding both resident. EasyRAG is one of the good ones.
Outputs are answer, context_used (the retrieved chunks - check this to see what RAG actually found), and raw_response (the full API response JSON).
The inputs that matter
base_url-http://127.0.0.1:1234by default. Change it if LM Studio is on another machine or port.model- a dropdown of models the running server reports. If it's empty, LM Studio isn't reachable from this default address at load time - see the gotcha below.system_prompt_source- same prompt-rule file dropdown as the External node, picking up the shipped SDXL / Anima / Z-Image rule files or anything you drop in thesystemprompt/ormodels/RAG/SystemPrompts/folders.temperature(default 0.2 - lower than the External node, because a local model answering from your docs benefits from less wandering),max_tokens,seed,top_k(RAG retrieval count, 5 default),stream(on by default).unload_model_after_response- leave it on. It's the feature.
Gotchas
- The
modeldropdown is populated from127.0.0.1:1234at node load, with a quarter-second timeout. If your LM Studio runs on a different port or a remote host, the dropdown can be empty even though the node works - at run time it re-queriesbase_url, so a blank selection falls back to the first model the server reports. Don't panic at an empty dropdown; check the server is listening first. - The server must be running and a model loaded. If the node errors at connect time, it's almost always this. Start LM Studio, flip on Local Server, load a GGUF, then re-run.
top_ktunes RAG retrieval, not the LLM. The model's own token sampling is set inside LM Studio; this node only controls how many chunks get pulled from your index.- Everything here is as good as the model you loaded in LM Studio. This node doesn't magically improve a weak 3B GGUF - it just makes retrieval work. For prompt work the KB's rule of thumb applies: small-and-obedient beats large-and-thinky.
Install
Whole-pack install - ComfyUI Manager, search "ComfyUI Easy RAG", or:
cd ComfyUI/custom_nodes
git clone https://github.com/nregret/Comfyui-Easy-RAG
cd Comfyui-Easy-RAG
pip install -r requirements.txt
Restart, and the node lives under RagPrompt. One workflow tip: run this node and the image sampler in the same graph - the auto-unload is precisely so the LLM gets out of the way before sampling starts.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| question | STRING | — | |
| base_url | STRING | http://127.0.0.1:1234 | — |
| model | COMBO | 1 options: | |
| system_prompt_source | COMBO | 🛠️ 自定义 | 5 options: 🛠️ 自定义, 📄 Anima_提示词规则.txt, 📄 SDXL_提示词规则.txt, 📄 Z-Image_step1中文提示词规则.txt, 📄 Z-Image_step1英文提示词规则.txt |
| system_prompt | STRING | You are a rigorous local RAG assistant. Prefer answering from the provided context. | — |
| temperature | FLOAT | 0.20 | — |
| max_tokens | INT | 20480–8192 | — |
| seed | INT | 00–18446744073709550000 | — |
| top_k | INT | 51–100 | — |
| stream | BOOLEAN | true | — |
| unload_model_after_response | BOOLEAN | true | — |
| rag_indexopt | RAG_INDEX | — | |
| imageopt | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| answer | STRING | — |
| context_used | STRING | — |
| raw_response | STRING | — |