From 9a13294f20abc08a66cb9e9c278de77c7caf6d17 Mon Sep 17 00:00:00 2001 From: Mrun25 <165297479+Mrun25@users.noreply.github.com> Date: Fri, 16 Oct 2026 14:18:06 +0530 Subject: [PATCH] fix(azure): strip gpt5_series routing marker from Responses API deployment name get_stripped_model_name stripped responses/, o_series/ and azure_ai/ but not gpt5_series/, so Azure received the routing prefix as part of the deployment name and the Responses call failed. Fixes #46866 --- .../llms/azure/responses/transformation.py | 8 ++++++- .../response/test_azure_transformation.py | 24 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/litellm/llms/azure/responses/transformation.py b/litellm/llms/azure/responses/transformation.py index 98b4241d7ab..199b097af1d 100644 --- a/litellm/llms/azure/responses/transformation.py +++ b/litellm/llms/azure/responses/transformation.py @@ -52,7 +52,13 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig): return BaseAzureLLM.base_validate_azure_environment(headers=headers, litellm_params=litellm_params) def get_stripped_model_name(self, model: str) -> str: - return model.replace("responses/", "").replace("o_series/", "").replace("azure_ai/", "") + # gpt5_series/ is a litellm routing marker, not part of the Azure deployment name + return ( + model.replace("responses/", "") + .replace("o_series/", "") + .replace("azure_ai/", "") + .replace(AzureOpenAIGPT5Config.GPT5_SERIES_ROUTE, "") + ) def _handle_reasoning_item(self, item: dict[str, Any]) -> dict[str, Any]: """ diff --git a/tests/unit/llms/azure/response/test_azure_transformation.py b/tests/unit/llms/azure/response/test_azure_transformation.py index fea5304a689..3478603e49a 100644 --- a/tests/unit/llms/azure/response/test_azure_transformation.py +++ b/tests/unit/llms/azure/response/test_azure_transformation.py @@ -19,6 +19,30 @@ from litellm.types.utils import LlmProviders from litellm.utils import ProviderConfigManager +@pytest.mark.serial +def test_get_stripped_model_name_strips_gpt5_series_route(): + """The gpt5_series/ routing marker must not be sent to Azure as part of the deployment name.""" + config = AzureOpenAIResponsesAPIConfig() + + assert ( + config.get_stripped_model_name("azure/gpt5_series/my-gpt5-deployment") + == "azure/my-gpt5-deployment" + ) + assert ( + config.get_stripped_model_name("azure/responses/gpt5_series/my-gpt5-deployment") + == "azure/my-gpt5-deployment" + ) + # existing markers still strip, and plain deployments pass through untouched + assert ( + config.get_stripped_model_name("azure/o_series/my-o3-deployment") + == "azure/my-o3-deployment" + ) + assert ( + config.get_stripped_model_name("azure/my-gpt5-deployment") + == "azure/my-gpt5-deployment" + ) + + @pytest.mark.serial def test_validate_environment_api_key_within_litellm_params(): azure_openai_responses_apiconfig = AzureOpenAIResponsesAPIConfig()