antig3n/llm-gateway-cost-guard: a Worker that enforces a per-licence monthly LLM cost cap under concurrency
The MIT-licensed repository antig3n/llm-gateway-cost-guard is a Cloudflare Worker that sits between a paid product and an LLM provider and is described as guaranteeing that no customer licence can spend more than its monthly cap, even under heavy concurrency. The README says a naive “read balance, call model, write cost” loop overspends as soon as two requests interleave, and that 29 tests include a concurrency check: 25 parallel requests against a cap that fits only 4, with 4 admitted and 21 refused. This tool caps the author’s own LLM provider spend, not Cloudflare’s product invoice. Reviewed from the public README on 2026-11-19.
- Products
- Workers
- Source
- Community resourceGitHub
- Author
- antig3n
Key points
- The README states the concurrency test holds every provider response until all admissions are decided, then checks the invariant after each database write.
Original sources
Last updated
antig3n/llm-gateway-cost-guard: a Worker that enforces a per-licence monthly LLM cost cap under concurrency
Open original sourceThe MIT-licensed repository antig3n/llm-gateway-cost-guard is a Cloudflare Worker that sits between a paid product and an LLM provider and is described as guaranteeing that no customer licence can spend more than its monthly cap, even under heavy concurrency. The README says a naive “read balance, call model, write cost” loop overspends as soon as two requests interleave, and that 29 tests include a concurrency check: 25 parallel requests against a cap that fits only 4, with 4 admitted and 21 refused. This tool caps the author’s own LLM provider spend, not Cloudflare’s product invoice. Reviewed from the public README on 2026-11-19.
More to read
Spend Management: spending limits and alerts for Workers and Durable Objects
Cloudflare’s 13 November 2026 open beta lets pay-as-you-go accounts set a monthly USD spending limit on Workers or Durable Objects usage charges (after included usage). The limit can block new billable work or send email only. It is not a guaranteed invoice cap, is account-wide per product, and does not cover the Workers Paid subscription fee, stored Durable Object data, or other products such as KV, R2 and Workers AI.
Kun Save Point (@Savepoint_kk): a D1 bug rewrote unchanged data into a $2,739.12 bill; $2,141 goodwill credit granted.
Kun Save Point (@Savepoint_kk), an indie developer who says he recently lost his job, says a bug repeatedly rewrote unchanged data while inefficient queries amplified reads, producing a $2,739.12 Cloudflare bill already paid via PayPal (D1 rows written $2,641.00, rows read $64.06, other services $34.06); he says his bills were usually under $10 a month. Cloudflare granted a $2,141 goodwill account credit under case #02391058. He asks for it to be converted into a refund to the original PayPal payment, or at least for relief on the $2,641 write charges, and later writes that the initial request was declined and has been reopened for additional review. On October 25 he adds that he missed the only alert email Cloudflare sent, whose amount was not particularly high, and received no further warning before the large card charge; on October 26 he writes that the refund request to the original payment method is still under further review. On November 10 he posts a timeline saying that after following up on November 10–11, support again stated the $2,141 could only remain as account credit and the remaining $598.12 was still undecided while the ticket was being closed.
EmDash on Cloudflare: what the Free plan covers, where $5 a month is needed, and R2 billing past its free tier
HIRO3 (@engineer_num1) checks EmDash 1.3.1 against Cloudflare’s pricing and limits pages: the site deploys to the Free plan by default, but registry plugins need Worker Loader on Workers Paid, Workers and D1 stop rather than bill at Free limits, and R2 needs a sign-up and bills usage beyond its free allowance.