From 7e6dd8d46036776eba89e07f7b7769a8dc61ea40 Mon Sep 17 00:00:00 2001 From: Kannan Priyadharshan Date: Tue, 23 Jun 2026 20:50:27 +0800 Subject: [PATCH] fix(anthropic): accept integral float cache token counts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- .../experimental_pass_through/adapters/transformation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py index fa99aa1bac3..5dd1b3c0bc6 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py @@ -1404,8 +1404,8 @@ class LiteLLMAnthropicMessagesAdapter: @staticmethod def _positive_int(value: object) -> int: - if isinstance(value, int) and value > 0: - return value + if isinstance(value, (int, float)) and not isinstance(value, bool) and value > 0: + return int(value) return 0 @classmethod