virus spreading via large tech.
Engineers are being judged, straight or not directly, by how a lot AI they’ll eat. Extra tokens, extra output, extra compute. Some corporations even had leaderboards.
It’s the 2026 model of rating engineers by strains of code.
Much less is extra
Tokenminning is the antithesis of tokenmaxxing.
Token effectivity turns into more and more essential as your utilization grows. Each pointless token will increase price, latency and complexity.
Tokenminning is a brand new sample, which systematically minimizes token use whereas sustaining, if not bettering, the efficiency of your AI brokers.
On this article, I cowl sensible methods for tokenminning that I exploit to cut back prices. All of those methods could be deployed with out important refactoring.
The outcome: considerably decrease AI prices with no sacrifice in high quality
The Price of Tokenmaxxing
Tokenmaxxing and different naïve approaches to AI utilization share a standard assumption: inputs with extra tokens result in higher outputs.
This assumption results in bigger than needed prompts, loaded with uncompressed context and RAG bloat. In some instances, it might probably enhance efficiency, however, it introduces some important issues.
1. Monetary Price
Unsurprisingly, prices skyrocket.
Each token despatched to and generated by a mannequin has a worth. Interactive chats have cheap sized inputs and outputs, so naively estimated prices first appear manageable.
Nonetheless, actual agent token utilization violates the entire assumptions you’ll have had concerning common token use. Working long-running brokers with frontier fashions can lead to ridiculous prices.
What are actual prices for utilizing AI each day?
I carried out a fast evaluation of my very own private utilization, for interactive chats and for my brokers.
For context, I’m at present the top of AI for a biotech startup. I exploit AI as an interactive analysis assistant (medical papers, most cancers analysis, machine studying), and I’ve additionally developed a number of brokers which carry out the next duties:
- Code evaluation and automatic unit testing: I push code day by day, and these brokers carry out vulnerability evaluation, floor potential points and repair minor points
- Experiment administration: observe and doc a number of working coaching experiments
- Devops: managing AWS assets, automating occasion provisioning and basic cloud administration help to optimize prices
Right here is the breakdown:
| Supply | Enter Tokens | Output Tokens | Complete | Day by day Complete |
| Interactive Chat (per chat) |
492 | 1650 | 2142 | 42,840 |
| Brokers (per invocation) |
56,497 | 4,594 | 61,091 | 1,221,820 |
As you may see, my interactive chats pale compared to my brokers. With these numbers, I’d spend roughly $40 per day in API utilization prices utilizing Claude Opus 4. I spend fairly a bit much less, resulting from optimizations.
Some engineers spend way more per day, particularly in the event you use autonomous engineering brokers. In some instances, engineers have reported spending over $10,000 per week1
Consequently, large tech corporations have began to implement AI utilization limits.
2. Inference Velocity
Extra tokens additionally imply extra latency.
Logically, bigger prompts take longer to course of, rising the time-to-first-token and general response instances. This may be detrimental with buyer going through AI or time delicate brokers.
3. High quality
An enormous false impression is that extra context produces higher outcomes. That is merely not the case, particularly with very lengthy contexts.
Fashions have restricted consideration. As prompts turn out to be more and more massive, essential data competes with irrelevant particulars for the mannequin’s focus. “Context rot,” is an actual drawback2, the place LLMs turn out to be much less efficient because the context grows, and a focus effectiveness deteriorates unusually with massive context: it really works for the start and finish of the context window, however degrades within the center3
On the whole, the trade is shifting mindsets in the direction of context high quality, not context quantity for simpler AI use.
🛠️ Actual methods for “tokenminning”
In case you haven’t already skilled the true price of utilizing AI, the issues outlined above ought to now be evident.
AI engineers want to start out enthusiastic about methods to realistically cut back token use whereas holding efficiency excessive.
Listed here are just a few methods I exploit to cut back AI prices. These methods are conceptually easy to keep away from derailing current AI workflows.
Technique #1: Routing
Realistically, most prompts don’t want a frontier mannequin.
It’s true, fashions like Claude Opus or GPT 5.5 excel at advanced reasoning, planning, and tough coding duties.
However easy requests, like device utilization, summarization and classification could be dealt with by smaller, decrease price fashions. You might even route these to a quantized native mannequin and skip the API price all collectively.
Right here, routing isn’t used as a token minimization technique, however as a brute drive price discount approach that works devastatingly properly. Consequently, many corporations are doing it.
Here’s a excessive stage abstract of the way it works:

A light-weight self-hosted webservice intercepts every immediate request
This webservice is light-weight, and conforms to both the OpenAI Chat Completions API or the Anthropic Messages API, relying on who your supplier is. This webservice is often known as an “LLM Gateway.”
You need to use this terribly bloated LiteLLM library or roll your individual*, which is ~1 day of precise work and testing (probably much less in the event you agentically code it.)
Inside the webservice, you will want the next hooks for every immediate:
- Course of: run any preprocessing required for every immediate
- Consider: run classification on the processed immediate
- Route: based mostly off the analysis, apply predefined guidelines to pick the mannequin
- Execute: execute the LLM name with the chosen mannequin
- Validate: [optional, but helpful], run validation guidelines on the output
- Return: Format and return the outcome to the caller
* There are just a few hidden complexities to rolling your individual, make sure you take note of streaming the response again from the supplier in addition to token counting, which varies throughout supplier.
Consider every immediate with a pretrained mannequin
Inside your consider hook, a number of pretrained classifiers evaluates the immediate, returning each the intent of the immediate and the complexity, a rating from 0 to 1.0.
🤚So I’ve to coach a classifier on prompts?
Probably. Listed here are your choices:
If you wish to go together with an off the shelf classifier, the chief is NVIDIA’s NemoCurator Immediate Activity and Complexity Classifier4. It makes use of a fusion complexity rating and evaluates prompts for creativity, reasoning, specialised area information, and so forth. and its structure + weights are publicly accessible.
You might discover that it’s extra efficient to coach your individual. Nemocurator was skilled on prompts from many domains, similar to artistic writing, science, programming, and so forth.
That is wasted mannequin capability in case your group is generally engaged on distributed machine studying and RL, and the standard of the predictions will endure.
Not all is wasted. The Nemocurator can both be fine-tuned, or skilled from scratch with prompts taken straight from you (or your group).
Coaching a classifier for prompts
The structure from NVIDIA’s immediate and complexity classifier makes use of a pretrained DeBERTa5 spine, with a number of classification heads. We modified this structure, leaving solely two heads, one for the intent class and one for the complexity rating.
Intent Lessons
We use the next intent lessons, largely impressed by the unique analysis from NVIDIA.
- Open QA
- Closed QA
- Instrument Name
- Summarization
- Code Technology
- Classification
- Rewrite
- Brainstorming
- Extraction
Complexity
In an effort to map complexity to a scalar, we first must quantify the extent of reasoning required to sufficiently reply the immediate. The hybrid complexity rating methodology utilized in Nemocurator was inapplicable for our wants.
Information assortment
Our LLM gateway collected prompts over a time period (we collected over 10,000 prompts, however a minimal of 4000 is advisable).
For every immediate:
We consider it with (4) separate fashions at totally different reasoning ranges, a neighborhood quantized LLM (Qwen 3.5 9B), a low tier mannequin (GPT 5 mini), a medium tier reasoning mannequin (GPT 5.5) and a frontier reasoning mannequin (o3-pro).
| Mannequin | Tier | Low Reasoning | Medium Reasoning |
Excessive Reasoning |
|---|---|---|---|---|
| Qwen 3.5 9B | Native | ❌ | ❌ | ❌ |
| GPT-5 mini | Low-tier | ✅ | ✅ | ✅ |
| GPT-5.5 | Medium-tier | ✅ | ✅ | ✅ |
| o3-pro | Frontier | ❌ | ❌ | ✅ |
We chosen every mannequin based mostly off of the fee class. Anthropic (or different) can have related availability.
Working every mannequin, with the reasoning ranges above, gave 8 separate solutions to every immediate.
To categorise the intent of the immediate: we used GPT 5.5 (medium reasoning) to label the intent of every given the enter and metadata from the LLM gateway (our gateway collects the calling software and agent).
To quantify the complexity: We once more used GPT 5.5 (medium reasoning) to judge the minimal stage {that a} query was sufficiently answered at every of the 8 ranges.
| Mannequin | Rating Methodology | Particulars |
|---|---|---|
| Qwen 3.5 9B | Base | A base rating of 0.1 given |
| GPT-5 mini | Base + Scaled Reasoning | A base rating of 0.2 + a scaled worth based mostly on the reasoning stage + variety of tokens used |
| GPT-5.5 | Base + Scaled Reasoning | A base rating of 0.4 + a scaled worth based mostly on the reasoning stage + variety of tokens used |
| o3-pro | Base | A rating of 1.0 given |
This complexity scoring methodology gave us a scalar worth for every immediate, starting from 0.1 to 1.0.
This gave us the coaching knowledge required to coach the mannequin.
Coaching the mannequin
As talked about beforehand, we reused the structure launched by NVIDIA’s Nemocurator, which merely has a pretrained DeBERTa spine with separate classification heads.

Our mannequin makes use of a simplified model, with two heads:
- A classifier head which was optimized by way of cross-entropy loss on the intent targets
- A regression head which was optimized utilizing MSE on the complexity scores
This gave us an eval accuracy of ~0.94 on intent class and an affordable MSE, which we deemed correct sufficient for routing.
Word: The intricacies of the coaching course of (coaching vs analysis, fantastic tuning studying charges, gradients, and so forth.) have deliberately been omitted to take care of the article’s focus
This mannequin offers us a option to deterministically consider every immediate
Routing every immediate to the right mannequin
That is half science and half guesswork. Nobody routing framework will work for everybody.
To develop a routing desk (with each the intent and the complexity), we thought of the constraints our firm has and the forms of knowledge we work with.
The consider step outputs:
{
"immediate": "...",
"intent": "closed_qa",
"complexity": 0.4,
// different metadata
...
}
Right here, every of the fashions in our structure is mapped to each an intent and a complexity rating.
| Class | Low Complexity x < 0.2 | Medium Complexity 0.2 < x <= 0.7 |
Excessive Complexity x > 0.7 |
|---|---|---|---|
| Open QA | GPT 5.5 (Excessive) |
GPT 5.5 (Excessive) |
GPT 5.5 (Excessive) |
| Closed QA | Qwen 3.5 |
GPT 5.5 (Med) |
GPT 5.5 (Excessive) |
| Instrument Name | Qwen 3.5 |
GPT-5 mini (Low) |
GPT-5 mini (Medium) |
| Summarization | Qwen 3.5 |
GPT-5 mini (Low) |
GPT 5.5 (Excessive) |
| Code Technology | GPT 5.5 (Low) |
GPT 5.5 (Excessive) |
o3-pro |
| Classification | Qwen 3.5 |
GPT-5 mini (Medium) |
GPT-5 mini (Excessive) |
| Rewrite | GPT-5 mini (Low) |
GPT-5 mini (Med) |
GPT-5 mini (Med) |
| Brainstorming | GPT 5.5 (Excessive) |
GPT 5.5 (Excessive) |
GPT 5.5 (Excessive) |
| Extraction | Qwen 3.5 |
GPT 5.5 (Low) |
GPT 5.5 (Excessive) |
📝We’ve got different “particular class prompts”, like medical paper summarization, machine studying analysis assessment which get auto-escalated to particular objective fashions, like o3-pro.
We’re nonetheless creating the best routing desk for our group which balances accuracy and prices.
Some key takeaways:
- When producing code, default to premium fashions. This leads to fewer roundtrip requests to repair errors.
- For summarizing, offload to the native mannequin or decrease tier mannequin.
The artwork right here is performing the utmost stage of downgrading whereas nonetheless sustaining high quality and efficiency. Systematically instrumenting your AI calls (with a homebrew device or a vendor) is paramount to examine success charges.
Executing, validating and returning the request
The remainder of the precise routing is comparatively easy to carry out, given the goal mannequin. Merely, execute the request in opposition to the specified API, Validate the response and return the information to the calling software.
If desired, right here you might carry out a model of cascaded routing, relying on if the immediate was efficiently resolved with the mannequin chosen. We’re nonetheless evaluating strategies to do that deterministically, with out having to make one other LLM name, which might invalidate the aim of routing altogether.
Routing is essential
Implementing a routing layer may look like a heavy carry at first look.
However if you have a look at the economics of LLM utilization at scale, this isn’t only a intelligent hack, it’s a foundational piece of AI structure.
💵💵 Utilizing solely routing, we’ve lowered our AI utilization prices by over 60% 💵💵
We’re nonetheless debugging, however the outcomes are fairly promising.
Technique #2: Context Compaction
Context home windows have turn out to be ultra-large. The dimensions of a 256k or 1M token context window isn’t actually understood till it’s comparatively in contrast.
For instance, a 256k token context window can maintain the primary two books of the Harry Potter sequence with room to spare.
A 1M token context window can maintain your complete Lord of the Rings sequence plus The Hobbit, and nonetheless go away house for extra context.
Huge context home windows are altering how we construct AI programs. Nonetheless, they arrive with main drawbacks as beforehand mentioned: price and diminishing effectiveness at scale.
For builders enthusiastic about tokenminning, prices and effectiveness, context compression, or “compaction” is essential. Don’t naively load each interplay into historical past, however “delicately” choose data based mostly off the present activity.
Right here’s an actual world sample you may make use of with out main adjustments to your brokers.
Compaction (lossy)
That is one we use with our long-running brokers and it really works properly, however comes with some tradeoffs.
As an agent nears a predefined restrict (both the higher tail of the context window or a restrict set by you), a summarization step happens.
This summarization step at all times runs with a decrease order mannequin, with the objective of retaining the related element of every agent step with out destroying data.
Inside the agent loop:
# Compress earlier than the mannequin hits the laborious restrict
COMPACTION_THRESHOLD=32000
# the remainder of agent loop is omitted for brevity
token_count = count_tokens([messages, memory])
if token_count >= COMPACTION_THRESHOLD:
compacted_state = compact_context(
compact_prompt=compact_prompt,
messages=messages,
reminiscence=reminiscence
)
# change the present context with the compacted context
messages = [
*messages[:2], # preserve system + preliminary context
{
"position": "system",
"content material": compacted_state
}
]}
# proceed agent loop with summarized context
we run a compact_context step after we attain a predefined threshold, with a compaction immediate much like the next:
You're a context compaction system for an autonomous coding agent.
Your activity is to compress the present dialog historical past right into a
compressed, structured reminiscence state.
Protect: architectural selections, accomplished work,
unresolved bugs and implementation particulars
Discard: redundant device outputs, messages, intermediate reasoning
Don't summarize vaguely. Extract actionable state. Return the outcome
in markdown format:
## Goal
[What are we trying to accomplish?]
## Present State
[Where things stand now]
## Key Selections
- Resolution:
Purpose:
## Technical Context
[Important architecture, code, configuration, environment details]
## Accomplished Work
- [Completed items]
## Remaining Duties
- [Next actions]
## Agent Reminiscence
[Reusable information that would help in future sessions]
What’s good about this method is that its very simple and sometimes results in higher outcomes with the agent, particularly with lengthy working agent classes.
Forcing the agent to construction its abstract is a good way to distill essential data.
It’s extraordinarily essential to tune your compaction step for recall, making certain that essentially the most related and essential particulars are retained when compressing context. However, as talked about, it’s inherently lossy. You’ll have to throw away data, which will increase the danger of hallucinations or errors.
Wrapping up
“Tokenmaxxing” is a symptom of a still-evolving trade.
Tokenminning isn’t nearly saving cash, it’s about reworking AI use right into a self-discipline. Clever routing and compaction are simply the primary steps to take. The trade is transferring towards extra superior methods, similar to structured episodic reminiscence, that purpose to make brokers extra environment friendly with out sacrificing functionality.
AI dominance will belong to the groups that optimize for outcomes, not token quantity. Cease chasing token counts. Begin chasing effectiveness.
References:
[1]: Bellan, R. (2026, June 5). The token invoice comes due: Contained in the trade scramble to handle AI’s runaway prices. TechCrunch.
[2]: Hong, Ok., Troynikov, A., & Huber, J. (2025). Context Rot: How Growing Enter Tokens Impacts LLM Efficiency. Chroma.
[3]: Liu, N. F., et al. (2023). “Misplaced within the Center: How Language Fashions Use Lengthy Contexts.” Stanford College.
[4]: NVIDIA. (2025). NemoCurator Immediate Activity and Complexity Classifier (Model 1.1) [Machine learning model]. NVIDIA NGC. https://catalog.ngc.nvidia.com/orgs/nvidia/nemo/fashions/prompt-task-and-complexity-classifier
Related hyperlinks:
[5]: P. He, X. Liu, J. Gao, and W. Chen, “DeBERTa: Decoding-enhanced BERT with Disentangled Consideration,” Worldwide Convention on Studying Representations (ICLR), 2021.

