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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
feat(key_management): allow @ in key_alias for email-based aliases (#23003)
hliu-roblox07ac97aff4ea
diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.pyindex 5d189e0db49..bce51b9ccd2 100644--- a/litellm/proxy/management_endpoints/key_management_endpoints.py+++ b/litellm/proxy/management_endpoints/key_management_endpoints.py@@ -4991,7 +4991,7 @@ async def test_key_logging()-_KEY_ALIAS_PATTERN = re.compile(r"^[a-zA-Z0-9][a-zA-Z0-9_\-/\.]{0,253}[a-zA-Z0-9]$")+_KEY_ALIAS_PATTERN = re.compile(r"^[a-zA-Z0-9][a-zA-Z0-9_\-/\.@]{0,253}[a-zA-Z0-9]$")def _validate_key_alias_format(key_alias: Optional[str]) -> None:@@ -5009,7 +5009,7 @@ def _validate_key_alias_format(key_alias: Optional[str]) -> None:if not _KEY_ALIAS_PATTERN.match(key_alias):raise ProxyException(- message="Invalid key_alias format. Must be 2-255 characters, start/end with alphanumeric, and only contain a-zA-Z0-9_-/.",+ message="Invalid key_alias format. Must be 2-255 characters, start/end with alphanumeric, and only contain a-zA-Z0-9_-/.@.",type=ProxyErrorTypes.bad_request_error,param="key_alias",code=400,diff --git a/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.pyindex bc5c6925107..5f068d4817a 100644--- a/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py+++ b/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py@@ -6460,6 +6460,8 @@ class TestValidateKeyAliasFormat:_validate_key_alias_format("valid/alias")_validate_key_alias_format("a" * 255)_validate_key_alias_format("my-key-123")+ _validate_key_alias_format("user/[email protected]")+ _validate_key_alias_format("team/[email protected]")def test_validate_key_alias_format_invalid(self):from litellm.proxy.management_endpoints.key_management_endpoints import _validate_key_alias_format@@ -6472,7 +6474,7 @@ class TestValidateKeyAliasFormat:"!", # special char"-start", # non-alphanumeric start"end-", # non-alphanumeric end- "invalid@char", # invalid char+ "invalid#char", # invalid char"a" * 256, # too long" leading","trailing ",