Skip to content

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]

Fix : Cost Tracking Callback Fails with KeyError: 'stream'

Sameer Kankute023e02bf73a3
diff --git a/litellm/proxy/hooks/proxy_track_cost_callback.py b/litellm/proxy/hooks/proxy_track_cost_callback.py
index dab5fb1bfd5..37b79e6d065 100644
--- a/litellm/proxy/hooks/proxy_track_cost_callback.py
+++ b/litellm/proxy/hooks/proxy_track_cost_callback.py
@@ -202,8 +202,8 @@ class _ProxyDBLogger(CustomLogger):
max_budget=end_user_max_budget,
)
else:
- if kwargs["stream"] is not True or (
- kwargs["stream"] is True and "complete_streaming_response" in kwargs
+ if kwargs.get("stream") is not True or (
+ kwargs.get("stream") is True and "complete_streaming_response" in kwargs
):
if sl_object is not None:
cost_tracking_failure_debug_info: Union[dict, str] = (