← Blog

AI Gateway Rate Limiting: Identity-Aware Quotas at the LLM Request Boundary

AI gateway rate limiting enforces request quotas at the LLM request boundary against identity, role, model destination, and data classification. The pattern differs from a traditional API rate limit at three points: token-based budgeting that accounts for prompt and completion tokens, identity-aware quotas that bind to the caller rather than the source IP, and policy-coupled enforcement that integrates with the same gate that handles classification and audit. I walk through the quota model, the enforcement points, and where rate limiting sits relative to cost control and compliance evidence.

ByParminder Singh· Founder & CEO, DeepInspect Inc.
Platform & Architectureai-gatewayrate-limitingengineeringai-securityenforcementcost-control
AI Gateway Rate Limiting: Identity-Aware Quotas at the LLM Request Boundary

AI gateway rate limiting enforces request quotas at the LLM request boundary against identity, role, model destination, and data classification. The pattern differs from a traditional API rate limit at three architectural points: token-based budgeting that accounts for prompt and completion tokens rather than request count alone, identity-aware quotas that bind to the verified caller rather than the source IP, and policy-coupled enforcement that integrates with the same gate that handles classification and audit. The design matters at 2026 enterprise scale because LLM cost per call varies by two orders of magnitude across models, prompts vary by three orders of magnitude in token count, and the EU AI Act Article 9 risk management obligation expects measurable controls on AI usage patterns.

I want to walk through what the quota model looks like, where the enforcement points sit, and how the rate limit interacts with the policy decision and the audit record.

The token-based quota model

A traditional API rate limit counts requests per source IP or per API key per time window: 1,000 requests per minute, 10,000 per hour, 100,000 per day. The model assumes that each request carries roughly the same cost. That assumption holds for stateless REST APIs.

LLM API costs and latencies vary by three orders of magnitude across requests. A 50-token prompt against GPT-4o-mini that returns a 100-token completion costs a fraction of a cent and returns in 200 milliseconds. A 100,000-token prompt against GPT-4o that returns a 4,000-token completion costs over a dollar and takes 30 seconds. A request-count limit charges the two calls equally and produces a control that fails both directions: the 50-token caller is throttled when the budget could have supported many more calls, and the 100,000-token caller passes the request-count gate while burning the budget.

The quota model the gateway enforces is token-based. The gate counts prompt tokens, expected completion tokens (a policy-defined cap), and actual completion tokens after the response returns. The budget for an identity, role, or use case is expressed in tokens per time window for each model class: 10 million GPT-4o-mini tokens per day for a support role, 2 million GPT-4o tokens per day for a research role, 50,000 tokens per hour against a fine-tuned reasoning model for a planning role.

[@portabletext/react] Unknown block type "code", specify a component for it in the `components.types` prop

The budget can also include a cost-equivalent ceiling per identity expressed in dollars, which lets finance teams cap spend without negotiating token math with engineers.

Identity-aware quotas

The gate binds the quota to the verified identity rather than the source IP. A source-IP rate limit fails the corporate deployment because most enterprise traffic egresses through shared proxies, NAT pools, or cloud workloads that share a small set of source IPs across many callers. A per-API-key rate limit fails because the API key identifies the application, not the human or agent on whose behalf the application is acting.

Identity-aware quotas read the SSO assertion, the OIDC bearer, the workload identity certificate, or the agent identity claim the caller supplies. The quota applies to the verified principal: the user, the service account, the agent identity. The gate maintains separate counters per identity, per role, per use case, and per model class.

The architectural property matters for fairness, auditability, and regulatory evidence. The fair-share property prevents one heavy user from exhausting the budget of an entire team. The auditability property means the audit record carries the exact quota the decision charged against. The regulatory evidence property means the deployer can answer the EU AI Act Article 12 question of "who initiated each request, with what quota, against what policy."

Enforcement points

The gate runs the quota check at three points in the request path.

The first is pre-request admission. Before the gate forwards the call to the model, it checks whether the requesting identity has remaining budget at the model class the request targets. If the budget is exhausted, the gate rejects the call with a structured response that the application can present to the user (a 429 with a JSON body indicating when the quota resets, which model class the caller still has budget on, and the role that controls the quota).

The second is token reservation. When the call is admitted, the gate reserves the prompt tokens against the budget immediately. The reservation guarantees that two concurrent requests from the same identity cannot both pass the admission check and then jointly exceed the budget. The reservation pattern is the same as a database transaction that locks the row before reading it.

The third is post-response reconciliation. When the model response returns, the gate reads the actual completion tokens, settles the reservation against the actual consumption, releases or charges the difference, and writes the audit record. A request that completed with fewer completion tokens than the policy-defined cap returns the unused tokens to the budget. A request that the model truncated at the cap charges the cap.

Policy coupling

The rate limit is one input to the gate's policy decision. The gate also evaluates classification (PHI, PII, source code, MNPI), model authorization (which models the caller is permitted to call), and use-case policy (whether this caller is permitted to use this model for this purpose). The four inputs combine into a single per-decision outcome.

The architectural property the coupling provides is consistency. A caller who exhausts the budget gets the same structured decision shape as a caller who fails the PHI authorization check or the use-case policy. The application processes one denial mechanism. The audit record has one shape. The compliance evidence the deployer produces has one structure regardless of which policy gate fired.

The coupling also enables policy expressions that span the inputs: deny if the caller exhausted the budget for the support role and the prompt contains source code, deny if the caller is approved for the planning role but the request is outside the approved model class, redact if the prompt contains PHI even when the budget is available.

Where rate limiting sits relative to cost control

Cost control on LLM spend has three layers. The first is the per-provider budget the cloud provider or the LLM vendor enforces (the OpenAI organization-level spend cap, the Anthropic workspace budget, the AWS service quota for Bedrock invocations). That layer is coarse and applies to the entire organization.

The second is the per-team or per-product budget the FinOps function manages through chargebacks and showback reports. That layer is reactive: the team sees the bill after the spend happened.

The third is the per-identity, per-role, per-use-case budget the AI gateway enforces in real time. That layer is the only one that can prevent overspend at the moment of the request. The gateway also produces the data that feeds the chargeback and the FinOps reporting, because every decision carries the identity, the role, the use case, and the token consumption.

The three layers compose. The cloud provider budget catches the top-level cap. The team budget allocates the spend. The gateway enforces at the request boundary and produces the evidence.

Audit evidence and regulatory mapping

The EU AI Act Article 9 risk management obligation expects controls that perform as intended across the lifecycle and produce evidence of operation. A rate limit at the AI request boundary is one of those controls. The audit record the gate produces shows the quota that was in effect, the consumption against it, the decision the gate made on the specific request, and the policy version that governed the decision.

NIST AI RMF Measure function expects measurable evidence of system performance. The token consumption metrics, the decision rates by policy gate, and the quota exhaustion events feed the measurement. ISO 42001 clause 8.3 expects operational controls that produce evidence on demand. The gateway is the operational control.

The audit record commits to a write path the application has no access to. The application cannot suppress the record by crashing after the decision. The application cannot rewrite the record because it has no write access. The application cannot selectively log because the gate logs every decision regardless of the application's behavior.

DeepInspect

This is part of what DeepInspect provides at the AI request boundary. DeepInspect enforces identity-aware token quotas alongside the classification, model authorization, and use-case policy checks the same gate runs. Every decision produces a per-decision audit record covering identity, role, model class, token consumption, decision outcome, and a tamper-evident signature.

Enforcement overhead runs under 50 milliseconds in internal DeepInspect testing, against LLM inference latency that runs 500 milliseconds to 5 seconds. The quota reservation and post-response reconciliation happen in the same request hot path the classification and policy decision run in, so the overhead is shared across all four operations rather than multiplied across them.

The deployment pattern works in front of any HTTP-accessible LLM endpoint. The same quota model and the same audit format apply whether the caller targets api.openai.com, api.anthropic.com, the Bedrock invoke endpoint, Azure OpenAI, Vertex, or a self-hosted Llama or Mistral deployment.

If you are running LLM workloads at enterprise scale and your only rate limit is the provider-side budget cap, book a demo today.

Frequently asked questions

How does the gate handle prompt token estimation?

The gate runs the provider's tokenizer (tiktoken for OpenAI-compatible models, the Anthropic tokenizer for Claude, the Bedrock-specific tokenizers for Llama and Titan) against the prompt body and gets an exact prompt token count for the request. The exact count drives the reservation. The completion token estimate uses a policy-defined cap (default values per model class, configurable per role and per use case). Post-response reconciliation settles the reservation against the actual completion tokens.

What happens to concurrent requests from the same identity?

The reservation pattern serializes the budget update against the identity's counter. Two concurrent requests both reserve prompt tokens against the same counter and both proceed only if the combined reservation fits the budget. If only one fits, the gate admits one and rejects the other with a 429 indicating the budget exhaustion. The pattern is the same as a database transaction that locks the row before reading.

How does the gate handle streaming responses?

Streaming responses arrive in chunks. The gate buffers the stream, applies the response-path policy at the chunk level, and reconciles the token consumption against the actual completion tokens at the end of the stream. The user-perceived latency budget for the stream is the chunk size the deployment configures. The audit record covers the full stream and the per-chunk decisions taken.

Can the rate limit be policy-driven rather than fixed?

The policy expression supports time-of-day windows, day-of-week windows, project-level allocations, and incident-driven temporary caps. A research team's budget can lift for a planned project sprint and revert on the end date. An incident-driven response can cap the budget on a specific role across the organization for a defined window. The policy expressions feed the same gate that runs the classification and the audit, so the rate limit operates as a unified policy surface alongside the other inputs.

What is the cost of the gate itself relative to the LLM spend?

The proxy adds enforcement overhead under 50 milliseconds end-to-end in internal DeepInspect testing. The compute cost of the proxy is two to three orders of magnitude lower than the LLM inference cost it gates. A proxy that prevents a single overspend incident through the quota enforcement typically returns its annual cost within a single billing cycle. The cost calculation is similar to a WAF in front of a public web service: the upstream cost saving and the audit evidence value dominate the proxy cost.