Claude Code model router

Tokdiet

Local streaming reverse proxy between AI coding agents (Claude Code, Cursor, Codex) and model APIs (Anthropic, OpenAI, Gemini, MiniMax). Meters every token + USD cost, compacts bloated context to cut pay-per-token API spend, and runs shadow-eval to prove quality held. ccusage-style metering + live local dashboard.

32 stars 2 forksModel routers & proxies Plugin marketplace Source

Install

Inside Claude Code
/plugin marketplace add agiwhitelist/tokdiet

Found in the project README. Check it for setup steps after installing.

From source
git clone https://github.com/agiwhitelist/tokdiet.git

From the README

tokdiet

Your AI agent is paying to send the same file dump five times. tokdiet is a local proxy that sits between your agent and the model API, meters every token, puts your bloated context on a diet — and *proves* the answer didn't get worse.
ccusage that shrinks the bill — without losing quality.

🌐 Live demo (watch one request lose the weight): agiwhitelist.github.io/tokdiet
📝 Launch write-up + full benchmark methodology: I cut an AI agent's input tokens by 71% and quality held — here's the 66-task benchmark

The proof (this is the whole point)

Every "context optimizer" cuts tokens. The scary question is the one they can't answer:
*"If I cut the context, does the model get dumber?"*

So we measured it. A 66-task A/B benchmark across 6 categories on a real model (MiniMax‑M3), each task run twice — full context (baseline) vs through tokdiet (governed) — graded against the known answer, repeated ×3 and majority‑voted to cancel model noise:

−71% tokens, quality on par with baseline. Real requests, real grading — not a mock. The ~1–2 task gap is model nondeterminism plus the model *declining to echo a secret* — not context loss; the hardest "needle buried in junk" adversarial cases pass, because tokdiet doesn't delete blindly — it pages cold context out *recoverably* and protects anything on‑topic. Reproduce it yourself: node bench/run.mjs (needs an API key in env).

How it compares

Everyone shows the bill or cuts it blind. tokdiet is the one that cuts it and proves the model didn't get dumber — and stops cutting the moment it might.

Quick start

Now run your agent (Claude Code, Cursor, Codex, your own script) as usual. Traffic flows through tokdiet, gets metered and compacted, and is forwarded upstream unchanged in every way that matters.

Your API key stays with…
Read the full README on GitHub

Details

Language
TypeScript
License
MIT
Last updated
18 June 2026
Topics
ai-gatewayanthropicccusageclaude-codeclicontext-compressioncontext-engineeringcost-optimizationcost-trackinggeminillmllm-gateway

FAQ

What is Tokdiet?

Local streaming reverse proxy between AI coding agents (Claude Code, Cursor, Codex) and model APIs (Anthropic, OpenAI, Gemini, MiniMax). Meters every token + USD cost, compacts bloated context to cut pay-per-token API spend, and runs shadow-eval to prove quality held. ccusage-style metering + live local dashboard. It is a model router for Claude Code, from agiwhitelist/tokdiet on GitHub.

How do I install Tokdiet?

Run /plugin marketplace add agiwhitelist/tokdiet inside Claude Code, then follow the setup in the README.

Is Tokdiet popular?

agiwhitelist/tokdiet has 32 GitHub stars and 2 forks. It was last updated on 18 June 2026.

More model routers & proxies

Browse the most popular Claude Code mods, all model routers & proxies, or the skills and MCP server directories.