From 7fb6643b465bcb27d2e9ba29415bc2f7de111ae2 Mon Sep 17 00:00:00 2001 From: IvanShang <77005282+qdivan@users.noreply.github.com> Date: Wed, 26 Aug 2026 09:37:04 +0800 Subject: [PATCH] fix(azure_ai): preserve OpenAI model provider identity --- litellm/llms/azure_ai/chat/transformation.py | 20 ------------------- .../chat/test_azure_ai_transformation.py | 11 ++++------ 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/litellm/llms/azure_ai/chat/transformation.py b/litellm/llms/azure_ai/chat/transformation.py index 9e7161120cc..396072b6748 100644 --- a/litellm/llms/azure_ai/chat/transformation.py +++ b/litellm/llms/azure_ai/chat/transformation.py @@ -8,7 +8,6 @@ import httpx from httpx import Response import litellm -from litellm._logging import verbose_logger from litellm.litellm_core_utils.prompt_templates.common_utils import ( _audio_or_image_in_message_content, convert_content_list_to_str, @@ -204,21 +203,6 @@ class AzureAIStudioConfig(OpenAIConfig): message["content"] = texts return stripped_messages - def _is_azure_openai_model(self, model: str, api_base: str | None) -> bool: - try: - if "/" in model: - model = model.split("/", 1)[1] - if ( - model in litellm.open_ai_chat_completion_models - or model in litellm.open_ai_text_completion_models - or model in litellm.open_ai_embedding_models - ): - return True - - except Exception: - return False - return False - def _get_openai_compatible_provider_info( self, model: str, @@ -228,10 +212,6 @@ class AzureAIStudioConfig(OpenAIConfig): ) -> tuple[str | None, str | None, str]: api_base = api_base or get_secret_str("AZURE_AI_API_BASE") dynamic_api_key: Final = api_key or get_secret_str("AZURE_AI_API_KEY") - - if self._is_azure_openai_model(model=model, api_base=api_base): - verbose_logger.debug("Model=%s is Azure OpenAI model. Setting custom_llm_provider='azure'.", model) - custom_llm_provider = "azure" return api_base, dynamic_api_key, custom_llm_provider def transform_request( diff --git a/tests/test_litellm/llms/azure_ai/chat/test_azure_ai_transformation.py b/tests/test_litellm/llms/azure_ai/chat/test_azure_ai_transformation.py index 11a727c9635..99f4a329fd5 100644 --- a/tests/test_litellm/llms/azure_ai/chat/test_azure_ai_transformation.py +++ b/tests/test_litellm/llms/azure_ai/chat/test_azure_ai_transformation.py @@ -10,11 +10,8 @@ from litellm.llms.azure_ai.chat.transformation import AzureAIStudioConfig @pytest.mark.asyncio -async def test_get_openai_compatible_provider_info(): - """ - Test that Azure AI requests are formatted correctly with the proper endpoint and parameters - for both synchronous and asynchronous calls - """ +async def test_azure_ai_openai_model_keeps_azure_ai_provider(): + """OpenAI-named Azure AI deployments must retain Azure AI pricing identity.""" config = AzureAIStudioConfig() ( @@ -22,13 +19,13 @@ async def test_get_openai_compatible_provider_info(): dynamic_api_key, custom_llm_provider, ) = config._get_openai_compatible_provider_info( - model="azure_ai/gpt-4o-mini", + model="azure_ai/gpt-5.4-nano", api_base="https://my-base", api_key="my-key", custom_llm_provider="azure_ai", ) - assert custom_llm_provider == "azure" + assert custom_llm_provider == "azure_ai" def test_azure_ai_validate_environment():