OpenAI API error 429: “You exceeded your current quota, please check your plan and billing details” [closed]

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#!/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)
</code>
<code>#!/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) </code>
#!/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.

9

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.
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.

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.

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.

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:

  1. Set up paid account.
  2. Add a credit or debit card.
  3. 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.

In the comment below, @JoeMornin confirmed that it took 10 minutes for his paid account to become active. In the meantime, he was getting 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.

19

I was facing the same error, and for me the steps were:

  1. Add a credit or debit card in payment methods.
  2. Generate a new API key in user preferences.
  3. (Optional) Delete the old API key.
  4. Be sure to set limits to not incur in charges

This are the limits for gpt-3.5-turbo: RPM 3,500 and TPM 90,000.

5

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.

Rate Limit Error

Some people said that if they waited for a while it started working, so maybe just hang tight.

Just create a new API Key and use it. It worked for me.

6

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

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật