From e0de9cbab272edb0c087b280295810225836bb84 Mon Sep 17 00:00:00 2001 From: nazsats Date: Mon, 24 Aug 2026 13:41:20 +0530 Subject: [PATCH] Trim the clamp comment down to the reason for it --- litellm/litellm_core_utils/llm_cost_calc/utils.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/litellm/litellm_core_utils/llm_cost_calc/utils.py b/litellm/litellm_core_utils/llm_cost_calc/utils.py index cf78ffbeaae..3f86afb10eb 100644 --- a/litellm/litellm_core_utils/llm_cost_calc/utils.py +++ b/litellm/litellm_core_utils/llm_cost_calc/utils.py @@ -947,11 +947,8 @@ def generic_cost_per_token( usage.completion_tokens - reasoning_tokens - audio_tokens - image_tokens - video_tokens, ) else: - # No breakdown at all, all tokens are text tokens. - # Clamped for the same reason the branch above is: a negative count - # would otherwise multiply straight into a negative cost, and this - # is the only one of the four token paths in this module that did - # not guard against it. + # No breakdown at all, all tokens are text tokens. Clamped like + # the branch above, so a negative count cannot credit the budget. text_tokens = max(0, usage.completion_tokens) is_text_tokens_total = True ## TEXT COST