Implementation:Openai Openai python API Model Type
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Python |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for representing an OpenAI model object provided by the openai-python SDK.
Description
Model is a Pydantic BaseModel that describes an OpenAI model offering that can be used with the API. It contains the model id (identifier referenced in API endpoints), created Unix timestamp, object type (always "model"), and owned_by (the organization that owns the model). This is the return type from the Models API endpoints for listing and retrieving models.
Usage
Import Model when you need to type-annotate or inspect the response from client.models.list() or client.models.retrieve().
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/model.py
Signature
class Model(BaseModel):
id: str
created: int
object: Literal["model"]
owned_by: str
Import
from openai.types import Model
I/O Contract
Fields
| Name | Type | Required | Description |
|---|---|---|---|
| id | str | Yes | The model identifier, which can be referenced in API endpoints. |
| created | int | Yes | Unix timestamp (in seconds) when the model was created. |
| object | Literal["model"] | Yes | The object type, always "model". |
| owned_by | str | Yes | The organization that owns the model. |
Usage Examples
from openai import OpenAI
from openai.types import Model
client = OpenAI()
# List all available models
models = client.models.list()
for model in models.data:
print(f"{model.id} - owned by {model.owned_by}")
# Retrieve a specific model
gpt4: Model = client.models.retrieve("gpt-4")
print(f"Model: {gpt4.id}, Created: {gpt4.created}")