Python 套件
我們有提供Python套件,你可以如以下方式安裝:
pip install openai
一旦安裝完成,你就可以使用套件和你的密鑰執行以下操作:
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)
套件還會安裝一個 command line 工具,你可以按如下方式使用:
openai api completions.create -m text-davinci-003 -p "Say this is a test" -t 0 -M 7 --stream
Node.js 套件
我們還有一個 Node.js 函式庫, 你可以在 Node.js 專案目錄中執行以下命令來安裝它:
npm install openai
一旦安裝完成,你可以使用函式庫與你的秘鑰執行以下操作:
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,
});
社群版函式庫
以下函式庫由廣泛的開發人員社區建立和維護。 如果你想在此處添加新的函式庫,請參閱此幫助文章。
請注意,OpenAI 不會驗證這些專案的正確性或安全性。
C# / .NET
Crystal
Dart
Go
Java
Node.js
openai-api by Njerschow openai-api-node by erlapso gpt-x by ceifa gpt3 by poteat gpts by thencc @dalenguyen/openai by dalenguyen tectalic/openai by tectalic
PHP
orhanerday/open-ai by orhanerday tectalic/openai by tectalic
Python
R
Ruby
openai by nileshtrivedi ruby-openai by alexrudall