Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Shared All Models

From Leeroopedia
Knowledge Sources
Domains API_Types, Python
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete tool for defining the union type of all supported OpenAI model identifiers provided by the openai-python SDK.

Description

AllModels is a TypeAlias representing a union of all model identifiers accepted across OpenAI API endpoints. It combines:

  • str - Any arbitrary model string for forward compatibility.
  • ChatModel - The full set of chat model literal identifiers.
  • A Literal union of additional model identifiers not covered by ChatModel, including o1-pro, o3-pro, o3-deep-research, o4-mini-deep-research, computer-use-preview, gpt-5-codex, gpt-5-pro, and gpt-5.1-codex-max variants.

This is the broadest model type alias in the SDK, encompassing every known model identifier.

Usage

Import AllModels when you need to type-annotate a parameter that can accept any OpenAI model identifier across all API surfaces.

Code Reference

Source Location

Signature

AllModels: TypeAlias = Union[
    str,
    ChatModel,
    Literal[
        "o1-pro",
        "o1-pro-2025-03-19",
        "o3-pro",
        "o3-pro-2025-06-10",
        "o3-deep-research",
        "o3-deep-research-2025-06-26",
        "o4-mini-deep-research",
        "o4-mini-deep-research-2025-06-26",
        "computer-use-preview",
        "computer-use-preview-2025-03-11",
        "gpt-5-codex",
        "gpt-5-pro",
        "gpt-5-pro-2025-10-06",
        "gpt-5.1-codex-max",
    ],
]

Import

from openai.types.shared import AllModels

I/O Contract

Type Members

Variant Description
str Any arbitrary model identifier string for forward compatibility.
ChatModel All chat model literals (gpt-4o, gpt-4, gpt-3.5-turbo, o1, o3, etc.).
Literal["o1-pro", ...] Additional model identifiers: o1-pro, o3-pro, o3-deep-research, o4-mini-deep-research, computer-use-preview, gpt-5-codex, gpt-5-pro, gpt-5.1-codex-max, and their dated variants.

Usage Examples

from openai.types.shared import AllModels

def create_completion(model: AllModels, prompt: str) -> str:
    """Accept any valid OpenAI model identifier."""
    from openai import OpenAI
    client = OpenAI()
    response = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": prompt}],
    )
    return response.choices[0].message.content

# All of these are valid AllModels values
result = create_completion("gpt-4o", "Hello!")
result = create_completion("o3-pro", "Hello!")
result = create_completion("gpt-5-codex", "Hello!")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment