claude-token-saver
<div align="center">
# πͺ claude-token-saver
**Make your Claude Code plan go further.**
Claude plans and checks the work. Free LLM APIs do the heavy, token-hungry part.
[](LICENSE)



</div>
---
Claude Code is great, but long generations (new modules, test suites, translations, docs) and reading huge files burn through your usage limit quickly. Plenty of strong models are available for **free** through API free tiers: Gemini, DeepSeek, Qwen, Kimi, GLM, GPT-OSS, Llama, Mistral and more.
`claude-token-saver` is an MCP server that gives Claude Code four new tools. With them, Claude can **hand the heavy work to the best free model available today**, have a model from **a different family review the result**, and spend its own tokens only on the **final check**.
```
You βββΊ Claude Code (plans, decides, verifies)
β delegate / delegate_checked / review
βΌ
claude-token-saver ββ reads files from disk, masks secrets, picks today's best free model
β
βββΊ Gemini (AI Studio) βββΊ OpenRouter :free βββΊ Groq
βββΊ optional: Cerebras, NVIDIA NIM, Mistral, SambaNova, GitHub Models
β²
model A drafts β model B (other family) reviews β A fixes β B re-checks
```
## β¨ Features
- **Daily auto-discovery.** On the first call of each day it asks every provider which models are free *today*, reads the live limits your keys report and rebuilds the routing table. When a model is renamed, removed or added, nothing breaks.
- **Smart routing per task.** `code`, `text`, `summarize`, `review`, `reasoning` and `general` each get the strongest fitting model. Coder models handle code, million-token-context models handle huge files, reasoning models handle logic.
- **Automatic fallback.** If a model is rate-limited, over its daily quota, too small for the prompt or failing, the next best one is tried, preferring other providers. Cooldowns are remembered.
- **Cross-checking built in.** `delegate_checked` runs a draft β independent review β fix β re-review loop, so you get a stabilized answer and a PASS/FAIL verdict.
- **Files never touch Claude's context.** Claude passes file *paths*; the server reads them from disk. With `save_to`, generated code goes straight to a file, so Claude never re-types it.
- **Secrets stay home.** Values in `.env` files, private keys, API tokens (OpenAI, GitHub, Google, Groq, Stripe, AWS, Slack, Telegramβ¦), JWTs and DB passwords are masked before anything is sent. Variable *names* stay, so models can still write code that uses them.
- **Zero cost.** Only free tiers are used. No new subscriptions.
## π How much does it save?
Your Claude tokens go to three things: **thinking/writing** (most expensive), **reading** (cheaper) and **briefs** (short). Delegation moves most of the writing and the bulk reading to free models. These numbers are rough estimates, not benchmarks; your results depend on the task.
| Task | Typical Claude-token saving |
|---|---|
| Large new code (module, page, test suite) | **50β70%** |
| Reading / summarizing big files, logs, docs | **60β80%** |
| Long text, translation, marketing copy | **50β70%** |
| Medium change across 2β3 files | 10β30% |
| Hard debugging, architecture decisions | ~0% (Claude does it itself) |
| One-line fix | negative (Claude does it itself) |
| **Mixed day-to-day work** | **~40β50%** |
What that means for your plan:
- **Pro:** your 5-hour and weekly limits stretch noticeably further, because the biggest consumer (long generations) moves to free models.
- **Max:** heavy agentic sessions run longer before you hit limits, or you can work in more projects at once.
- **API / pay-as-you-go:** fewer output tokens means a smaller bill.
## π Quick start
**1. Get free keys.** These three are free with **no credit card**, and they cover everything:
| Provider | Free tier highlights | Get a key | Env var |
|---|---|---|---|
| **Google AI Studio** | Gemini Flash models with a 1M-token context, ideal for big files and text. Pro models are not in the free tier; the tool skips them automatically. | [aistudio.google.com/apikey](https://aistudio.google.com/apikey) | `GEMINI_API_KEY` |
| **OpenRouter** | All `:free` models: DeepSeek, Qwen, Kimi, GLM, Nemotron, Llama⦠Shared daily cap on free requests. | [openrouter.ai/keys](https://openrouter.ai/keys) | `OPENROUTER_API_KEY` |
| **Groq** | Very fast GPT-OSS-120B, Qwen, Llama. Small tokens-per-minute cap, so big prompts go to the other providers automatically. | [console.groq.com/keys](https://console.groq.com/keys) | `GROQ_API_KEY` |
**Optional providers** are supported, but as of **November 2026** each one has a catch:
| Provider | Status | Env var |
|---|---|---|
| Cerebras | Asks for a payment card to unlock a one-time $5 credit (30 days). | `CEREBRAS_API_KEY` |
| NVIDIA NIM | Free developer access, but sign-up is not available in every country. | `NVIDIA_API_KEY` |
| Mistral | API access on the Free plan now needs *pay-as-you-go* billing. The key alone returns HTTP 402. | `MISTRAL_API_KEY` |
| SambaNova | Most models return `PAYMENT_METHOD_REQUIRED` without a card on file. | `SAMBANOVA_API_KEY` |
| GitHub Models | The endpoint currently answers a plain `OK` instead of JSON, so it is skipped until GitHub fixes it. | `GITHUB_MODELS_TOKEN` |
If you add a key for a provider that turns out to need billing, nothing breaks. The tool sees the 402 or "payment required" answer, pauses that provider and keeps using the others.
> Free tiers change often. That's why the tool discovers models and limits every day instead of hard-coding them, and why `claude-token-saver test` tells you exactly which keys work today.
**2. Initialize.** This needs [Node.js 18+](https://nodejs.org).
```bash
npx -y github:nedcas69/claude-token-saver init
```
This creates `~/.claude-token-saver/keys.env`, where you paste your keys, and installs a Claude Code skill that teaches Claude *when* delegating pays off.
**3. Register it with Claude Code** (once, for all projects):
```bash
# macOS / Linux
claude mcp add token-saver --scope user -- npx -y github:nedcas69/claude-token-saver
# Windows
claude mcp add token-saver --scope user -- cmd /c npx -y github:nedcas69/claude-token-saver
```
**4. Check your keys:**
```bash
npx -y github:nedcas69/claude-token-saver test
```
Restart Claude Code and ask: *"show me today's free models"*. From then on, Claude delegates automatically when it makes sense, or you can ask explicitly: *"generate the tests with delegate_checked"*.
## π§° Tools Claude gets
| Tool | What it does |
|---|---|
| `delegate` | One free model does a self-contained task. Options: `kind`, `files`, `save_to`, `model`, `max_tokens`. |
| `delegate_checked` | Draft by model A β review by a model of a different family β fix β re-review (up to `rounds`). Returns `FINAL STATUS: PASS/FAIL` plus open issues. |
| `review` | 1β3 independent reviewers (different families) check files or a diff. Returns only verdicts and issue lists, so it is cheap to read. |
| `free_models` | Today's providers, model counts, live limits and the routing table. `refresh: true` forces discovery. |
Illustrative example of what Claude sees after a delegated generation:
```
FINAL STATUS: PASS
[draft by openrouter/qwen/qwen3-coder:free Β· 3,912β2,488 tok Β· 21.4s]
[review by gemini/gemini-2.5-flash Β· 6,540β212 tok Β· 4.1s] β FAIL
[fix by openrouter/qwen/qwen3-coder:free Β· 6,830β2,530 tok Β· 19.8s]
[review by gemini/gemini-2.5-flash Β· 6,600β18 tok Β· 2.2s] β PASS
Saved 214 lines (7,904 chars) to src/api/orders.test.ts. Read or diff it before relying on it.
```
Claude read about 90 tokens instead of writing about 2,500.
## π₯οΈ CLI
```bash
claude-token-saver init # keys file + skill + setup command
claude-token-saver test # ping every configured provider
claude-token-saver status [--refresh] # today's catalog and routing
claude-token-saver ask "prompt" --kind code [--checked]
```
(Use `npx -y github:nedcas69/claude-token-saver <command>` if you haven't installed it globally.)
## βοΈ Configuration (optional)
`~/.claude-token-saver/config.json`:
```json
{
"disabledProviders": ["nvidia"],
"excludeModels": ["llama-3.1-8b"],
"pin": { "code": "qwen3-coder", "summarize": "gemini-2.5-pro" },
"timeoutMs": 180000
}
```
Keys can also come from real environment variables, which take precedence over `keys.env`. Set `CTS_HOME` to move the data directory.
## π Privacy and security
- Your keys live only in `~/.claude-token-saver/keys.env` on your machine.
- Before sending, the server masks secret **values**: `.env*` files (except `.env.example`), private-key files, common token formats, `password=`/`apiKey:` style assignments and passwords in connection strings. Names are kept.
- **Free tiers may use your prompts to train or improve models** (Google AI Studio's free tier says so, and some OpenRouter free endpoints log prompts). Don't use it on code you aren't allowed to share with third parties.
- Masking is pattern-based and best-effort. It is not a guarantee.
## β FAQ
**Does Claude get worse?** No. Claude still plans, decides and verifies. Free models only do work Claude would otherwise type out, and Claude checks the results (tests, lint, reading the diff).
**What if all free models are busy?** The tool says so and Claude simply does the task itself.
**Does it work with the free Claude plan?** It works with any plan that includes Claude Code, and with API billing. The tighter your limits, the more it helps.
**A provider asks for my card. Should I add it?** No need. Gemini, OpenRouter and Groq work without one. Providers that need billing are paused automatically.
**Is this affiliated with Anthropic, Google, OpenRouter�** No. This is an independent open-source project.
## π οΈ Development
```bash
git clone https://github.com/nedcas69/claude-token-saver
cd claude-token-saver
npm install
npm test
node bin/cli.js status
```
The code is plain modern JavaScript (ESM, no build step):
- `src/catalog.js`: daily discovery
- `src/router.js`: model scoring and routing
- `src/client.js`: calls and fallback
- `src/secrets.js`: masking
- `src/tools.js`: the four tools
- `src/server.js`: the MCP server
PRs are welcome, especially new free providers. Any OpenAI-compatible endpoint can be added in `src/providers.js`.
## π License
MIT Β© nedcas69
TDQS
Scored across 4 tools
Each tool has a reasonably clear lane: free_models is discovery, delegate is raw offload, delegate_checked adds a review loop, and review returns only verdicts. The main risk is delegate vs delegate_checked vs review, which all involve multiple free models and could be confused, but the descriptions give usable triggers (bulk generation vs important output vs second opinions).
All names are lowercase snake_case, and delegate/delegate_checked follow a predictable base-plus-variant pattern. Minor deviations exist (free_models is a noun resource rather than a verb, and review is a bare verb), but the set remains readable and predictable.
Four tools is on the lean side but fits a narrow, single-purpose server: catalog lookup, basic delegation, verified delegation, and review. Each tool maps to a distinct workflow rather than being filler, though a fifth capability (e.g. job status) would not feel bloated.
The surface covers the full loop of discovering free models, delegating, verifying, and getting independent review, which matches the stated domain well. Gaps are secondary: no async/long-running job tracking, no cancellation or result retrieval, and no visibility into token savings or usage.