scriptRun Beta

OpenAI API Rate Limits: How to Fix 429 Errors and Keep Your App Running

AnnaAnna
November 12, 2026
Business
AI WorkflowsAutomation
OpenAI API Rate Limits: How to Fix 429 Errors (2026 Guide)

OpenAI API rate limits cap how many requests and tokens your app can send per minute and per day.

Cross one, or let your account hit a credit, spend or usage cap, and the API returns a 429 error instead of an answer.

Your users see a failure, and retrying blindly often makes it worse.

This guide shows you how to tell the different 429 errors apart, how OpenAI’s limits work, and how to fix them with Python retry code.

It also covers what to do when one provider’s limits aren’t enough, such as sending traffic through an OpenAI-compatible API that retries and fails over to other providers for you.

Which 429 error do you have

OpenAI's error codes page lists six different causes for a 429.

Check the message or the code field in the error body, then find it below.

Error (message or code)What it meansHow to fix it
Rate limit reached for requestsYou're sending requests too quicklySlow down and retry with backoff, following the Retry-After header
slow_downYour request rate rose too fastReduce your rate, then increase it gradually
credit_balance_exhaustedYour organization has no prepaid credits leftAdd credits; retrying won't help
organization_spend_limit_exceededThe organization hit its own spend limitRaise or remove the organization spend limit
project_spend_limit_exceededA project hit its spend limitRaise or remove the limit in the project settings
organization_usage_limit_exceededYou reached the usage limit OpenAI assigned to your organizationRequest a higher limit or contact support

The first two are true rate limits: wait and they clear.

The last four are account caps: no amount of retrying fixes them, so your code should stop and alert someone instead.

In the Python SDK, all of them raise RateLimitError.

How OpenAI API rate limits work

OpenAI measures your traffic in several ways at once, and hitting any one of them returns a 429:

  • RPM: requests per minute

  • RPD: requests per day

  • TPM: tokens per minute

  • TPD: tokens per day

  • IPM: images per minute, for image models

You can be well under your RPM and still be blocked on TPM if your prompts are long.

Each limit is set per model, so moving a job to a different model gives it a separate allowance, unless the two models share a limit (your organization's limits page lists shared limits).

OpenAI rate limits apply at the organization and project level, not per user or per API key. Every key in a project draws from the same pool, so a batch job can use up the capacity your customer-facing feature needs.

Creating more keys doesn't raise your limits.

Two details catch many teams out.

📌 First, failed requests count toward your per-minute limits, so a tight retry loop makes the problem worse.

📌 Second, OpenAI estimates a request's token use from the larger of your max_tokens value and its own estimate, so a high max_tokens uses up TPM even when the actual response is short.

Usage tiers and how to increase your limits

Your limits depend on your usage tier, which is based on how much you've spent on credits in total. At the time of writing, OpenAI's rate limits guide lists these tiers:

TierQualificationMonthly usage limit
FreeLocated in an allowed geography$100
Build$5 in total credit purchases$500
Launch$100 in total credit purchases$5,000
Grow$500 in total credit purchases$200,000

You move up automatically once your total purchases reach the next threshold.

You can also choose Upgrade tier under Settings > Organization > Limits. 

Your exact RPM and TPM for each model are on that same Limits page.

OpenAI changes tiers and limits from time to time, so check that page rather than relying on numbers in blog posts.

Reading the rate-limit headers

Every response includes headers that show how much of your limit is left:

HeaderWhat it tells you
x-ratelimit-limit-requests / x-ratelimit-limit-tokensYour current request and token limits
x-ratelimit-remaining-requests / x-ratelimit-remaining-tokensHow many you have left in the current window
x-ratelimit-reset-requests / x-ratelimit-reset-tokensHow long until the window resets
x-ratelimit-limit-project-tokens, -remaining-project-tokens, -reset-project-tokensThe same, for your project's token limit
Retry-AfterHow long to wait before retrying; treat it as a minimum

In Python, use with_raw_response to see them:

from openai import OpenAI

client = OpenAI()

raw = client.chat.completions.with_raw_response.create(
    model="MODEL_ID",
    messages=[{"role": "user", "content": "Hello"}],
)
print(raw.headers.get("x-ratelimit-remaining-requests"))
print(raw.headers.get("x-ratelimit-remaining-tokens"))
completion = raw.parse()  # the normal response object

How to fix and prevent OpenAI rate limit errors

These fixes work for true rate limits, the "Rate limit reached" and slow_down errors. For credit, spend and usage-limit errors, change the account settings described in the table above.

Step 1: Retry with exponential backoff and jitter

When a request is rate limited, wait and try again, doubling the wait each time and adding a little randomness (jitter) so many clients don't retry at the same moment. Always respect Retry-After when OpenAI sends it, and cap both the number of attempts and the total wait.

The OpenAI SDK already retries some errors by itself.

If you write your own loop, set max_retries=0 on the client so the two don't stack up.

import random
import time

from openai import OpenAI, RateLimitError, InternalServerError

client = OpenAI(max_retries=0)  # we handle retries ourselves

# 429s that retrying can't fix
ACCOUNT_CAPS = {
    "credit_balance_exhausted",
    "organization_spend_limit_exceeded",
    "project_spend_limit_exceeded",
    "organization_usage_limit_exceeded",
}

def create_with_backoff(max_attempts=6, max_wait=60, kwargs):
    delay = 1.0
    for attempt in range(1, max_attempts + 1):
        try:
            return client.chat.completions.create(kwargs)
        except (RateLimitError, InternalServerError) as err:
            if getattr(err, "code", None) in ACCOUNT_CAPS or attempt == max_attempts:
                raise
            retry_after = err.response.headers.get("retry-after")
            wait = max(delay, float(retry_after)) if retry_after else delay
            time.sleep(min(wait + random.uniform(0, wait  0.25), max_wait))
            delay = 2

response = create_with_backoff(
    model="MODEL_ID",
    messages=[{"role": "user", "content": "Summarize this ticket in two lines."}],
)

InternalServerError is included because OpenAI also asks you to retry 503 "model temporarily overloaded" errors with backoff.

Step 2: Set max_tokens close to what you need

Because OpenAI counts the larger of max_tokens and its own estimate against your TPM, a max_tokens of 4,000 on a request that returns 300 tokens wastes most of that allowance.

Set it close to your real output length and you can fit more requests into the same limit.

Step 3: Batch work, or use the Batch API

If you hit your request limit but have tokens to spare, combine several small tasks into one request.

For work that doesn't need an answer right away, such as overnight classification or bulk embeddings, use OpenAI's Batch API.

Batch jobs have their own queue limit and don't use up your synchronous rate limits.

Step 4: Throttle requests on your side

Retries react to errors after they happen.

A client-side rate limiter prevents them: track how many requests and tokens you've sent in the last minute and hold back new requests when you're near your limit.

A shared queue or token-bucket limiter works well when several workers call the API with the same project.

Step 5: Ramp up traffic gradually

The slow_down error means your traffic grew too quickly, for example when you switch a big feature on all at once.

Once you're above 1 million input tokens per minute, OpenAI asks that you increase traffic by no more than 50% every 15 minutes.

Roll out new high-volume features in stages.

Monitor your limits before they bite

Most teams find out about rate limits from an angry user. A little monitoring warns you first:

  • Log the headers. Record x-ratelimit-remaining-requests and x-ratelimit-remaining-tokens on every call, tagged by model and project.

  • Alert on headroom. Warn when remaining capacity regularly drops below a set share of your limit, for example 20%, so you can raise your tier or move traffic before requests fail.

  • Track the 429 rate. Count 429s per model and project, and keep account-cap errors separate from true rate limits, because they need different people to fix them.

  • Watch spend limits too. A project spend limit set months ago can start blocking traffic as usage grows.

When one provider isn't enough

Backoff handles short bursts. It can't fix demand that is consistently higher than your limits, and it can't help when OpenAI itself is overloaded or down.

At that point you have three options:

  1. Raise your limits. Move up a tier, or ask OpenAI for a higher usage limit.

  2. Move work off the hot path. Send anything that can wait to the Batch API.

  3. Spread traffic across models and providers. Send some requests to another model with its own limit, and fail over to another provider when one returns errors. An LLM router automates this.

The third option is where an OpenAI-compatible gateway helps. ScriptRun's OpenAI-compatible API works with the OpenAI SDK you already use, so you only change the base URL and key. 

It adds automatic retries with backoff, request-level idempotency so a retried call isn't processed twice, failover between providers during outages, and per-project keys, limits and quotas so one workload can't starve another. 

Your code keeps calling one endpoint, and you aren't tied to a single provider's rate limits.

What about Azure OpenAI rate limits

Azure OpenAI has its own quota system. Limits are managed in Azure for each model deployment, not in OpenAI's dashboard, and you raise them through Azure.

The error-handling advice in this guide still applies:
💡 Retry 429s with backoff, honor Retry-After, and keep max_tokens realistic.


Helpful?
Share this article!

Build AI workflows in minutes

Create automations, connect APIs, and access 50+ AI models from a single platform.

Visual workflow builder
OpenAI-compatible API
Workflow marketplace & templates
Start free, plans from $5

FAQs about OpenAI API Rate Limits

Why do I get a 429 error on my first request?

This is almost always an account cap, not a rate limit. Check the error code. credit_balance_exhausted means your organization has no prepaid credits, which is common on new accounts. Add credits and try again.

How do I increase my OpenAI API rate limit?

Your limits rise automatically as your total credit purchases move you into a higher usage tier. You can also choose Upgrade tier under Settings > Organization > Limits. Organizations with very high volume can ask OpenAI about larger dedicated capacity.

Do failed requests count toward OpenAI rate limits?

Yes. Unsuccessful requests count toward your per-minute limits, so retrying immediately and repeatedly makes the problem worse. Use exponential backoff.

What's the difference between RPM and TPM?

RPM limits how many requests you send per minute. TPM limits how many tokens those requests use, including input tokens and the output allowance set by max_tokens. You can hit either one first: many short requests hit RPM, a few long ones hit TPM.

Does the Batch API have rate limits?

Yes, but they're separate. Batch jobs count against a queue limit based on the input tokens waiting for each model, and they don't use your normal per-minute limits. OpenAI limits and error codes last checked on November 11, 2026 against OpenAI's rate limits and error codes pages.

Read more from our blog

Related posts

AI WorkflowsAutomation
Cheapest LLM API 2026: Verified Prices per 1M Tokens
BusinessNovember 20, 2026

Cheapest LLM API 2026: Verified Prices per 1M Tokens

Which is the cheapest LLM API? Verified prices for OpenAI, Claude, Gemini, DeepSeek, Qwen, Mistral and Groq, plus real workload costs and hidden fees.

1734
AnnaAnna
AI MarketplaceAI WorkflowsAutomation
AI Agent Marketplace: 10 Best Platforms Compared (2026)
BusinessNovember 19, 2026

AI Agent Marketplace: 10 Best Places to Find, Run and Sell AI Agents in 2026

What an AI agent marketplace is, 10 top platforms compared on cost to try and who can sell, a safety checklist, and how to list your own agent in 2026.

1886
AnnaAnna
AI WorkflowsAutomation
Free LLM API: 2026 Providers, Limits and Real Catches
BusinessNovember 18, 2026

Free LLM API: Which Providers Are Still Free in 2026 (Limits, Keys and Catches)

Every free LLM API worth using in 2026, checked against official docs: free tiers vs credits, limits, data terms, how to get a key, and fallback code.

1905
AnnaAnna
AI WorkflowsAutomation
OpenAI Compatible API: How It Works and What Breaks
BusinessNovember 17, 2026

OpenAI Compatible API: What It Is, Who Supports It and How to Switch Safely

An OpenAI compatible API guide: base URLs for 15 providers, what breaks when you switch, a copy-paste smoke test and a safe migration checklist.

1709
AnnaAnna
© 2024-2026 PIXEL LORIS IT SERVICES L.L.C. All rights reserved.