A budget that says no before the spend.
This is not a dashboard you read after the invoice. The model proxy sits in front of your model API. It meters every call by identity, refuses once the budget is spent — before the provider — and breaks a runaway loop before it drains the window. A spike can freeze the grant. pyxgrant payback lists prevented events you can re-derive from those decisions — exact counts or labelled estimates, not your invoice. payback prove dumps that ledger as an offline pack. Each refusal is a signed decision in the same audit log as everything else. This is not a SIEM or SOAR.
A ceiling per identity, checked before the call is sent.
Set a cost or token budget per principal for a window, 24 hours by default, or give each identity its own in a budgets file. Once it is spent, the next call gets a 429 and never reaches the provider. Setting "locked": true stops an identity's spend outright.
-hold-models parks every request to the models you name until someone approves it.agency-exhausted. Under the hardened profile, a model with no configured price is refused with 403 model-unpriced. Governed model-route can advise or enforce which model a principal may call.HTTP/1.1 429 Too Many Requests X-PyxGrant-Refusal: budget-exhausted {"error": { "message": "PyxGrant: …", "type": "pyxgrant_budget_exhausted" }}
Stop the retry storm before the budget does.
A loop can burn a day's budget in minutes. Spend-rate and call-rate limits refuse a principal that spikes, marked wallet-abuse so your SIEM can tell it from an ordinary spent budget. Identical repeats can be routed to a cheaper model to break the loop instead of failing it.
-cache on, a byte-identical request is answered from the cache at $0 and metered as savings.-max-output-tokens trims what a single request can ask for.$ pyxgrant llm \ -budget-cost 5 -budget-window 24h \ -max-cost-per-min 0.50 \ -max-calls-per-min 60 \ -loop-degrade-threshold 3 \ -loop-degrade-model a-cheaper-model \ -cache
One ceiling, however many processes share it.
Tag a workflow with a run id and every gateway on that run, on the model and tool side, is tied to it. pyxgrant runs shows what each run has spent and which sessions joined it. A freeze on the run stops all of them.
-reserve-budget holds headroom before each call, so two processes can't both pass a nearly spent budget.proxy A reserves $0.40 admitted proxy B reserves $0.40 429 no headroom left proxy A metered $0.31 reservation released one window budget across both
Who spent what, and where it is heading.
pyxgrant economy prints the consumption ledger per identity: tokens, cost, and budget, with a forecast of who runs out first. pyxgrant quote issues a signed cost quote that a spend can be checked against later, offline.
identity tokens cost budget billing-agent … … $5.00 claims-bot … … $20.00 values come from your own audit log
What the decision prevented, re-derived from the record.
pyxgrant payback reads a signed ledger of events that did not happen because a control fired: a spawn refused, a herd block, a tool-result cache hit. LLM cache hits book avoided tokens as labelled estimates. payback prove dumps every signed line as a pack you re-check offline. showback -by grant -rollup folds each grant's spend into its ancestors. Each line is an exact count or a labelled estimate from a stated rate. It is not your provider invoice. Cascade dollar-rate delta is not a token line on this file. Unpinned passport-verify reports self-attested (exit 3), not verified, until you pin a key.
control event basis spawn-budget compute_spawns exact injection-herd injection_actions exact tool-result-cache downstream_calls exact estimates carry the rate; they are not a bill cut
Put a ceiling on agent spend this week.
The model proxy runs from the same binary that already decides your tool calls.