英文:
OpenAI ChatGPT (GPT-3.5) API error 429: "You exceeded your current quota, please check your plan and billing details"
问题
我正在编写一个Python脚本,通过其API使用OpenAI。然而,我遇到了以下错误:
> openai.error.RateLimitError: 您已超出当前配额,请检查您的计划和账单详情
我的脚本如下:
#!/usr/bin/env python3.8
# -*- coding: utf-8 -*-
import openai
openai.api_key = "<我的PAI密钥>"
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "以海盗风格告诉世界有关ChatGPT API。"}
]
)
print(completion.choices[0].message.content)
我声明了shebang python3.8
,因为我正在使用pyenv。我认为它应该可以工作,因为我还没有发出任何API请求,所以我认为错误在我的代码中。
英文:
I'm making a Python script to use OpenAI via its API. However, I'm getting this error:
> openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details
My script is the following:
#!/usr/bin/env python3.8
# -*- coding: utf-8 -*-
import openai
openai.api_key = "<My PAI Key>"
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Tell the world about the ChatGPT API in the style of a pirate."}
]
)
print(completion.choices[0].message.content)
I'm declaring the shebang python3.8
, because I'm using pyenv. I think it should work, since I did 0 API requests, so I'm assuming there's an error in my code.
答案1
得分: 92
以下是翻译好的部分:
TL;DR:您需要升级到付费计划。设置一个付费帐户,添加信用卡或借记卡,并生成一个新的API密钥(如果您的旧密钥是在升级之前生成的)。升级到付费计划后,可能需要大约10分钟才能激活付费帐户并消除错误。
问题
正如在官方OpenAI文档中所述:
类型 | 概述 |
---|---|
RateLimitError | 原因: 您已达到分配的速率限制。<br>解决方案: 控制您的请求速度。在我们的速率限制指南中了解更多信息。 |
另请阅读更多关于错误代码429 - 您已超出当前配额,请检查您的计划和计费详细信息的内容:
> 此(即429
)错误消息表示您已达到API的最大月度消费限制(硬限制)。这意味着您已消耗了分配给您的计划的所有积分或单位,并已达到了计费周期的限制。这可能发生出于几个原因,例如:
> - 您使用的是消耗大量积分或单位的高容量或复杂服务。
>
> - 您使用了一个需要大量请求来处理的大型或多样化的数据集。
>
> - 您的限制对于您的组织的使用来说设置得太低。
<br>
您是否一段时间前注册?
您收到429
错误,因为要么您已经用完了所有的免费令牌,要么自您注册以来已经过去了3个月。
正如在官方OpenAI文章中所述:
> 为了探索和尝试API,所有新用户都会获得价值5美元的免费令牌。这些令牌在3个月后过期。
> 配额用完后,您可以选择输入结算信息,以升级到付费计划,并以按使用付费的方式继续使用API。如果未输入结算信息,您仍将具有登录访问权限,但将无法进行进一步的API请求。
> 请参阅定价页面,获取有关按使用付费定价的最新信息。
注意:如果您早些时候注册(例如,在2022年12月),您将获得价值18美元的免费令牌。
在使用仪表板中检查您的API使用情况。
例如,我的免费试用将于明天到期,这是我在使用仪表板中当前看到的情况:
这是我的仪表板在到期后的情况:
如果我的免费试用到期后运行一个简单的脚本,我将收到以下错误:
> openai.error.RateLimitError:您已超出当前配额,请检查您的计划和计费详细信息。
<br>
您创建了第二个OpenAI帐户吗?
您收到429
错误,因为您使用相同的电话号码创建了第二个OpenAI帐户。看起来免费积分是根据电话号码分配的。
正如在官方OpenAI论坛由@SapphireFelineBytes解释的:
> 我在11月创建了一个Open AI帐户,我的18美元积分在3月1日过期。所以,像这里的许多人一样,我尝试使用不同的电子邮件地址,但是相同的号码创建了一个新帐户。他们给了我0美元的积分。
> 现在,我尝试使用不同的电话号码和电子邮件。这次我得到了5美元的积分。
更新:
由@logankilpatrick在官方OpenAI论坛上解释,已经确认免费积分是根据电话号码分配的:
> 还要注意,只有与您的电话号码相关的第一个帐户才会获得免费积分。后续帐户不会获得免费积分。
解决方案
尝试执行以下操作:
当您升级到付费计划时,不要期望错误会立即消失,正如@dcferreira在上面的评论中提到的那样。在升级后,错误消失之前可能需要几分钟。
更新:
在下面的评论中,@JoeMornin确认他的付费帐户需要10分钟才能激活。在此期间,他会收到以下错误:
> 您已达到使用限制。请查看您的使用仪表板和计费设置以获取更多详细信息。如果您有更多问题,请通过help.openai.com上的帮助中心与我们联系。
英文:
TL;DR: You need to upgrade to a paid plan. Set up a paid account, add a credit or debit card, and generate a new API key if your old one was generated before the upgrade. It might take 10 minutes or so after you upgrade to a paid plan before the paid account becomes active and the error disappears.
Problem
As stated in the official OpenAI documentation:
TYPE | OVERVIEW |
---|---|
RateLimitError | Cause: You have hit your assigned rate limit. <br>Solution: Pace your requests. Read more in our rate limit guide. |
Also, read more about Error Code 429 - You exceeded your current quota, please check your plan and billing details:
> This (i.e., 429
) error message indicates that you have hit your maximum monthly
> spend (hard limit) for the API. This means that you have consumed all
> the credits or units allocated to your plan and have reached the limit
> of your billing cycle. This could happen for several reasons, such as:
>
> - You are using a high-volume or complex service that consumes a lot of credits or units per request.
>
> - You are using a large or diverse data set that requires a lot of requests to process.
>
> - Your limit is set too low for your organization’s usage.
<br>
Did you sign up some time ago?
You're getting error 429
because either you used all your free tokens or 3 months have passed since you signed up.
As stated in the official OpenAI article:
> To explore and experiment with the API, all new users get $5
> worth of free tokens. These tokens expire after 3 months.
>
> After the quota has passed you can choose to enter billing information
> to upgrade to a paid plan and continue your use of the API on
> pay-as-you-go basis. If no billing information is entered you will
> still have login access, but will be unable to make any further API
> requests.
>
> Please see the pricing page for the latest information on
> pay-as-you-go pricing.
Note: If you signed up earlier (e.g., in December 2022), you got $18 worth of free tokens.
Check your API usage in the usage dashboard.
For example, my free trial expires tomorrow and this is what I see right now in the usage dashboard:
This is how my dashboard looks after expiration:
If I run a simple script after my free trial has expired, I get the following error:
> openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.
<br>
Did you create your second OpenAI account?
You're getting error 429
because you created a second OpenAI account with the same phone number. It seems like free credit is given based on phone numbers.
As explained on the official OpenAI forum by @SapphireFelineBytes:
> I created an Open AI account in November and my $18 credits expired on
> March 1st. So, like many of you here, I tried creating a new account
> with a different email address, but same number. They gave me $0
> credits.
>
> I tried now with a different phone number and email. This time I got
> $5 credits.
UPDATE:
It's confirmed that free credit is given based on phone numbers, as explained on the official OpenAI forum by @logankilpatrick:
> Also note, you only get free credits for the first account associated
> with your phone number. Subsequent accounts are not granted free credits.
Solution
Try to do the following:
- Set up paid account.<br>
- Add a credit or debit card.<br>
- Generate a new API key if your old API key was generated before you upgraded to the paid plan.
When you upgrade to a paid plan, don't expect the error to disappear immediately, as @dcferreira mentioned in the comment above. It might take a few minutes after the upgrade before the error disappears.
UPDATE:
In the comment below, @JoeMornin confirmed that it took 10 minutes for his paid account to become active. In the meantime, he got the following error:
> You've reached your usage limit. See your usage dashboard and billing settings for more details. If you have further questions, please contact us through our help center at help.openai.com.
答案2
得分: 5
你的代码看起来没问题。事实上,我相信这是他们在他们的网站上提供的一个示例。问题似乎出在OpenAI这边。如果你滚到底部,有人四天前发布了关于这个问题的帖子。
有些人说如果他们等一会儿,它就开始工作了,所以也许只需要稍等一下。
英文:
Your code looks fine. In fact, I believe it's an example they give on their website. The problem appears to be on OpenAI's side. If you scroll all the way to the bottom, someone posted about this four days ago.
Some people said that if they waited for a while it started working, so maybe just hang tight.
答案3
得分: 3
以下是已经翻译好的部分:
我遇到了相同的错误,对我来说,以下是步骤:
- 在支付方式中添加信用卡或借记卡。
- 在用户首选项中生成新的API密钥。
- (可选)删除旧的API密钥。
- 请确保设置限制以避免产生费用。
这些是gpt-3.5-turbo的限制 RPM 3,500 TPM 90,000
希望对你有所帮助。
英文:
I was facing the same error, and for me the steps were:
- Add a credit or debit card in payment methods.
- Generate a new API key in user preferences.
- (Optional) Delete the old API key.
- Be sure to set limits to not incur in charges
This are the limits for gpt-3.5-turbo RPM 3,500 TPM 90,000
Hope it helps.
答案4
得分: 2
创建一个新的API密钥并使用它。这对我有效。
英文:
Just create a new API Key and use it. It worked for me.
答案5
得分: 1
遇到了类似的问题,找到了适用于我的解决方案。首先,我取消了我的付费帐户,然后使用不同的付款方式进行了续订。接下来,我进入了“API密钥”部分,在“默认组织”下拉菜单中选择了我的组织,并保存了更改。这个操作重置了我的软限制,但我仍然需要创建一个新的API密钥来完全解决问题。
- 取消付费帐户并使用新付款方式重新创建
- 确认组织
- 创建新的API密钥
英文:
I encountered a similar issue and found a solution that worked for me. I first canceled my paid account and renewed it with a different payment method. Next, I went to the 'API Keys' section, selected my organization under the 'Default Organizations' dropdown, and saved the changes. This action reset my soft limit, but I still needed to create a new API key to resolve the issue completely.
- Cancel paid account and recreate with new payment method
- Confirm Organization
- Create new API Key
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论