From b977bf74149c704c91092f0e1db0372695f452bc Mon Sep 17 00:00:00 2001 From: hodtien Date: Sat, 13 Jun 2026 09:45:59 +0700 Subject: [PATCH] fix(anthropic-compatible): send Bearer auth for third-party gateways Third-party Anthropic-compatible gateways that require Authorization: Bearer (in addition to x-api-key) returned 401 missing_api_key on the forward path. For non-official upstreams, also send Bearer alongside x-api-key. Official api.anthropic.com behavior is unchanged. Co-authored-by: Cursor --- open-sse/executors/default.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/open-sse/executors/default.js b/open-sse/executors/default.js index 1af130c2..db5a290a 100644 --- a/open-sse/executors/default.js +++ b/open-sse/executors/default.js @@ -157,6 +157,12 @@ export class DefaultExecutor extends BaseExecutor { const baseUrl = credentials?.providerSpecificData?.baseUrl || ""; const isOfficialAnthropic = baseUrl === "" || baseUrl.includes("api.anthropic.com"); if (!isOfficialAnthropic) { + // Some third-party Anthropic-compatible gateways require Bearer auth in + // addition to x-api-key. Send both (x-api-key already set above) so + // gateways that read either header succeed. + if (credentials.apiKey && !headers["Authorization"]) { + headers["Authorization"] = `Bearer ${credentials.apiKey}`; + } delete headers["anthropic-dangerous-direct-browser-access"]; delete headers["Anthropic-Dangerous-Direct-Browser-Access"]; delete headers["x-app"];