AI Gateway spend limits
Cloudflare documents cost-based budgets on an AI Gateway that block requests, or fall back to a cheaper model, once cumulative spend in a time window reaches the limit.
- Products
- AI GatewayWorkers AI
- Source
- Official docsCloudflare Docs
- Author
- Cloudflare
Key points
- Spend limits are configured per gateway. Each rule sets a dollar budget over a rolling or fixed time window, can be scoped by model, provider or custom metadata such as user ID, and a gateway can have up to 20 rules.
- When a limit is exceeded, AI Gateway returns 429 and blocks requests until the window resets by default; alternatively, a Dynamic Route can fall back to a cheaper model.
- The docs say limits are eventually consistent: a request’s cost is recorded after it completes, so a burst of concurrent requests can briefly exceed the limit. Cost tracking is a best-effort estimate from token counts and model pricing, and the provider dashboard remains authoritative for billing.
- Spend limits apply to Unified Billing and BYOK requests for models with known pricing.
Original sources
Original source · Last updated
Open original sourceChangelog: AI Gateway adds spend limits that track cumulative dollar spend by token usage and model pricing and block requests when the budget is exceeded, unlike rate limiting, which caps request counts.
Open original source
More to read
Why hard spending caps take time: Ashley Peacock on billing latency
Ashley Peacock (@ashleypeacock), who works on Durable Objects at Cloudflare, explains from experience why near-real-time spending caps are hard to build, says hard billing caps are coming soon, and suggests budget alerts plus issue alerts in the meantime.
hfcorriez: $100+ of AI-driven extra usage over two months, reported cancelled after emails.
@hfcorriez says AI caused over $100 of extra consumption over two months. He says that after two rounds of email explaining the situation to Cloudflare, the charges were cancelled, and posts a screenshot of two negative line items (-$31.92 and -$75.42) marked Fully Applied.
sylwair: nearly $900 of usage in under two days after a project mistake.
@sylwair says a recent project mistake ran up nearly $900 in less than two days. He says he spotted it in Cloudflare's billable-usage view and stopped the abnormal service, and in a reply adds that the daily billing figures appeared with a delay, so the amount did not visibly drop after he stopped it.