> For the complete documentation index, see [llms.txt](https://docs.51buygpt.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.51buygpt.net/tutorial/api.md).

# ChatGPT API调用教程

如果你正在开发自己的AI产品，或者因为种种原因只能通过接口来使用ChatGPT，本文将教你如何使用API接口的方式来调用ChatGTP模型。

## 方式一：使用官方API Key

如果你购买的套餐中包含可用的API Key，可以通过以下对话网站来使用：

**ChatGPT对话网：**[**https://openkey.cloud/chat**](https://openkey.cloud/chat)

打开[设置](https://chat.openkey.cloud/#/settings)页面，找到【接口地址】和【API KEY】，填入以下参数即可使用：

`【接口地址】-` [`https://api.openai.com`](https://api.openai.com)

`【API Key】- sk-*************************`

<figure><img src="/files/vIZKlu2tNEWjM4z0vJEW" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/w5ZHmhjW2kRkrFe4NZXO" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/0xOpZVsbPelKQt98tXUM" alt=""><figcaption></figcaption></figure>

以上就是使用官方API Key调用ChatGPT的流程了，可是这样有一个问题。

即使你是Plus用户，你账号内的API Key也只能调用GPT-3.5相关模型，而无法使用GPT-4.0。

所以，如果需要使用GPT-4.0接口的用户，请参考方法二，也是我们推荐的ChatGPT接口调用方式。

## 方式二：使用OpenKey

OpenKEY 是一个 OpenAI API 反代服务，它可以让用户直接调用 OpenAI 的人工智能 API，而无需自行申请 OpenAI API 的额度。

**网站地址：**[**https://openkey.cloud/**](https://openkey.cloud/)

首先你需要拥有一个OpenKey账号，并且拥有一定余额。如果没有，可前往以下地址购买：

**51BuyGPT：**[**https://shop.51buygpt.net/**](https://shop.51buygpt.net/)

**Box小铺：**[**https://shop.terobox.com/**](https://shop.terobox.com/)

以下是如何使用Web对话工具，配合使用OpenKey的接口进行ChatGPT对话的教程。

### 1.创建令牌

请前往[令牌](https://openkey.cloud/token)页面，创建一个新令牌。

<figure><img src="/files/5USlyI6cqQONdQBVGnrs" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/VvQI2NL9Wwo6gsYDFgVM" alt=""><figcaption></figcaption></figure>

### 2. 配置对话

打开[设置](https://chat.openkey.cloud/#/settings)页面，找到API KEY一栏，输入即可使用。

<figure><img src="/files/N37EfCumRbPcBLTcEXt5" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/l7fCNfzS7WIHwbR62qxn" alt=""><figcaption></figcaption></figure>

## 3. 开始对话

完成以上步骤后就可以正常对话了，快来试试吧。

<figure><img src="/files/QLOZMGDWia664CSdOSDY" alt=""><figcaption></figcaption></figure>

OpenKey平台自2023年7月初开始运营，保持着99%的高可用性和稳定性，提供7x24小时售后支持。

选购地址：<https://openkey.cloud/topup>

价格对照：<https://openkey.cloud/pricing>

OpenKey帮助文档：<https://docs.openkey.cloud/>
