In-process spend and policy library
Cap model spend inside your own app.
AgentGuard® SDK checks spend caps and policy rules in your process before a model call leaves your server, and writes signed local records.
Sample data. A spend guard around a model client blocks a call that would pass the daily cap and writes a signed local record.
Stop loops before the provider charges you
Wrap your provider client so policy runs in-process before dispatch. Set caps per call, minute, hour, day and month, each with hard block, model downgrade or shadow logging.
Scope limits to any dimension
Build one policy scope from tenant, team, user, agent, task and provider keys. Error messages and blocked traces localize in English, Spanish and Portuguese.
Signed local records you can check offline
Add Ed25519 keys to record every completed decision in a tamper-evident local log. Verify records offline or in the browser at /verify with no account.
"action": "block","reasons": ["Cap 'per_day=50000c' exceeded"],"triggeredScopeKey": "tenantId=demo|agentId=agent-finance-bot-v3","signature": "bd53625d...0c3f06"# the demo receipt at /verify (Load demo)Drops into Node.js and Python
Published for Node.js (@agentguard-run/spend) and Python (agentguard-spend), with bindings for OpenAI-compatible clients, Anthropic Messages, Bedrock, Vercel AI SDK, LangChain.js and OpenRouter.
npm install @agentguard-run/spendpip install agentguard-spendnpm install @agentguard-run/spend openaiHow it works
Questions
Does AgentGuard® SDK proxy my model traffic?
No. Policy checks run inside your own process before the request leaves your server.
How is this different from AgentGuard® Local?
AgentGuard® Local caps Claude Code and Codex through hooks; AgentGuard® SDK caps model calls inside apps you build.
Can I log before blocking?
Yes. Set any cap window to shadow mode to log decisions without blocking calls.
Live packages published on npm (@agentguard-run/spend 0.22.0) and PyPI (agentguard-spend 0.16.0).