跳转至

Default Models

gpt_5_reasoning_settings_required

gpt_5_reasoning_settings_required(model_name: str) -> bool

Returns True if the model name is a GPT-5 model and reasoning settings are required.

Source code in src/agents/models/default_models.py
def gpt_5_reasoning_settings_required(model_name: str) -> bool:
    """
    Returns True if the model name is a GPT-5 model and reasoning settings are required.
    """
    if any(pattern.fullmatch(model_name) for pattern in _GPT_5_CHAT_MODEL_PATTERNS):
        # Chat-latest aliases do not accept reasoning.effort.
        return False
    # matches any of gpt-5 models
    return model_name.startswith("gpt-5")

is_gpt_5_default

is_gpt_5_default() -> bool

Returns True if the default model is a GPT-5 model. This is used to determine if the default model settings are compatible with GPT-5 models. If the default model is not a GPT-5 model, the model settings are compatible with other models.

Source code in src/agents/models/default_models.py
def is_gpt_5_default() -> bool:
    """
    Returns True if the default model is a GPT-5 model.
    This is used to determine if the default model settings are compatible with GPT-5 models.
    If the default model is not a GPT-5 model, the model settings are compatible with other models.
    """
    return gpt_5_reasoning_settings_required(get_default_model())

get_default_model

get_default_model() -> str

Returns the default model name.

Source code in src/agents/models/default_models.py
def get_default_model() -> str:
    """
    Returns the default model name.
    """
    return os.getenv(OPENAI_DEFAULT_MODEL_ENV_VARIABLE_NAME, "gpt-4.1").lower()

get_default_model_settings

get_default_model_settings(
    model: Optional[str] = None,
) -> ModelSettings

Returns the default model settings. If the default model is a GPT-5 model, returns the GPT-5 default model settings. Otherwise, returns the legacy default model settings.

Source code in src/agents/models/default_models.py
def get_default_model_settings(model: Optional[str] = None) -> ModelSettings:
    """
    Returns the default model settings.
    If the default model is a GPT-5 model, returns the GPT-5 default model settings.
    Otherwise, returns the legacy default model settings.
    """
    _model = model if model is not None else get_default_model()
    if gpt_5_reasoning_settings_required(_model):
        effort = _get_default_reasoning_effort(_model)
        if effort is not None:
            return copy.deepcopy(_GPT_5_DEFAULT_MODEL_SETTINGS_BY_REASONING_EFFORT[effort])
        # Keep the GPT-5 verbosity default, but omit reasoning.effort for
        # variants whose supported values are not confirmed yet.
        return copy.deepcopy(_GPT_5_TEXT_ONLY_DEFAULT_MODEL_SETTINGS)
    return ModelSettings()