Skip to content

Conversation

@xingyaoww
Copy link
Collaborator

@xingyaoww xingyaoww commented Nov 3, 2025

Problem

Azure OpenAI Responses API was incorrectly blocking the temperature parameter for GPT-5 models with the following error:

litellm.exceptions.UnsupportedParamsError: LlmProviders.AZURE does not support parameters: {'temperature': 1.0}, for model=gpt-5

However, according to both OpenAI documentation and Azure AI documentation, the Responses API does support the temperature parameter for non-O-series models.

Source issue: fix OpenHands/software-agent-sdk#986

Root Cause

The bug occurred because LiteLLM was using supports_reasoning(model) as a proxy to detect O-series models (o1, o3, o4). This caused GPT-5 to be incorrectly classified:

  1. In litellm/utils.py (line 7400): Used supports_reasoning(model) to determine if a model should use AzureOpenAIOSeriesResponsesAPIConfig
  2. In litellm/llms/azure/responses/o_series_transformation.py (line 93): The is_o_series_model() method also used supports_reasoning(model)
  3. The Issue: GPT-5 has "supports_reasoning": true in model_prices_and_context_window.json, but GPT-5 is NOT an O-series model
  4. Result: GPT-5 incorrectly used AzureOpenAIOSeriesResponsesAPIConfig which blocks temperature, instead of AzureOpenAIResponsesAPIConfig which allows it

The Key Distinction

  • O-series models are specific model families: o1, o3, o4 (e.g., o1-preview, o3-mini)
    • These models have parameter restrictions (no temperature, etc.)
  • Models that support reasoning is a broader category that includes:
    • O-series models (o1, o3, o4)
    • GPT-5 (supports reasoning but is NOT O-series)

Solution

Updated the O-series detection logic to check for specific model name patterns instead of using the supports_reasoning flag:

Changes Made

  1. litellm/llms/azure/responses/o_series_transformation.py:

    • Updated is_o_series_model() to check for explicit O-series model names: "o1", "o3", "o4", or "o_series" in model name
    • Removed dependency on supports_reasoning()
    • Removed unused supports_reasoning import
  2. litellm/utils.py:

    • Updated ProviderConfigManager.get_provider_responses_api_config() to use explicit O-series model name checks
    • No longer relies on supports_reasoning() for determining config selection
  3. tests/test_litellm/llms/azure/response/test_azure_transformation.py:

    • Enhanced test_o_series_model_detection() to include GPT-5 test cases
    • Enhanced test_provider_config_manager_o_series_selection() to verify:
      • GPT-5 gets AzureOpenAIResponsesAPIConfig (not O-series config)
      • GPT-5 supports the temperature parameter
      • O1/O3 models still correctly get AzureOpenAIOSeriesResponsesAPIConfig

Verification

Before Fix

config = ProviderConfigManager.get_provider_responses_api_config(
    provider=litellm.LlmProviders.AZURE, model="gpt-5"
)
# Returns: AzureOpenAIOSeriesResponsesAPIConfig (WRONG!)
# Temperature supported: False (BUG!)

After Fix

config = ProviderConfigManager.get_provider_responses_api_config(
    provider=litellm.LlmProviders.AZURE, model="gpt-5"
)
# Returns: AzureOpenAIResponsesAPIConfig (CORRECT!)
# Temperature supported: True (FIXED!)

Test Results

Model: gpt-5          (Regular model with reasoning support)
  Config: AzureOpenAIResponsesAPIConfig
  Supports temperature: True ✓

Model: gpt-4o         (Regular model)
  Config: AzureOpenAIResponsesAPIConfig
  Supports temperature: True ✓

Model: o1-preview     (O-series model)
  Config: AzureOpenAIOSeriesResponsesAPIConfig
  Supports temperature: False ✓

Model: o3-mini        (O-series model)
  Config: AzureOpenAIOSeriesResponsesAPIConfig
  Supports temperature: False ✓

All 15 tests in test_azure_transformation.py pass ✅

Impact

  • ✅ GPT-5 now correctly supports the temperature parameter on Azure Responses API
  • ✅ O-series models (o1, o3, o4) continue to work correctly with appropriate restrictions
  • ✅ All existing functionality remains intact
  • ✅ No breaking changes

Files Changed

  • litellm/llms/azure/responses/o_series_transformation.py (+7, -6)
  • litellm/utils.py (+4, -2)
  • tests/test_litellm/llms/azure/response/test_azure_transformation.py (+38, -0)

Total: 3 files changed, 48 insertions(+), 9 deletions(-)

@xingyaoww can click here to continue refining the PR

…PT-5

**Problem:**
Azure OpenAI Responses API was incorrectly blocking the temperature parameter
for GPT-5 models. The issue occurred because the code was using
supports_reasoning() as a proxy to detect O-series models (o1, o3, etc.).
Since GPT-5 has supports_reasoning=true in model_prices_and_context_window.json,
it was incorrectly treated as an O-series model, which blocks temperature.

**Root Cause:**
1. In utils.py line 7400: Used supports_reasoning(model) to detect O-series models
2. In o_series_transformation.py line 93: is_o_series_model() also used supports_reasoning()
3. GPT-5 supports reasoning but is NOT an O-series model

**Solution:**
- Updated is_o_series_model() in o_series_transformation.py to check for specific
  O-series model names (o1, o3, o4) instead of using supports_reasoning()
- Updated config selection logic in utils.py to use explicit O-series model name
  checks instead of supports_reasoning()
- Removed unused supports_reasoning import from o_series_transformation.py

**Testing:**
- Enhanced test_o_series_model_detection() to verify GPT-5 is correctly identified
  as NOT O-series
- Enhanced test_provider_config_manager_o_series_selection() to verify:
  - GPT-5 gets AzureOpenAIResponsesAPIConfig (not O-series config)
  - GPT-5 supports temperature parameter
  - O1/O3 models still get O-series config correctly
- All existing tests pass

Fixes: Azure GPT-5 temperature parameter blocked incorrectly
Co-authored-by: openhands <[email protected]>
@vercel
Copy link

vercel bot commented Nov 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Nov 4, 2025 2:30pm

@krrishdholakia
Copy link
Contributor

this change seems wrong @xingyaoww , shouldn't it be to make sure gpt-5 is not routed into the o-series logic?

- Use startswith() for o1/o3/o4 prefix matching instead of substring search
- Prevents false positives with models like 'gpt-4o1' or 'modelo3'
- Aligns with OpenAI implementation pattern in openai/chat/o_series_transformation.py
- Handle 'o_series/' routing prefix explicitly
- Add edge case tests to verify no false positives
- All 15 tests pass including GPT-5 validation

Co-authored-by: openhands <[email protected]>
@xingyaoww
Copy link
Collaborator Author

@krrishdholakia maybe this is the correct fix: #16246

@xingyaoww xingyaoww closed this Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Azure GPT-5 fails due to hardcoded temperature in responses_options.py

4 participants