From b5a4c2624807feece10fd6c4ad366e6a719ff762 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Tue, 14 Apr 2026 18:20:37 -0700 Subject: [PATCH] feat(logging): pass cache_read_cost and cache_creation_cost through set_cost_breakdown --- litellm/litellm_core_utils/litellm_logging.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index e84c1e13a8b..e335ebabd8b 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -1387,6 +1387,8 @@ class Logging(LiteLLMLoggingBaseClass): margin_percent: Optional[float] = None, margin_fixed_amount: Optional[float] = None, margin_total_amount: Optional[float] = None, + cache_read_cost: Optional[float] = None, + cache_creation_cost: Optional[float] = None, ) -> None: """ Helper method to store cost breakdown in the logging object. @@ -1411,6 +1413,10 @@ class Logging(LiteLLMLoggingBaseClass): total_cost=total_cost, tool_usage_cost=cost_for_built_in_tools_cost_usd_dollar, ) + if cache_read_cost is not None and cache_read_cost > 0: + self.cost_breakdown["cache_read_cost"] = cache_read_cost + if cache_creation_cost is not None and cache_creation_cost > 0: + self.cost_breakdown["cache_creation_cost"] = cache_creation_cost # Store additional costs if provided (free-form dict for extensibility) if (