Skip to content

Commit 6bb2303

Browse files
committed
feat(anthropic): accept base_url for OpenAI-compat proxies
Forward base_url through to anthropic.AsyncAnthropic so downstream consumers can route to Anthropic-compat gateways (e.g. DeepSeek's /anthropic surface) without monkey-patching the SDK client. Discovered while diagnosing why cubebox's prompt-cache E2E failed against DeepSeek: the provider silently connected to api.anthropic.com with a DeepSeek key. With base_url forwarded, the cache test passes (cache_read 1900+/2000 on turn 2).
1 parent 42269cd commit 6bb2303

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

cubepi/providers/anthropic.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,16 @@ def __init__(
6262
self,
6363
*,
6464
api_key: str | None = None,
65+
base_url: str | None = None,
6566
cache_retention: CacheRetention = "short",
6667
cache_policy: CacheMarkerPolicy | None = None,
6768
) -> None:
6869
import anthropic
6970

70-
self._client = anthropic.AsyncAnthropic(api_key=api_key)
71+
kwargs: dict[str, Any] = {"api_key": api_key}
72+
if base_url is not None:
73+
kwargs["base_url"] = base_url
74+
self._client = anthropic.AsyncAnthropic(**kwargs)
7175
self._cache_retention = cache_retention
7276
self._cache_policy: CacheMarkerPolicy = (
7377
cache_policy or DefaultCacheMarkerPolicy()

0 commit comments

Comments
 (0)