- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在制作一个 Python 脚本以通过其 API 使用 OpenAI。但是,我收到此错误:
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details
我的脚本如下:
#!/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)
我宣布 Shebang python3.8
,因为我正在使用 pyenv 。我认为它应该可以工作,因为我执行了 0 个 API 请求,所以我假设我的代码中有错误。
最佳答案
TL;DR:您需要升级到付费计划。设置付费帐户,添加信用卡或借记卡,并生成新的 API key (如果您的旧 API key 是在升级前生成的)。升级到付费计划后,可能需要 10 分钟左右,付费帐户才会生效并且错误会消失。
正如官方所说OpenAI documentation :
此外,请阅读有关 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 monthlyspend (hard limit) for the API. This means that you have consumed allthe credits or units allocated to your plan and have reached the limitof 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.
您收到错误429
因为您要么用完所有免费代币,要么自注册以来已经过去了 3 个月。
正如官方所说OpenAI article :
To explore and experiment with the API, all new users get $5worth of free tokens. These tokens expire after 3 months.
After the quota has passed you can choose to enter billing informationto upgrade to a paid plan and continue your use of the API onpay-as-you-go basis. If no billing information is entered you willstill have login access, but will be unable to make any further APIrequests.
Please see the pricing page for the latest information onpay-as-you-go pricing.
注意:如果您较早注册(例如,在 2022 年 12 月),您将获得值(value) 18 美元的免费代币。
在 usage dashboard 中检查您的 API 使用情况.
例如,我的免费试用明天到期,这是我现在在使用仪表板中看到的内容:
这是我的仪表板在过期后的样子:
如果我在免费试用期结束后运行一个简单的脚本,则会收到以下错误:
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.
您收到错误429
因为您使用相同的电话号码创建了第二个 OpenAI 帐户。似乎免费信用是根据电话号码提供的。
正如官方解释的OpenAI forum by @SapphireFelineBytes :
I created an Open AI account in November and my $18 credits expired onMarch 1st. So, like many of you here, I tried creating a new accountwith a different email address, but same number. They gave me $0credits.
I tried now with a different phone number and email. This time I got$5 credits.
更新:
已确认根据电话号码给予免费积分,官方说明OpenAI forum by @logankilpatrick :
Also note, you only get free credits for the first account associatedwith your phone number. Subsequent accounts are not granted free credits.
尝试执行以下操作:
当您升级到付费计划时,不要指望错误会立即消失,正如@dcferreira 在上面的评论中提到的那样。升级后可能需要几分钟时间错误才会消失。
更新:
在下面的评论中,@JoeMornin 确认他的付费帐户需要 10 分钟才能激活。与此同时,他得到了以下错误:
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.
关于python - OpenAI ChatGPT (GPT-3.5) API 错误 429 : "You exceeded your current quota, please check your plan and billing details",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77020970/
我是一名优秀的程序员,十分优秀!