How to fix the OpenAI API Key Error: “You exceeded your current quota, please check your plan and billing details” or “insufficient_quota”
Recently, OpenAI changed their billing structure so that instead of a “surprise bill” at the end of the month where you might not know how much you were going to be charged unless you were constantly checking the OpenAI API usage dashboard, you now need to buy “credits” to use the OpenAI API.
As I always had, I proceeded to use my new OpenAI API key as normal with a python script in a Jupyter Notebook like this:
However, this didn’t work and I got an error saying something about how I exceeded my current quota?
It can be quite alarming seeing something like the below without knowing this information.
The Error:
RateLimitError: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}}
How to Fix:
To fix this, we will need to go to Settings > Billing > Pay as you go and then click the button that says “Add to credit balance”
This will allow us to deposit credits into our Credit balance
✨ Ta-da! I can now continue with using my OpenAI API Keys
And we can see that the balance went down from $5.00 to $4.99, meaning the key was used and cost me barely anything at all!
I hope this helps you on your AI journey if you encounter this bug!
Looking for more resources?
Read more related content here:
- Automating Code Generation with OpenAI GPT Agents: A Developer's Journey to Efficiency
- Thankful for the AWS Community Builders Program & Building + AWS Step Functions 101
- AWS: Predicting Stock Prices Using AI & NO CODE!
- Want to Learn How to Code? Discover the Top 4 Platforms to Kickstart Your Software Engineer Journey of Coding
- Turn Your AI Model into a Real Product (Amazon SageMaker, API Gateway, AWS Lambda, Next.js, Python)
- Launch your own LLM (Deploy LLaMA 2 on Amazon SageMaker with Hugging Face Deep Learning Containers)
Snag my 7 Days of Development ebook here:
I'll send you a FREE copy of my 7 Days of Development Ebook to get you started writing Python scripts, Node.js functions, Next.js apps, and building in the cloud!