EasyRAG - External API (Advanced)
Frontier-model answers grounded in your own documents
- rag_index
- image
- answer
- context_used
- raw_response
Here's the honest version: this node is a RAG-powered chat client for OpenAI-compatible APIs. You paste a key, pick a model, ask a question, and it answers - but with one thing the plain chat-completions approach can't do: it can retrieve from your FAISS index first and ground the answer in your documents. That's the difference between asking a cloud model something and asking it something about your corpus. It shows up in the menu as EasyRAG - External API (Advanced), and it's the branch of EasyRAG you reach for when you want frontier-chat quality - DeepSeek, GPT-4o, Claude-compatible endpoints - instead of a local model.
How it works
Wire a RAG_INDEX into the rag_index input and the node does three things in order: it loads the embedding model back up, embeds your question, searches the FAISS index for the top_k most similar chunks, and unloads the embedding model again - that load-retrieve-unload dance is deliberate, so the embedding model only exists in VRAM for the milliseconds it's needed. Then it builds a system prompt ("You are a rigorous local RAG assistant. Prefer answering from the provided context."), stuffs the retrieved chunks into the user message as context, and calls the API.
The request goes to <base_url>/v1/chat/completions - the node auto-appends the /v1 path if you leave it off, so https://api.deepseek.com just works. It streams by default, and if you connect IMAGE sockets it converts them to base64 PNG data URLs and sends them along in order (more sockets appear as you connect more - the pack adds dynamic image_2, image_3, … inputs on the fly). The README's framing is "GPT-4o, Claude, DeepSeek etc." - anything that speaks the OpenAI chat format.
Outputs: answer (the cleaned response), context_used (the retrieved chunks, verbatim - great for sanity-checking whether RAG actually pulled anything relevant), and raw_response (the full JSON blob, for people who like debugging).
The inputs that matter
Beyond question, the ones you'll actually set:
base_url- defaults tohttps://api.deepseek.com. Point it at any OpenAI-compatible endpoint. If you're using a full endpoint URL, the node detects the/chat/completionsand uses it as-is.api_key- paste your key. No local node, no key stored anywhere except the workflow file, so: don't share that workflow.model-deepseek-chatby default; set whatever your provider calls the model.system_prompt_source- this is the pack's secret weapon. It's a dropdown of the prompt-rule files the pack ships (SDXL_提示词规则.txt,Anima_提示词规则.txt, the Z-Image step-1 rules). Pick one and it loads that file as the system prompt, which is how EasyRAG turns a generic chat node into a "write prompts the way SDXL likes them" node. "🛠️ 自定义" (custom) keeps your ownsystem_promptbox. Drop your own.txt/.mdfiles intocustom_nodes/Comfyui-Easy-RAG/systemprompt/ormodels/RAG/SystemPrompts/to add to that list.temperature(0.7),max_tokens,seed,top_k-top_kis the RAG retrieval count, not an LLM sampler setting; 5 is a sane default.stream- on by default. Off if you want a single clean response instead of tokens trickling into the console.
Gotchas and the honest tradeoffs
- Your data leaves the machine. That's the mechanism, not a bug - every prompt and image you feed this node goes to a server you don't control, subject to that provider's logging and moderation. The KB's
external-api-nodes.mdmakes the point that this is exactly the axis on which the local path wins: if your documents are private or your subject matter is anything a cloud filter would refuse, use the LM Studio nodes instead. The node can't bypass a provider's filter - there are no weights to edit. - The API key rides in the workflow. Locally that's fine. Exporting the workflow to share means exporting your key. Keep an eye on it, and treat "node that holds a credential and phones home by design" with the respect it deserves - this is the exact shape of the category that already shipped malware once in this ecosystem.
system_prompt_sourceandsystem_promptinteract. If you pick a file from the dropdown, it overrides whatever's in thesystem_promptbox. Don't tune both and wonder which one won.
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 you'll find it under RagPrompt. One last take: this node is the reason to use the advanced external chat over the simple LM Studio node if you have a paid key - the system-prompt presets and the context_used output are where the pack's actual cleverness lives. If you don't have a key, skip this one entirely and go local.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| question | STRING | — | |
| base_url | STRING | https://api.deepseek.com | — |
| api_key | STRING | — | |
| model | STRING | deepseek-chat | — |
| 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.70 | — |
| max_tokens | INT | 20480–8192 | — |
| seed | INT | 00–18446744073709550000 | — |
| top_k | INT | 51–100 | — |
| stream | BOOLEAN | true | — |
| rag_indexopt | RAG_INDEX | — | |
| imageopt | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| answer | STRING | — |
| context_used | STRING | — |
| raw_response | STRING | — |