Skip to content

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]

test(azure_ai): drop responses test __init__ to fix package name collision; cover api-version, missing api_base, AD fallback

shivam34d32c04e5cd
diff --git a/tests/test_litellm/llms/azure_ai/responses/__init__.py b/tests/test_litellm/llms/azure_ai/responses/__init__.py
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/tests/test_litellm/llms/azure_ai/responses/test_azure_ai_responses_transformation.py b/tests/test_litellm/llms/azure_ai/responses/test_azure_ai_responses_transformation.py
index 0a2f2a4ab8e..b853b114645 100644
--- a/tests/test_litellm/llms/azure_ai/responses/test_azure_ai_responses_transformation.py
+++ b/tests/test_litellm/llms/azure_ai/responses/test_azure_ai_responses_transformation.py
@@ -103,6 +103,25 @@ def test_get_complete_url(api_base, expected):
assert config.get_complete_url(api_base=api_base, litellm_params={}) == expected
+def test_get_complete_url_adds_api_version_from_params():
+ config = AzureAIResponsesAPIConfig()
+ url = config.get_complete_url(
+ api_base="https://res.services.ai.azure.com/api/projects/proj",
+ litellm_params={"api_version": "2025-04-01-preview"},
+ )
+ assert url == (
+ "https://res.services.ai.azure.com/api/projects/proj/openai/v1/responses?api-version=2025-04-01-preview"
+ )
+
+
+def test_get_complete_url_raises_without_api_base(monkeypatch):
+ monkeypatch.setattr(litellm, "api_base", None)
+ monkeypatch.delenv("AZURE_AI_API_BASE", raising=False)
+ config = AzureAIResponsesAPIConfig()
+ with pytest.raises(ValueError):
+ config.get_complete_url(api_base=None, litellm_params={})
+
+
def test_validate_environment_api_key_header_for_foundry_host():
config = AzureAIResponsesAPIConfig()
headers = config.validate_environment(
@@ -129,6 +148,22 @@ def test_validate_environment_bearer_for_serverless_host():
assert "api-key" not in headers
+def test_validate_environment_falls_back_to_base_azure_env_without_key(monkeypatch):
+ monkeypatch.setattr(litellm, "api_key", None)
+ monkeypatch.setattr(litellm, "openai_key", None)
+ monkeypatch.delenv("AZURE_AI_API_KEY", raising=False)
+ monkeypatch.delenv("AZURE_OPENAI_API_KEY", raising=False)
+ monkeypatch.delenv("AZURE_API_KEY", raising=False)
+ config = AzureAIResponsesAPIConfig()
+ headers = config.validate_environment(
+ headers={},
+ model="gpt-5.6-luna",
+ litellm_params=GenericLiteLLMParams(api_base="https://res.services.ai.azure.com/api/projects/proj"),
+ )
+ assert headers["Content-Type"] == "application/json"
+ assert "api-key" not in headers
+
+
@pytest.mark.asyncio
async def test_aresponses_routes_to_native_endpoint_with_reasoning_and_tools():
"""Core LIT-4427 regression: reasoning_effort + function tools must be sent to the