openai / openai/openai-python

Add convenience methods for detecting model parameter support (temperature, reasoning)

Open
#3,073 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
31.6k
Forks
5.7k
Avg merge
1d 6h
Merged PRs (30d)
96

Description

Confirm this is a feature request for the Python library and not the underlying OpenAI API.
  • This is a feature request for the Python library
Describe the feature or improvement you're requesting

Feature request

When building applications that support multiple OpenAI models (e.g., gpt-4.1-mini, gpt-5, gpt-5.1, gpt-5.4), developers need to know which parameters each model supports. Currently this requires maintaining hardcoded model lists or prefix checks, which break as new models are released.

The problem

Different model families have different parameter constraints:

  • temperature: Supported by gpt-4.x but rejected by gpt-5.x reasoning models when reasoning_effort != none
  • reasoning: Only supported by gpt-5 family models, not gpt-4.x
  • reasoning.effort values: Vary by model — gpt-5 supports minimal/low/medium/high, gpt-5.1+ adds none, gpt-5.4+ adds xhigh

Today, developers must write code like:

def is_reasoning_model(model: str) -> bool:
    return model.startswith("gpt-5")

def get_reasoning_effort_options(model: str) -> list[str]:
    if not is_reasoning_model(model):
        return []
    if model.startswith("gpt-5."):
        minor = int(model[6:].split("-")[0])
        options = ["none", "low", "medium", "high"]
        if minor >= 4:
            options.append("xhigh")
        return options
    return ["minimal", "low", "medium", "high"]

This is fragile — it breaks whenever a new model family is released, and the version-based logic for effort levels is reverse-engineered from documentation rather than provided by the SDK.

Proposed solution

Add model capability metadata to the SDK in some way, for example:

# Check if a parameter is supported
openai.models.supports(model="gpt-5.4", parameter="temperature")  # False
openai.models.supports(model="gpt-5.4", parameter="reasoning")  # True

# Get valid values for an enum parameter
openai.models.valid_values(model="gpt-5.4", parameter="reasoning.effort")
# ["none", "low", "medium", "high", "xhigh"]

openai.models.valid_values(model="gpt-5", parameter="reasoning.effort")
# ["minimal", "low", "medium", "high"]

Or alternatively, expose it as model metadata:

from openai.models import get_model_capabilities

caps = get_model_capabilities("gpt-5.4")
caps.supports_temperature  # False
caps.supports_reasoning  # True
caps.reasoning_effort_options  # ["none", "low", "medium", "high", "xhigh"]
Use case

This came up while migrating azure-search-openai-demo from Chat Completions to the Responses API. The app supports multiple model deployments and needs to dynamically adjust which parameters it sends and presents in the UI for users. I imagine there are many similar apps that provide users with model options and parameters.

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no implementation files, tests, or entry points. Start by locating the Python library's model-related public API and existing model metadata, then determine how capability checks and valid reasoning-effort values should be represented; done means documented behavior for the listed model families and coverage for supported and unsupported parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.