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.
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:
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:
Did you sign up some time ago?
You're getting error
429because either you used all your free tokens or 3 months have passed since you signed up.As stated in the official OpenAI article:
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:
Did you create your second OpenAI account?
You're getting error
429because 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:
It's confirmed that free credit is given based on phone numbers, as explained on the official OpenAI forum by @logankilpatrick:
Solution
Try to do the following:
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: