BurnGuard protects against runaway AI spend through two complementary layers. The first layer is a set of soft alerts: when cumulative spend crosses a configured fraction of your budget, BurnGuard fires a Slack or Discord notification so you can take action early. The second layer is a hard block: once total spend reachesDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Verifieddanny/BurnGuard/llms.txt
Use this file to discover all available pages before exploring further.
budget.limit, every subsequent request is rejected with HTTP 403 before it ever leaves your machine — no tokens are consumed and no charges are incurred.
Budget enforcement
BurnGuard’sBudgetGuard middleware checks the in-memory spend tracker before forwarding every request to the provider. If the tracker reports that total spend has reached or exceeded the configured limit, the request is blocked immediately.
How the check works
When a request arrives, the tracker comparestotalSpend against budgetLimit using a mutex-protected read. If totalSpend >= budgetLimit, BurnGuard returns an HTTP 403 to your application and drops the request. The provider never receives it, so you are not charged.
What your app sees
Blocked!. Any error handling or retry logic in your code will run, but further retries will also return 403 until you reset the budget (see below).
Persistence across restarts
BurnGuard stores every usage record in the SQLite database atserver.db_path. On startup it loads the cumulative spend from the database and initialises the in-memory tracker with that total. This means budget enforcement survives restarts: if you have spent $45 of a $50 limit and restart the proxy, it will still block requests once spend reaches $50.
How to reset enforcement
You have two options:- Delete the database file — removes all stored spend history. The proxy starts fresh from $0.
- Increase
budget.limitinburnguard.yamland restart — raises the ceiling without losing history.
burnguard.yaml
Alert thresholds
Thresholds are decimal fractions ofbudget.limit in the range 0.0–1.0. When cumulative spend crosses a threshold, BurnGuard logs the event and fires webhook alerts to any configured destinations.
How thresholds are evaluated
After every request the alerter dividesspent by budget to get a ratio, then iterates through the thresholds list. If the ratio is greater than or equal to a threshold value and that threshold has not already fired this session, the alert triggers and the threshold is marked as triggered.
Threshold state and resets
Triggered state is stored in memory, not in the database. Each threshold fires exactly once per proxy session. Restartingburnguard start resets all triggered flags, so thresholds will fire again if spend still exceeds them at startup.
Recommended thresholds
burnguard.yaml
Slack alerts
Getting a Slack webhook URL
Create an incoming webhook for your workspace at api.slack.com/messaging/webhooks. Slack will give you a URL starting withhttps://hooks.slack.com/services/....
Configuration
burnguard.yaml
Alert message format
BurnGuard sends a plain-text message with the percentage used and the raw dollar amounts:Discord alerts
Getting a Discord webhook URL
Open your Discord server settings, navigate to Integrations → Webhooks, and create a new webhook for the channel you want to receive alerts. Discord will give you a URL starting withhttps://discord.com/api/webhooks/....
Configuration
burnguard.yaml
Alert message format
The message text is identical to Slack. The payload sent to Discord uses thecontent field:
Using Slack and Discord together
burnguard.yaml
Webhook requests are dispatched with
go a.send(message) — they run in a background goroutine and do not block the proxied request. Even if your Slack or Discord endpoint is slow or temporarily unavailable, the latency of the original AI API call is not affected.