100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
AI Guardrails & Safety Engineering
32 minadvanced

Rate Limiting, Quotas and Abuse Prevention

A single compromised API key, or one enthusiastic script a legitimate user wrote to 'automate their workflow,' can send an agent thousands of requests in a minute — and every one of those requests costs real money, consumes a shared inference quota other users depend on, and, if the agent has tool access, potentially executes thousands of real-world actions before anyone notices. An agent with no rate limiting is not just financially exposed; it has no mechanism to distinguish a burst of legitimate demand from an abuse pattern, because both look identical at the level of 'many requests arrived quickly.'

Rate limiting and quotas are the guardrail that makes volume itself a controllable variable instead of an unbounded one. A per-user request cap turns 'this account is sending an unusual number of requests' from a fact you discover during a billing review into a fact your system enforces in real time, before the hundredth request lands rather than after the ten-thousandth. This is a different concern from the content-level guardrails in earlier lessons — prompt injection defences and grounding checks constrain what a single request is allowed to do; rate limiting constrains how many requests get to try.

What breaks without it is any assumption that a system's cost and capacity scale predictably. An agent without quotas treats every caller as equally trusted and equally bounded — which is to say, unbounded — and the first caller (malicious or merely careless) who sends requests faster than the system was designed for degrades service for everyone else sharing that inference capacity, while quietly running up a bill nobody approved.

Analogy🏏Cricket
🏏 Think of it like cricket: A bowler is allowed six legal deliveries per over, not an unlimited stream of balls until the batting side calls a halt — the cap exists regardless of how well or badly the over is going, and it is enforced by the umpire counting every single delivery, not by trusting the bowler to stop at a reasonable point. Ravindra Jadeja does not get a seventh ball because his sixth was particularly threatening, and he does not get cut off at four because the batting side found the over uncomfortable — the limit is a fixed, counted quantity applied uniformly, independent of how the individual deliveries are going. Just as an over's six-ball cap is enforced by a running count rather than by hoping the bowler self-regulates, a rate limit is enforced by a running request count rather than by hoping a caller self-regulates their own volume. Just as the cap protects the fairness of the match — a batting side that faced unlimited deliveries in one over would never get to bat again — a request cap protects the fairness of shared inference capacity, ensuring one caller's volume cannot consume resources meant for everyone else waiting their turn. The insight is that rate limiting, quotas and abuse prevention: a hard, counted, uniformly-enforced cap is what turns volume from an assumption into a guarantee, exactly as the umpire's over count turns 'the bowler will probably stop around six balls' into a rule nobody can quietly exceed.
Lesson 25 of 35
0% complete