Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a list of all available OpenAI models? [closed]

Tags:

openai-api

Can anyone find the cURL command to get a list of all available OpenAI models? I've been looking for like 10 minutes and can't find it.

like image 475
Gerry Avatar asked Sep 08 '25 03:09

Gerry


1 Answers

Python

from openai import OpenAI
import os
client = OpenAI(
    api_key = os.getenv('OPENAI_API_KEY')
)
models = client.models.list()
for model in models:
    print(model.id)

Node.js

const OpenAI = require("openai");

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

async function main() {
  const list = await client.models.list();

  for await (const model of list) {
    console.log(model);
  }
}

main();

cURL

curl https://api.openai.com/v1/models \
  -H "Authorization: Bearer $OPENAI_API_KEY"

See the official OpenAI documentation.

like image 192
Rok Benko Avatar answered Sep 10 '25 18:09

Rok Benko