Skip to main content

Overview

Retrieves a list of all models currently available through the OpenAI API. Each model object provides basic information including the owner and availability.

Method

client.models.list()

Parameters

This endpoint takes no required parameters. Optional parameters include:
extra_headers
dict
Send extra headers with the request
extra_query
dict
Add additional query parameters to the request
timeout
float
Override the client-level default timeout for this request, in seconds

Response

Returns a paginated list of Model objects.
data
array
Array of model objects

Examples

List All Models

from openai import OpenAI

client = OpenAI()

# List all available models
models = client.models.list()

for model in models:
    print(f"{model.id} (owned by {model.owned_by})")

Filter Models

# Get all GPT-4 models
models = client.models.list()
gpt4_models = [m for m in models if 'gpt-4' in m.id]

for model in gpt4_models:
    print(model.id)

Check Model Availability

def is_model_available(model_id: str) -> bool:
    models = client.models.list()
    return any(m.id == model_id for m in models)

if is_model_available('gpt-4-turbo'):
    print("Model is available!")

Pagination

# The list method returns a SyncPage object that supports iteration
models_page = client.models.list()

# Iterate through all models (handles pagination automatically)
for model in models_page:
    print(model.id)

Async Usage

from openai import AsyncOpenAI

client = AsyncOpenAI()

models = client.models.list()

# AsyncPaginator supports async iteration
async for model in models:
    print(model.id)

Notes

  • The list includes base models from OpenAI as well as any fine-tuned models you have created
  • Models are returned in no particular order
  • The response is paginated but the SDK handles pagination automatically
  • Use this endpoint to verify model availability before making API calls

Build docs developers (and LLMs) love