Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(providers): route agentrouter through anthropic endpoint headers

diegosouzapwf6fdfea3ae5b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e6eb7e5bfe..26ace9d61d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@
### 🐛 Bug Fixes
- **fix(providers):** allow local OpenAI-compatible endpoints (like Ollama) to be added without an API key (fixes #1893)
+- **fix(providers):** bypass AgentRouter unauthorized_client_error by spoofing Claude CLI headers via Anthropic endpoints (fixes #1921)
- **fix(copilot):** emit compatible reasoning text deltas (#1919 — thanks @ivan-mezentsev)
- **fix(api-manager):** show validation errors inline in modals, not behind (#1920 — thanks @andrewmunsell)
- **fix(compression):** align seeded standard savings combo with stacked default, preserve stacked defaults, and secure metadata routes.
diff --git a/open-sse/config/providerRegistry.ts b/open-sse/config/providerRegistry.ts
index 8265f3376f..063d047396 100644
--- a/open-sse/config/providerRegistry.ts
+++ b/open-sse/config/providerRegistry.ts
@@ -672,17 +672,39 @@ export const REGISTRY: Record<string, RegistryEntry> = {
agentrouter: {
id: "agentrouter",
alias: "agentrouter",
- format: "openai",
+ format: "claude",
executor: "default",
- baseUrl: "https://agentrouter.org/v1/chat/completions",
+ baseUrl: "https://agentrouter.org/v1/messages",
authType: "apikey",
- authHeader: "bearer",
+ authHeader: "x-api-key",
defaultContextLength: 128000,
headers: {
- "HTTP-Referer": "https://endpoint-proxy.local",
- "X-Title": "OmniRoute",
+ "Anthropic-Version": ANTHROPIC_VERSION_HEADER,
+ "Anthropic-Beta": ANTHROPIC_BETA_CLAUDE_OAUTH,
+ "Anthropic-Dangerous-Direct-Browser-Access": "true",
+ "User-Agent": CLAUDE_CLI_USER_AGENT,
+ "X-App": "cli",
+ "X-Stainless-Helper-Method": "stream",
+ "X-Stainless-Retry-Count": "0",
+ "X-Stainless-Runtime-Version": CLAUDE_CLI_STAINLESS_RUNTIME_VERSION,
+ "X-Stainless-Package-Version": CLAUDE_CLI_STAINLESS_PACKAGE_VERSION,
+ "X-Stainless-Runtime": "node",
+ "X-Stainless-Lang": "js",
+ "X-Stainless-Arch": mapStainlessArch(),
+ "X-Stainless-Os": mapStainlessOs(),
+ "X-Stainless-Timeout": "600",
},
- models: [{ id: "auto", name: "Auto (Best Available)" }],
+ models: [
+ { id: "claude-haiku-4-5-20251001", name: "Claude 4.5 Haiku" },
+ { id: "claude-opus-4-6", name: "Claude 4.6 Opus" },
+ { id: "deepseek-r1-0528", name: "DeepSeek R1 0528" },
+ { id: "deepseek-v3.1", name: "DeepSeek V3.1" },
+ { id: "deepseek-v3.2", name: "DeepSeek V3.2" },
+ { id: "glm-4.5", name: "GLM 4.5" },
+ { id: "glm-4.6", name: "GLM 4.6" },
+ { id: "glm-5.1", name: "GLM 5.1" },
+ ],
+ passthroughModels: true,
},
openrouter: {
diff --git a/scripts/scratch/pr_body.md b/scripts/scratch/pr_body.md
index ed771ff7e7..c19067d4c5 100644
--- a/scripts/scratch/pr_body.md
+++ b/scripts/scratch/pr_body.md
@@ -15,6 +15,7 @@
### 🐛 Bug Fixes
- **fix(providers):** allow local OpenAI-compatible endpoints (like Ollama) to be added without an API key (fixes #1893)
+- **fix(providers):** bypass AgentRouter unauthorized_client_error by spoofing Claude CLI headers via Anthropic endpoints (fixes #1921)
- **fix(copilot):** emit compatible reasoning text deltas (#1919 — thanks @ivan-mezentsev)
- **fix(api-manager):** show validation errors inline in modals, not behind (#1920 — thanks @andrewmunsell)
- **fix(compression):** align seeded standard savings combo with stacked default, preserve stacked defaults, and secure metadata routes.