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(passthrough): read the stream flag by truthiness in the timeout resolver
mateo-berri58beea227547
diff --git a/litellm/passthrough/timeout_utils.py b/litellm/passthrough/timeout_utils.pyindex 829277105e3..9284f7143b0 100644--- a/litellm/passthrough/timeout_utils.py+++ b/litellm/passthrough/timeout_utils.py@@ -10,7 +10,6 @@ DEFAULT_PASS_THROUGH_REQUEST_TIMEOUT_SECONDS: Final = 600.0class _TimeoutFields(BaseModel):model_config = ConfigDict(frozen=True)- stream: bool = Falsestream_timeout: float | None = Nonetimeout: float | None = Nonerequest_timeout: float | None = None@@ -61,10 +60,11 @@ def resolve_llm_passthrough_timeout(kwargs stream_timeout -> litellm_params stream_timeout -> router_stream_timeout, then thenon-streaming chain above."""+ streaming: Final = bool((kwargs or {}).get("stream"))request: Final = _TimeoutFields.model_validate(kwargs or {})deployment: Final = _TimeoutFields.model_validate(litellm_params or {})stream_candidates: Final = (- (request.stream_timeout, deployment.stream_timeout, router_stream_timeout) if request.stream else ()+ (request.stream_timeout, deployment.stream_timeout, router_stream_timeout) if streaming else ())candidates: Final = (*stream_candidates,diff --git a/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py b/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.pyindex 54336800db4..abff897c4f5 100644--- a/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py+++ b/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py@@ -1175,6 +1175,20 @@ def test_resolve_llm_passthrough_timeout_stream_timeout_precedence():)+ "stream, expected",+ [(None, 90.0), (0, 90.0), ("", 90.0), (1, 1800.0), ("yes", 1800.0)],+)+def test_resolve_llm_passthrough_timeout_reads_stream_by_truthiness(stream: object, expected: float):+ assert (+ resolve_llm_passthrough_timeout(+ kwargs={"stream": stream},+ litellm_params={"stream_timeout": 1800, "timeout": 90},+ )+ == expected+ )++@pytest.mark.asyncioasync def test_pass_through_request_uses_resolved_timeout():with patch("litellm.proxy.proxy_server.proxy_logging_obj") as mock_proxy_logging: