diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml index 778ae703b..d1bf53a6b 100644 --- a/litellm/proxy/proxy_config.yaml +++ b/litellm/proxy/proxy_config.yaml @@ -10,17 +10,7 @@ model_list: api_key: os.environ/OPENAI_API_KEY -litellm_settings: - default_team_settings: - - team_id: team-1 - success_callback: ["langfuse"] - langfuse_public_key: os.environ/LANGFUSE_PROJECT1_PUBLIC # Project 1 - langfuse_secret: os.environ/LANGFUSE_PROJECT1_SECRET # Project 1 - - team_id: team-2 - success_callback: ["langfuse"] - langfuse_public_key: os.environ/LANGFUSE_PROJECT2_PUBLIC # Project 2 - langfuse_secret: os.environ/LANGFUSE_PROJECT2_SECRET # Project 2 - general_settings: store_model_in_db: true - master_key: sk-1234 \ No newline at end of file + master_key: sk-1234 + alerting: ["slack"] \ No newline at end of file diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 643e5e3a5..2fccbc74e 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -360,22 +360,25 @@ class ProxyLogging: f"Budget Alerts: Percent left: {percent_left} for {user_info}" ) - # check if crossed budget - if user_current_spend >= user_max_budget: - verbose_proxy_logger.debug("Budget Crossed for %s", user_info) - message = "Budget Crossed for" + user_info - await self.alerting_handler( - message=message, - level="High", - ) - return - ## PREVENTITIVE ALERTING ## - https://github.com/BerriAI/litellm/issues/2727 # - Alert once within 28d period # - Cache this information # - Don't re-alert, if alert already sent _cache: DualCache = self.internal_usage_cache + # check if crossed budget + if user_current_spend >= user_max_budget: + verbose_proxy_logger.debug("Budget Crossed for %s", user_info) + message = "Budget Crossed for" + user_info + result = await _cache.async_get_cache(key=message) + if result is None: + await self.alerting_handler( + message=message, + level="High", + ) + await _cache.async_set_cache(key=message, value="SENT", ttl=2419200) + return + # check if 5% of max budget is left if percent_left <= 0.05: message = "5% budget left for" + user_info