OpenAI API Models

2023-03-21 14:16 更新

列出并描述 API 中可用的各种模型。您可以参考模型文档以了解可用的模型以及它们之间的区别。


列出模型

GET https://api.openai.com/v1/models

列出当前可用的模型,并提供有关每个模型的基本信息,例如所有者和可用性。

示例请求:

 curl python  node.js 
curl https://api.openai.com/v1/models \
  -H "Authorization: Bearer $OPENAI_API_KEY"
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Model.list()
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.listModels();

响应

{
  "data": [
    {
      "id": "model-id-0",
      "object": "model",
      "owned_by": "organization-owner",
      "permission": [...]
    },
    {
      "id": "model-id-1",
      "object": "model",
      "owned_by": "organization-owner",
      "permission": [...]
    },
    {
      "id": "model-id-2",
      "object": "model",
      "owned_by": "openai",
      "permission": [...]
    },
  ],
  "object": "list"
}


检索模型

GET https://api.openai.com/v1/models/{model}

检索模型实例,提供有关模型的基本信息,例如所有者和权限。

路径参数

 字段 类型  是否可选 
 model string  必须 

示例请求

 curl python node.js 
curl https://api.openai.com/v1/models/ada \
  -H "Authorization: Bearer $OPENAI_API_KEY"
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Model.retrieve("ada")
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.retrieveModel("ada");

响应

{
  "id": "ada",
  "object": "model",
  "owned_by": "openai",
  "permission": [...]
}


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号