AgentGuard · agentguard.run

Spend caps for your agent framework, in a few lines

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.

Same guarantees everywhere: the call is checked in your runtime before the provider is touched. Over the cap, it throws AgentGuardBlockedError. Every decision signs an Ed25519, content-free receipt you can verify at /verify. Zero data plane.

Install

npm install @agentguard-run/spend        # Node / TypeScript
pip install agentguard-spend             # Python
LangChain · LangGraph

Attach one callback handler

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

Guard the client your crew runs on

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.

Vercel AI SDK

Wrap the model with middleware

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' },
  }),
});
Any OpenAI or Anthropic client

Wrap the client directly

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' },
});
Free forever with your own key. Caps, kill switch, capability gates, and signed receipts are never paywalled. Want us to handle AI access so there is no key to manage? That is Managed ($99/mo, inference included). See the Managed quickstart.