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(streaming): include ModelResponseStream in _extract_usage_chunk annotation
mateo-berri21c126464b8d
diff --git a/litellm/litellm_core_utils/streaming_chunk_builder_utils.py b/litellm/litellm_core_utils/streaming_chunk_builder_utils.pyindex fbb11fa7a1f..d52d9849310 100644--- a/litellm/litellm_core_utils/streaming_chunk_builder_utils.py+++ b/litellm/litellm_core_utils/streaming_chunk_builder_utils.py@@ -517,7 +517,7 @@ class ChunkProcessor:return reasoning_tokens@staticmethod- def _extract_usage_chunk(chunk: dict[str, Any] | ModelResponse) -> Usage | None:+ def _extract_usage_chunk(chunk: dict[str, Any] | ModelResponse | ModelResponseStream) -> Usage | None:usage_chunk: Usage | dict[str, Any] | None = Noneif hasattr(chunk, "usage") and chunk.usage is not None:usage_chunk = chunk.usage