https://platform.openai.com/docs/libraries/python-library

Python 库

我们提供了一个Python 库,您可以通过运行以下命令来安装:

pip install openai

安装后,您可以使用该库和您的密钥来运行以下命令:


from openai import OpenAI
client = OpenAI(
    # Defaults to os.environ.get("OPENAI_API_KEY")
)

chat_completion = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[{"role": "user", "content": "Hello world"}]
)

绑定还将安装一个命令行实用程序,您可以按如下方式使用:

$ openai api chat_completions.create -m gpt-3.5-turbo -g user "Hello world"

TypeScript / JavaScript 库

我们提供了一个TypeScript/JavaScript 库,支持 Node.js 和各种其他运行时。通过运行安装它:

npm install --save openai
# or
yarn add openai

安装后,您可以使用该库和您的密钥来运行以下命令:

import OpenAI from "openai";

const openai = new OpenAI({
    apiKey: process.env.OPENAI_API_KEY,
});

const chatCompletion = await openai.chat.completions.create({
    messages: [{ role: "user", content: "Say this is a test" }],
    model: "gpt-3.5-turbo",
});

Azure OpenAI 库

Microsoft 的 Azure 团队维护着与 OpenAI API 和 Azure OpenAI 服务兼容的库。阅读下面的库文档,了解如何将它们与 OpenAI API 一起使用。

社区库

下面的库由更广泛的开发人员社区构建和维护。如果您想在此处添加新库,请按照我们的帮助中心文章中有关添加社区库的说明进行操作。您还可以在 GitHub 上查看我们的 OpenAPI 规范存储库,以便在我们对 API 进行更改时及时获得更新。

请注意,OpenAI 不验证这些项目的正确性或安全性。使用它们需要您自担风险

C#/.NET
C++

liboai by D7EAD

Clojure

openai-clojure by wkok

Crystal

openai-crystal by sferik

Dart/Flutter

openai by anasfik

Delphi

DelphiOpenAI by HemulGM

Elixir

openai.ex by mgallo

Go

go-gpt3 by sashabaranov

Java

openai-java by Theo Kanning

Julia

OpenAI.jl by rory-linehan

Kotlin

openai-kotlin by Mouaad Aallam

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
openai-php client by openai-php

Python

chronology by OthersideAI

R

rgpt3 by ben-aaron188

Ruby

openai by nileshtrivedi
ruby-openai by alexrudall

Rust

async-openai by 64bit
fieri by lbkolev

Scala

openai-scala-client by cequence-io

Swift

OpenAIKit by dylanshine
OpenAI by MacPaw

Unity

OpenAi-Api-Unity by hexthedev
com.openai.unity by RageAgainstThePixel

Unreal Engine

OpenAI-Api-Unreal by KellanM

作者:Jeebiz  创建时间:2023-12-28 00:34
最后编辑:Jeebiz  更新时间:2023-12-28 16:43