From c15064fa372c68d7daa976c56eb48aac14a1bc16 Mon Sep 17 00:00:00 2001 From: HangGlidersRule <637186+HangGlidersRule@users.noreply.github.com> Date: Thu, 2 Apr 2026 10:11:22 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20pass=20api-version=20as=20default=5Fquer?= =?UTF-8?q?y=20param,=20not=20in=20base=5Furl=20=E2=80=94=20SDK=20was=20pr?= =?UTF-8?q?oducing=20malformed=20URLs=20like=20/anthropic=3Fapi-version=3D?= =?UTF-8?q?.../v1/messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/anthropic_adapter.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/agent/anthropic_adapter.py b/agent/anthropic_adapter.py index 96903875..af358a2d 100644 --- a/agent/anthropic_adapter.py +++ b/agent/anthropic_adapter.py @@ -390,7 +390,16 @@ def build_anthropic_client(api_key: str, base_url: str = None, timeout: float = "timeout": Timeout(timeout=float(_read_timeout), connect=10.0), } if normalized_base_url: - kwargs["base_url"] = normalized_base_url + # Azure Anthropic endpoints require an ``api-version`` query parameter. + # Pass it via default_query so the SDK appends it to every request URL + # without corrupting the base_url (appending it directly produces + # malformed paths like /anthropic?api-version=.../v1/messages). + _is_azure_endpoint = "azure.com" in normalized_base_url.lower() + if _is_azure_endpoint and "api-version" not in normalized_base_url: + kwargs["base_url"] = normalized_base_url.rstrip("/") + kwargs["default_query"] = {"api-version": "2025-04-15"} + else: + kwargs["base_url"] = normalized_base_url common_betas = _common_betas_for_base_url(normalized_base_url) if _is_kimi_coding_endpoint(base_url):