cf-usage-guard
An open-source library that reads account usage from the Cloudflare GraphQL API and circuit-breaks individual Worker bindings before overages.
- Products
- WorkersKVD1R2Queues
- Source
- Community resourceGitHub repository
- Author
- tristanwagner
Key points
- The README requires the Workers Paid plan, an API token with Account Analytics: Read, a KV namespace for state, and a cron trigger that calls guard.evaluate(), for example every five minutes.
- It trips per resource with throw, skip, or custom behavior; wraps KV, D1, R2, Queues, AI, and Vectorize bindings; and offers dry-run mode, recovery 5% below the threshold, alert deduplication, and an optional global overage budget. If KV is unavailable, it defaults to not tripped.
- The README says the library is not affiliated with Cloudflare. Analytics can lag by several minutes, so it cannot stop overages that happen faster than the cron interval plus that delay, and it does not guarantee no overage charges.
Original sources
Undated
Original post
Open original source
More to read
Durable Objects
shmily7: a Durable Object alarm loop and a reported US$10,811.41 bill.
@shmily7 reports a Durable Object alarm loop in an unused test project, then says he paid the full US$10,811.41 bill to avoid service suspension. Cloudflare’s Ashley Peacock publicly says he is looking into it internally and will follow up.
Author experienceWorkers +4
Cloudflare billing pitfalls thread
The author organizes Cloudflare billing risks by product and shares experience with budget alert emails.
Workers AI
Jason Silberman: an approximately $1,000 AI-billing dispute, later reported resolved.
@_jasonsilberman reports an invoice around $1,000 with AI usage rows he says were duplicated and already prepaid. Cloudflare personnel reply, including Matthew Prince, who says the case was escalated. The author later says the issue was resolved.