OpenAI API Models

2023-03-21 14:16 更新

列出并描述 API 中可用的各種模型。您可以參考模型文檔以了解可用的模型以及它們之間的區(qū)別。


列出模型

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

列出當前可用的模型,并提供有關(guān)每個模型的基本信息,例如所有者和可用性。

示例請求:

 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}

檢索模型實例,提供有關(guān)模型的基本信息,例如所有者和權(quán)限。

路徑參數(shù)

 字段 類型  是否可選 
 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": [...]
}


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號