From 7520be35851df0c3ab7102e8b04bccfa0ee8e7fc Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 20:55:48 +0000 Subject: [PATCH] fix(cost): read the stored breakdown total through the logging object's typed field --- litellm/cost_calculator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index 42a7fb0bb02..cec5fa16339 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -1506,8 +1506,8 @@ def _response_time_ms_for_cost( def _breakdown_total(litellm_logging_obj: LitellmLoggingObject | None) -> float | None: - breakdown: Final[object] = getattr(litellm_logging_obj, "cost_breakdown", None) - total: Final[object] = breakdown.get("total_cost") if isinstance(breakdown, Mapping) else None + breakdown: Final = None if litellm_logging_obj is None else litellm_logging_obj.cost_breakdown + total: Final[object] = None if breakdown is None else breakdown.get("total_cost") return float(total) if isinstance(total, (int, float)) and not isinstance(total, bool) else None