llm-budget is a budget control tool for AI agents, implemented in Rust. The project points out that almost all current agent frameworks only limit the number of loops and iterations; their guardrails cover prompt injection, personal privacy data, and harmful content, but not cost. Even when a budget cap exists, it often relies on unreliable price tables, causing budget accounting to be far lower than actual spending. llm-budget addresses this problem by providing hard dollar caps.
Main capabilities:
- Reject overspending calls: reserve a dollar amount before the call based on the worst case; if the call would exceed the cap, reject it directly.
- Precise pricing: prices come from llm-prices, and every row is annotated with the provider's pricing page and verification date.
- Reject when pricing is impossible: by default it uses a fail-closed policy and rejects any call that cannot be priced precisely, rather than recording overspending after the fact.
- Cluster cap: a unified budget cap can be set for an entire agent cluster.
- Kill switch: stop all agents with a single switch.
- Model degradation: automatically switch to a cheaper model when the balance is insufficient.
- Audit function: audit can be pointed at a JSON-lines log of calls (including the model, the provider's usage block, and optionally the booked_usd recorded value) to assess the amount of overspending that a soft limit might let through; when any cost crosses the cap, the exit status is 2, which can be used as a CI gate, and --json output is supported for machine reading.
Usage: the project provides documentation, a crates.io release package, and integration instructions for other projects, covering features, the minimum supported Rust version, stability, and a five-line integration example.
Applicable scenarios: Rust projects that need strict cost control over AI agent calls, especially multi-agent clusters and scenarios requiring CI budget gates.
Limitations: the materials do not provide specific installation commands, API examples, or the full contents of the price table; the project uses the MIT license.