Update litellm/litellm_core_utils/llm_cost_calc/utils.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
Praveen11558 2026-03-12 17:07:13 +05:30 • committed by GitHub
parent 4beea89471
commit ce0c50204b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -690,7 +690,13 @@ def generic_cost_per_token( # noqa: PLR0915
- image_tokens,
)
prompt_tokens_details["text_tokens"] = text_tokens
elif (text_tokens == 0 and not has_alternative_billing):
elif text_tokens == 0 and not has_alternative_billing:
# text_tokens not set by provider; no alternative billing dimensions active.
# NOTE: This branch was formerly `text_tokens == 0 and image_count == 0`,
# which unintentionally filled text_tokens even for character- or
# video-billed models. The broader `not has_alternative_billing` guard
# correctly prevents that over-billing, but it is a silent behaviour
# change for providers that previously relied on the fill.
# text_tokens not set by provider and no alternative billing dimensions:
# calculate text_tokens as the remainder of prompt_tokens
text_tokens = max(