LOCAL SPEND CAP FOR AI AGENTS
Stop an agent's API spend at a cap you set.
CostCap wraps your agent process with a local metering proxy. Once the cap is reached, further provider calls are refused. No account or sign-in needed.
Install from source
The npm package is not published yet. Node 20 or newer. The CLI needs no npm install; the optional pg driver is used only by the hosted service.
git clone https://github.com/persooninc/costcap.git
cd costcapWrap your agent
node src/cli.js wrap --cap 5 --day-cap 10 --max-steps 40 -- node your-agent.js--cap is USD per run, --day-cap and --month-cap are USD per UTC day and month, and --max-steps limits provider calls. Pause every agent sharing the kill file with node src/cli.js kill "reason", then node src/cli.js resume.
Enforcement limits
- Only proxy-routed calls are capped. The wrapper sets provider base URL environment variables. SDKs that ignore them, hardcoded endpoints, and subprocesses that drop them bypass CostCap.
- One accepted call can exceed the remaining cap. Cost is metered from provider-reported usage after each response, so the call that crosses the cap completes. Calls after it are refused. This is not a prepaid reservation.
- Prices are estimates. Cost comes from a versioned price table, not your provider invoice. Unknown models use a declared fallback rate. Check
src/pricing-table.jsonbefore relying on rates. - Missing usage or an uncertain network outcome pauses further calls. Unknown cost is never counted as zero.
- Day and month caps use UTC. Separate receipt ledgers do not share day or month caps.
- The kill file does not undo a request the provider already accepted, and it does not stop remote agents.
- The proxy binds to 127.0.0.1 for a trusted local machine. It is not an authentication boundary against other local processes.
Full enforcement limits in the README · Offline policy proof and its limits