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 Params Chat Model

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

Overview

Concrete tool for specifying valid chat model identifiers as input parameters in the openai-python SDK.

Description

ChatModel is a TypeAlias defined as a Literal union of all supported OpenAI chat model identifiers for use in request parameters. This is the shared_params variant, intended for input/request contexts (as opposed to the shared response variant). It enumerates model strings spanning the full range of supported models including gpt-5.2, gpt-5.1, gpt-5, gpt-4.1, o4-mini, o3, o3-mini, o1, gpt-4o, gpt-4-turbo, gpt-4, and gpt-3.5-turbo families with their dated and variant suffixes.

Usage

Import this type when you need to type-annotate or validate a model parameter being passed to a chat completion or other API request. This ensures only recognized model identifiers are used.

Code Reference

Source Location

Signature

ChatModel: TypeAlias = Literal[
    "gpt-5.2",
    "gpt-5.2-2025-12-11",
    "gpt-5.2-chat-latest",
    "gpt-5.2-pro",
    "gpt-5.2-pro-2025-12-11",
    "gpt-5.1",
    "gpt-5.1-2025-11-13",
    "gpt-5.1-codex",
    "gpt-5.1-mini",
    "gpt-5.1-chat-latest",
    "gpt-5",
    "gpt-5-mini",
    "gpt-5-nano",
    # ... plus o-series, gpt-4o, gpt-4, gpt-3.5-turbo variants
]

Import

from openai.types.shared_params import ChatModel

I/O Contract

Type Definition

Type Description
Literal[...] A union of 73 string literals representing all supported OpenAI chat model identifiers.

Notable Model Families

Family Example Identifiers
gpt-5.2 "gpt-5.2", "gpt-5.2-pro", "gpt-5.2-2025-12-11"
gpt-5.1 "gpt-5.1", "gpt-5.1-mini", "gpt-5.1-codex"
gpt-5 "gpt-5", "gpt-5-mini", "gpt-5-nano"
gpt-4.1 "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano"
o-series "o4-mini", "o3", "o3-mini", "o1", "o1-mini"
gpt-4o "gpt-4o", "gpt-4o-mini", "gpt-4o-audio-preview", "chatgpt-4o-latest"
gpt-4 "gpt-4", "gpt-4-turbo", "gpt-4-32k"
gpt-3.5 "gpt-3.5-turbo", "gpt-3.5-turbo-16k"

Usage Examples

from openai.types.shared_params import ChatModel

# Use as a type annotation for model parameters
def create_completion(model: ChatModel, prompt: str) -> str:
    from openai import OpenAI
    client = OpenAI()
    response = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": prompt}],
    )
    return response.choices[0].message.content

result = create_completion("gpt-4o", "Hello!")

Related Pages

Page Connections

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