Skip to main content
Cap LLM call rate so agents stay within provider quotas and budget — safely, even when many agents share one limiter.
Replaces the deprecated rate_limiter= kwarg on Agent() — see Legacy Agent Parameters.
The user runs agents at scale; the limiter queues or throttles LLM calls so quotas are not exceeded.
For bot/messaging rate limiting (Telegram, Discord, Slack), see Bot Rate Limiting. This page covers LLM API rate limiting.

How It Works

Quick Start

1

Simple Usage

Set max_rpm on execution config for a single agent:
max_rpm=60 alone is enough — the Agent auto-creates a live RateLimiter(requests_per_minute=60) behind the scenes. No RateLimiter import required for the simple case.
2

With Configuration

Share one RateLimiter across multiple agents:

How It Works

Token bucket algorithm: tokens refill at requests_per_minute / 60 per second; each LLM call consumes one token. Under contention, callers wait until a token is available. The limiter applies to both the initial LLM call and the follow-up after tool execution in streaming mode. The rate limiter applies to every LLM call the agent issues — single-shot, streaming, tool-iteration and reflection turns, sync and async — so a per-model token budget is never spent on a path that bypasses throttling.
Since PraisonAI PR #3877, achat() / astart() / arun() and managed-backend delegation all await rate_limiter.acquire_async() before hitting the LLM. Earlier releases could burst past max_rpm on async entry points.

Precedence

The Agent picks a limiter from three levels: an explicit rate_limiter wins, else max_rpm auto-builds one, else no throttling. rate_limiter (explicit) > max_rpm (auto-built) > no limiter max_rpm <= 0 short-circuits and raises ValueError at construction — regardless of whether an explicit rate_limiter was also supplied, because validation runs before the precedence check.

Configuration Options

Setting max_rpm=N on ExecutionConfig now auto-creates a live RateLimiter — passing a full rate_limiter object is only needed for burst or tokens_per_minute control.

Errors

Zero or negative max_rpm raises ValueError at construction, before the explicit-limiter precedence check.
max_rpm=0 raises even when a valid rate_limiter is also provided — validation runs before precedence.

YAML

max_rpm in agents.yaml now throttles requests — it auto-creates a live RateLimiter when no limiter is set on the agent, and raises ValueError on max_rpm <= 0.

Best Practices

Low burst (1–5) smooths traffic; higher burst tolerates spiky demand.
Providers quote RPM and TPM — limiting only RPM can still trigger 429 errors.
agent.achat() / astart() / arun() call acquire_async() automatically — sync and async entry points are throttled equally, so pick whichever fits your event loop.

CLI


Thread Safety

Thread-safe chat history and caches

Concurrency

Limit parallel agent runs