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]

fix(azure): keep the model group segment exact and casefold only deployment names in the relay guard

mateo-berri5ea447e29510
diff --git a/litellm/llms/azure/passthrough/transformation.py b/litellm/llms/azure/passthrough/transformation.py
index 69767bb29a3..1b5a4083ebe 100644
--- a/litellm/llms/azure/passthrough/transformation.py
+++ b/litellm/llms/azure/passthrough/transformation.py
@@ -82,11 +82,10 @@ def foreign_azure_deployment(
if match is None:
return None
deployment: Final = match.group(1)
- folded: Final = deployment.casefold()
- if folded == model_group.casefold():
+ if deployment == model_group:
return None
served: Final = frozenset(name.casefold() for name in served_models())
- return None if folded in served else deployment
+ return None if deployment.casefold() in served else deployment
def without_api_version(api_base: str) -> str:
diff --git a/tests/test_litellm/llms/azure/passthrough/test_azure_passthrough_transformation.py b/tests/test_litellm/llms/azure/passthrough/test_azure_passthrough_transformation.py
index 798ef1f5a4f..c7e86616ee2 100644
--- a/tests/test_litellm/llms/azure/passthrough/test_azure_passthrough_transformation.py
+++ b/tests/test_litellm/llms/azure/passthrough/test_azure_passthrough_transformation.py
@@ -457,7 +457,7 @@ def test_azure_passthrough_is_streaming_request_reads_the_stream_flag(request_da
("openai/deployments/gpt/chat/completions", None),
("gpt/openai/deployments/gpt-5.4-mini/chat/completions", None),
("gpt/openai/deployments/GPT-5.4-MINI/chat/completions", None),
- ("gpt/openai/deployments/Gpt/chat/completions", None),
+ ("gpt/openai/deployments/Gpt/chat/completions", "Gpt"),
("gpt/models/chat/completions", None),
("gpt/openai/deployments/gpt-5.4/chat/completions", "gpt-5.4"),
("gpt/openai/deployments/other-group/chat/completions", "other-group"),
@@ -473,7 +473,7 @@ def test_foreign_azure_deployment_skips_the_router_when_the_segment_is_the_group
def served_models():
raise AssertionError("the router must not be consulted for the group's own name")
- assert foreign_azure_deployment("gpt/openai/deployments/Gpt/chat/completions", "gpt", served_models) is None
+ assert foreign_azure_deployment("gpt/openai/deployments/gpt/chat/completions", "gpt", served_models) is None
@pytest.mark.parametrize(