模型
列出并描述API中可用的各种模型。您可以参考模型文档以了解可用的模型及其之间的区别。
获取支持的模型列表
GET https://api.openai.com/v1/models
列出当前可用的模型,并提供有关每个模型的基本信息,例如所有者和可用性。
请求示例
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 字符串 必需
用于此请求的模型的ID。
请求示例
curl https://api.openai.com/v1/models/text-davinci-003 \
-H "Authorization: Bearer $OPENAI_API_KEY"
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Model.retrieve("text-davinci-003")
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("text-davinci-003");
返回结果
{
"id": "text-davinci-003",
"object": "model",
"owned_by": "openai",
"permission": [...]
}
最后更新于