OpenAI 中文在线文档
  • 开始
    • 介绍
    • 快速开始
    • 库
    • 模型
    • 引导
      • 如何构建一个能够回答关于你的网站问题的人工智能
    • 数据使用政策
    • 使用政策
  • 指南
    • 文本完成
    • 代码完成(内测)
    • 聊天完成
    • 图片生成
    • 微调
    • 嵌入
    • 语音转文本
    • 内容审核
    • 速率限制
    • 错误码
    • 安全最佳实践
    • 生产应用最佳实践
  • API 参考
    • 介绍
    • 身份认证
    • 创建请求
    • 模型
    • 完成
    • 聊天
    • 编辑
    • 图片
    • 嵌入
    • 音频
    • 文件
    • 微调
    • 内容审核
    • 引擎
    • 参数详情
  • 翻译修订记录
由 GitBook 提供支持
在本页
  • Python库
  • Node.js库
  • 社区库
  • C# / .NET
  • Crystal
  • Go
  • Java
  • Kotlin
  • Node.js
  • PHP
  • R
  • Ruby
  • Scala
  • Swift
  • Unity
  • Unreal Engine
  1. 开始

库

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)

该Python库也会安装一个命令行工具,你可以按照如下方式使用:

$ 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

Go

Java

Kotlin

Node.js

PHP

Python

R

Ruby

Scala

Swift

Unity

Unreal Engine

上一页快速开始下一页模型

最后更新于2年前

by

by

by

by

by

by

by

by

by

by

by

by

by

by

by

by

by

by

by

by

by

by

Betalgo.OpenAI.GPT3
Betalgo
openai-crystal
sferik
go-gpt3
sashabaranov
openai-java
Theo Kanning
openai-kotlin
Mouaad Aallam
openai-api
Njerschow
openai-api-node
erlapso
gpt-x
ceifa
gpt3
poteat
gpts
thencc
@dalenguyen/openai
dalenguyen
tectalic/openai
tectalic
orhanerday/open-ai
orhanerday
tectalic/openai
tectalic
chronology
OthersideAI
rgpt3
ben-aaron188
openai
nileshtrivedi
ruby-openai
alexrudall
openai-scala-client
cequence-io
OpenAIKit
dylanshine
OpenAi-Api-Unity
hexthedev
OpenAI-Api-Unreal
KellanM