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 TTFT prioritization for streaming in LowestLatencyLoggingHandler
Emerson Gomes1cc832f53ef7
diff --git a/litellm/router_strategy/lowest_latency.py b/litellm/router_strategy/lowest_latency.pyindex 0ec71116e29..a48b5442d4f 100644--- a/litellm/router_strategy/lowest_latency.py+++ b/litellm/router_strategy/lowest_latency.py@@ -469,8 +469,6 @@ class LowestLatencyLoggingHandler(CustomLogger):total: float = 0.0if (request_kwargs is not None- and len(item_latency) > 0- and isinstance(item_latency[0], timedelta)and request_kwargs.get("stream", None) is not Noneand request_kwargs["stream"] is Trueand len(item_ttft_latency) > 0@@ -478,6 +476,7 @@ class LowestLatencyLoggingHandler(CustomLogger):for _call_latency in item_ttft_latency:if isinstance(_call_latency, float):total += _call_latency+ total = total / len(item_ttft_latency) if total > 0 else float('inf')elif len(item_latency) > 0 and isinstance(item_latency[0], timedelta):for _call_latency in item_latency:total += _call_latency.total_seconds()@@ -485,7 +484,7 @@ class LowestLatencyLoggingHandler(CustomLogger):for _call_latency in item_latency:if isinstance(_call_latency, float):total += _call_latency- item_latency = total / len(item_latency)+ item_latency = total / len(item_latency) if total > 0 else float('inf')# -------------- ## Debugging Logic