我們提供了一個 Python 庫,您可以按如下方式安裝它:
$ pip install openai
安裝后,您可以使用綁定和您的密鑰運(yùn)行以下命令:
import os
import openai
# Load your API key from an environment variable or secret management service
openai.api_key = os.getenv("OPENAI_API_KEY")
response = openai.Completion.create(model="text-davinci-003", prompt="Say this is a test", temperature=0, max_tokens=7)
綁定還將安裝一個命令行實(shí)用程序,您可以按如下方式使用:
$ openai api completions.create -m text-davinci-003 -p "Say this is a test" -t 0 -M 7 --stream
我們還有一個 Node.js 庫,您可以通過在 Node.js 項(xiàng)目目錄中運(yùn)行以下命令來安裝它:
$ npm install openai
安裝后,您可以使用該庫和您的密鑰運(yùn)行以下命令:
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createCompletion({
model: "text-davinci-003",
prompt: "Say this is a test",
temperature: 0,
max_tokens: 7,
});
下面的庫由更廣泛的開發(fā)人員社區(qū)構(gòu)建和維護(hù)。如果您想在此處添加新庫,請按照我們幫助中心文章中有關(guān)添加社區(qū)庫的說明進(jìn)行操作。
請注意,OpenAI 不會驗(yàn)證這些項(xiàng)目的正確性或安全性。
更多建議: