各种开发语言OpenAI类库
# 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)
绑定还将安装一个命令行实用程序,您可以按如下方式使用:
$ 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
- Betalgo.OpenAI.GPT3 (opens new window) by Betalgo (opens new window)
- OpenAI-API-dotnet (opens new window) by OkGoDoIt (opens new window)
- OpenAI-DotNet (opens new window) by RageAgainstThePixel (opens new window)
# C++
# Clojure
# Crystal
# Dart/Flutter
# Delphi
# Elixir
# Go
# Java
# Julia
# Kotlin
# Node.js
- openai-api (opens new window) by Njerschow (opens new window)
- openai-api-node (opens new window) by erlapso (opens new window)
- gpt-x (opens new window) by ceifa (opens new window)
- gpt3 (opens new window) by poteat (opens new window)
- gpts (opens new window) by thencc (opens new window)
- @dalenguyen/openai (opens new window) by dalenguyen (opens new window)
- tectalic/openai (opens new window) by tectalic (opens new window)
# PHP
- orhanerday/open-ai (opens new window) by orhanerday (opens new window)
- tectalic/openai (opens new window) by tectalic (opens new window)
- openai-php clinet (opens new window) by openai-php (opens new window)
# Python
# R
# Ruby
- openai (opens new window) by nileshtrivedi (opens new window)
- ruby-openai (opens new window) by alexrudall (opens new window)
# Rust
- async-openai (opens new window) by 64bit (opens new window)
- fieri (opens new window) by lbkolev (opens new window)
# Scala
# Swift
# Unity
- OpenAi-Api-Unity (opens new window) by hexthedev (opens new window)
- com.openai.unity (opens new window) by RageAgainstThePixel (opens new window)
# Unreal Engine
上次更新: 2023/06/28, 19:28:04