From 29e96f58233674a77ccdd86ec08d3391276fe309 Mon Sep 17 00:00:00 2001 From: Christian-Sidak <61099993+Christian-Sidak@users.noreply.github.com> Date: Tue, 1 Sep 2026 20:08:43 -0700 Subject: [PATCH] fix: correct timeout precedence in async_anthropic_messages_handler Per-request litellm_params.timeout should take priority over the proxy global kwargs["request_timeout"]. Fixes the precedence flagged in code review. --- litellm/llms/custom_httpx/llm_http_handler.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py index 6e5b4ddea94..486ec84435a 100644 --- a/litellm/llms/custom_httpx/llm_http_handler.py +++ b/litellm/llms/custom_httpx/llm_http_handler.py @@ -1955,11 +1955,12 @@ class BaseLLMHTTPHandler: ) # Resolve the request timeout so a silent upstream is not waited on - # indefinitely. Priority: per-request kwargs["request_timeout"] > - # litellm_params.timeout > litellm.request_timeout > client default. + # indefinitely. Priority: litellm_params.timeout (per-request explicit) + # > kwargs["request_timeout"] (proxy global) > litellm.request_timeout + # (library global) > client default. _request_timeout: Optional[Union[float, httpx.Timeout]] = ( - kwargs.get("request_timeout") - or litellm_params.get("timeout") + litellm_params.get("timeout") + or kwargs.get("request_timeout") or litellm.request_timeout or None )