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(invoke_handler.py): support cache token tracking on converse streaming
Krrish Dholakia0af6cde99464
diff --git a/litellm/llms/bedrock/chat/invoke_handler.py b/litellm/llms/bedrock/chat/invoke_handler.pyindex 44e5b403801..9fa791e0699 100644--- a/litellm/llms/bedrock/chat/invoke_handler.py+++ b/litellm/llms/bedrock/chat/invoke_handler.py@@ -72,6 +72,9 @@ _response_stream_shape_cache = Nonebedrock_tool_name_mappings: InMemoryCache = InMemoryCache(max_size_in_memory=50, default_ttl=600)+from litellm.llms.bedrock.chat.converse_transformation import AmazonConverseConfig++converse_config = AmazonConverseConfig()class AmazonCohereChatConfig:@@ -1274,7 +1277,7 @@ class AWSEventStreamDecoder:text = ""tool_use: Optional[ChatCompletionToolCallChunk] = Nonefinish_reason = ""- usage: Optional[ChatCompletionUsageBlock] = None+ usage: Optional[Usage] = Noneprovider_specific_fields: dict = {}reasoning_content: Optional[str] = Nonethinking_blocks: Optional[List[ChatCompletionThinkingBlock]] = None@@ -1350,12 +1353,7 @@ class AWSEventStreamDecoder:elif "stopReason" in chunk_data:finish_reason = map_finish_reason(chunk_data.get("stopReason", "stop"))elif "usage" in chunk_data:- usage = ChatCompletionUsageBlock(- prompt_tokens=chunk_data.get("inputTokens", 0),- completion_tokens=chunk_data.get("outputTokens", 0),- total_tokens=chunk_data.get("totalTokens", 0),- )-+ usage = converse_config._transform_usage(chunk_data.get("usage", {}))model_response_provider_specific_fields = {}if "trace" in chunk_data:trace = chunk_data.get("trace")