From 73407b1e303a13782812675869047dfab60ca650 Mon Sep 17 00:00:00 2001 From: sharziki Date: Sat, 16 May 2026 13:03:31 -0400 Subject: [PATCH] fix(auth): send Bearer auth for Azure Foundry anthropic_messages endpoints Azure AI Foundry's Anthropic-style endpoint requires `Authorization: Bearer` instead of `x-api-key`. Add `azure.com` to `_requires_bearer_auth()` so the existing Bearer path at line 586 fires before the generic third-party branch sets `api_key` (x-api-key). Fixes #26970 --- agent/anthropic_adapter.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/agent/anthropic_adapter.py b/agent/anthropic_adapter.py index e7e1a8acb6..469b0fc9bb 100644 --- a/agent/anthropic_adapter.py +++ b/agent/anthropic_adapter.py @@ -471,14 +471,18 @@ def _requires_bearer_auth(base_url: str | None) -> bool: """Return True for Anthropic-compatible providers that require Bearer auth. Some third-party /anthropic endpoints implement Anthropic's Messages API but - require Authorization: Bearer *** of Anthropic's native x-api-key header. - MiniMax's global and China Anthropic-compatible endpoints follow this pattern. + require Authorization: Bearer instead of Anthropic's native x-api-key header. + MiniMax's global and China Anthropic-compatible endpoints, and Azure AI + Foundry's Anthropic-style endpoint follow this pattern. """ normalized = _normalize_base_url_text(base_url) if not normalized: return False normalized = normalized.rstrip("/").lower() - return normalized.startswith(("https://api.minimax.io/anthropic", "https://api.minimaxi.com/anthropic")) + return ( + normalized.startswith(("https://api.minimax.io/anthropic", "https://api.minimaxi.com/anthropic")) + or "azure.com" in normalized + ) def _base_url_needs_context_1m_beta(base_url: str | None) -> bool: