list all openai models in python

To list all the available OpenAI models you can use the models() method of the openai package.

Here's the code to do so:

main.py
import openai

# set up your API key
openai.api_key = "YOUR_API_KEY"

# list all models
models = openai.Model.list()

# print the models
for model in models['data']:
    print(model.id)
186 chars
12 lines

This will give you a list of all the available OpenAI models, such as text-davinci-002, davinci-codex, curie, etc. If you don't have an API key, you can sign up for one on the OpenAI website.

related categories

gistlibby LogSnag