fix(providers): support anthropic proxy v1 endpoints

This commit is contained in:
helix4u
2026-06-14 02:09:16 -07:00
committed by Teknium
parent 81e42335a1
commit 85e6232a07
8 changed files with 133 additions and 14 deletions
+9
View File
@@ -113,6 +113,15 @@ class TestBuildAnthropicClient:
"anthropic-beta": "interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"
}
def test_custom_base_url_strips_trailing_v1(self):
with patch("agent.anthropic_adapter._anthropic_sdk") as mock_sdk:
build_anthropic_client(
"sk-ant-api03-x",
base_url="https://proxy.example.com/anthropic/v1",
)
kwargs = mock_sdk.Anthropic.call_args[1]
assert kwargs["base_url"] == "https://proxy.example.com/anthropic"
def test_azure_anthropic_endpoint_keeps_context_1m_beta(self):
with patch("agent.anthropic_adapter._anthropic_sdk") as mock_sdk:
build_anthropic_client(
@@ -39,6 +39,8 @@ def _clean_env(monkeypatch):
("https://api.moonshot.ai/v1", False, "Moonshot legacy"),
("https://api.minimax.io/anthropic", True, "MiniMax /anthropic"),
("https://litellm.example.com/v1/anthropic", True, "/anthropic suffix"),
("https://litellm.example.com/anthropic/v1", True, "/anthropic/v1 base"),
("https://litellm.example.com/anthropic/v1/models", False, "/anthropic/v1 subpath"),
("https://api.anthropic.com", True, "native Anthropic"),
("https://api.anthropic.com/v1", True, "native Anthropic /v1"),
("https://openrouter.ai/api/v1", False, "OpenRouter"),