From 0c1d00864d36d1bffe41566d277ea0d3b58be2e7 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 17 Mar 2025 22:17:56 -0700 Subject: [PATCH] fix ProxyUpdateSpend --- litellm/proxy/hooks/proxy_track_cost_callback.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/litellm/proxy/hooks/proxy_track_cost_callback.py b/litellm/proxy/hooks/proxy_track_cost_callback.py index e068a446c5..e8a947329d 100644 --- a/litellm/proxy/hooks/proxy_track_cost_callback.py +++ b/litellm/proxy/hooks/proxy_track_cost_callback.py @@ -13,6 +13,7 @@ from litellm.litellm_core_utils.core_helpers import ( from litellm.litellm_core_utils.litellm_logging import StandardLoggingPayloadSetup from litellm.proxy._types import UserAPIKeyAuth from litellm.proxy.auth.auth_checks import log_db_metrics +from litellm.proxy.utils import ProxyUpdateSpend from litellm.types.utils import ( StandardLoggingPayload, StandardLoggingUserAPIKeyMetadata, @@ -230,6 +231,11 @@ def _should_track_cost_callback( """ Determine if the cost callback should be tracked based on the kwargs """ + + # don't run track cost callback if user opted into disabling spend + if ProxyUpdateSpend.disable_spend_updates() is True: + return False + if ( user_api_key is not None or user_id is not None