Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

feat: add TrustedRouter as a model provider (#21105)

Joseph Perlaf9138d2c3916
diff --git a/conf/llm_factories.json b/conf/llm_factories.json
index 8f43acc691..762e9b24e0 100644
--- a/conf/llm_factories.json
+++ b/conf/llm_factories.json
@@ -3483,6 +3483,14 @@
"rank": "989",
"url": "https://openrouter.ai/api/v1"
},
+ {
+ "name": "TrustedRouter",
+ "logo": "",
+ "tags": "LLM,TEXT EMBEDDING,IMAGE2TEXT",
+ "status": "1",
+ "llm": [],
+ "url": "https://api.trustedrouter.com/v1"
+ },
{
"name": "Demon Route",
"logo": "",
diff --git a/conf/model.md b/conf/model.md
index 93b20a4f16..09ee84fb9b 100644
--- a/conf/model.md
+++ b/conf/model.md
@@ -195,6 +195,7 @@ The following providers are **aggregators** — they host models from multiple u
| **SiliconFlow** | Chinese aggregator |
| **TogetherAI** | Open-source model hosting |
| **TokenHub** | Multi-provider aggregator |
+| **TrustedRouter** | OpenAI-compatible router |
| **TokenPony** | Multi-provider aggregator |
| **Volcengine (Doubao)** | ByteDance's cloud (hosts Doubao + third-party) |
diff --git a/conf/models/trustedrouter.json b/conf/models/trustedrouter.json
new file mode 100644
index 0000000000..f96015f982
--- /dev/null
+++ b/conf/models/trustedrouter.json
@@ -0,0 +1,75 @@
+{
+ "name": "TrustedRouter",
+ "url": {
+ "default": "https://api.trustedrouter.com/v1"
+ },
+ "url_suffix": {
+ "chat": "chat/completions",
+ "models": "models",
+ "embedding": "embeddings"
+ },
+ "class": "trustedrouter",
+ "models": [
+ {
+ "name": "trustedrouter/auto",
+ "context_length": 200000,
+ "model_types": [
+ "chat",
+ "vision"
+ ],
+ "tools": {
+ "support": true
+ }
+ },
+ {
+ "name": "anthropic/claude-sonnet-5.5",
+ "context_length": 1000000,
+ "model_types": [
+ "chat",
+ "vision"
+ ],
+ "tools": {
+ "support": true
+ }
+ },
+ {
+ "name": "openai/gpt-5.5",
+ "context_length": 1050000,
+ "model_types": [
+ "chat",
+ "vision"
+ ],
+ "tools": {
+ "support": true
+ }
+ },
+ {
+ "name": "google/gemini-3.8-flash",
+ "context_length": 1048576,
+ "model_types": [
+ "chat",
+ "vision"
+ ],
+ "tools": {
+ "support": true
+ }
+ },
+ {
+ "name": "deepseek/deepseek-v4-pro",
+ "context_length": 1048576,
+ "model_types": [
+ "chat"
+ ],
+ "tools": {
+ "support": true
+ }
+ },
+ {
+ "name": "openai/text-embedding-3-small",
+ "max_tokens": 8191,
+ "model_types": [
+ "embedding"
+ ]
+ }
+ ]
+}
diff --git a/internal/entity/models/factory.go b/internal/entity/models/factory.go
index 93860f240a..c007e635ca 100644
--- a/internal/entity/models/factory.go
+++ b/internal/entity/models/factory.go
@@ -121,6 +121,8 @@ func (f *ModelFactory) CreateModelDriver(providerName string, baseURL map[string
return NewTokenHubModel(baseURL, urlSuffix), nil
case "demon route":
return NewDemonRouteModel(baseURL, urlSuffix), nil
+ case "trustedrouter":
+ return NewTrustedRouterModel(baseURL, urlSuffix), nil
case "novitaai":
return NewNovitaModel(baseURL, urlSuffix), nil
case "avian":
diff --git a/internal/entity/models/trustedrouter.go b/internal/entity/models/trustedrouter.go
new file mode 100644
index 0000000000..8b0ff00270
--- /dev/null
+++ b/internal/entity/models/trustedrouter.go
@@ -0,0 +1,42 @@
+//
+// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package models
+
+// TrustedRouterModel drives TrustedRouter, an OpenAI-compatible LLM router
+// (https://api.trustedrouter.com/v1) that serves models from many providers
+// under provider-prefixed ids such as "openai/gpt-5.5", so the embedded
+// OpenAIAPICompatibleModel covers every call.
+type TrustedRouterModel struct {
+ *OpenAIAPICompatibleModel
+}
+
+// NewTrustedRouterModel creates a TrustedRouter driver.
+func NewTrustedRouterModel(baseURL map[string]string, urlSuffix URLSuffix) *TrustedRouterModel {
+ return &TrustedRouterModel{
+ OpenAIAPICompatibleModel: NewOpenAIAPICompatibleModel(baseURL, urlSuffix),
+ }
+}
+
+// Name returns the driver name.
+func (m *TrustedRouterModel) Name() string {
+ return "trustedrouter"
+}
+
+// NewInstance returns a driver bound to the given base URL.
+func (m *TrustedRouterModel) NewInstance(baseURL map[string]string) ModelDriver {
+ return NewTrustedRouterModel(baseURL, m.baseModel.URLSuffix)
+}
diff --git a/internal/entity/models/trustedrouter_test.go b/internal/entity/models/trustedrouter_test.go
new file mode 100644
index 0000000000..0fa73e7578
--- /dev/null
+++ b/internal/entity/models/trustedrouter_test.go
@@ -0,0 +1,181 @@
+//
+// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package models
+
+import (
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "ragflow/internal/common"
+ "testing"
+)
+
+// newTrustedRouterForTest creates an TrustedRouterModel instance for testing.
+func newTrustedRouterForTest(baseURL string) *TrustedRouterModel {
+ return NewTrustedRouterModel(
+ map[string]string{"default": baseURL},
+ URLSuffix{Chat: "chat/completions", Models: "models", Embedding: "embeddings"},
+ )
+}
+
+// TestTrustedRouterName tests the driver name.
+func TestTrustedRouterName(t *testing.T) {
+ if got := newTrustedRouterForTest("http://unused").Name(); got != "trustedrouter" {
+ t.Errorf("Name()=%q", got)
+ }
+}
+
+// TestTrustedRouterFactory tests creating the driver from factory.
+func TestTrustedRouterFactory(t *testing.T) {
+ driver, err := NewModelFactory().CreateModelDriver("trustedrouter", map[string]string{"default": "http://unused"}, URLSuffix{})
+ if err != nil {
+ t.Fatalf("CreateModelDriver: %v", err)
+ }
+ if _, ok := driver.(*TrustedRouterModel); !ok {
+ t.Fatalf("driver type=%T, want *TrustedRouterModel", driver)
+ }
+ if _, ok := driver.NewInstance(map[string]string{"default": "http://other"}).(*TrustedRouterModel); !ok {
+ t.Fatal("NewInstance did not return *TrustedRouterModel")
+ }
+}
+
+// The shipped config must resolve to the TrustedRouter driver. CreateModelDriver
+// dispatches on strings.ToLower(name), so the "TrustedRouter" provider name has
+// to match the "trustedrouter" case; anything else silently falls through to
+// DummyModel.
+func TestTrustedRouterProviderConfig(t *testing.T) {
+ dir, restore := setupProviderTestDir(t, "trustedrouter.json")
+ defer restore()
+
+ if err := InitProviderManager(dir); err != nil {
+ t.Fatalf("InitProviderManager: %v", err)
+ }
+
+ provider := GetProviderManager().FindProvider("TrustedRouter")
+ if provider == nil {
+ t.Fatal("TrustedRouter provider not found")
+ }
+ if _, ok := provider.ModelDriver.(*TrustedRouterModel); !ok {
+ t.Fatalf("ModelDriver=%T, want *models.TrustedRouterModel", provider.ModelDriver)
+ }
+}
+
+// TestTrustedRouterChatSendsAPIKey tests chat completion authentication and that
+// the provider-prefixed model id reaches the API unchanged.
+func TestTrustedRouterChatSendsAPIKey(t *testing.T) {
+ withSSRFBypass(t)
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path != "/chat/completions" {
+ t.Errorf("path=%s", r.URL.Path)
+ }
+ if got := r.Header.Get("Authorization"); got != "Bearer sk-gw-test" {
+ t.Errorf("Authorization=%q", got)
+ }
+ var body struct {
+ Model string `json:"model"`
+ }
+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
+ t.Errorf("decode request: %v", err)
+ }
+ if body.Model != "anthropic/claude-sonnet-5.5" {
+ t.Errorf("model=%q", body.Model)
+ }
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "id": "chat-trustedrouter",
+ "choices": []map[string]any{{"message": map[string]any{"content": "pong"}}},
+ "usage": map[string]any{"prompt_tokens": 3, "completion_tokens": 5, "total_tokens": 8},
+ })
+ }))
+ defer srv.Close()
+
+ usage := &common.ModelUsage{}
+ resp, err := newTrustedRouterForTest(srv.URL).ChatWithMessages(
+ t.Context(),
+ "anthropic/claude-sonnet-5.5",
+ []Message{{Role: "user", Content: "ping"}},
+ &APIConfig{ApiKey: &testAPIKey},
+ nil,
+ usage,
+ )
+ if err != nil {
+ t.Fatalf("ChatWithMessages: %v", err)
+ }
+ if *resp.Answer != "pong" {
+ t.Errorf("Answer=%q", *resp.Answer)
+ }
+ assertModelUsage(t, usage, 3, 5, 8)
+}
+
+// TestTrustedRouterEmbed tests embedding requests.
+func TestTrustedRouterEmbed(t *testing.T) {
+ withSSRFBypass(t)
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path != "/embeddings" {
+ t.Errorf("path=%s", r.URL.Path)
+ }
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "data": []map[string]any{{"embedding": []float64{0.1, 0.2}, "index": 0}},
+ "usage": map[string]any{"prompt_tokens": 7, "total_tokens": 7},
+ })
+ }))
+ defer srv.Close()
+
+ modelName := "openai/text-embedding-3-small"
+ embeddings, err := newTrustedRouterForTest(srv.URL).Embed(
+ t.Context(),
+ &modelName,
+ EmbedRequest{Texts: []string{"document"}},
+ &APIConfig{ApiKey: &testAPIKey},
+ nil,
+ &common.ModelUsage{},
+ )
+ if err != nil {
+ t.Fatalf("Embed: %v", err)
+ }
+ if len(embeddings) != 1 || len(embeddings[0].Embedding) != 2 {
+ t.Fatalf("embeddings=%#v", embeddings)
+ }
+}
+
+// TestTrustedRouterListModelsAndCheckConnection tests model listing and connectivity check.
+func TestTrustedRouterListModelsAndCheckConnection(t *testing.T) {
+ withSSRFBypass(t)
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodGet || r.URL.Path != "/models" {
+ t.Errorf("%s %s", r.Method, r.URL.Path)
+ }
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "data": []map[string]any{
+ {"id": "anthropic/claude-sonnet-5.5"},
+ {"id": "openai/text-embedding-3-small"},
+ },
+ })
+ }))
+ defer srv.Close()
+
+ model := newTrustedRouterForTest(srv.URL)
+ list, err := model.ListModels(t.Context(), &APIConfig{ApiKey: &testAPIKey})
+ if err != nil {
+ t.Fatalf("ListModels: %v", err)
+ }
+ if joinModelNames(list, ",") != "anthropic/claude-sonnet-5.5,openai/text-embedding-3-small" {
+ t.Errorf("models=%v", list)
+ }
+ if err := model.CheckConnection(t.Context(), &APIConfig{ApiKey: &testAPIKey}); err != nil {
+ t.Fatalf("CheckConnection: %v", err)
+ }
+}
diff --git a/web/src/assets/svg/llm/trustedrouter.svg b/web/src/assets/svg/llm/trustedrouter.svg
new file mode 100644
index 0000000000..6f6d45aaac
--- /dev/null
+++ b/web/src/assets/svg/llm/trustedrouter.svg
@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24">
+ <rect width="24" height="24" rx="5" fill="#F4F1EA"/>
+ <g fill="none" stroke-linecap="round" stroke-linejoin="round" transform="translate(2.4 2.4) scale(0.8)">
+ <path d="M1.4 7.5 H6.5 L11 12 M1.4 16.5 H4 L8.5 12 M1.4 12 H15.5" stroke="#171C16" stroke-width="2"/>
+ <circle cx="15.5" cy="12" r="1.9" fill="#46705C"/>
+ <path d="M17.4 12 H22.6" stroke="#46705C" stroke-width="2"/>
+ </g>
+</svg>
diff --git a/web/src/components/svg-icon.tsx b/web/src/components/svg-icon.tsx
index 1786c374e1..b6502b4920 100644
--- a/web/src/components/svg-icon.tsx
+++ b/web/src/components/svg-icon.tsx
@@ -118,6 +118,7 @@ const svgIcons = [
LLMFactory.MWS,
LLMFactory.CheaperInference,
LLMFactory.Opper,
+ LLMFactory.TrustedRouter,
];
export const LlmIcon = ({
diff --git a/web/src/constants/llm.ts b/web/src/constants/llm.ts
index 6d3f1ade1a..2e367dac56 100644
--- a/web/src/constants/llm.ts
+++ b/web/src/constants/llm.ts
@@ -112,6 +112,7 @@ export enum LLMFactory {
CheaperInference = 'Cheaper Inference',
Opper = 'Opper',
DemonRoute = 'Demon Route',
+ TrustedRouter = 'TrustedRouter',
}
// Please lowercase the file name
@@ -206,6 +207,7 @@ export const IconMap = {
[LLMFactory.MWS]: 'mws',
[LLMFactory.CheaperInference]: 'cheaperinference',
[LLMFactory.Opper]: 'opper',
+ [LLMFactory.TrustedRouter]: 'trustedrouter',
};
export const ModelTypeToField: Record<string, string> = {
@@ -235,6 +237,7 @@ export const APIMapUrl = {
[LLMFactory.DaoXE]: 'https://daoxe.com',
[LLMFactory.CheaperInference]: 'https://cheaperinference.com',
[LLMFactory.Opper]: 'https://platform.opper.ai',
+ [LLMFactory.TrustedRouter]: 'https://trustedrouter.com/keys',
[LLMFactory.MWS]:
'https://mws.ru/docs/cloud-platform/gpt/general/inference-text.html',
[LLMFactory.Anthropic]: 'https://console.anthropic.com/settings/keys',