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]

[Bug Fix]: Azure OpenAI GPT-5 max_tokens + `reasoning` param support (#13510)

Ishaan Jaff9f7828700026
diff --git a/docs/my-website/docs/providers/azure/azure.md b/docs/my-website/docs/providers/azure/azure.md
index 69f8db538e0..8471ca94066 100644
--- a/docs/my-website/docs/providers/azure/azure.md
+++ b/docs/my-website/docs/providers/azure/azure.md
@@ -9,8 +9,8 @@ import TabItem from '@theme/TabItem';
| Property | Details |
|-------|-------|
-| Description | Azure OpenAI Service provides REST API access to OpenAI's powerful language models including o1, o1-mini, GPT-4o, GPT-4o mini, GPT-4 Turbo with Vision, GPT-4, GPT-3.5-Turbo, and Embeddings model series |
-| Provider Route on LiteLLM | `azure/`, [`azure/o_series/`](#azure-o-series-models) |
+| Description | Azure OpenAI Service provides REST API access to OpenAI's powerful language models including o1, o1-mini, GPT-5, GPT-4o, GPT-4o mini, GPT-4 Turbo with Vision, GPT-4, GPT-3.5-Turbo, and Embeddings model series |
+| Provider Route on LiteLLM | `azure/`, [`azure/o_series/`](#o-series-models), [`azure/gpt5_series/`](#gpt-5-models) |
| Supported Operations | [`/chat/completions`](#azure-openai-chat-completion-models), [`/responses`](./azure_responses), [`/completions`](#azure-instruct-models), [`/embeddings`](./azure_embedding), [`/audio/speech`](#azure-text-to-speech-tts), [`/audio/transcriptions`](../audio_transcription), `/fine_tuning`, [`/batches`](#azure-batches-api), `/files`, [`/images`](../image_generation#azure-openai-image-generation-models) |
| Link to Provider Doc | [Azure OpenAI ↗](https://learn.microsoft.com/en-us/azure/ai-services/openai/overview)
@@ -207,6 +207,7 @@ model_list:
|------------------|----------------------------------------|
| o1-mini | `response = completion(model="azure/<your deployment name>", messages=messages)` |
| o1-preview | `response = completion(model="azure/<your deployment name>", messages=messages)` |
+| gpt-5 | `response = completion(model="azure/<your deployment name>", messages=messages)` |
| gpt-4o-mini | `completion('azure/<your deployment name>', messages)` |
| gpt-4o | `completion('azure/<your deployment name>', messages)` |
| gpt-4 | `completion('azure/<your deployment name>', messages)` |
@@ -368,6 +369,82 @@ model_list:
</Tabs>
+## GPT-5 Models
+
+| Property | Details |
+|-------|-------|
+| Description | Azure OpenAI GPT-5 models |
+| Provider Route on LiteLLM | `azure/gpt5_series/<custom-name>` or `azure/gpt-5-deployment-name` |
+
+LiteLLM supports using Azure GPT-5 models in one of the two ways:
+1. Explicit Routing: `model = azure/gpt5_series/<deployment-name>`. In this scenario the model onboarded to litellm follows the format `model=azure/gpt5_series/<deployment-name>`.
+2. Inferred Routing (If the azure deployment name contains `gpt-5` in the name): `model = azure/gpt-5-mini`. In this scenario the model onboarded to litellm follows the format `model=azure/gpt-5-mini`.
+
+#### Explicit Routing
+Use `azure/gpt5_series/<deployment-name>` for explicit GPT-5 model routing.
+
+<Tabs>
+<TabItem value="sdk" label="SDK">
+
+```python
+import litellm
+
+response = litellm.completion(
+ model="azure/gpt5_series/my-gpt-5-deployment",
+ messages=[{"role": "user", "content": "Hello, world!"}]
+)
+```
+</TabItem>
+<TabItem value="proxy" label="PROXY">
+
+```yaml
+model_list:
+ - model_name: gpt-5
+ litellm_params:
+ model: azure/gpt5_series/my-gpt-5-deployment
+ api_base: os.environ/AZURE_API_BASE
+ api_key: os.environ/AZURE_API_KEY
+```
+
+</TabItem>
+</Tabs>
+
+#### Inferred Routing (gpt-5 in the deployment name)
+If your Azure deployment name contains `gpt-5`, LiteLLM automatically recognizes it as a GPT-5 model.
+
+<Tabs>
+<TabItem value="sdk" label="SDK">
+
+```python
+import litellm
+
+# Deployment name contains 'gpt-5' - automatically inferred
+response = litellm.completion(
+ model="azure/my-gpt-5-deployment",
+ messages=[{"role": "user", "content": "Hello, world!"}]
+)
+```
+
+</TabItem>
+<TabItem value="proxy" label="PROXY">
+
+```yaml
+model_list:
+ - model_name: gpt-5-mini
+ litellm_params:
+ model: azure/my-gpt-5-deployment # deployment name contains 'gpt-5'
+ api_base: os.environ/AZURE_API_BASE
+ api_key: os.environ/AZURE_API_KEY
+```
+
+</TabItem>
+</Tabs>
+
+
+
+
+
+
## Azure Audio Model
<Tabs>
diff --git a/litellm/__init__.py b/litellm/__init__.py
index d1f06488898..adf1ad4f04c 100644
--- a/litellm/__init__.py
+++ b/litellm/__init__.py
@@ -1200,6 +1200,7 @@ from .llms.azure.azure import (
)
from .llms.azure.chat.gpt_transformation import AzureOpenAIConfig
+from .llms.azure.chat.gpt_5_transformation import AzureOpenAIGPT5Config
from .llms.azure.completion.transformation import AzureOpenAITextConfig
from .llms.hosted_vllm.chat.transformation import HostedVLLMChatConfig
from .llms.llamafile.chat.transformation import LlamafileChatConfig
diff --git a/litellm/caching/caching_handler.py b/litellm/caching/caching_handler.py
index f41b745bb1c..7580752c307 100644
--- a/litellm/caching/caching_handler.py
+++ b/litellm/caching/caching_handler.py
@@ -18,7 +18,6 @@ import asyncio
import datetime
import inspect
import threading
-from functools import lru_cache, wraps
from typing import (
TYPE_CHECKING,
Any,
@@ -36,7 +35,6 @@ from pydantic import BaseModel
import litellm
from litellm._logging import print_verbose, verbose_logger
-from litellm._service_logger import ServiceLogging
from litellm.caching import InMemoryCache
from litellm.caching.caching import S3Cache
from litellm.litellm_core_utils.logging_utils import (
diff --git a/litellm/litellm_core_utils/get_supported_openai_params.py b/litellm/litellm_core_utils/get_supported_openai_params.py
index b2a2c364240..6f2299c777f 100644
--- a/litellm/litellm_core_utils/get_supported_openai_params.py
+++ b/litellm/litellm_core_utils/get_supported_openai_params.py
@@ -121,6 +121,10 @@ def get_supported_openai_params( # noqa: PLR0915
return litellm.AzureOpenAIO1Config().get_supported_openai_params(
model=model
)
+ elif litellm.AzureOpenAIGPT5Config.is_model_gpt_5_model(model=model):
+ return litellm.AzureOpenAIGPT5Config().get_supported_openai_params(
+ model=model
+ )
else:
return litellm.AzureOpenAIConfig().get_supported_openai_params(model=model)
elif custom_llm_provider == "openrouter":
diff --git a/litellm/llms/azure/azure.py b/litellm/llms/azure/azure.py
index 285f176026d..5ee9065f5e1 100644
--- a/litellm/llms/azure/azure.py
+++ b/litellm/llms/azure/azure.py
@@ -230,6 +230,14 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):
)
data = {"model": None, "messages": messages, **optional_params}
+ elif litellm.AzureOpenAIGPT5Config.is_model_gpt_5_model(model=model):
+ data = litellm.AzureOpenAIGPT5Config().transform_request(
+ model=model,
+ messages=messages,
+ optional_params=optional_params,
+ litellm_params=litellm_params,
+ headers=headers or {},
+ )
else:
data = litellm.AzureOpenAIConfig().transform_request(
model=model,
diff --git a/litellm/llms/azure/chat/gpt_5_transformation.py b/litellm/llms/azure/chat/gpt_5_transformation.py
new file mode 100644
index 00000000000..b8c032f4e9d
--- /dev/null
+++ b/litellm/llms/azure/chat/gpt_5_transformation.py
@@ -0,0 +1,58 @@
+"""Support for Azure OpenAI gpt-5 model family."""
+
+from typing import List
+
+from litellm.llms.openai.chat.gpt_5_transformation import OpenAIGPT5Config
+from litellm.types.llms.openai import AllMessageValues
+
+from .gpt_transformation import AzureOpenAIConfig
+
+
+class AzureOpenAIGPT5Config(AzureOpenAIConfig, OpenAIGPT5Config):
+ """Azure specific handling for gpt-5 models."""
+ GPT5_SERIES_ROUTE = "gpt5_series/"
+
+ @classmethod
+ def is_model_gpt_5_model(cls, model: str) -> bool:
+ """Check if the Azure model string refers to a gpt-5 variant.
+
+ Accepts both explicit gpt-5 model names and the ``gpt5_series/`` prefix
+ used for manual routing.
+ """
+ return "gpt-5" in model or "gpt5_series" in model
+
+ def get_supported_openai_params(self, model: str) -> List[str]:
+ return OpenAIGPT5Config.get_supported_openai_params(self, model=model)
+
+ def map_openai_params(
+ self,
+ non_default_params: dict,
+ optional_params: dict,
+ model: str,
+ drop_params: bool,
+ api_version: str = "",
+ ) -> dict:
+ return OpenAIGPT5Config.map_openai_params(
+ self,
+ non_default_params=non_default_params,
+ optional_params=optional_params,
+ model=model,
+ drop_params=drop_params,
+ )
+
+ def transform_request(
+ self,
+ model: str,
+ messages: List[AllMessageValues],
+ optional_params: dict,
+ litellm_params: dict,
+ headers: dict,
+ ) -> dict:
+ model = model.replace(self.GPT5_SERIES_ROUTE, "")
+ return super().transform_request(
+ model=model,
+ messages=messages,
+ optional_params=optional_params,
+ litellm_params=litellm_params,
+ headers=headers,
+ )
diff --git a/litellm/utils.py b/litellm/utils.py
index 1a571d30270..badc4bfba47 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -3927,6 +3927,17 @@ def get_optional_params( # noqa: PLR0915
else False
),
)
+ elif litellm.AzureOpenAIGPT5Config.is_model_gpt_5_model(model=model):
+ optional_params = litellm.AzureOpenAIGPT5Config().map_openai_params(
+ non_default_params=non_default_params,
+ optional_params=optional_params,
+ model=model,
+ drop_params=(
+ drop_params
+ if drop_params is not None and isinstance(drop_params, bool)
+ else False
+ ),
+ )
else:
verbose_logger.debug(
"Azure optional params - api_version: api_version={}, litellm.api_version={}, os.environ['AZURE_API_VERSION']={}".format(
@@ -6860,6 +6871,8 @@ class ProviderConfigManager:
elif litellm.LlmProviders.AZURE == provider:
if litellm.AzureOpenAIO1Config().is_o_series_model(model=model):
return litellm.AzureOpenAIO1Config()
+ if litellm.AzureOpenAIGPT5Config.is_model_gpt_5_model(model=model):
+ return litellm.AzureOpenAIGPT5Config()
return litellm.AzureOpenAIConfig()
elif litellm.LlmProviders.AZURE_AI == provider:
return litellm.AzureAIStudioConfig()
diff --git a/tests/llm_translation/test_azure_ai.py b/tests/llm_translation/test_azure_ai.py
index 3873aa7abff..9f648aee057 100644
--- a/tests/llm_translation/test_azure_ai.py
+++ b/tests/llm_translation/test_azure_ai.py
@@ -297,3 +297,19 @@ async def test_azure_ai_request_format():
model=model,
messages=messages,
)
+
+
[email protected]("model", ["azure/gpt5_series/gpt-5", "azure/gpt-5"])
+async def test_azure_gpt5_reasoning(model):
+ litellm._turn_on_debug()
+ response = await litellm.acompletion(
+ model="azure/gpt5_series/gpt-5",
+ messages=[{"role": "user", "content": "What is the capital of France?"}],
+ reasoning_effort="minimal",
+ max_tokens=10,
+ api_base=os.getenv("AZURE_GPT5_API_BASE"),
+ api_key=os.getenv("AZURE_GPT5_API_KEY"),
+ )
+ print("response: ", response)
+ assert response.choices[0].message.content is not None
diff --git a/tests/test_litellm/llms/azure/chat/test_azure_gpt5_transformation.py b/tests/test_litellm/llms/azure/chat/test_azure_gpt5_transformation.py
new file mode 100644
index 00000000000..81d64d70578
--- /dev/null
+++ b/tests/test_litellm/llms/azure/chat/test_azure_gpt5_transformation.py
@@ -0,0 +1,48 @@
+import pytest
+
+import litellm
+from litellm.llms.azure.chat.gpt_5_transformation import AzureOpenAIGPT5Config
+
+
+def config() -> AzureOpenAIGPT5Config:
+ return AzureOpenAIGPT5Config()
+
+
+def test_azure_gpt5_supports_reasoning_effort(config: AzureOpenAIGPT5Config):
+ assert "reasoning_effort" in config.get_supported_openai_params(model="gpt-5")
+ assert "reasoning_effort" in config.get_supported_openai_params(model="gpt5_series/my-deployment")
+
+
+def test_azure_gpt5_maps_max_tokens(config: AzureOpenAIGPT5Config):
+ params = config.map_openai_params(
+ non_default_params={"max_tokens": 5},
+ optional_params={},
+ model="gpt5_series/gpt-5",
+ drop_params=False,
+ api_version="2024-05-01-preview",
+ )
+ assert params["max_completion_tokens"] == 5
+ assert "max_tokens" not in params
+
+
+def test_azure_gpt5_temperature_error(config: AzureOpenAIGPT5Config):
+ with pytest.raises(litellm.utils.UnsupportedParamsError):
+ config.map_openai_params(
+ non_default_params={"temperature": 0.2},
+ optional_params={},
+ model="gpt-5",
+ drop_params=False,
+ api_version="2024-05-01-preview",
+ )
+
+
+def test_azure_gpt5_series_transform_request(config: AzureOpenAIGPT5Config):
+ request = config.transform_request(
+ model="gpt5_series/gpt-5",
+ messages=[],
+ optional_params={},
+ litellm_params={},
+ headers={},
+ )
+ assert request["model"] == "gpt-5"