From f6fdfea3ae5bd44d36f2b0896cc9157e10b0ff74 Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Mon, 4 May 2026 01:08:14 -0300 Subject: [PATCH] fix(providers): route agentrouter through anthropic endpoint headers Update the AgentRouter provider registry to use the Claude-compatible messages API and required Anthropic-style authentication headers. This bypasses unauthorized_client_error responses and exposes the supported model list through passthrough configuration. Also update the changelog and release PR notes to document the fix for #1921 --- CHANGELOG.md | 1 + open-sse/config/providerRegistry.ts | 34 ++++++++++++++++++++++++----- scripts/scratch/pr_body.md | 1 + 3 files changed, 30 insertions(+), 6 deletions(-) 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 = { 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.