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(proxy): stop leaking the client_side_timeout marker to providers
mateo-berrie3a93c40be34
diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex 13831799c7f..efa87203fb6 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -3476,6 +3476,7 @@ all_litellm_params = ("bos_token","eos_token","request_timeout",+ "client_side_timeout","complete_response","self","client",diff --git a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py b/tests/test_litellm/proxy/test_litellm_pre_call_utils.pyindex 0171e83be08..b1071150f3b 100644--- a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py+++ b/tests/test_litellm/proxy/test_litellm_pre_call_utils.py@@ -1037,6 +1037,65 @@ async def test_add_litellm_data_to_request_ignores_forged_client_side_timeout():assert not updated.get("client_side_timeout")+async def test_client_side_timeout_marker_never_reaches_the_provider():+ """A proxy request with a caller-supplied timeout gets kwargs["client_side_timeout"]+ stamped for the router's cooldown logic. That router-only marker must not ride+ into the provider payload: unregistered kwargs are swept into extra_body /+ additionalModelRequestFields, so Bedrock rejects the whole call with+ `client_side_timeout: Extra inputs are not permitted`."""+ from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler++ request_mock = MagicMock(spec=Request)+ request_mock.url.path = "/v1/chat/completions"+ request_mock.url = MagicMock()+ request_mock.url.__str__.return_value = "http://localhost/v1/chat/completions"+ request_mock.method = "POST"+ request_mock.query_params = {}+ request_mock.headers = {"Content-Type": "application/json"}+ request_mock.client = MagicMock()+ request_mock.client.host = "127.0.0.1"++ updated = await add_litellm_data_to_request(+ data={+ "model": "bedrock/us.anthropic.claude-sonnet-5",+ "messages": [{"role": "user", "content": "hi"}],+ "max_tokens": 10,+ "timeout": 30,+ },+ request=request_mock,+ user_api_key_dict=UserAPIKeyAuth(api_key="hashed-key"),+ proxy_config=MagicMock(),+ general_settings={},+ version="test-version",+ )+ assert updated["client_side_timeout"] is True++ converse_response = MagicMock()+ converse_response.status_code = 200+ converse_response.headers = {}+ converse_response.json.return_value = {+ "output": {"message": {"role": "assistant", "content": [{"text": "ok"}]}},+ "stopReason": "end_turn",+ "usage": {"inputTokens": 10, "outputTokens": 5, "totalTokens": 15},+ }+ converse_response.text = json.dumps(converse_response.json.return_value)+ client = AsyncHTTPHandler()+ with patch.object(client, "post", return_value=converse_response) as mock_post:+ await litellm.acompletion(+ **updated,+ aws_access_key_id="fake-access-key",+ aws_secret_access_key="fake-secret-key",+ aws_region_name="us-east-1",+ client=client,+ )++ mock_post.assert_called_once()+ assert mock_post.call_args.kwargs["url"].endswith("/converse")+ provider_body = json.loads(mock_post.call_args.kwargs["data"])+ assert "client_side_timeout" not in json.dumps(provider_body), provider_body++@pytest.mark.asyncioasync def test_add_litellm_data_to_request_allows_client_mock_response_with_admin_opt_in():request_mock = MagicMock(spec=Request)diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.pyindex 2b0b8b6ab20..99a824511f6 100644--- a/tests/test_litellm/test_utils.py+++ b/tests/test_litellm/test_utils.py@@ -4797,6 +4797,24 @@ def test_bedrock_batch_params_never_reach_the_provider():)+def test_client_side_timeout_marker_never_reaches_the_provider():+ """The proxy stamps kwargs["client_side_timeout"] = True whenever a request carries+ a caller-supplied timeout (body timeout / request_timeout / stream_timeout or the+ x-litellm-timeout headers) so the router can skip cooldowns on the resulting 408s.+ The marker is only meaningful to the router, so it must be filtered out of the+ provider params: swept into extra_body / additionalModelRequestFields it turns every+ timed-out request into a provider 400 (`client_side_timeout: Extra inputs are not+ permitted`)."""+ kwargs = {"a_real_provider_specific_param": 1, "client_side_timeout": True}++ non_default = get_non_default_completion_params(kwargs)++ assert non_default == {"a_real_provider_specific_param": 1}, (+ "client_side_timeout leaked into the provider params: "+ f"{sorted(set(non_default) - {'a_real_provider_specific_param'})}"+ )++def test_rust_flag_not_forwarded_as_provider_param():forwarded = get_non_default_completion_params({"rust": True, "temperature": 0.5})assert "rust" not in forwarded