A hard budget cap and per-feature cost attribution in one npm install. A runaway retry loop can't drain your account — Budget Guard trips the breaker before it does. No proxy, no signup, MIT.
npm i budget-guard
View on GitHub →
"I set up an agent with the API and when I woke up I saw a $40 bill from a $5 task."
"One bug puts you in a retry loop that silently drains $30 in 8 minutes."
"We could see our AI bill, but not explain it. Which workflow caused the spike? Real usage or retry noise?"
Real public posts collected while researching this problem — the pain is everywhere.
// install npm i budget-guard // wrap your existing client import { guard } from 'budget-guard' const ai = guard(openai.chat.completions, { project: 'agent-worker', dailyCapUSD: 50, // hard stop }) // use it exactly like before. await ai.create( { model: 'gpt-4o', messages }, { feature: 'summarize' }, // tagged for attribution ) // runaway loops get blocked, not billed.
Your requests still go straight to OpenAI/Anthropic. We never sit in your critical path — just count, tag, and cap.
Hit the daily limit and the next call throws before it bills. Retry storms die at the breaker.
Tag by project & feature. spendReport() tells you "agent-loop cost $212 today" — no more mystery invoices.
spendReport() for cost breakdownsBuilding the hosted layer only if enough of you want it — the waitlist is the vote.