Documentation 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.
burnguard start is the main runtime command. It reads burnguard.yaml from the current directory, opens the SQLite database, restores historical spend so budget tracking survives restarts, and begins accepting HTTP traffic on the configured port — forwarding every request to the appropriate upstream AI provider while counting tokens and enforcing your budget cap.
Usage
burnguard start. Both forms fall through to the same proxy startup path in main.go.
What happens on startup
Locate burnguard.yaml
BurnGuard looks for
burnguard.yaml in the current working directory. If the file does not exist the process exits immediately with a fatal error — see Error conditions below.Load and parse config
The YAML file is read and unmarshalled into the internal
Config struct. A parse error (invalid YAML, wrong types) is also fatal.Open the SQLite database
BurnGuard opens (or creates) the SQLite database at the path given by
server.db_path. The database stores every proxied request along with its token count and cost.Initialise the database schema
db.Init runs the schema migration that creates the requests table if it does not already exist. This is idempotent and safe to run against an existing database.Restore historical spend
BurnGuard queries the database for total lifetime spend:The result is used to seed the in-memory budget tracker, so your current-month spend is accurate across proxy restarts.
Initialise the budget tracker
An in-memory
Tracker is created with the restored spend total and the budget.limit from config. Every proxied request increments this tracker in real time.Create the alerter
The alerter is initialised with the Slack webhook, Discord webhook, and threshold list from
alerts in config. It fires notifications when spend crosses a threshold percentage of the budget limit.Start the reverse proxy
The proxy handler is registered on the default
http.ServeMux behind a BudgetGuard middleware that blocks requests once the hard cap is reached. The server starts listening on server.proxy_port.Expected startup output
sync.enabled: true. The spend figure reflects the sum of all rows in the requests table at boot time.
Error conditions
| Message | Cause | Fix |
|---|---|---|
No burnguard.yaml found. Run 'burnguard init' first. | Config file is missing from the current directory | Run burnguard init or cd to the directory that contains burnguard.yaml |
| Database open / init error | BurnGuard cannot create or open the file at server.db_path | Check that the directory exists and the process has read/write permission on that path |
| YAML parse error | burnguard.yaml contains invalid syntax or wrong value types | Validate the file against the burnguard.yaml reference |
All startup errors are fatal — the process exits with a non-zero code and prints the error via
log.Fatal. There is no partial startup.Stopping the proxy
Send SIGINT (Ctrl+C) or SIGTERM to the process to stop the proxy. The proxy binary uses a bare log.Fatal(http.ListenAndServe(...)) call with no signal handler and no graceful-shutdown logic. In-flight requests are terminated immediately when the process exits.
Running as a background service
For long-running deployments you will want the proxy managed by your operating system’s service supervisor.macOS — launchd
Create~/Library/LaunchAgents/run.burnguard.plist:
Linux — systemd
Create/etc/systemd/system/burnguard.service:
Port conflicts
If port8080 is already in use you will see:
burnguard.yaml and change server.proxy_port:
base_url reference in your application to point to the new port (e.g. http://localhost:9090/anthropic/v1/messages).