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: use correct list length when averaging TTFT latency for streaming requests (#23100)
JiangNan3ce37e6c35f4
diff --git a/litellm/router_strategy/lowest_latency.py b/litellm/router_strategy/lowest_latency.pyindex 0449a843bd2..e09b5c1456d 100644--- a/litellm/router_strategy/lowest_latency.py+++ b/litellm/router_strategy/lowest_latency.py@@ -490,20 +490,22 @@ class LowestLatencyLoggingHandler(CustomLogger):# get average latency or average ttft (depending on streaming/non-streaming)total: float = 0.0- if (+ use_ttft = (request_kwargs is not Noneand request_kwargs.get("stream", None) is not Noneand request_kwargs["stream"] is Trueand len(item_ttft_latency) > 0- ):+ )+ if use_ttft:for _call_latency in item_ttft_latency:if isinstance(_call_latency, float):total += _call_latency+ item_latency = total / len(item_ttft_latency)else: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)# -------------- ## Debugging Logic