Implementation:Openai Openai python Shared Chat Model
Appearance
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Python |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for defining the literal type of all chat-compatible model identifiers provided by the openai-python SDK.
Description
ChatModel is a TypeAlias defined as a Literal union of all known chat-compatible model identifier strings. It covers the full range of OpenAI chat models across multiple generations:
- GPT-5.x series - gpt-5.2, gpt-5.2-pro, gpt-5.1, gpt-5.1-codex, gpt-5.1-mini, gpt-5, gpt-5-mini, gpt-5-nano and their dated variants.
- GPT-4.1 series - gpt-4.1, gpt-4.1-mini, gpt-4.1-nano and their dated variants.
- O-series reasoning models - o4-mini, o3, o3-mini, o1, o1-preview, o1-mini and their dated variants.
- GPT-4o series - gpt-4o, gpt-4o-audio-preview, gpt-4o-mini-audio-preview, gpt-4o-search-preview, gpt-4o-mini-search-preview, chatgpt-4o-latest, codex-mini-latest, gpt-4o-mini and dated variants.
- GPT-4 legacy series - gpt-4-turbo, gpt-4, gpt-4-32k and their dated variants.
- GPT-3.5 series - gpt-3.5-turbo, gpt-3.5-turbo-16k and dated variants.
Usage
Import ChatModel when you need strict type checking for model identifiers accepted by the Chat Completions API.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/shared/chat_model.py
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",
# ... (73 total literal values)
"gpt-3.5-turbo-0125",
"gpt-3.5-turbo-16k-0613",
]
Import
from openai.types.shared import ChatModel
I/O Contract
Model Families
| Family | Example Identifiers | Description |
|---|---|---|
| GPT-5.2 | gpt-5.2, gpt-5.2-pro, gpt-5.2-2025-12-11 | Latest generation models. |
| GPT-5.1 | gpt-5.1, gpt-5.1-codex, gpt-5.1-mini | Previous generation with codex variant. |
| GPT-5 | gpt-5, gpt-5-mini, gpt-5-nano | Base GPT-5 models in multiple sizes. |
| GPT-4.1 | gpt-4.1, gpt-4.1-mini, gpt-4.1-nano | GPT-4.1 generation models. |
| O-series | o4-mini, o3, o3-mini, o1, o1-mini | Reasoning-focused models. |
| GPT-4o | gpt-4o, gpt-4o-mini, chatgpt-4o-latest | Optimized GPT-4 variants with audio and search. |
| GPT-4 | gpt-4-turbo, gpt-4, gpt-4-32k | Legacy GPT-4 models. |
| GPT-3.5 | gpt-3.5-turbo, gpt-3.5-turbo-16k | Legacy GPT-3.5 models. |
Usage Examples
from openai import OpenAI
from openai.types.shared import ChatModel
def chat(model: ChatModel, message: str) -> str:
"""Type-safe chat using only known chat model identifiers."""
client = OpenAI()
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": message}],
)
return response.choices[0].message.content
# Type checker validates the model string
result = chat("gpt-4o", "Explain Python type aliases.")
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment