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:

Code Snippet: OpenAI Key Error

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:



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!


7 Days of Development Ebook
Previous
Previous

How to fix the PyVis Knowledge Graph error: localhost refused to connect

Next
Next

How to fix: Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')