Already building on LangChain, LangGraph, CrewAI, or the Vercel AI SDK? Add a hard spend cap, a kill switch, capability gates, and a signed audit receipt to every model call without changing your agent logic. Your own key, in your process, free forever. A runaway loop stops before it drains your budget.
AgentGuardBlockedError. Every decision signs an Ed25519, content-free receipt you can verify at /verify. Zero data plane.
npm install @agentguard-run/spend # Node / TypeScript
pip install agentguard-spend # Python
Works for any LangChain chat model, and for LangGraph (same underlying LLM). No wrapper, no proxy.
import { ChatOpenAI } from '@langchain/openai';
import { AgentGuardSpendCallbackHandler } from '@agentguard-run/spend/dist/integrations/langchain-callback';
const guard = new AgentGuardSpendCallbackHandler({
dailyCapDollars: 20, // hard block at $20/day
agentId: 'research-agent',
// optional: softCapDollars + downgradeTo, perMinuteCapDollars, tenantId
});
const llm = new ChatOpenAI({ callbacks: [guard] });
await llm.invoke('hello'); // throws AgentGuardBlockedError if over cap
CrewAI (Python) runs on LangChain or LiteLLM under the hood. Guard the LLM client your crew uses with agentguard-spend, and every agent step inherits the same cap, kill switch, and signed receipt. See the Python quickstart for the exact cap-and-sign call. On a TypeScript stack, use the LangChain callback shown above, since CrewAI agents ride on the same chat models.
One middleware on your language model. Works with generateText and streaming.
import { wrapLanguageModel } from 'ai';
import { openai } from '@ai-sdk/openai';
import { agentguard } from '@agentguard-run/spend/frameworks/vercel-ai';
const model = wrapLanguageModel({
model: openai('gpt-4o-mini'),
middleware: agentguard({
policy: { caps: [{ amountCents: 2000, window: 'per_day', action: 'block' }] },
scope: { tenantId: 'acme', agentId: 'assistant' },
}),
});
Not on a framework? Wrap the raw client. This is the base pattern the others build on.
import { withSpendGuard } from '@agentguard-run/spend';
const guarded = withSpendGuard(new Anthropic(), {
policy: { caps: [{ amountCents: 2000, window: 'per_day', action: 'block' }] },
scope: { tenantId: 'acme', agentId: 'my-agent' },
});