Hero Barua
All articles
Nov 27, 20265 min readAI workflowRate limitsLaravelHow AI counts

AI rate limits: what RPM, TPM and a 429 error mean

A 429 error means "not now". Here is how AI rate limits are counted, why they refill like a bucket, and a Laravel pattern for retrying politely.

Your AI feature worked fine in testing. Then ten users clicked at once and half of them got an error with the number 429. That's a rate limit. This is part 4 of the series; earlier parts covered tokens, pricing and the context window.

What is an AI API rate limit?

A rate limit caps how much you can ask for in a short time. It protects the provider's servers and keeps one customer from slowing down everyone else. It's separate from your bill: you can have money in your account and still hit a rate limit.

Anthropic measures it three ways, for each model class:

  • RPM: requests per minute.
  • ITPM: input tokens per minute.
  • OTPM: output tokens per minute.

OpenAI uses similar names: requests and tokens per minute (RPM, TPM) and per day (RPD, TPD), plus limits for images and audio.

Limits refill like a bucket, not a clock

Many people picture the limit resetting at the top of each minute. It doesn't. Anthropic says the API uses the token bucket algorithm, so your capacity is continuously replenished up to your maximum, rather than being reset at fixed intervals.

Picture a bucket of water. Each request takes some out. A tap fills it back at a steady speed. If you pour out more than the tap refills, the bucket runs dry and you wait. Short bursts are fine as long as the bucket has water. A steady flood isn't.

Which tokens count

Here's a detail that saves real money and limits. On Anthropic's API, the default ITPM limits count only uncached input tokens. Tokens read from the prompt cache don't count toward ITPM, while tokens written to the cache do.

So caching, which we priced in part 2, does two jobs: it lowers the bill and it lets you send more per minute.

What a 429 error means

When you go over any limit, Anthropic returns a 429 error that says which limit was exceeded. If the response has a retry-after header, it tells you how many seconds to wait.

A 429 is not a bug in your code. It's the API saying "not now, try a bit later". The fix is to wait and retry, politely.

Limits grow with your usage tier

Your limits aren't fixed forever. Anthropic places organisations on a usage tier automatically, based on usage history and account standing, and you can move up over time. OpenAI works the same way: limits are set per organisation and project and rise with spending. New accounts start small, so test with realistic traffic before a launch.

How to retry the right way

OpenAI's guide recommends exponential backoff: wait briefly after a failed request, then wait longer after each new failure. It also says to limit both the number of attempts and the total time spent retrying, and to treat retry-after as a minimum, adding a small random delay.

That random delay matters. If 50 jobs all fail at once and all retry after exactly 10 seconds, they hit the limit again together. Spreading them out avoids that.

In a Laravel app, the cleanest home for AI work is a queued job. Here's a sketch of the pattern:

code
class SummariseProduct implements ShouldQueue
{
    use Queueable;

    public int $tries = 5;

    // Wait longer after each failure: 10s, 30s, 60s, 120s.
    public function backoff(): array
    {
        return [10, 30, 60, 120];
    }

    public function handle(): void
    {
        $response = Http::withHeaders([...])->post($url, $payload);

        if ($response->status() === 429) {
            // Respect retry-after, plus a little jitter.
            $wait = (int) ($response->header('retry-after') ?: 30);
            $this->release($wait + random_int(1, 5));

            return;
        }

        $response->throw();
        // ... save the result
    }
}

If you use an official SDK, check its retry setting first. The AI helper on this site uses Anthropic's PHP SDK with two automatic retries, and if the service is still busy it tells the editor "The AI service is busy right now. Try again in a minute." instead of showing a raw error.

Five habits that avoid 429s

  1. Queue AI work. Don't call the API inside a web request when a background job will do.
  2. Limit concurrency. Run a fixed number of AI workers, not one per user click.
  3. Cache shared prompts. Cached reads don't use your input-per-minute limit on Anthropic.
  4. Cap output. A lower max_tokens keeps you under the output-per-minute limit.
  5. Batch what can wait. Big nightly jobs belong in a batch API, not in your live limits.

Quick summary

  • Rate limits cap requests and tokens per minute, per model class.
  • Capacity refills continuously, like a bucket, not once a minute.
  • On Anthropic, cached input reads don't count toward input tokens per minute.
  • A 429 means wait: follow retry-after, back off and add jitter.
  • Limits rise with your usage tier.

Next: the limits you feel as a subscriber, Claude's 5-hour and weekly windows.

References

  1. Rate limits, Claude Platform Docs, Anthropic, accessed 24 November 2026.
  2. Rate limits, OpenAI API Docs, accessed 24 November 2026.
  3. Queues, Laravel Documentation.

Questions people ask

What does a 429 error mean in an AI API?

You went over a rate limit. Wait and retry; if the response has a retry-after header, wait at least that many seconds.

What are RPM, ITPM and OTPM?

Requests per minute, input tokens per minute and output tokens per minute. Anthropic sets them for each model class.

Do rate limits reset every minute?

No. Anthropic uses a token bucket, so capacity refills continuously up to your maximum instead of resetting at fixed times.

Do cached tokens count toward rate limits?

On Anthropic, tokens read from the prompt cache do not count toward input tokens per minute. Tokens written to the cache do.

How useful was this article?

Tap a star

Written by Hero Barua

Full-stack SaaS engineer, 12+ years and Top Rated Plus on Upwork. AI builds the structure; I give it life.

Work with me