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(