OpenAI API 给出错误:429 请求过多

Kar*_*ran 31 node.js express http-status-code-429 openai-api

我正在尝试使用 Express NodeJS 中的以下代码向 openai API 发出请求:

import { Configuration, OpenAIApi } from "openai";

const configuration = new Configuration({
    organization: "org-Fn2EqsTpiUCTKb8m61wr6H8m",
    apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
});
const openai = new OpenAIApi(configuration);

async function callApi() {
    const response = await openai.createCompletion({
        model: "text-davinci-003",
        prompt: "Say this is a test",
        max_tokens: 3000,
        temperature: 0,
      });

    console.log(response.data.choices[0].text);
}

callApi();
Run Code Online (Sandbox Code Playgroud)

问题是我不断收到错误 429 Too much requests。

这里有更多信息:

  • API 密钥正确。
  • 当我进入我的 openai 帐户 > 查看 API KEY 时:它显示该密钥从未使用过,因此我从未能够拨打电话。那么我怎么可能收到错误 Too much requests 呢?
  • 我已经尝试在函数中实现指数退避,但没有成功。

小智 32

我遇到过同样的问题。原因是我在将 OpenAI 帐户转换为付费帐户(添加信用卡)之前创建了 API 密钥。如果您只升级也没关系,您还需要完全创建一个新的 api 密钥。

添加信用卡后,我创建了另一个 API 密钥,效果很好!


小智 24

如果您在 4 月 1 日之后收到相同的错误 (429),则意味着您的免费试用 18 美元(在 4 月之前注册的所有帐户中)已过期,即使您一次都没有使用过 api 密钥。

在您的 API 使用页面中,您会发现如下所示:

GRANT # CREDIT GRANTED  EXPIRES (UTC)
Grant 1 $18.00  Expired 2023-04-01
Run Code Online (Sandbox Code Playgroud)

好消息是您仍然可以使用官方网络聊天页面。


小智 8

不适合OP,但就我而言,问题是我需要向方法提供我的组织ID,Configuration如下所示:

import { Configuration } from "openai";

const configuration = new Configuration({
    organization: "org-xxxx",
    apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
});
Run Code Online (Sandbox Code Playgroud)

您可以从此页面获取组织 ID: https: //platform.openai.com/account/org-settings


joe*_*nni 2

答案就在您收到的错误中。

该错误429 Too Many Requests意味着您已经超出了 18 美元的免费 API 积分。您可以在官方网站上支付更多费用。

您的密钥不可能正确,但在您尝试提出请求时未被使用。仔细检查您在代码中使用的密钥是否正确。

  • 我在使用全新 API 密钥的第一个请求时看到此错误。 (3认同)