diff --git a/litellm/llms/custom_httpx/aiohttp_handler.py b/litellm/llms/custom_httpx/aiohttp_handler.py index 93b6c563dc1..81cc2b08b91 100644 --- a/litellm/llms/custom_httpx/aiohttp_handler.py +++ b/litellm/llms/custom_httpx/aiohttp_handler.py @@ -198,6 +198,7 @@ class BaseLLMAIOHTTPHandler: headers=headers, json=data, data=form_data, + timeout=timeout, ) if not response.ok: response.raise_for_status() diff --git a/tests/test_litellm/llms/custom_httpx/test_aiohttp_handler.py b/tests/test_litellm/llms/custom_httpx/test_aiohttp_handler.py index 6e19b2341a7..9c4ee1a695f 100644 --- a/tests/test_litellm/llms/custom_httpx/test_aiohttp_handler.py +++ b/tests/test_litellm/llms/custom_httpx/test_aiohttp_handler.py @@ -423,3 +423,39 @@ class TestBaseLLMAIOHTTPHandler: # Should use transport, not connector mock_transport._get_valid_client_session.assert_called_once() assert result is mock_session_from_transport + + @pytest.mark.asyncio + async def test_make_common_async_call_forwards_timeout(self): + """Test _make_common_async_call forwards timeout to aiohttp ClientSession.post""" + handler = BaseLLMAIOHTTPHandler() + + timeout = aiohttp.ClientTimeout(total=1) + mock_response = Mock() + mock_response.ok = True + + mock_session = Mock() + mock_session.post = AsyncMock(return_value=mock_response) + + provider_config = Mock() + provider_config.max_retry_on_unprocessable_entity_error = 0 + + response = await handler._make_common_async_call( + async_client_session=mock_session, + provider_config=provider_config, + api_base="https://example.com/test", + headers={"Authorization": "Bearer test"}, + data={"input": "hello"}, + timeout=timeout, + litellm_params={}, + form_data=None, + stream=False, + ) + + assert response is mock_response + mock_session.post.assert_awaited_once_with( + url="https://example.com/test", + headers={"Authorization": "Bearer test"}, + json={"input": "hello"}, + data=None, + timeout=timeout, + )