Run RAGFlow chat on an OpenAI-API-Compatible base URL.
Updated 2026-07-16
RAGFlow ships an OpenAI-API-Compatible provider for exactly this: add each model with its id, https://api.apisrouter.com/v1 as the base url, and one key. Claude, GPT, DeepSeek, GLM, Kimi, and Qwen ids then serve your datasets, chats, and agents from a single endpoint.
Quick answer: add the model on the Model providers page.
Log into RAGFlow, click your logo on the top right, and open Model providers. Under Models to be added, find the OpenAI-API-Compatible card and click Add the model. In the Add LLM dialog, set Model type to chat, enter the exact catalog id as Model name, put https://api.apisrouter.com/v1 in Base url, paste your key in API-Key, and set Max tokens to the model's real context size. Click OK. Then make it do something: open Set default models on the same page and pick your new model as the default LLM. Chat assistants, dataset question answering, and agent nodes all resolve to that default unless they override it. One sharp edge to know before the first run: RAGFlow's Max tokens field defaults to 512 and its own tooltip warns that an invalid value causes errors, so entering the model's documented window is part of the setup, not an optimization.
Model type: chat
Model name: deepseek-v4-pro
Base url: https://api.apisrouter.com/v1
API-Key: sk-YOUR-APISROUTER-KEY
Max tokens: 128000
then: Set default models → LLM → deepseek-v4-proHow RAGFlow binds models to work.
RAGFlow (infiniflow on GitHub, roughly 85K stars) is a deep-document RAG engine: layout-aware parsing of PDFs and tables, chunking with grounded citations, datasets, chat assistants, and agent workflows on top. Different parts of that pipeline bind to different model slots, and the binding is explicit. Chat models generate answers. Embedding models vectorize chunks for retrieval. Rerank models reorder candidates, and img2txt models describe figures during parsing. The OpenAI-API-Compatible provider can register models for these types individually, each Add LLM dialog creating one binding of type, id, base url, and key. Every registered chat model speaks standard chat completions to the base url with the Model name as the wire string, so any id the gateway serves is valid, regardless of vendor. That separation matters operationally: switching your answer model from gpt-5.5 to claude-sonnet-4-6 is safe any day, but the embedding model is welded to your indexed vectors. RAGFlow enforces this with a compatibility check when switching embedding models on a dataset that already has chunks, and the practical rule is simpler: pick the embedding setup once, and treat chat models as the layer you tune freely.
One key for Chinese and Western models together.
RAGFlow deployments skew bilingual: Chinese-origin teams processing mixed-language document bases, and international teams who specifically want Chinese models for Chinese documents. Served directly, that mix is painful, since DeepSeek, Zhipu, Moonshot, and Alibaba each bill separately and some are awkward to pay from abroad, while Anthropic and OpenAI are awkward from the other direction. Through one OpenAI-API-Compatible base url, the mix is just more Add LLM dialogs: deepseek-v4-pro and glm-5.2 for Chinese-heavy corpora, qwen3.7-max and kimi-k2.6 as strong regional alternates, claude-sonnet-4-6 where answer polish matters most. Same base url, same key, ids straight from the catalog. For teams in Asia the same route works in reverse: Claude and GPT ids become reachable on a prepaid balance without a Western card, which for many RAGFlow shops is the difference between evaluating a model and reading about it. There is also a boot-time path worth knowing: service_conf.yaml.template accepts a user_default_llm block (factory, api_key, base_url) so fresh installs come up pre-wired. RAGFlow's docs are explicit that after login, configuration happens only on the Model providers page, so treat the YAML as first-boot provisioning, not live config.
user_default_llm:
factory: OpenAI-API-Compatible
api_key: sk-YOUR-APISROUTER-KEY
base_url: https://api.apisrouter.com/v1Choosing models for a document pipeline.
Retrieval quality sets the ceiling and the answer model decides how close you get, so A/B answer models on your real corpus: same dataset, same questions, two assistants pinned to two ids, and the per-model spend in the APIsRouter console alongside your own judgment of the answers.
- Grounded answering over retrieved chunks is input-heavy work where mid-tier models shine: deepseek-v4-pro and glm-5.2 carry citation-following answers well on bilingual corpora.
- qwen3.7-max and kimi-k2.6 are the regional heavyweights worth testing when answers must read natively in Chinese; quality differences across Chinese models show more in generation than retrieval.
- claude-sonnet-4-6 earns the answer slot where synthesis quality is the product, executive summaries, contract analysis, anything a human forwards unedited.
- Agent workflows that call tools need dependable function calling; test the agent path on claude-sonnet-4-6 first, then see which regional id matches it on your flows.
- Max tokens is per-registration, so register the same id twice with different limits if one assistant needs long answers and another needs tight ones.
Pay-as-you-go · transparent per-model pricing
Selected models are priced below official list prices. Exact input, output, cache, and per-request prices are shown for each model.
| Model | Official Price | Our Price |
|---|---|---|
| DeepSeek V4 Pro | $0.43 / $0.87 per M | $0.39 / $0.78 per M |
| GLM-5.2 | $1.14 / $4.00 per M | $1.03 / $3.60 per M |
| Qwen 3.7 Max | $2.50 / $7.50 per M | $2.25 / $6.75 per M |
| Kimi K2.6 | $0.95 / $4.00 per M | $0.85 / $3.60 per M |
| Claude Sonnet 4.6 | $3.00 / $15.00 per M | $2.40 / $12.00 per M |
Failure modes specific to RAGFlow.
The Max tokens default is the classic. Left at 512, long answers truncate or error in ways that look like model problems; set the documented context size when registering, as the tooltip itself warns. A registered model that errors immediately is usually the Model name spelling (it must match the /v1/models listing exactly) or a Base url missing its /v1 suffix, since RAGFlow appends route paths to what you enter. Nothing happening after registration is a defaults problem: registering a model does not select it. Check Set default models, and check per-assistant model settings, which override the workspace default. Embedding confusion rounds out the list. If you bind an embedding id through the compatible provider, confirm the endpoint actually serves it before indexing; and once a dataset has chunks, changing its embedding model is gated by a similarity check and may require re-indexing from zero. Chat model changes carry no such cost, which is exactly why the chat layer is where you should experiment.
Who routes RAGFlow through a gateway.
- Bilingual document teams mixing DeepSeek, GLM, Qwen, and Kimi with Claude and GPT ids behind one base url and one key.
- Teams in Asia who want Claude-quality answers on a prepaid balance without a Western card, and Western teams who want Chinese models without regional billing.
- Self-hosters running RAGFlow for internal knowledge bases who want the whole deployment's cloud spend on one usage log.
- Builders comparing answer models on a fixed corpus, where each candidate is one Add LLM dialog rather than a vendor account.
- Ops teams provisioning fresh installs from service_conf.yaml.template with the endpoint pre-wired at first boot.
Verify the endpoint and debug the first chat.
Curl the models listing first; the Model name field is free text, and copying ids from the listing eliminates the most common failure before it happens. Then run one chat completion against the id you plan to register. Inside RAGFlow, register the model, set it as default LLM, and test in a plain chat assistant before involving datasets. Authentication errors point at API-Key; not-found at Model name; connection errors at Base url or container egress, since it is the RAGFlow server, not your browser, that must reach the endpoint. Truncated or failing long answers point back at Max tokens. Once chats flow, the APIsRouter console shows per-request model, token counts, and spend. RAG traffic is input-dominated, and the usage log is where you see what your corpus actually costs to query, per model, per day, one page for the Chinese and Western ids together.
curl -s https://api.apisrouter.com/v1/models \
-H "Authorization: Bearer $APISROUTER_API_KEY" | head -50
curl -s https://api.apisrouter.com/v1/chat/completions \
-H "Authorization: Bearer $APISROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek-v4-pro",
"messages":[{"role":"user","content":"ping"}]}'FAQ
How do I add an OpenAI-API-Compatible model in RAGFlow?
Click your avatar, open Model providers, find OpenAI-API-Compatible under Models to be added, and click Add the model. Fill Model type (chat), Model name (the exact catalog id), Base url https://api.apisrouter.com/v1, API-Key, and a real Max tokens value, then confirm with OK.
Why do my answers truncate or error after adding a model?
Almost always Max tokens: RAGFlow defaults it to 512 and its tooltip warns that incorrect values cause errors. Edit the model registration and enter the model's documented context size.
Can RAGFlow mix Chinese and Western models through one provider?
Yes. Each registration sends its Model name string to the same base url, so deepseek-v4-pro, glm-5.2, qwen3.7-max, kimi-k2.6, and claude-sonnet-4-6 can all be registered side by side and selected per assistant, billed through one key.
Do chat and embedding models bind separately?
Yes. Each Add LLM dialog registers one model of one type, and Set default models assigns the default LLM and embedding slots independently. Chat models can be swapped freely; embedding models are tied to indexed vectors and gated by a compatibility check once a dataset has chunks.
Can I pre-configure the endpoint before first boot?
Yes, through the user_default_llm block in docker/service_conf.yaml.template: factory OpenAI-API-Compatible, your api_key, and base_url. RAGFlow reads it at first startup; after login, configuration moves to the Model providers page only.
Why does my registered model not get used?
Registration and selection are separate steps. Set the model as default LLM under Set default models, and check per-assistant model settings, which override the default. If it still fails, compare the Model name against the /v1/models listing spelling.