From 8c53b3a107192c74be32021bf486d17df1c7b4dd Mon Sep 17 00:00:00 2001 From: ghostface Date: Wed, 18 Feb 2026 00:12:23 -0500 Subject: [PATCH] fix: forward vendor-specific headers through proxy Anthropic's API requires the `anthropic-version` header on all requests. The proxy was only forwarding common headers (content-type, accept, user-agent), causing all Anthropic model calls to fail with 400. Add `forwardHeaders` field to VendorConfig so each vendor can declare extra headers to forward. Anthropic gets `anthropic-version` and `anthropic-beta`; other vendors are unaffected. Co-Authored-By: Claude Opus 4.6 --- proxy/src/routes/proxy.ts | 5 +++-- proxy/src/types.ts | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/proxy/src/routes/proxy.ts b/proxy/src/routes/proxy.ts index bd4d93c..f03dd79 100644 --- a/proxy/src/routes/proxy.ts +++ b/proxy/src/routes/proxy.ts @@ -73,9 +73,10 @@ export function registerProxyRoutes( keyId = keySelection.keyId; } - const FORWARDED_HEADERS = ['content-type', 'accept', 'user-agent']; + const COMMON_HEADERS = ['content-type', 'accept', 'user-agent']; + const forwardHeaders = [...COMMON_HEADERS, ...(vendorConfig.forwardHeaders ?? [])]; const headers: Record = {}; - for (const name of FORWARDED_HEADERS) { + for (const name of forwardHeaders) { const value = req.headers[name]; if (typeof value === 'string') { headers[name] = value; diff --git a/proxy/src/types.ts b/proxy/src/types.ts index 2d4f087..4c3dbbc 100644 --- a/proxy/src/types.ts +++ b/proxy/src/types.ts @@ -33,6 +33,7 @@ export interface VendorConfig { protocol?: 'http' | 'https'; // default: 'https' noAuth?: boolean; // Skip API key injection (e.g., local Ollama) forceNonStreaming?: boolean; // Strip stream:true, convert response to SSE + forwardHeaders?: string[]; // Extra vendor-specific headers to forward from client } const VENDOR_CONFIGS: Record = { @@ -47,6 +48,7 @@ const VENDOR_CONFIGS: Record = { basePath: '', // OpenClaw's anthropic-messages API includes /v1 in its path authHeader: 'x-api-key', authFormat: (key) => key, + forwardHeaders: ['anthropic-version', 'anthropic-beta'], }, venice: { host: 'api.venice.ai',