Search code examples
pythonopenai-apichatgpt-api

openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details


I recently obtained a free API key from OpenAI and attempted to use it in my script. However, I encountered the following error on my very first attempt:

openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.

I haven't used the API key before, so I'm puzzled by this error. Could someone please help me understand what might be causing this issue and how I can resolve it?


Solution

  • This also happened to me when I sent a lot of prompts via the API. The rate limit is dependent on the amount of credits paid on your account and how long it has been since you have made your first payment.

    According to the OpenAI documentation, there are different rate limits:

    Rate limits are measured in five ways: RPM (requests per minute), RPD (requests per day), TPM (tokens per minute), TPD (tokens per day), and IPM (images per minute). Rate limits can be hit across any of the options depending on what occurs first. For example, you might send 20 requests with only 100 tokens to the ChatCompletions endpoint and that would fill your limit (if your RPM was 20), even if you did not send 150k tokens (if your TPM limit was 150k) within those 20 requests.

    This limit is bumped up if you upgrade your plan tier. The plans are as follows according to the OpenAI documentation:

    Tier Qualification
    Free User must be in allowed geography
    Tier 1 $5 paid
    Tier 2 $50 paid and more than 7 days since first successful payment
    Tier 3 $100 paid and more than 7 days since first successful payment
    Tier 4 $250 paid and more than 14 days since first successful payment
    Tier 5 $1,000 paid and more than 30 days since first successful payment

    Depending on your Tier and the model you use, you can find your limits in the OpenAI doucentation.