Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(anthropic/chat/transformation.py): ignore user mapping if email given (e.g. from openwebui)

Krrish Dholakia0e10e73f31e4
diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py
index 44ca229be77..144cccfa4d0 100644
--- a/litellm/llms/anthropic/chat/transformation.py
+++ b/litellm/llms/anthropic/chat/transformation.py
@@ -479,7 +479,12 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
optional_params = self._add_tools_to_optional_params(
optional_params=optional_params, tools=[_tool]
)
- if param == "user":
+ if (
+ param == "user"
+ and value is not None
+ and isinstance(value, str)
+ and _valid_user_id(value) # anthropic fails on emails
+ ):
optional_params["metadata"] = {"user_id": value}
if param == "thinking":
optional_params["thinking"] = value
diff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yaml
index d339856116d..7ea414d262d 100644
--- a/litellm/proxy/_new_secret_config.yaml
+++ b/litellm/proxy/_new_secret_config.yaml
@@ -82,6 +82,10 @@ model_list:
litellm_params:
model: "openai/*"
api_key: os.environ/OPENAI_API_KEY_TEST
+ - model_name: "anthropic-claude"
+ litellm_params:
+ model: "anthropic/claude-3-5-sonnet-latest"
+ api_key: os.environ/ANTHROPIC_API_KEY
general_settings:
store_model_in_db: true