From 9b0da0618b41a9600b7b2b4d9a6647f69e6bf8d8 Mon Sep 17 00:00:00 2001 From: Filippo Mattia Menghi Date: Wed, 10 Jun 2026 09:26:54 +0200 Subject: [PATCH] fix(openai/gpt-5): detect gpt-5.4+ in prefixed custom deployment names is_model_gpt_5_4_plus_model required the model name to start with "gpt-5.", so prefixed Azure deployment names like my-prefix-gpt-5.5 returned False and the Responses API bridge never engaged, causing "Function tools with reasoning_effort are not supported" errors on chat completions. Locate "gpt-5." inside the last path segment and run the existing version parse from there, matching the substring approach already used by is_model_gpt_5_model. Fixes #28782. --- .../llms/openai/chat/gpt_5_transformation.py | 10 +++++++-- .../llms/openai/test_gpt5_transformation.py | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/litellm/llms/openai/chat/gpt_5_transformation.py b/litellm/llms/openai/chat/gpt_5_transformation.py index 9ccb2e1c267..6923a3a4612 100644 --- a/litellm/llms/openai/chat/gpt_5_transformation.py +++ b/litellm/llms/openai/chat/gpt_5_transformation.py @@ -103,10 +103,16 @@ class OpenAIGPT5Config(OpenAIGPTConfig): @classmethod def is_model_gpt_5_4_plus_model(cls, model: str) -> bool: - """Check if the model is gpt-5.4 or newer (5.4, 5.5, 5.6, etc., including pro).""" + """Check if the model is gpt-5.4 or newer (5.4, 5.5, 5.6, etc., including pro). + + Handles custom deployment names with prefixes (e.g. Azure deployments + like ``my-prefix-gpt-5.5``) by locating ``gpt-5.`` inside the name. + """ model_name = model.split("/")[-1] - if not model_name.startswith("gpt-5."): + idx = model_name.find("gpt-5.") + if idx == -1: return False + model_name = model_name[idx:] try: version_str = model_name.replace("gpt-5.", "").split("-")[0] major = version_str.split(".")[0] diff --git a/tests/test_litellm/llms/openai/test_gpt5_transformation.py b/tests/test_litellm/llms/openai/test_gpt5_transformation.py index d279b119efe..ad0658615bd 100644 --- a/tests/test_litellm/llms/openai/test_gpt5_transformation.py +++ b/tests/test_litellm/llms/openai/test_gpt5_transformation.py @@ -342,6 +342,27 @@ def test_gpt5_4_pro_allows_reasoning_effort_xhigh(config: OpenAIConfig): assert params["reasoning_effort"] == "xhigh" +def test_is_model_gpt_5_4_plus_model_prefixed_deployment_names( + gpt5_config: OpenAIGPT5Config, +): + """Custom deployment names with prefixes (e.g. Azure) are recognized as gpt-5.4+.""" + assert gpt5_config.is_model_gpt_5_4_plus_model("my-prefix-gpt-5.5") + assert gpt5_config.is_model_gpt_5_4_plus_model("azure/something-something-gpt-5.5") + assert gpt5_config.is_model_gpt_5_4_plus_model("my-prefix-gpt-5.4-pro") + assert gpt5_config.is_model_gpt_5_4_plus_model("gpt-5.4") + assert gpt5_config.is_model_gpt_5_4_plus_model("openai/gpt-5.6") + + +def test_is_model_gpt_5_4_plus_model_rejects_non_5_4_plus_names( + gpt5_config: OpenAIGPT5Config, +): + """Names below 5.4 or merely containing gpt-5 without a version must not match.""" + assert not gpt5_config.is_model_gpt_5_4_plus_model("my-prefix-gpt-5.2") + assert not gpt5_config.is_model_gpt_5_4_plus_model("my-gpt-5-deployment") + assert not gpt5_config.is_model_gpt_5_4_plus_model("gpt-5") + assert not gpt5_config.is_model_gpt_5_4_plus_model("azure/prefix-gpt-5.x") + + def test_gpt5_4_mini_allows_reasoning_effort_xhigh(config: OpenAIConfig): """gpt-5.4-mini supports reasoning_effort='xhigh'.""" params = config.map_openai_params(