AI spend guardrails
Your agent doesn't know when to stop. Now it does.
One bad loop turns a $200 month into a $2,000 one — and you find out when the invoice lands. Cap it, watch it, get paged before it hurts.
Simulated meter: an unguarded month runs away past $2,000. With a guardrail, the same month is capped at $500.
// the problem
Costs compound, not add.
Every retry and tool call feeds context back in. Spend doesn't grow with traffic — it grows with traffic times loop depth.
No smoke alarm.
You can't cap what you can't see. Right now the bill is the first signal — and it arrives thirty days late.
It worked in testing.
Prototypes don't loop. Production does. One user with a weird input is all it takes.
// how it works
How it works
- 01
Wrap your calls
One line. The SDK drops in around your existing Claude or GPT calls — same interface, now metered.
- 02
Set the cap
Per-project and per-user budgets. Hard limits, not suggestions — when the cap is hit, calls stop.
- 03
See it live
Spend by feature and by user, with alerts to Slack the moment something spikes.
import { Guard } from "@tokenguardrail/sdk";
const guard = new Guard(anthropic, {
project: "prod-app",
cap: { monthly: 500, perUser: 5 },
});
// before: anthropic.messages.create(...)
const res = await guard.messages.create({
model: "claude-sonnet-5",
max_tokens: 1024,
messages,
});
// throws CapExceededError past the budget// what you get
What you get
Hard spend caps
Budgets that actually stop calls at the limit — per project, per environment, per month.
Live cost visibility
See spend as it happens, broken down by feature, model, and user. No more waiting for the invoice.
Spike alerts
Anomaly detection pages you in Slack the moment spend departs from baseline — minutes in, not weeks later.
Per-user quotas
One user hammering your app can't eat the whole budget. Set fair limits and enforce them automatically.
// questions, answered
How teams keep AI costs under control
- How do I stop my OpenAI or Anthropic bill from spiking?
- Token Guardrail wraps your existing Claude and GPT calls and enforces a hard spend cap. When a project or a single user crosses the budget, calls stop instead of quietly running up the bill — so a looping agent can't turn a $200 month into a $2,000 one.
- Can I set a hard spend cap per user?
- Yes. You set budgets per project and per user, and the limits are enforced rather than advisory. Once a user hits their quota their calls are blocked until it resets, so one person hammering your app can't drain the whole budget.
- Does it work with both Claude and GPT?
- Yes. The SDK drops in around your existing Anthropic and OpenAI calls with the same interface, so you keep your current models and code — the calls are simply metered and capped.
- How is this different from the usage limits my provider already offers?
- Provider limits are account-wide and coarse. Token Guardrail caps by project, feature, and individual user, alerts you the moment spend departs from baseline, and shows exactly where the money goes — the control and visibility a provider dashboard doesn't give you.
- Will wrapping my calls add latency?
- The guard check is a lightweight lookup that runs alongside your request, so the overhead is negligible next to the model's own response time.
- What happens when a cap is hit?
- The call is rejected with a clear error instead of going through, so your app can degrade gracefully — show a message, queue the request, or fall back — rather than silently spending past the limit.
- Do you store my prompts or completions?
- Token Guardrail is built to meter tokens and cost, not to warehouse your content. Full data-handling details will ship with the privacy policy before general availability.
- When will Token Guardrail be available?
- It's in early access. Join the waitlist and we'll reach out as spots open up.
// get started