-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Description
The AnthropicClient does not respect the custom base_url configured in BYOK (Bring Your Own Key) providers. Instead, it always connects to the official Anthropic API endpoint regardless of the provider configuration.
Impact
This prevents users from:
- Using third-party Anthropic API proxies
- Connecting to API aggregation platforms
- Self-hosting Anthropic-compatible API endpoints
- Using enterprise API gateways that require custom endpoints
Current Behavior
When creating an agent with a BYOK provider that has:
provider_config = {
"provider_category": "byok",
"provider_name": "my-custom-anthropic",
"base_url": "https://my-custom-endpoint.example.com"
}The AnthropicClient ignores the base_url and still connects to https://api.anthropic.com.
Expected Behavior
The client should use the base_url from the provider configuration when provider_category is "byok", similar to how other BYOK-enabled clients work in the codebase.
Root Cause
The _get_anthropic_client() and _get_anthropic_client_async() methods in letta/llm_api/anthropic_client.py do not fetch or use the provider's base_url from ProviderManager, unlike other client implementations.
Proposed Solution
Follow the same pattern used by other BYOK-enabled clients:
- Add
get_byok_overrides()andget_byok_overrides_async()methods - Fetch
base_urlandapi_keyfromProviderManagerwhenprovider_category == "byok" - Pass the custom
base_urlto the Anthropic SDK client initialization
I have a working fix with comprehensive tests ready to submit as a PR.
Environment
- Letta version:
mainbranch (latest) - Affected component:
letta/llm_api/anthropic_client.py