Open Source

Claw back your agent spend.

"I left an agent running overnight. Woke up to a $280 bill."
Yeah. We've all been there. tokenclaw is the hard stop that should have existed from day one.

npx tokenclaw-dev proxy GitHub
terminal
$ tokenclaw set --key sk-ant-proj-research --budget 10/day
Set budget: sk-ant-proj-research → $10/day
$ tokenclaw proxy
Forwarding: /v1/messages → Anthropic, /v1/chat/completions → OpenAI
1 key budget active
sk-ant-proj-research claude-sonnet-4-6 in=12K out=3K $0.0810
sk-ant-proj-research claude-sonnet-4-6 in=45K out=8K $0.2550
...
WARNING: sk-ant-proj-research at 84% of budget
sk-ant-proj-research claude-sonnet-4-6 in=22K out=5K $0.1410
BLOCKED sk-ant-proj-research — $10.42 / $10.00 day
THE PROBLEM

Your provider's spending limits are monthly.
The damage happens overnight.

OpenAI silently converted their hard caps to email alerts. Anthropic only has workspace-level monthly limits. Neither has per-key budgets. Neither has daily limits. You find out what your agent spent after it already spent it.

"There is no hard stop"

Dashboards show you numbers. Alerts tell you after the fact. Neither one actually prevents your agent from burning through $200 at 3am while you're asleep.

"$4,200 in a weekend"

Agent infinite loops. Runaway retries. A "quick test" that scans your monorepo twice. Monthly limits don't catch this. Daily ones do.

"I had no idea I was getting charged this much"

Multiple agents sharing one API key. No way to know which one is spending what. Per-key budgets fix that.

THE FIX

A local proxy that actually blocks requests.

Not a soft limit. Not a warning. Not an email you'll see tomorrow. A 429 that stops the spend right now.

🛑

Hard budget caps

Per API key. Daily, weekly, or monthly. Budget gone? Proxy returns 429. Agent can't spend past the limit. Done.

Multi-provider, one proxy

Anthropic and OpenAI auto-detected from request path. Also covers Groq, Together, Fireworks — anything OpenAI-compatible. One port, one proxy.

Per-key tracking

One key per agent. See exactly who's spending what. Longest-prefix matching handles key rotation. Unregistered keys still tracked, just not limited.

🔔

Slack alerts that escalate

Warning at 80%. Blocked at 100%. Account-level alerts get louder if you don't acknowledge them. Hourly until you say "this is fine."

🔒

Runs on your machine

No cloud. No telemetry. No accounts. No third party sees your requests. Just localhost. The way it should be.

$

Also scans your tools

Even without the proxy, scans 9 AI tools on your machine (Claude Code, Cursor, Windsurf, Aider, etc.) and shows what you've been spending.

HOW IT WORKS

Set budgets. Start proxy. Sleep easy.

1

Give each key a budget

tokenclaw set --key sk-ant-proj-research --budget 10/day — the research agent gets $10/day. The deploy agent gets $100. A runaway on one can't touch the other.

2

Start the proxy

tokenclaw proxy — runs on localhost:4040. Set ANTHROPIC_BASE_URL or OPENAI_BASE_URL to point at it. One env var per agent. That's it.

3

Go to sleep

The proxy watches every request. Budget hit? Blocked. Slack alert fired. The 429 response tells the agent exactly what happened and the CLI command to increase the limit. No surprises in the morning.

🔔 What your Slack looks like at 3am
[tokenclaw] Key budget exceeded: sk-ant-proj-research
$10.42 spent (limit: $10.00/day)
Requests blocked until midnight UTC
The agent tried to keep going. We said no.
INSTALL

Three commands. Two minutes. No signup.

$ npm install -g tokenclaw-dev
$ tokenclaw set --key sk-ant-proj-research --budget 10/day
$ tokenclaw set --key sk-proj-deploy --budget 100/day
$ tokenclaw proxy
Then point your agents at it
$ ANTHROPIC_BASE_URL=http://localhost:4040 claude
$ OPENAI_BASE_URL=http://localhost:4040 your-gpt-agent
Anthropic OpenAI Groq Together Fireworks + any OpenAI-compatible

Tracking what you spent is not controlling what you'll spend next.

tokenclaw is the difference between an alert and a stop.

View on GitHub npm