SuperAPIAI Directory

llm-budget

github.com · AI developer platforms

llm-budget is an AI agent budget control library written in Rust that provides hard dollar caps for agent calls. It prices each call according to a price table with dates and source citations, reserves cost before the call based on the worst case, rejects calls that would exceed the budget or cannot be priced precisely, and supports a unified cap for an entire agent cluster, a one-switch kill switch, and degradation to a cheaper model when the balance is insufficient.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)

About this tool

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.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools