AI agents should never have unlimited spending power. BoltzPay enforces budget limits before any payment is signed or sent. If a request would exceed your limits, it fails immediately with a clear error. No money leaves your wallet.Documentation Index
Fetch the complete documentation index at: https://docs.boltzpay.ai/llms.txt
Use this file to discover all available pages before exploring further.
Budget Check Flow
Safety Guarantees
Budget checks happen before payment
The SDK validates all three limits (per-transaction, daily, monthly) before signing. If any limit is exceeded, aBudgetExceededError is thrown and the payment flow stops. Your wallet is never touched.
Spending is only recorded on success
If the payment fails or the server returns an error after payment, the amount is not recorded against your budget. This prevents phantom spending from eating into your limits.Warning events at 80%
When cumulative spending crosses 80% of any configured limit, the SDK emits abudget:warning event. You can listen for these to alert your agent or operator before hitting a hard stop.
Session Budget (Reserve / Release)
Sessions use a reservation pattern to prevent budget overcommitment when multiple sessions run concurrently.How it works
- Reserve — When
openSession()is called, the SDK reserves the deposit amount from the available budget. This atomically decrements available capacity. - Per-voucher check — During streaming, each voucher’s cumulative amount is checked against the reserved deposit. If it exceeds the deposit, the session is force-closed and a
MppSessionBudgetErroris thrown. - Release — When
session.close()is called, unused deposit (deposit minus actual spent) is released back to the budget.
Orphan detection
Sessions write two history entries: one atopen (with sessionStatus: "open") and one at close (with sessionStatus: "closed"). If a session opens but never closes (crash, timeout), the open entry without a matching close entry is detectable in payment history.
MCP Budget Enforcement
When usingwrapMcpClient(), the SDK intercepts payment challenges before credential creation. The challenge includes an amount field — the SDK converts it to USD and runs the standard budget check (per-transaction, daily, monthly) before allowing the credential to be created.
If the budget check fails, a BudgetExceededError is thrown and the MCP call returns an error. No payment is made.
Configuration
Set budget limits in the constructor:satToUsdRate (default: 0.001, ~$100K/BTC) and count toward the same limits. If you omit a limit, that check is skipped (no limit enforced for that tier).
Checking Remaining Budget
Listening for Warnings
What Happens Without a Budget
If you create aBoltzPay instance without a budget config, no spending limits are enforced. Every payment that the server requests will be signed and sent. This is fine for testing but not recommended for production agents.
Next Steps
- How It Works — the full payment flow, including where budget checks fit in
- Sessions — reservation lifecycle, streaming vouchers, and session receipts
- Configuration — all constructor options and environment variables