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
Merge remote-tracking branch 'origin' into litellm_email_budget_alerts_2
yuneng-jiang087dfbf648a5
diff --cc litellm/proxy/proxy_config.yamlindex 91bbed21291,af74853d82d..a773e934ef1--- a/litellm/proxy/proxy_config.yaml+++ b/litellm/proxy/proxy_config.yaml@@@ -1,19 -1,9 +1,10 @@@model_list:- - model_name: openai/gpt-4o-mini+ - model_name: gemini/*litellm_params:- model: openai/gpt-4o-mini- tpm: 1000-- # LangGraph models- - model_name: langgraph/*- litellm_params:- model: langgraph/*+ model: gemini/*--litellm_settings:- callbacks: ["langfuse"]+ callbacks: ["dynamic_rate_limiter_v3"]+ priority_reservation:+ "prod": 0.9 # 90% reserved for production+ "dev": 0.1 # 10% reserved for development-- general_settings:- alerting: ["email"]diff --cc tests/test_litellm/test_utils.pyindex b9485f6a317,46b828e7940..7dba7c99916--- a/tests/test_litellm/test_utils.py+++ b/tests/test_litellm/test_utils.py@@@ -2603,127 -2603,29 +2603,155 @@@ class TestIsCachedMessagemessage = {"role": "user", "content": []}assert is_cached_message(message) is False++class TestProxyLoggingBudgetAlerts:+ """Test budget_alerts method in ProxyLogging class."""++ async def test_budget_alerts_when_alerting_is_none(self):+ """Test that budget_alerts returns early when alerting is None."""+ from litellm.caching.caching import DualCache+ from litellm.proxy.utils import ProxyLogging++ proxy_logging = ProxyLogging(user_api_key_cache=DualCache())+ proxy_logging.alerting = None+ proxy_logging.slack_alerting_instance = AsyncMock()+ proxy_logging.email_logging_instance = AsyncMock()++ user_info = MagicMock()++ # Should return without calling any alerting instances+ await proxy_logging.budget_alerts(type="user_budget", user_info=user_info)++ # Verify no calls were made+ proxy_logging.slack_alerting_instance.budget_alerts.assert_not_called()+ proxy_logging.email_logging_instance.budget_alerts.assert_not_called()++ async def test_budget_alerts_with_slack_only(self):+ """Test that budget_alerts calls slack_alerting_instance when slack is in alerting."""+ from litellm.caching.caching import DualCache+ from litellm.proxy.utils import ProxyLogging++ proxy_logging = ProxyLogging(user_api_key_cache=DualCache())+ proxy_logging.alerting = ["slack"]+ proxy_logging.slack_alerting_instance = AsyncMock()++ user_info = MagicMock()++ await proxy_logging.budget_alerts(type="token_budget", user_info=user_info)++ proxy_logging.slack_alerting_instance.budget_alerts.assert_called_once_with(+ type="token_budget", user_info=user_info+ )++ async def test_budget_alerts_with_email_only(self):+ """Test that budget_alerts calls email_logging_instance when email is in alerting."""+ from litellm.caching.caching import DualCache+ from litellm.proxy.utils import ProxyLogging++ proxy_logging = ProxyLogging(user_api_key_cache=DualCache())+ proxy_logging.alerting = ["email"]+ proxy_logging.email_logging_instance = AsyncMock()++ user_info = MagicMock()++ await proxy_logging.budget_alerts(type="team_budget", user_info=user_info)++ proxy_logging.email_logging_instance.budget_alerts.assert_called_once_with(+ type="team_budget", user_info=user_info+ )++ async def test_budget_alerts_with_email_when_instance_is_none(self):+ """Test that budget_alerts does not call email_logging_instance when it is None."""+ from litellm.caching.caching import DualCache+ from litellm.proxy.utils import ProxyLogging++ proxy_logging = ProxyLogging(user_api_key_cache=DualCache())+ proxy_logging.alerting = ["email"]+ proxy_logging.email_logging_instance = None++ user_info = MagicMock()++ # Should not raise an error+ await proxy_logging.budget_alerts(type="organization_budget", user_info=user_info)++ async def test_budget_alerts_with_both_slack_and_email(self):+ """Test that budget_alerts calls both slack and email instances when both are in alerting."""+ from litellm.caching.caching import DualCache+ from litellm.proxy.utils import ProxyLogging++ proxy_logging = ProxyLogging(user_api_key_cache=DualCache())+ proxy_logging.alerting = ["slack", "email"]+ proxy_logging.slack_alerting_instance = AsyncMock()+ proxy_logging.email_logging_instance = AsyncMock()++ user_info = MagicMock()++ await proxy_logging.budget_alerts(type="proxy_budget", user_info=user_info)++ proxy_logging.slack_alerting_instance.budget_alerts.assert_called_once_with(+ type="proxy_budget", user_info=user_info+ )+ proxy_logging.email_logging_instance.budget_alerts.assert_called_once_with(+ type="proxy_budget", user_info=user_info+ )++ @pytest.mark.parametrize(+ "alert_type",+ [+ "token_budget",+ "user_budget",+ "soft_budget",+ "team_budget",+ "organization_budget",+ "proxy_budget",+ "projected_limit_exceeded",+ ],+ )+ async def test_budget_alerts_with_all_alert_types(self, alert_type):+ """Test that budget_alerts works with all supported alert types."""+ from litellm.caching.caching import DualCache+ from litellm.proxy.utils import ProxyLogging++ proxy_logging = ProxyLogging(user_api_key_cache=DualCache())+ proxy_logging.alerting = ["slack", "email"]+ proxy_logging.slack_alerting_instance = AsyncMock()+ proxy_logging.email_logging_instance = AsyncMock()++ user_info = MagicMock()++ await proxy_logging.budget_alerts(type=alert_type, user_info=user_info)++ proxy_logging.slack_alerting_instance.budget_alerts.assert_called_once_with(+ type=alert_type, user_info=user_info+ )+ proxy_logging.email_logging_instance.budget_alerts.assert_called_once_with(+ type=alert_type, user_info=user_info+ )+++++ def test_azure_ai_claude_provider_config():+ """Test that Azure AI Claude models return AzureAnthropicConfig for proper tool transformation."""+ from litellm import AzureAnthropicConfig, AzureAIStudioConfig+ from litellm.utils import ProviderConfigManager++ # Claude models should return AzureAnthropicConfig+ config = ProviderConfigManager.get_provider_chat_config(+ model="claude-sonnet-4-5",+ provider=LlmProviders.AZURE_AI,+ )+ assert isinstance(config, AzureAnthropicConfig)++ # Test case-insensitive matching+ config = ProviderConfigManager.get_provider_chat_config(+ model="Claude-Opus-4",+ provider=LlmProviders.AZURE_AI,+ )+ assert isinstance(config, AzureAnthropicConfig)++ # Non-Claude models should return AzureAIStudioConfig+ config = ProviderConfigManager.get_provider_chat_config(+ model="mistral-large",+ provider=LlmProviders.AZURE_AI,+ )+ assert isinstance(config, AzureAIStudioConfig)