Tokenthrift sits between your app and the AI models. It removes wasted tokens, sends each request to the cheapest model that can do the job, and checks the answer before your user sees it.
Most products pick one strong model and send everything to it. Greetings, lookups and reformatting get billed at the same rate as the hard reasoning. That gap is where the savings come from.
Price of one typical request, 6,000 tokens in and 350 out, at Anthropic list prices read on 25 November 2026. The plan covers OpenAI, Google and open models as well, through a price sheet refreshed daily.
Choose a request and follow it through. Each stop is a chance to spend less, and the check at the end is why spending less stays safe.
Illustrative requests priced at the list prices above. Baseline is Claude Opus 5.5 without caching.
| Step | What happens | Where it pays most | Risk to answers |
|---|---|---|---|
| Reuse | Identical or near-identical questions get a stored answer. Near matches only in categories you approve. | Help centres, FAQs | Low, scoped per customer and expiring |
| Trim | Remove padding, repeated text, unused tool definitions and stale history. Ask for shorter replies, because output costs five times as much as input. | Agents, JSON-heavy apps | Low, nothing is reworded |
| Route | A small classifier predicts the cheapest model likely to pass, using task type, length, stakes and your own history. | Mixed traffic on one model | Managed by the check |
| Check | Schema, rule and judge tests on the answer. A failure reruns on a stronger model. This step adds cost, and we show it. | Everywhere routing is on | Reduces it |
| Cache | Reorder prompts so the unchanging part comes first and gets the provider's cached price, 95% off input on Claude Opus 5.5 and Sonnet 5.5. | Long system prompts, chat, agents | None |
| Batch | Work nobody is waiting for goes to the batch queue at 50% off. | Reports, extraction, evaluation | None, slower by design |
This is the safest part, running in your browser. It compacts JSON, drops HTML comments and repeated sentences, and closes blank gaps. Code blocks and data rows stay as they are, and nothing is reworded.
We don't chop words out of questions. A 2026 study of eight models found that compressing the user's prompt raised net cost about 1.15 times, because models replied at greater length while accuracy collapsed. Compressing the reply cut cost 1.4 to 2.4 times on most API models. So we strip waste from inputs and shorten outputs. (Cavewoman, arXiv 2606.24083)
We read a sample of your traffic and replay it on cheaper models. Users still get today's answers. You get a report of savings and failures by request type.
Only request types that met your quality bar are routed. The other 95% stay put as a control group, so savings and quality are measured side by side.
Each type moves up in steps: 5%, 25%, 100%. If its pass rate drops below your floor, it returns to the original model automatically.
| What could go wrong | How it is handled |
|---|---|
| A cheap model gives a worse answer | Checked before delivery and rerun on a stronger model. Streaming replies are routed only in types that have already proved out, then checked after the fact. |
| Switching models mid-conversation loses the cache | Caches belong to one model. Conversations stay put unless the saving on the remaining turns beats the cost of rebuilding the cache. |
| Retries cost more than they save | We price each finished task, including failed attempts. A route that costs more per finished task is switched off. |
| The gateway goes down | Add our small client wrapper and it falls back to calling your provider directly with your original model and prompt. |
| Added delay | Design target: under 40 ms added at the 95th percentile before the model call. Post-answer checks run only where you allow the wait. |
| Private data | By default we keep only counts and scores. Reuse and audit samples are the two features that store text. Both are opt-in, and you can host the whole gateway yourself. |
| High-stakes requests | Pin any route, user group or keyword to a fixed model. Pinned traffic is never downgraded. |
RouteLLM, 2024: cost cut against using only GPT-4, while keeping 95% of its performance (LMSYS). An earlier cascade, FrugalGPT, matched the best single model with up to 98% lower cost on its test tasks (arXiv 2305.05176). Both used older models, so treat them as evidence for the method. Your own number comes from the audit.
client = Anthropic(- base_url="https://api.anthropic.com",+ base_url="https://gateway.tokenthrift.example", ) client.messages.create( model="claude-opus-5-5", # now your ceiling max_tokens=16000, messages=messages, extra_headers={ "x-thrift-route": "support-chat", "x-thrift-floor": "0.97", }, )
Keep your SDK, your provider account and your provider keys. The model you name becomes the ceiling, and the floor is the pass rate you will accept.
Every response says which model answered, what was trimmed, what it cost and what it would have cost. Those lines add up to your invoice.
Finance gets spend by team, feature and customer, with budget caps that step routes down before they overrun.
One week, no live changes.
Runs inside your own cloud, quoted per deployment.
The certain savings ship first. Routing follows once there is enough traffic to judge it.
Planned duration for a team of three or four engineers. Stack: a Rust or Go proxy for the request path, Redis for stored answers, ClickHouse for metering, a small fine-tuned classifier for routing, and Python workers for replay and judging.
Teams already on the smallest model, spending little, or sending only hard reasoning work. Choose Claude Haiku 5.5 above and the estimate shrinks. The audit will say so.
A control group keeps using your original setup. We compare cost per finished task, retries and our own checks included.
Caching and batching, you can. Routing needs constant re-testing as models and prices change, and that is the part we run.
Agents keep one model per session to protect the cache. Savings come from caching, trimming tool output, and handing self-contained steps to cheaper models.