Retrieving all OpenAI model names through API call

Hey everyone! I’m trying to figure out how to fetch all the available models from OpenAI using their API. I’ve been searching through the documentation but it’s pretty confusing since everything seems to be scattered around on a single massive page.

I specifically need the API endpoint or cURL command that returns the complete list of models I can use. Been stuck on this for a while now and could really use some help from someone who has done this before.

Anyone know the right way to do this? Thanks in advance!

To retrieve all available models from OpenAI, use the endpoint https://api.openai.com/v1/models. Simply make a GET request, ensuring you include your API key in the Authorization header formatted as Bearer YOUR_API_KEY. This will yield a JSON response that lists all models, including their identifiers and associated details like creation timestamps. Be aware that the available models can change, so it’s wise to make this call regularly instead of hardcoding any specific model names.