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

huangapple go评论79阅读模式
英文:

OpenAI API giving error: 429 Too Many Requests

问题

我正在尝试使用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();

问题是,我不断收到错误429,表示请求过多。

以下是一些更多信息:

  • API密钥是正确的。
  • 当我登录到我的OpenAI帐户>查看API密钥时,显示该密钥从未被使用,因此我从未能够发出调用。那么为什么我会收到请求过多的错误?
  • 我已经尝试在函数中实现指数退避,但它没有起作用。
英文:

I am trying to make a request to the openai API with the following code in express nodeJS:

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();

The problem is that I keep getting error 429 Too many requests.

Here some more information:

  • The API key is correct.
  • When I go to my openai account > view API KEY: it shows that the key was never used so I have never been able to make a call. So how is it possibile that I'm getting error Too many requests?
  • I have already tried to implement exponential backoff in the function, but it didn't work.

答案1

得分: 22

如果在4月1日之后仍然出现相同的错误(429),这意味着您之前注册的所有帐户的免费试用期(18美元)已经过期,即使您从未使用过API密钥。

在您的API使用页面上,您会发现如下信息:

授权编号	已授信额度	过期时间(UTC)
授权 1	$18.00	已过期 2023-04-01

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

英文:

If you get the same error (429) after April 1st, that means your free trial 18$ (of all accounts registed before April) expired, even you haven't use api key once.

In your API Usage page, you will found like this:

GRANT #	CREDIT GRANTED	EXPIRES (UTC)
Grant 1	$18.00	Expired 2023-04-01

Good news is you can still use official web chat page.

答案2

得分: 17

我遇到了相同的问题。原因是我在将我的OpenAI账户升级为付费账户(添加信用卡)之前创建了API密钥。不管你只是升级,你还需要完全创建一个新的API密钥。

我在添加了信用卡之后创建了另一个API密钥,然后一切正常运作!

英文:

I had the same issue. The reason was that I created my API key BEFORE converting my OpenAI account to paid (adding credit card). Doesn't matter if you only upgrade, you also need to create a new api key entirely.

I created another API key AFTER I added my credit card and it worked fine!

答案3

得分: 4

不适用于OP,但在我的情况下,问题是我需要像这样向Configuration方法提供我的组织ID:

import { Configuration } from "openai";

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

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

英文:

Not for OP, but in my case, the issue was that I needed to provide my organisation Id to the Configuration method like this:

import { Configuration } from "openai";

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

You can get the organisation Id from this page: https://platform.openai.com/account/org-settings

答案4

得分: 3

答案在你收到的错误中。

错误429 Too Many Requests意味着你已经超出了你的免费18美元的API信用额度。你可以在官方网站上付费获取更多信用。

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

英文:

The answer is in the error that you have received.

The error 429 Too Many Requests means that you have exceeded your free $18 in API credits. You can pay for more on the official website.

It's not possible that your key is correct but is not being used when you try to make a request. Double check that you are using the correct key in your code.

huangapple
  • 本文由 发表于 2023年1月7日 23:38:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75041580.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定