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 flaky CI tests: mock timeout race, update deprecated model, fix callback leak
yuneng-jiang023654d9ad52
diff --git a/tests/local_testing/conftest.py b/tests/local_testing/conftest.pyindex e3809e93bdb..6c5c0d3b35c 100644--- a/tests/local_testing/conftest.py+++ b/tests/local_testing/conftest.py@@ -54,6 +54,7 @@ def isolate_litellm_state():# Clear callbacks before testfor attr in (+ "callbacks","success_callback","failure_callback","_async_success_callback",diff --git a/tests/local_testing/test_completion.py b/tests/local_testing/test_completion.pyindex 51ed6a53bbb..800ee382ffa 100644--- a/tests/local_testing/test_completion.py+++ b/tests/local_testing/test_completion.py@@ -2937,7 +2937,7 @@ def test_completion_together_ai_mixtral():def test_completion_together_ai_llama():litellm.set_verbose = True- model_name = "together_ai/meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo"+ model_name = "together_ai/meta-llama/Llama-3.2-3B-Instruct-Turbo"try:messages = [{"role": "user", "content": "What llm are you?"},diff --git a/tests/local_testing/test_timeout.py b/tests/local_testing/test_timeout.pyindex bca299f817b..4128a595d76 100644--- a/tests/local_testing/test_timeout.py+++ b/tests/local_testing/test_timeout.py@@ -94,8 +94,15 @@ def test_bedrock_timeout():def test_hanging_request_azure():+ """+ Test that a slow Azure request properly raises APITimeoutError via the Router.++ Uses a mock to simulate a slow HTTP response so the timeout fires reliably,+ rather than racing against real network latency.+ """litellm.set_verbose = Trueimport asyncio+ from unittest.mock import AsyncMock, patchtry:router = litellm.Router(@@ -103,7 +110,7 @@ def test_hanging_request_azure():{"model_name": "azure-gpt","litellm_params": {- "model": "azure/gpt-4o-new-test",+ "model": "azure/gpt-4.1-mini","api_base": os.environ["AZURE_API_BASE"],"api_key": os.environ["AZURE_API_KEY"],},@@ -118,17 +125,27 @@ def test_hanging_request_azure():encoded = litellm.utils.encode(model="gpt-3.5-turbo", text="blue")[0]+ original_send = httpx.AsyncClient.send++ async def _slow_send(self, request, *args, **kwargs):+ await asyncio.sleep(5)+ return await original_send(self, request, *args, **kwargs)+async def _test():- response = await router.acompletion(- model="azure-gpt",- messages=[- {"role": "user", "content": f"what color is red {uuid.uuid4()}"}- ],- logit_bias={encoded: 100},- timeout=0.01,- )- print(response)- return response+ with patch.object(httpx.AsyncClient, "send", new=_slow_send):+ response = await router.acompletion(+ model="azure-gpt",+ messages=[+ {+ "role": "user",+ "content": f"what color is red {uuid.uuid4()}",+ }+ ],+ logit_bias={encoded: 100},+ timeout=0.01,+ )+ print(response)+ return responseresponse = asyncio.run(_test())