From e4da6304f236b82eba11fb2adb9970365d27c84c Mon Sep 17 00:00:00 2001 From: onatozmenn Date: Wed, 23 Sep 2026 11:55:52 +0300 Subject: [PATCH] \fix(logging): keep uncomputed hidden cost silent while falling through to calculator" --- litellm/litellm_core_utils/litellm_logging.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index dc4324470a3..18ce456dd14 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -2405,7 +2405,16 @@ class Logging(LiteLLMLoggingBaseClass): # Do not preserve 0 from failure_handler on intermediate router retries. pass else: - self.model_call_details["response_cost"] = self._response_cost_calculator(result=logging_result) + if "response_cost" in hidden_params: + warned = self.zero_cost_warned + self.zero_cost_warned = True + try: + self.model_call_details["response_cost"] = self._response_cost_calculator(result=logging_result) + finally: + self.model_call_details["zero_cost_diagnostic"] = None + self.zero_cost_warned = warned + else: + self.model_call_details["response_cost"] = self._response_cost_calculator(result=logging_result) if not build_logging_payload: return