The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(bedrock/converse): capture raw input_tokens as text_tokens before cache inflation in PromptTokensDetailsWrapper
Ishaan Jafferc84597ecd096
diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.pyindex 5cfb00d69b6..4e71c9584ab 100644--- a/litellm/llms/bedrock/chat/converse_transformation.py+++ b/litellm/llms/bedrock/chat/converse_transformation.py@@ -1651,6 +1651,7 @@ class AmazonConverseConfig(BaseConfig):cache_creation_input_tokens: int = 0cache_read_input_tokens: int = 0+ raw_input_tokens = input_tokens # capture before inflationif "cacheReadInputTokens" in usage:cache_read_input_tokens = usage["cacheReadInputTokens"]input_tokens += cache_read_input_tokens@@ -1659,7 +1660,9 @@ class AmazonConverseConfig(BaseConfig):input_tokens += cache_creation_input_tokensprompt_tokens_details = PromptTokensDetailsWrapper(- cached_tokens=cache_read_input_tokens+ cached_tokens=cache_read_input_tokens,+ cache_creation_tokens=cache_creation_input_tokens,+ text_tokens=raw_input_tokens,)reasoning_tokens = (token_counter(text=reasoning_content, count_response_tokens=True)