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(tests): move test_router_azure_acompletion to llm_translation testing (#21837)
Ishaan Jaffd7b22d340b29
diff --git a/tests/llm_translation/test_router_llm_translation_tests.py b/tests/llm_translation/test_router_llm_translation_tests.pyindex 49d06afac1c..61446ce6136 100644--- a/tests/llm_translation/test_router_llm_translation_tests.py+++ b/tests/llm_translation/test_router_llm_translation_tests.py@@ -2,13 +2,17 @@Uses litellm.Router, ensures router.completion and router.acompletion pass BaseLLMChatTest"""+import asyncioimport osimport sys+import pytest+sys.path.insert(0, os.path.abspath("../..")) # Adds the parent directory to the system path+import litellmfrom base_llm_unit_tests import BaseLLMChatTestfrom litellm.router import Routerfrom litellm._logging import verbose_logger, verbose_router_logger@@ -50,3 +54,81 @@ class TestRouterLLMTranslation(BaseLLMChatTest):Works locally but CI/CD is failing this test. Temporary skip to push out a new release."""pass+++def test_router_azure_acompletion():+ # [PROD TEST CASE]+ # This is 90% of the router use case, makes an acompletion call, acompletion + stream call and verifies it got a response+ # DO NOT REMOVE THIS TEST. It's an IMP ONE. Speak to Ishaan, if you are tring to remove this+ litellm.set_verbose = False++ try:+ print("Router Test Azure - Acompletion, Acompletion with stream")++ # remove api key from env to repro how proxy passes key to router+ old_api_key = os.environ["AZURE_API_KEY"]+ os.environ.pop("AZURE_API_KEY", None)++ model_list = [+ {+ "model_name": "gpt-3.5-turbo", # openai model name+ "litellm_params": { # params for litellm completion/embedding call+ "model": "azure/gpt-4.1-mini",+ "api_key": old_api_key,+ "api_version": os.getenv("AZURE_API_VERSION"),+ "api_base": os.getenv("AZURE_API_BASE"),+ },+ "rpm": 1800,+ },+ {+ "model_name": "gpt-3.5-turbo", # openai model name+ "litellm_params": { # params for litellm completion/embedding call+ "model": "azure/gpt-4.1-mini",+ "api_key": old_api_key,+ "api_version": os.getenv("AZURE_API_VERSION"),+ "api_base": os.getenv("AZURE_API_BASE"),+ },+ "rpm": 1800,+ },+ ]++ router = Router(+ model_list=model_list, routing_strategy="simple-shuffle", set_verbose=True+ ) # type: ignore++ async def test1():+ response = await router.acompletion(+ model="gpt-3.5-turbo",+ messages=[{"role": "user", "content": "hello this request will pass"}],+ )+ str_response = response.choices[0].message.content+ print("\n str_response", str_response)+ assert len(str_response) > 0+ print("\n response", response)++ asyncio.run(test1())++ print("\n Testing streaming response")++ async def test2():+ response = await router.acompletion(+ model="gpt-3.5-turbo",+ messages=[{"role": "user", "content": "hello this request will pass"}],+ stream=True,+ )+ completed_response = ""+ async for chunk in response:+ if chunk is not None:+ print(chunk)+ completed_response += chunk.choices[0].delta.content or ""+ print("\n completed_response", completed_response)+ assert len(completed_response) > 0++ asyncio.run(test2())+ print("\n Passed Streaming")+ os.environ["AZURE_API_KEY"] = old_api_key+ router.reset()+ except Exception as e:+ os.environ["AZURE_API_KEY"] = old_api_key+ print(f"FAILED TEST")+ pytest.fail(f"Got unexpected exception on router! - {e}")diff --git a/tests/local_testing/test_router.py b/tests/local_testing/test_router.pyindex 3be06374408..5da618d6399 100644--- a/tests/local_testing/test_router.py+++ b/tests/local_testing/test_router.py@@ -594,84 +594,6 @@ def test_call_one_endpoint():# test_call_one_endpoint()-def test_router_azure_acompletion():- # [PROD TEST CASE]- # This is 90% of the router use case, makes an acompletion call, acompletion + stream call and verifies it got a response- # DO NOT REMOVE THIS TEST. It's an IMP ONE. Speak to Ishaan, if you are tring to remove this- litellm.set_verbose = False- import openai-- try:- print("Router Test Azure - Acompletion, Acompletion with stream")-- # remove api key from env to repro how proxy passes key to router- old_api_key = os.environ["AZURE_API_KEY"]- os.environ.pop("AZURE_API_KEY", None)-- model_list = [- {- "model_name": "gpt-3.5-turbo", # openai model name- "litellm_params": { # params for litellm completion/embedding call- "model": "azure/gpt-4.1-mini",- "api_key": old_api_key,- "api_version": os.getenv("AZURE_API_VERSION"),- "api_base": os.getenv("AZURE_API_BASE"),- },- "rpm": 1800,- },- {- "model_name": "gpt-3.5-turbo", # openai model name- "litellm_params": { # params for litellm completion/embedding call- "model": "azure/gpt-4.1-mini",- "api_key": old_api_key,- "api_version": os.getenv("AZURE_API_VERSION"),- "api_base": os.getenv("AZURE_API_BASE"),- },- "rpm": 1800,- },- ]-- router = Router(- model_list=model_list, routing_strategy="simple-shuffle", set_verbose=True- ) # type: ignore-- async def test1():- response = await router.acompletion(- model="gpt-3.5-turbo",- messages=[{"role": "user", "content": "hello this request will pass"}],- )- str_response = response.choices[0].message.content- print("\n str_response", str_response)- assert len(str_response) > 0- print("\n response", response)-- asyncio.run(test1())-- print("\n Testing streaming response")-- async def test2():- response = await router.acompletion(- model="gpt-3.5-turbo",- messages=[{"role": "user", "content": "hello this request will fail"}],- stream=True,- )- completed_response = ""- async for chunk in response:- if chunk is not None:- print(chunk)- completed_response += chunk.choices[0].delta.content or ""- print("\n completed_response", completed_response)- assert len(completed_response) > 0-- asyncio.run(test2())- print("\n Passed Streaming")- os.environ["AZURE_API_KEY"] = old_api_key- router.reset()- except Exception as e:- os.environ["AZURE_API_KEY"] = old_api_key- print(f"FAILED TEST")- pytest.fail(f"Got unexpected exception on router! - {e}")-@pytest.mark.asyncio@pytest.mark.parametrize("sync_mode", [True, False])