To list and print the IDs of OpenAI models using the OpenAI Python library, you can use the following code:
main.py128 chars9 lines
Make sure to replace "YOUR_API_KEY"
with your actual OpenAI API key. This code first sets your API key using openai.api_key
and then lists the available models using openai.models.list()
. It then iterates over each model in the models.data
list and prints the ID of each model using print(model['id'])
.
gistlibby LogSnag