<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: TokenLat</title>
    <description>The latest articles on DEV Community by TokenLat (@tokenlat).</description>
    <link>https://dev.to/tokenlat</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4028280%2F94d16010-df94-45df-aee5-7d51647fcb74.png</url>
      <title>DEV Community: TokenLat</title>
      <link>https://dev.to/tokenlat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tokenlat"/>
    <language>en</language>
    <item>
      <title>Your agent's cost problem isn't the model. It's the steps you never measured.</title>
      <dc:creator>TokenLat</dc:creator>
      <pubDate>Tue, 22 Sep 2026 02:47:08 +0000</pubDate>
      <link>https://dev.to/tokenlat/your-agents-cost-problem-isnt-the-model-its-the-steps-you-never-measured-38ag</link>
      <guid>https://dev.to/tokenlat/your-agents-cost-problem-isnt-the-model-its-the-steps-you-never-measured-38ag</guid>
      <description>&lt;p&gt;A few weeks back I watched an agentic pipeline burn a month of budget in three days. The instinct everyone reached for was the obvious one: "the frontier model is too expensive, switch to a smaller one." That's the wrong diagnosis, and it's worth writing down why.&lt;/p&gt;

&lt;p&gt;When we finally tagged every token to the &lt;code&gt;(step, tool, model)&lt;/code&gt; tuple that spent it, the picture was uncomfortable. The expensive model wasn't the problem. The problem was that &lt;em&gt;every&lt;/em&gt; step — the trivial classifier, the summary, the hard reasoning call — silently defaulted to it, and nobody could see which step was responsible. We'd been arguing about which model to buy when we should have been arguing about which step was allowed to call it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cost in an agent isn't a number. It's a tree.
&lt;/h2&gt;

&lt;p&gt;In a single LLM call, cost is one line item. In an agentic loop it's a tree: each step calls a model, maybe a tool, maybe a retry, maybe a sub-step that calls again. The bill at the end is the sum over that whole tree.&lt;/p&gt;

&lt;p&gt;If you only ever see the total, you are optimizing blind. "Make it cheaper" with only a total in front of you means guessing. And the guess is almost always "use a smaller model everywhere," which throws away quality on the steps that actually needed the frontier model while leaving the real waste untouched.&lt;/p&gt;

&lt;h2&gt;
  
  
  The silent default that inflates everything
&lt;/h2&gt;

&lt;p&gt;Most agent frameworks let you set "the model" once, at the top. So a routing decision that should have been per-step gets frozen into a single global choice. A classification step that a small model handles fine? Frontier. A summarization of text the model just produced? Frontier. The one genuinely hard reasoning call? Also frontier — but now it's lost in the noise.&lt;/p&gt;

&lt;p&gt;The waste here isn't that frontier models are pricey. It's that ~80% of those calls never needed them, and without per-step attribution you can't even prove which 80%. You're paying a premium on steps whose output quality wouldn't have moved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Per-step attribution is boring infrastructure, not a feature
&lt;/h2&gt;

&lt;p&gt;There's no clever trick. You log, for every call: step id, tool, model, input/output tokens, latency, retry count. That's it. Once that data exists, the waste shows up in minutes — usually a handful of steps dominate the bill, and they're rarely the ones you'd have guessed.&lt;/p&gt;

&lt;p&gt;I've lost count of how many times the "expensive" step turned out to be a retry loop quietly re-running a hard call five times because the tool returned a shape the parser rejected, not because the model was wrong. That's not a model-cost problem. That's an un-instrumented step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Failover is where the blind spots explode
&lt;/h2&gt;

&lt;p&gt;Here's the part that actually blows budgets. A model errors, or times out, or returns garbage. The naive fix re-runs the &lt;em&gt;whole trajectory&lt;/em&gt; — or at best the whole step — against the same model. Cost spikes exactly when you can least afford it, on the run that was already failing.&lt;/p&gt;

&lt;p&gt;A planned failover routes that &lt;em&gt;single step&lt;/em&gt; to a fallback at the step boundary: same tool contract, different model, the rest of the run continues. The gap between "retry the universe" and "swap the model for this one call" is most of the cost story nobody talks about, because you only see it when things break — and by then you're not measuring.&lt;/p&gt;

&lt;h2&gt;
  
  
  The lever lives at the routing layer, not in prompts
&lt;/h2&gt;

&lt;p&gt;The point that took me too long to internalize: you cannot prompt your way to per-step cost governance. The layer that decides which model serves each step is the &lt;em&gt;only&lt;/em&gt; place that can both measure the spend and act on it. Put the attribution and the failover decision anywhere else and you're asking a component that doesn't see the calls to fix calls it can't see.&lt;/p&gt;

&lt;p&gt;This is also where the compliance constraint and the cost lever happen to land on the same component. In Southeast Asia, PDPA-aligned handling means prompts and outputs can't wander out of region — so the routing layer has to be SG-hosted (Tencent Cloud) and keep data resident. That same in-region gateway is exactly where per-step attribution naturally lives: the router is already on the path of every token, so measuring them costs nothing extra. A gateway that exposes 25+ models behind one OpenAI-compatible endpoint isn't just a convenience for failover — it's the only place the measurement and the swap can share state.&lt;/p&gt;

&lt;h2&gt;
  
  
  The question I keep coming back to
&lt;/h2&gt;

&lt;p&gt;When your agent's bill doubles, can you point to the three steps that caused it — or do you just know the total went up? If you can't attribute per step, the fix was never a cheaper model. It was instrumenting the routing you already had.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>architecture</category>
      <category>agents</category>
    </item>
    <item>
      <title>Language is a routing problem, not a translation problem</title>
      <dc:creator>TokenLat</dc:creator>
      <pubDate>Tue, 15 Sep 2026 08:54:48 +0000</pubDate>
      <link>https://dev.to/tokenlat/language-is-a-routing-problem-not-a-translation-problem-1227</link>
      <guid>https://dev.to/tokenlat/language-is-a-routing-problem-not-a-translation-problem-1227</guid>
      <description>&lt;p&gt;Most teams approach a multilingual support bot as a translation problem. Wire up a translation layer, send everything to one big model, done. We did roughly that the first time, and it mostly worked — until we looked at the bill and at which customers were actually being served well.&lt;/p&gt;

&lt;p&gt;This is the field-note version of what we learned building support bots for businesses serving Southeast Asia: the "multilingual" part is not one problem, it's three, and conflating them is why these deployments quietly cost 3x and quietly fail the Tamil- or Malay-speaking customer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three problems hiding under "multilingual"
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Language detection under code-switching.&lt;/strong&gt;&lt;br&gt;
A real SEA customer doesn't pick a language. They write &lt;em&gt;"boleh tolong check my order ah?"&lt;/em&gt; — Malay and English in one breath. A monolingual pipeline treats that as an error condition. The first routing decision isn't "which model," it's "is this even one language," and most systems answer wrong. Miss it and you've already degraded the interaction before the model sees it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Language is not model size.&lt;/strong&gt;&lt;br&gt;
This is the one nobody warns you about. English is relatively simple — SVO, minimal inflection — and a small model holds quality fine. Arabic, Malay, and Tamil carry morphological complexity that needs a larger model to stay accurate. Routing every language to the same frontier model leaves money and latency on the table for English while still under-serving the harder languages. We saw a 3.5B-class model hold English quality while a 7B-class tier was needed for the others. One published pipeline routes low-resource languages through translate-to-English before classification and lifts low-tier accuracy from ~0.46 to ~0.68 Macro-F1 — same idea: not every language deserves the same path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Per-step routing inside a single turn.&lt;/strong&gt;&lt;br&gt;
"Check my order" is classify-and-lookup. "Explain why my transfer failed and draft a reply" is synthesis. Same customer, same language, two completely different model tiers — and most bots send both to the expensive one because the router only sees "it's a support message."&lt;/p&gt;

&lt;h2&gt;
  
  
  Then PDPA decides your topology
&lt;/h2&gt;

&lt;p&gt;Singapore's PDPA (and Malaysia's, moving alongside it) wants clarity on where data is processed and stored, PII redaction, and no-train terms with the underlying providers. For a support bot handling customer PII, that means inference runs in-region.&lt;/p&gt;

&lt;p&gt;Here's the part we didn't expect: the residency requirement and the latency requirement turn out to be the &lt;em&gt;same&lt;/em&gt; decision. Keep inference in-region and you've satisfied the residency half of PDPA while staying under the ~300ms threshold for natural conversation. Push it overseas and you're violating one and degrading the other. "Where does the model run" stops being a cost footnote and becomes the architecture. We run inference in-region (SG-hosted, on Tencent Cloud, PDPA-aligned) partly because the regulation demands it and partly because it's the cleanest way the latency math works — the compliance team and the performance team ended up arguing for the identical topology.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this only works if the models are a dial
&lt;/h2&gt;

&lt;p&gt;None of the above is a single-model story. The language-tier decision — 3.5B for English, 7B for the harder languages, a frontier model for the synthesis step — only pays off if switching tiers is a config change, not a migration. We sit 25+ models behind one OpenAI-compatible endpoint, so "route Malay to a bigger tier" is a line in a routing table, not a procurement cycle. That unglamorous fact is the reason routing works at all: the models are a dial, not a commitment. And per-language routing is also where most of the cost saving actually comes from — you stop paying frontier rates for English classification.&lt;/p&gt;

&lt;h2&gt;
  
  
  The part we're still getting wrong
&lt;/h2&gt;

&lt;p&gt;We measure routing quality with one global score, but the failure modes are per-tier. English can be perfect while a low-resource language drifts for a week and nobody notices until a customer complains in Tamil. We're moving to Macro-F1 &lt;em&gt;per language tier&lt;/em&gt; as the monitoring signal. Curious whether others running multilingual routing monitor drift per-language or still trust a single aggregate — that's the open question we haven't settled.&lt;/p&gt;

&lt;p&gt;The whole point: a multilingual bot isn't a translation layer bolted onto one model. It's a router whose first dimension is language, and language is messier, more tiered, and more regulated than the translation mental model admits.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We're writing these up as we run them — more at tokenlat.com.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>llm</category>
    </item>
    <item>
      <title>Stop asking "is this task hard?" Route by what the token is for.</title>
      <dc:creator>TokenLat</dc:creator>
      <pubDate>Fri, 11 Sep 2026 08:03:38 +0000</pubDate>
      <link>https://dev.to/tokenlat/stop-asking-is-this-task-hard-route-by-what-the-token-is-for-nei</link>
      <guid>https://dev.to/tokenlat/stop-asking-is-this-task-hard-route-by-what-the-token-is-for-nei</guid>
      <description>&lt;p&gt;Last week I made the case for measuring whether your routing actually works — comparing output distributions per route, computing cost per &lt;em&gt;successful&lt;/em&gt; task instead of per token, versioning the harness. If you did that, you've already beaten most teams.&lt;/p&gt;

&lt;p&gt;But even teams that route correctly are usually routing at the wrong granularity. The decision they make is "is this request hard?" — and then the whole request goes to frontier or to cheap. The request is the wrong unit.&lt;/p&gt;

&lt;h2&gt;
  
  
  The expensive part was never the model
&lt;/h2&gt;

&lt;p&gt;A recent write-up described cutting token use roughly 42x on a code-editing workload. The tempting read is "they found a smaller model." They didn't. The saving came from deleting the agent's explore-reread-redecide loop — the tokens spent &lt;em&gt;figuring out what to do&lt;/em&gt; rather than &lt;em&gt;doing it&lt;/em&gt;. The model barely changed. What changed was which job the tokens were performing.&lt;/p&gt;

&lt;p&gt;That's the tell. When a workload gets dramatically cheaper without changing models, the lever wasn't model choice. It was that someone stopped spending tokens on a job that didn't need a frontier model at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Most "hard" requests are mostly mechanical
&lt;/h2&gt;

&lt;p&gt;Look at almost any production request. A single task that feels hard — summarize this thread, draft a reply, extract structured fields from a doc — is usually a thin slice of genuine reasoning wrapped in a lot of mechanical work: pull the right context, classify it, format the output, validate the schema, retry on parse failure.&lt;/p&gt;

&lt;p&gt;Route the whole request to a frontier model and you pay frontier prices for the 80% that was extraction and formatting. Route the whole request to a cheap model and you gamble the 20% that actually needed the frontier.&lt;/p&gt;

&lt;p&gt;Per-request routing forces you to answer a question you can't reliably answer up front: "how hard is this?" Difficulty is a property you discover, not one you know at the door.&lt;/p&gt;

&lt;h2&gt;
  
  
  Route by token-purpose, not by difficulty
&lt;/h2&gt;

&lt;p&gt;The more useful axis is &lt;em&gt;what the token is for&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Instruction and system tokens.&lt;/strong&gt; Stable, repeated, cacheable. They barely benefit from a frontier model — and they're the easiest to keep on the cheap route.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structured extraction, classification, formatting.&lt;/strong&gt; Routine by definition. These are where most of your volume lives, and where cheaper models — typically 70%+ cheaper, often up to 90%+ on China models — are indistinguishable in output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;First pass vs. escalation.&lt;/strong&gt; You can't know a request is hard before you generate. A gate that decides &lt;em&gt;after&lt;/em&gt; a cheap first pass fails — and only escalates the part that failed — spends frontier tokens only where they earn it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The genuinely ambiguous slice.&lt;/strong&gt; Keep frontier here. But make it the slice, not the request.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why you can't do this by hand
&lt;/h2&gt;

&lt;p&gt;You can't easily split a prompt into "tokens that are formatting" and "tokens that are reasoning" before you send it. That's the job of the call boundary. A routing gateway sits there, sees each request, and assigns the job — so the 80% mechanical portion never reaches a frontier model, and the thin hard portion does.&lt;/p&gt;

&lt;p&gt;And you can only trust it if you can &lt;em&gt;see&lt;/em&gt; it. This is where last week's point lands: route by job, then measure cost per successful task including retries and escalations, with request-level tracing. A gateway that hides the blend is just a black box you're told is cheaper.&lt;/p&gt;

&lt;h2&gt;
  
  
  A realistic shape
&lt;/h2&gt;

&lt;p&gt;Take a support pipeline: classify the ticket, draft a reply, validate against a template. At frontier prices the extraction and formatting alone might run six figures a year. Split by job — cheap model for classify and format, frontier only for the draft's hard cases, escalation after a failed first pass — and the bill typically drops 70%+. On China models the same split can reach 90%+ cheaper. The saving only counts, of course, if you measured cost per &lt;em&gt;successful&lt;/em&gt; task and the retries didn't eat it back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this matters most
&lt;/h2&gt;

&lt;p&gt;For teams in Southeast Asia — Malaysia, Singapore, Indonesia — building on tight infrastructure budgets and answering to data-sovereignty rules that US-default tooling tends to ignore, the unit of routing is also a unit of control. A gateway that is SG-hosted (Tencent Cloud) and PDPA-aligned, exposing one OpenAI-compatible endpoint over 25+ models, lets a KL-based team route by job without shipping data out of the region or stitching five providers together.&lt;/p&gt;

&lt;h2&gt;
  
  
  The habit I'd steal
&lt;/h2&gt;

&lt;p&gt;Next time you reach for "is this task hard?", stop. Ask "what job is this token doing?" Route the mechanical jobs to cheap models, keep frontier for the slice that earns it, escalate &lt;em&gt;after&lt;/em&gt; the cheap pass fails — and trace every request so you can prove the blend worked. Routing by difficulty guesses at the door. Routing by token-purpose decides after it reads the work.&lt;/p&gt;

&lt;p&gt;If you're wiring this up, &lt;a href="https://tokenlat.com" rel="noopener noreferrer"&gt;TokenLat&lt;/a&gt; exposes a single OpenAI-compatible endpoint over 25+ models with request-level tracing, so the blend you route is the blend you can actually prove.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>machinelearning</category>
      <category>productivity</category>
    </item>
    <item>
      <title>You routed 80% to cheaper models. Now measure whether it worked.</title>
      <dc:creator>TokenLat</dc:creator>
      <pubDate>Thu, 03 Sep 2026 09:11:43 +0000</pubDate>
      <link>https://dev.to/tokenlat/you-routed-80-to-cheaper-models-now-measure-whether-it-worked-4pf5</link>
      <guid>https://dev.to/tokenlat/you-routed-80-to-cheaper-models-now-measure-whether-it-worked-4pf5</guid>
      <description>&lt;p&gt;Last week I argued the obvious part: most production LLM traffic — extraction, classification, short rewrites — rarely needs the frontier model, and routing it to cheaper models (Chinese open-weight models are typically 70%+ cheaper, often up to 90%+ on China models) turns a flat bill into a blended one.&lt;/p&gt;

&lt;p&gt;The easy part is done. The hard part is the question nobody answers: &lt;strong&gt;did the routing actually work, or did you just make your bills cheaper and your outputs silently worse?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Success rate is a half-truth
&lt;/h2&gt;

&lt;p&gt;The first metric teams reach for is "did the call succeed." 200 OK. JSON parsed. Task completed. Green checkmark.&lt;/p&gt;

&lt;p&gt;That metric can't answer the question. A cheap-model call can return 200, parse cleanly, and still be wrong in a way that only surfaces three steps later. The call that &lt;em&gt;looks&lt;/em&gt; fine and is quietly wrong is the dangerous failure — and it's exactly the failure routing introduces, because you changed which model handles the work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure distributions, not pass rates
&lt;/h2&gt;

&lt;p&gt;For a sample of real traffic on each route, compare the &lt;em&gt;distribution&lt;/em&gt; of outputs against a frontier baseline — not a single "did it pass" flag.&lt;/p&gt;

&lt;p&gt;A median output length collapsing from ~20k tokens to 0 is a different signal than an empty result. A confidence score shifting by a point is noise; a whole cluster of outputs landing in a range the frontier never produced is a behavior change. You only see this if you measure the blend, not the pass rate. Route cheap, but verify the cheap route is still producing output you'd have trusted before.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cost per successful task, not cost per token
&lt;/h2&gt;

&lt;p&gt;The second trap is counting tokens. "I saved 70% per call" is true and irrelevant if the cheap call fails 15% of the time and each failure triggers a retry or an escalation to frontier anyway.&lt;/p&gt;

&lt;p&gt;The number that matters is cost per &lt;em&gt;successful&lt;/em&gt; task: total spend across the retry and escalation path divided by tasks that actually completed correctly. A cheap-first policy with a clean fallback can still win — but you have to measure the whole path, not the first hop. If your "savings" vanish once you include the retries, you haven't optimized, you've deferred the cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  The router is part of the benchmark
&lt;/h2&gt;

&lt;p&gt;Here's the one people miss: when you change the routing policy and re-run your eval, you're not measuring the model. You're measuring the &lt;em&gt;router plus&lt;/em&gt; the model. Version the harness — the prompts, the retry logic, the memory, the tool schemas — the same way you version the model. A benchmark number with an unversioned harness is a number you can't reproduce and can't trust.&lt;/p&gt;

&lt;p&gt;And don't trust a single run. "All 20 passed" tells you the mean passed; it tells you nothing about the tail. Variance in latency, in failure modes, in output quality lives in the tail, and the tail is where production breaks. One trial is a point estimate, not a confidence interval.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this bites harder on a tight budget
&lt;/h2&gt;

&lt;p&gt;This is where it lands hardest for teams in Southeast Asia — Malaysia, Singapore, Indonesia — building on tight infrastructure budgets and answering to data-sovereignty rules (Malaysia's PDPA, for instance) that US-default tooling tends to ignore. When every dollar of inference is scrutinized, "we saved 70%" on a slide means nothing if nobody measured whether the work still got done. A routing gateway that is SG-hosted (Tencent Cloud) and PDPA-aligned lets a KL-based team route cheap-when-possible and frontier-when-needed — but the saving only counts if you can prove the cheap route is trustworthy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The habit I'd steal
&lt;/h2&gt;

&lt;p&gt;Stop celebrating "everything succeeded." Start measuring the blend. Pick a sample, compare distributions per route, compute cost per &lt;em&gt;successful&lt;/em&gt; task including retries, and version the harness so the number means something next month. Routing without measurement is just hope with extra steps.&lt;/p&gt;

&lt;p&gt;If you're wiring this up, &lt;a href="https://tokenlat.com" rel="noopener noreferrer"&gt;TokenLat&lt;/a&gt; exposes a single OpenAI-compatible endpoint over 25+ models with request-level tracing, so the blend you measure is the blend you actually shipped.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>api</category>
      <category>llm</category>
    </item>
    <item>
      <title>Most of Your LLM Spend Is Wasted on Calls That Don't Need a Frontier Model</title>
      <dc:creator>TokenLat</dc:creator>
      <pubDate>Tue, 25 Aug 2026 07:31:22 +0000</pubDate>
      <link>https://dev.to/tokenlat/most-of-your-llm-spend-is-wasted-on-calls-that-dont-need-a-frontier-model-39o</link>
      <guid>https://dev.to/tokenlat/most-of-your-llm-spend-is-wasted-on-calls-that-dont-need-a-frontier-model-39o</guid>
      <description>&lt;p&gt;If your LLM bill looks like a flat line of frontier-model calls, you're probably overpaying by 70% or more for work that a cheaper model would do just as well.&lt;/p&gt;

&lt;p&gt;I'm not talking about a toy benchmark. I mean the actual shape of production traffic: extraction, classification, short rewrites, JSON shaping, routing decisions, draft summaries. The kinds of calls that make up the bulk of a real pipeline — and almost none of which need the most expensive model on the menu.&lt;/p&gt;

&lt;p&gt;This post is a practical routing playbook, grounded in what Chinese open-weight models are actually capable of in 2026, and why the "one model to rule them all" habit is the most expensive default in modern AI infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trap: every call goes to the most expensive model
&lt;/h2&gt;

&lt;p&gt;Here's a pipeline I audited recently. ~12,000 LLM calls/day:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;61% were structured extraction (pull fields from an email, a ticket, a PDF)&lt;/li&gt;
&lt;li&gt;22% were classification (intent, sentiment, spam/not-spam)&lt;/li&gt;
&lt;li&gt;11% were short rewrites / tone adjustments&lt;/li&gt;
&lt;li&gt;6% were genuinely hard: open-ended reasoning, ambiguous multi-step planning&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every single one was sent to the top-tier model. The 6% that justified it. And the 94% that absolutely did not.&lt;/p&gt;

&lt;p&gt;The instinct is understandable. Frontier models are the safe choice. If you route to a cheaper model and it fails, that's on you. So everyone defaults to the best — and quietly pays a premium on traffic that would never have noticed the difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Chinese models actually do now
&lt;/h2&gt;

&lt;p&gt;The "Chinese models are cheap but worse" framing is two years out of date. In 2026 the top open-weight models from China — DeepSeek, Kimi, GLM, Qwen — routinely match or beat frontier models on the majority of practical, production-shaped tasks.&lt;/p&gt;

&lt;p&gt;Two data points that reframed how I think about this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The MoE argument from the model itself.&lt;/strong&gt; A recent write-up on Kimi K3's Mixture-of-Experts architecture noted that of 896 experts, only ~1.8% activate per token. The model is &lt;em&gt;already routing internally&lt;/em&gt; — deciding, token by token, which sliver of capacity a given input needs. If the model architects route by difficulty at the parameter level, it's a little odd that we don't route by difficulty at the request level.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The benchmark reality.&lt;/strong&gt; On standard reasoning and coding evals, the gap between frontier and top Chinese models has collapsed on everything except the hardest 10–20% of tasks. For extraction, classification, and most summarization, the delta is within noise.&lt;/p&gt;

&lt;p&gt;That last 10–20% is real and worth paying for. The other 80% is where the money leaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  The playbook: route by scenario, not by model name
&lt;/h2&gt;

&lt;p&gt;The fix isn't "use a cheap model for everything." It's a tiered policy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Pseudo-policy: route by task difficulty, not model brand
&lt;/span&gt;&lt;span class="n"&gt;routes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;extraction&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cheap&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;# structured field pulling — deterministic enough
&lt;/span&gt;    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;classification&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cheap&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;# intent/sentiment/spam — high volume, low variance
&lt;/span&gt;    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rewrite&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;         &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cheap&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;# tone/format — cheap models are fine
&lt;/span&gt;    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;summarize&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;       &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cheap&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;# unless source is very long/technical
&lt;/span&gt;    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;reasoning&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;       &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;frontier&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# open-ended, ambiguous, multi-step
&lt;/span&gt;    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;planning&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;frontier&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# high-stakes, low-tolerance
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# The 80/20 default: assume cheap until a signal says otherwise
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;select_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cheap&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;confidence&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.9&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cheap_pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pick&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;    &lt;span class="c1"&gt;# e.g. a top Chinese open-weight model
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;frontier_pool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pick&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key design choice: &lt;strong&gt;default to cheap, escalate on signal.&lt;/strong&gt; Not the other way around. A confidence threshold or a fast pre-classifier decides whether a call deserves the expensive model.&lt;/p&gt;

&lt;p&gt;A gateway that exposes 25+ models behind one OpenAI-compatible endpoint makes this trivial — you write the policy once, the gateway routes, and you stop hand-wiring API keys for every provider.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this actually saves
&lt;/h2&gt;

&lt;p&gt;For most teams the math is not subtle. Routing ~80% of traffic to cheaper models — with Chinese open-weight models typically &lt;strong&gt;70%+ cheaper&lt;/strong&gt; than frontier list prices, and on many Chinese models &lt;strong&gt;up to 90%+ cheaper&lt;/strong&gt; — turns a flat frontier bill into a blended one.&lt;/p&gt;

&lt;p&gt;The number that matters isn't "how much did the model cost per token." It's "how much of my traffic never needed the expensive model in the first place." That's the lever.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't route blind — watch the distribution
&lt;/h2&gt;

&lt;p&gt;One trap I've seen: teams set up routing, see "everything succeeds," and declare victory. But success rate lies. The dangerous failure is the call that &lt;em&gt;looks&lt;/em&gt; fine and is quietly wrong.&lt;/p&gt;

&lt;p&gt;If you route 80% to cheap models, the metric that matters isn't "did the call return 200." It's "does the cheap-model output still look like the data we trusted before." Watch the distribution of outputs per route. A median collapsing from ~20k to 0 is a different signal than an empty result — and it only shows up if you're measuring the blend, not just the pass rate. Route cheap, but verify the cheap route is actually producing trustworthy output. Routing without measurement is just hope with extra steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this matters more outside the US
&lt;/h2&gt;

&lt;p&gt;There's a reason this playbook resonates harder in emerging markets. In Southeast Asia — Malaysia, Singapore, Indonesia — teams build on tight infrastructure budgets and answer to data-sovereignty rules (Malaysia's PDPA, for instance) that US-default tooling tends to ignore.&lt;/p&gt;

&lt;p&gt;A routing gateway that is &lt;strong&gt;SG-hosted (Tencent Cloud)&lt;/strong&gt; and &lt;strong&gt;PDPA-aligned&lt;/strong&gt; lets a KL-based team get frontier-when-needed and cheap-when-possible, without shipping customer data through jurisdictions that complicate compliance. Cost-sensitive markets are exactly where the 80/20 split stops being an optimization and starts being the difference between a project that ships and one that doesn't.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one rule I'd steal from this
&lt;/h2&gt;

&lt;p&gt;Stop treating the model selector like a constant. Treat it like a router. Most of your calls are mechanical — route them cheap. Keep frontier for the slice that earns it. The models to do both are already here, and most of them don't cost what you're paying.&lt;/p&gt;

&lt;p&gt;If you're wiring this up, &lt;a href="https://tokenlat.com" rel="noopener noreferrer"&gt;TokenLat&lt;/a&gt; exposes a single OpenAI-compatible endpoint over 25+ models — route by scenario, measure the blend, and tune the thresholds as signal accumulates.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>machinelearning</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Your coding agent bills per task, not per token</title>
      <dc:creator>TokenLat</dc:creator>
      <pubDate>Tue, 18 Aug 2026 07:15:01 +0000</pubDate>
      <link>https://dev.to/tokenlat/your-coding-agent-bills-per-task-not-per-token-40ai</link>
      <guid>https://dev.to/tokenlat/your-coding-agent-bills-per-task-not-per-token-40ai</guid>
      <description>&lt;p&gt;If you price a coding agent the way you price a chatbot, you will misread the bill every time.&lt;/p&gt;

&lt;p&gt;A normal code chat turns one prompt into one completion. A coding agent runs a loop: it reads files, calls tools, reads the output, edits, re-runs the tests, and self-corrects — often a dozen turns. 2026 research (Stanford, MIT, and others) puts a single agentic-coding task at roughly &lt;strong&gt;1–3.5 million tokens&lt;/strong&gt;, with &lt;strong&gt;~76% of them reads&lt;/strong&gt;. One study found agentic coding burns up to &lt;strong&gt;1000× more tokens&lt;/strong&gt; than a normal code chat.&lt;/p&gt;

&lt;p&gt;The takeaway is not "agents are expensive." It is that &lt;strong&gt;the unit is wrong&lt;/strong&gt;. You do not pay per million tokens. You pay per &lt;em&gt;task&lt;/em&gt; — and two levers move that number 5–10× more than the model name does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lever 1: caching (the one that beats model-switching)
&lt;/h2&gt;

&lt;p&gt;A coding agent re-sends the same context — system prompt, project files, tool definitions — on nearly every turn. Cache reads bill a fraction of base input. On a gateway with transparent cache pricing, the gap is stark:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Input (¤/1M)&lt;/th&gt;
&lt;th&gt;Cache read (¤/1M)&lt;/th&gt;
&lt;th&gt;Cache advantage&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;deepseek-v4-Pro&lt;/td&gt;
&lt;td&gt;560&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~56×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;qwen3.5-plus&lt;/td&gt;
&lt;td&gt;130&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~6.5×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;hy3-preview&lt;/td&gt;
&lt;td&gt;180&lt;/td&gt;
&lt;td&gt;60&lt;/td&gt;
&lt;td&gt;3×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;minimax-m3&lt;/td&gt;
&lt;td&gt;390&lt;/td&gt;
&lt;td&gt;80&lt;/td&gt;
&lt;td&gt;~4.9×&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Structure prompts so the stable context is cacheable and new content appends at the end, and that discount compounds across a long session. One change, bigger impact than most model swaps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lever 2: route by difficulty, not by habit
&lt;/h2&gt;

&lt;p&gt;The same studies show a ~40× per-task cost spread across models for the &lt;em&gt;same&lt;/em&gt; task. The pattern that holds: run the cheapest model that passes your evals by default, and escalate only the hard tasks. A unified gateway with &lt;strong&gt;25+ models across 8 providers&lt;/strong&gt; makes that a one-line switch instead of a refactor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REQUEST -&amp;gt; AUTH -&amp;gt; ROUTE(model:"auto") -&amp;gt; RESPONSE -&amp;gt; METER
                                    ^ picks by cost / quality / speed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The catch most teams miss: you cannot route by difficulty if you cannot &lt;em&gt;see&lt;/em&gt; the cost. That is why per-request traceability matters — every call should show model choice, latency, tokens, and cost on one line, not buried in a dashboard.&lt;/p&gt;

&lt;h2&gt;
  
  
  The move
&lt;/h2&gt;

&lt;p&gt;Stop benchmarking models on $/M. Benchmark them on &lt;strong&gt;$/task&lt;/strong&gt; for 15–30 real tasks from your own repo. Cache the stable context. Route the routine work to cheaper models. And make the meter visible, because an agent that hides its own cost is the most expensive agent you will run.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Building agentic systems on a unified, OpenAI-compatible gateway (SG-hosted, PDPA-aligned, up to 90%+ cheaper on China models): &lt;a href="https://tokenlat.com" rel="noopener noreferrer"&gt;tokenlat.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>machinelearning</category>
      <category>llm</category>
    </item>
    <item>
      <title>Cache affinity in practice: 5 patterns that keep your agent's prompt cache warm</title>
      <dc:creator>TokenLat</dc:creator>
      <pubDate>Tue, 11 Aug 2026 07:46:05 +0000</pubDate>
      <link>https://dev.to/tokenlat/cache-affinity-in-practice-5-patterns-that-keep-your-agents-prompt-cache-warm-3a9m</link>
      <guid>https://dev.to/tokenlat/cache-affinity-in-practice-5-patterns-that-keep-your-agents-prompt-cache-warm-3a9m</guid>
      <description>&lt;p&gt;You shipped an agent. Tokens/month exploded. You switched to a "cheaper" model and the bill barely moved.&lt;/p&gt;

&lt;p&gt;Here's the thing nobody prints on the pricing page: in a loop, the model price is often a rounding error next to the &lt;strong&gt;repeat tax&lt;/strong&gt; — and the repeat tax is, at its core, a &lt;em&gt;cache-affinity&lt;/em&gt; problem.&lt;/p&gt;

&lt;p&gt;This is the practical follow-up to &lt;em&gt;why agentic systems should care about cache-hit pricing&lt;/em&gt;. That post argued the cost lives in cache behavior, not in raw model price. This one is about what you can actually do about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What prefix caching actually rewards
&lt;/h2&gt;

&lt;p&gt;Most providers (OpenAI, Gemini, Anthropic, and the OpenAI-compatible gateways on top of them) offer &lt;em&gt;automatic&lt;/em&gt; prefix caching: if the start of your prompt is byte-for-byte identical to a previous request, the cached tokens cost a fraction of a fresh input token.&lt;/p&gt;

&lt;p&gt;The keyword is &lt;strong&gt;byte-for-byte identical&lt;/strong&gt;, and it only helps if the identical part sits at the &lt;em&gt;front&lt;/em&gt; of the prompt. Reorder one line, inject a timestamp above the system prompt, or re-serialize history with a fresh UUID, and you've evicted your own cache. The model never sees the hit — you just pay full input, every step.&lt;/p&gt;

&lt;p&gt;So "cheaper model" optimizes the wrong number. The lever is &lt;strong&gt;cache affinity&lt;/strong&gt;: how stable is your prefix across the loop?&lt;/p&gt;

&lt;h2&gt;
  
  
  5 patterns that keep the cache warm
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stable system prompt + fixed tool schemas at the very top.&lt;/strong&gt; Tools definitions rarely change between steps. Put them first, verbatim, and stop touching them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Append-only history.&lt;/strong&gt; Don't re-serialize the whole conversation each step. Keep a canonical transcript and &lt;em&gt;append&lt;/em&gt;; let the unchanged prefix stay cached.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Inject volatile context &lt;em&gt;after&lt;/em&gt; the stable prefix.&lt;/strong&gt; Scratchpads, retrieved docs, and tool results are fine — as long as they sit below the system prompt + history, not above it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Route the easy 80% to a small model, but preserve the shared prefix.&lt;/strong&gt; Routing by scenario is smart. Just don't let the small model re-format the prefix; a different tokenizer can silently break the cache.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;One gateway, one canonical formatter.&lt;/strong&gt; When three sub-agents each format "the context" their own way, you get three incompatible prefixes and zero cache reuse. Centralize prompt assembly.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  5 patterns that evict your cache (the O(n²) traps)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Re-sending the entire conversation every step.&lt;/strong&gt; Frameworks that replay full memory each turn pay O(n²) tokens over a session. The prefix can never stabilize.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Re-serializing history with a timestamp or UUID in the prefix.&lt;/strong&gt; A new &lt;code&gt;updated_at&lt;/code&gt; each call = a new prefix = no cache, forever.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Putting volatile content &lt;em&gt;above&lt;/em&gt; the stable prefix.&lt;/strong&gt; Current time, request id, trace id — if it's before the system prompt, it poisons every cache hit downstream.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mixing tokenizers across models without a stable canonical form.&lt;/strong&gt; Switching models mid-loop without canonicalizing the prefix resets the cache and doubles your input cost.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No observability.&lt;/strong&gt; If you can't see &lt;em&gt;cache hit vs miss&lt;/em&gt; per request, you can't tell which of the above you're doing. You're flying blind on the single biggest cost lever.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The trace you're missing
&lt;/h2&gt;

&lt;p&gt;The fix that makes everything else measurable is boring but decisive: a &lt;strong&gt;per-request trace&lt;/strong&gt; that reports, for every call, whether the prefix hit cache and how many tokens were charged vs cached.&lt;/p&gt;

&lt;p&gt;Once you have that, the O(n²) traps show up as a line item. You stop guessing and start watching the cache-hit ratio the way you watch p99 latency. That's the difference between "we cut model cost" and "we cut agent cost."&lt;/p&gt;

&lt;h2&gt;
  
  
  Landing AI means making this the default
&lt;/h2&gt;

&lt;p&gt;"AI 落地" (getting AI into production) is sold as a model-access problem. It isn't. Access is solved. The hard part is the boring operational layer: warm caches, visible traces, sane routing — by default, not as a heroic refactor after the bill arrives.&lt;/p&gt;

&lt;p&gt;If you want a gateway that surfaces cache-hit/miss per request and keeps one canonical prefix across models, that's the whole point of what we're building at TokenLat: &lt;a href="https://tokenlat.com" rel="noopener noreferrer"&gt;https://tokenlat.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>machinelearning</category>
      <category>automation</category>
    </item>
    <item>
      <title>Why agentic systems should care about cache-hit pricing</title>
      <dc:creator>TokenLat</dc:creator>
      <pubDate>Fri, 07 Aug 2026 08:32:46 +0000</pubDate>
      <link>https://dev.to/tokenlat/why-agentic-systems-should-care-about-cache-hit-pricing-9j9</link>
      <guid>https://dev.to/tokenlat/why-agentic-systems-should-care-about-cache-hit-pricing-9j9</guid>
      <description>&lt;p&gt;The metric that quietly decides your agent bill isn't the input price of your model. It's how much you pay to read what you already sent.&lt;/p&gt;

&lt;p&gt;If you run multi-step agents, you've probably had this moment: a task you &lt;em&gt;expected&lt;/em&gt; to cost pennies comes back as a small surprise on the invoice. You didn't change models. You didn't prompt more. So where did the tokens go?&lt;/p&gt;

&lt;p&gt;Most of the time, they went to paying for the same context, again and again.&lt;/p&gt;

&lt;h2&gt;
  
  
  A 2-minute task can fire 40+ billable calls
&lt;/h2&gt;

&lt;p&gt;Here's a shape I keep seeing. An agent does a "2-minute" job:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reads a file&lt;/li&gt;
&lt;li&gt;drafts a plan&lt;/li&gt;
&lt;li&gt;calls a tool&lt;/li&gt;
&lt;li&gt;reflects on the result&lt;/li&gt;
&lt;li&gt;retries&lt;/li&gt;
&lt;li&gt;summarizes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each step is an LLM call. And each call re-sends the same scaffolding: the system prompt, the task description, and — critically — the growing conversation history. A step that adds 200 new tokens of &lt;em&gt;thinking&lt;/em&gt; can still carry 4,000 tokens of &lt;em&gt;context it already paid for once&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Multiply that across 40 steps and the math stops being about "model price." It's about &lt;strong&gt;how many times you re-pay for context you already have&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What cache-hit pricing actually is
&lt;/h2&gt;

&lt;p&gt;Normal input pricing charges you per token you send, every time. Cache-hit pricing changes the unit: if the provider already has your prefix cached (because you sent it recently and it hasn't expired), the &lt;em&gt;read&lt;/em&gt; of that cached prefix is billed at a deep discount instead of full input price.&lt;/p&gt;

&lt;p&gt;On a unified gateway this is visible per model. Two concrete examples from the model catalog:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DeepSeek-v4-Pro: &lt;strong&gt;¤10 / 1M tokens for a cached read&lt;/strong&gt; (¤ is the platform's billing unit)&lt;/li&gt;
&lt;li&gt;Qwen3.5-plus: &lt;strong&gt;¤20 / 1M tokens for a cached read&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those aren't the full input rates — they're the &lt;em&gt;cached-read&lt;/em&gt; rates, and that's the number that matters for agentic workloads, because agentic workloads are mostly repeats.&lt;/p&gt;

&lt;p&gt;The takeaway isn't "this model is cheaper." It's: &lt;strong&gt;for any loop that re-sends context, cached-read price is the real marginal cost, and most teams optimize for the wrong number.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The math that actually moves the bill
&lt;/h2&gt;

&lt;p&gt;Skip the exact figures and look at the shape. Say a loop runs 40 calls, and each carries ~4k tokens of repeated context plus ~200 tokens of new content.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pay full input on every repeated token: you're billed for 4k × 40 = 160k "new" tokens that were actually old.&lt;/li&gt;
&lt;li&gt;Pay cached-read on the repeated prefix: that 160k drops to a fraction — the cached-read rate instead of full input.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the two models above, cached reads land at ¤10–¤20 / 1M versus full input that's multiple times higher. The loop's cost doesn't go to zero, but the &lt;em&gt;repeat tax&lt;/em&gt; collapses. In agentic systems, the repeat tax is most of the bill — so this is where the 70%+ savings actually live, not in "pick a cheaper model."&lt;/p&gt;

&lt;h2&gt;
  
  
  You can't optimize what you can't see
&lt;/h2&gt;

&lt;p&gt;There's a trap here. Cache-hit pricing only helps if you can see hits and misses. A black-box API that just returns text hides the one number you need: &lt;strong&gt;was this token a cache hit or a fresh charge?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A request trace makes it observable. Each call should expose its stages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;REQUEST — what came in&lt;/li&gt;
&lt;li&gt;AUTH — who/what called&lt;/li&gt;
&lt;li&gt;ROUTE — which model served it&lt;/li&gt;
&lt;li&gt;RESPONSE — what came back&lt;/li&gt;
&lt;li&gt;METER — what it cost, including cache hit/miss&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When every call shows its cache hit/miss and per-stage cost, the loop stops being a mystery. You can see &lt;em&gt;which step&lt;/em&gt; blows the budget and &lt;em&gt;whether your prefix is actually staying warm&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Routing + cache affinity is the real lever
&lt;/h2&gt;

&lt;p&gt;Cache-hit pricing is necessary but not sufficient. The other half is &lt;strong&gt;keeping the cache warm&lt;/strong&gt;, and that's a routing problem.&lt;/p&gt;

&lt;p&gt;The 80/20 pattern holds: route the easy 80% of calls to a small/fast model, keep frontier for the hard 20%. But the part people miss is &lt;em&gt;cache affinity&lt;/em&gt; — if you keep the same system prompt and stable prefix across the loop, the cache stays warm and the cheap reads keep hitting. Change the prefix on every step (reformat the history, rewrite the system prompt, shuffle the order) and you silently evict your own cache. You pay full input forever.&lt;/p&gt;

&lt;p&gt;With &lt;code&gt;model: "auto"&lt;/code&gt; style routing behind one OpenAI-compatible endpoint, the loop doesn't have to think about which model serves which step — but it still has to respect cache affinity, because that's what turns "cheap model" into "cheap &lt;em&gt;and&lt;/em&gt; cached."&lt;/p&gt;

&lt;h2&gt;
  
  
  A practical cache-friendly checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep the system prompt and stable prefix byte-identical across loop steps&lt;/li&gt;
&lt;li&gt;Append new content; don't rebuild the whole context each time&lt;/li&gt;
&lt;li&gt;Prefer providers/models that expose cache-hit pricing and a request trace&lt;/li&gt;
&lt;li&gt;Watch cache hit rate per step, not just total spend&lt;/li&gt;
&lt;li&gt;Route by task, but preserve prefix stability so the cache survives&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The point
&lt;/h2&gt;

&lt;p&gt;Agentic cost isn't a model-selection problem. It's a &lt;strong&gt;repeat-tax&lt;/strong&gt; problem: how many times you pay to read context you already sent, and whether you can see it happening.&lt;/p&gt;

&lt;p&gt;Cache-hit pricing + request trace + cache-friendly routing is the combination that turns a scary agent bill into a boring one. Most teams optimize the first and ignore the other two — which is why their invoices still surprise them.&lt;/p&gt;

&lt;p&gt;If you want the routing playbook that pairs with this (the 80/20 split and how to keep the cache warm), it's at &lt;a href="https://tokenlat.com" rel="noopener noreferrer"&gt;https://tokenlat.com&lt;/a&gt; — but the idea stands on its own: &lt;strong&gt;stop counting input price. Start counting cache hits.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
    </item>
    <item>
      <title>The 80/20 routing playbook: cut your AI agent bill 70%+ without touching quality</title>
      <dc:creator>TokenLat</dc:creator>
      <pubDate>Fri, 31 Jul 2026 04:43:52 +0000</pubDate>
      <link>https://dev.to/tokenlat/the-8020-routing-playbook-cut-your-ai-agent-bill-70-without-touching-quality-21ai</link>
      <guid>https://dev.to/tokenlat/the-8020-routing-playbook-cut-your-ai-agent-bill-70-without-touching-quality-21ai</guid>
      <description>&lt;h1&gt;
  
  
  The 80/20 routing playbook: cut your AI agent bill 70%+ without touching quality
&lt;/h1&gt;

&lt;p&gt;Your agent's token bill is probably 5x higher than it needs to be — not because the models are expensive, but because of &lt;em&gt;routing discipline&lt;/em&gt;. Most teams wire every call to one frontier model and call it a day. This post is the practical fix: how to send the easy 80% of agent calls to cheap models, keep frontier for the hard 20%, and not lose a point of quality doing it.&lt;/p&gt;

&lt;p&gt;Everything below uses real numbers from a gateway that exposes 25 models across 8 providers behind one OpenAI-compatible API.&lt;/p&gt;




&lt;h2&gt;
  
  
  The default that's costing you
&lt;/h2&gt;

&lt;p&gt;Here's the shape of a typical agent loop:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;classify the request&lt;/li&gt;
&lt;li&gt;extract structured fields&lt;/li&gt;
&lt;li&gt;pick a tool&lt;/li&gt;
&lt;li&gt;call the tool, parse the result&lt;/li&gt;
&lt;li&gt;summarize what happened&lt;/li&gt;
&lt;li&gt;decide the next step&lt;/li&gt;
&lt;li&gt;draft the reply&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of those, maybe one or two steps actually need frontier-level reasoning. The rest are classification, extraction, and formatting — work that a fast, cheap model does &lt;em&gt;indistinguishably&lt;/em&gt; from a flagship. Yet most setups send all of it to &lt;code&gt;gpt-5.5&lt;/code&gt; (or whatever their default is) because it's the path of least resistance.&lt;/p&gt;

&lt;p&gt;That's the tax. You're paying flagship prices for steps that don't need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 80/20 split, with the math
&lt;/h2&gt;

&lt;p&gt;Route by &lt;em&gt;task difficulty&lt;/em&gt;, not by &lt;em&gt;model loyalty&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Easy 80%&lt;/strong&gt; — classification, extraction, summarization, short tool-formatting, routing decisions → a fast China-model tier&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Medium 15%&lt;/strong&gt; — coding, planning, multi-step reasoning → a strong reasoning tier&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hard 5%&lt;/strong&gt; — the genuinely gnarly frontier cases → flagship, reserved&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A blended-cost estimate (input tokens, per 1M):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;80% × ¤160   (cheap tier input)   = ¤128
15% × ¤560   (reasoning tier)     = ¤84
 5% × ¤7000  (flagship input)     = ¤350
---------------------------------------
blended input cost               ≈ ¤562 / 1M
vs. all-flagship                 = ¤7000 / 1M
savings                          ≈ 70%+ in this example
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even with a more conservative split, &lt;strong&gt;70%+ cheaper is the floor&lt;/strong&gt; — and quality doesn't move, because the hard calls still go to frontier.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trap: why "just use the cheapest model" backfires
&lt;/h2&gt;

&lt;p&gt;Naive cost-cutting picks one cheap model for everything. That fails for two reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Quality cliffs.&lt;/strong&gt; A ¤160/1M model is great at extraction and terrible at planning a 12-file refactor. Push hard tasks down and users notice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache invalidation (the silent tax).&lt;/strong&gt; This is the one almost nobody budgets for. Long agent conversations re-send the system prompt + tool definitions on &lt;em&gt;every&lt;/em&gt; turn. If you switch providers mid-conversation, you reset prompt-cache affinity and re-pay the full prefix each turn. A conversation that &lt;em&gt;should&lt;/em&gt; be cheap suddenly isn't.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The win isn't "use a cheap model" — it's &lt;strong&gt;routing discipline with cache affinity intact&lt;/strong&gt;: pin the easy 80% to a &lt;em&gt;stable&lt;/em&gt; cheap model so the cache stays warm, and only escalate to frontier for the calls that earn it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a real routing layer looks like
&lt;/h2&gt;

&lt;p&gt;With a unified gateway, this is roughly ten lines. One API, models swapped by &lt;code&gt;model:&lt;/code&gt; — no per-provider SDK juggling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;complexity&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;easy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;        &lt;span class="c1"&gt;# classify, extract, summarize
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;TokenLat-deepseek-v4-Flash&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;   &lt;span class="c1"&gt;# ¤160/1M input
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;needs_reasoning&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;             &lt;span class="c1"&gt;# code, plan, multi-step
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;TokenLat-deepseek-v4-Pro&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;     &lt;span class="c1"&gt;# ¤560/1M input, ¤10/1M cache read
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;chatgpt-5.5&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;                 &lt;span class="c1"&gt;# frontier, only the hard 5%
&lt;/span&gt;
&lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;responses&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or skip the router entirely and let the gateway decide per call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;responses&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;auto&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;          &lt;span class="c1"&gt;# gateway picks the right tier per request
&lt;/span&gt;    &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;model: "auto"&lt;/code&gt; is the zero-config version of the same idea — the gateway applies routing policy so you don't hand-roll it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real numbers from a 25-model gateway
&lt;/h2&gt;

&lt;p&gt;A unified gateway should show you its pricing up front. Per 1M tokens, in credits (¤), here's a slice (input / cache-read):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;TokenLat-deepseek-v4-Flash&lt;/code&gt; — cheap / fast tier → ¤160 / ¤40&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TokenLat-qwen3.5-plus&lt;/code&gt; — general tier → ¤130 / ¤20&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TokenLat-deepseek-v4-Pro&lt;/code&gt; — reasoning tier → ¤560 / &lt;strong&gt;¤10&lt;/strong&gt; (lowest cache-read)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TokenLat-glm-5.1&lt;/code&gt; — Chinese-stable → ¤950 / ¤160&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TokenLat-kimi-k3&lt;/code&gt; — flagship (China) → ¤3000 / ¤300&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gemini-3.1-pro&lt;/code&gt; — frontier → ¤2800 / ¤300&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;chatgpt-5.5&lt;/code&gt; — frontier → ¤7000 / ¤700&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The headline gap: cheap-tier input is ~44x cheaper than flagship input. That's the entire 80/20 argument in one line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cache-hit pricing — the agentic loophole
&lt;/h2&gt;

&lt;p&gt;For agentic systems, the &lt;em&gt;input&lt;/em&gt; price is almost a distraction. What matters is the &lt;strong&gt;cache-read&lt;/strong&gt; price, because the static prefix (system prompt, tool schemas, retrieved context) gets re-sent every turn.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;TokenLat-deepseek-v4-Pro&lt;/code&gt; caches reads at &lt;strong&gt;¤10/1M&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TokenLat-qwen3.5-plus&lt;/code&gt; at &lt;strong&gt;¤20/1M&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So a long-running agent loop that pins a stable model and keeps its prefix cached can serve most turns at the cache-read rate — a fraction of the input rate. The providers that reset your cache on every switch quietly erase this saving. Cache affinity is a routing decision, not an afterthought.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make it visible
&lt;/h2&gt;

&lt;p&gt;You can't optimize what you can't see. Every request through a proper gateway should leave a trace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;REQUEST → AUTH → ROUTE(auto→text-pro) → RESPONSE → METER
region: SEA | status: 200 OK | latency: 842ms | tokens: 1,284 | cost: ¤0.0048
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Five stages, one line, per call. When a bill spikes, you see &lt;em&gt;which&lt;/em&gt; model, &lt;em&gt;which&lt;/em&gt; route, and &lt;em&gt;which&lt;/em&gt; request — instead of staring at a monthly total and guessing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't guess — measure quality
&lt;/h2&gt;

&lt;p&gt;The one thing this playbook assumes: you actually check that the cheap tier is good enough. Route a sample of real tasks through both tiers, score the outputs on &lt;em&gt;your&lt;/em&gt; success criteria, and only then commit the split. Most teams find the quality cliff is far smaller than they feared — and the ones where it isn't, they've already reserved frontier for.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;The takeaway:&lt;/strong&gt; the savings aren't in hunting for a cheaper model. They're in &lt;em&gt;routing the easy 80% to a stable cheap tier, keeping cache affinity, and escalating only the hard calls to frontier.&lt;/em&gt; Do that and 70%+ cheaper is routine — with quality intact.&lt;/p&gt;

&lt;p&gt;If you want to try this without wiring up eight providers yourself: TokenLat is a unified AI gateway for Malaysia &amp;amp; Southeast Asia — one OpenAI-compatible API across 25 models, with &lt;code&gt;auto&lt;/code&gt; routing and per-request cost traces. The model list above is live at &lt;a href="https://tokenlat.com" rel="noopener noreferrer"&gt;tokenlat.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What's your current cost per agent-task — single digits or scaling faster than you'd like? Curious how the 80/20 split would land on your workload.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Your agent's token bill is 5x too high — and it's not the model price</title>
      <dc:creator>TokenLat</dc:creator>
      <pubDate>Mon, 27 Jul 2026 09:45:27 +0000</pubDate>
      <link>https://dev.to/tokenlat/your-agents-token-bill-is-5x-too-high-and-its-not-the-model-price-2ng9</link>
      <guid>https://dev.to/tokenlat/your-agents-token-bill-is-5x-too-high-and-its-not-the-model-price-2ng9</guid>
      <description>&lt;p&gt;Most teams blame their model provider when the inference bill spikes. They're looking at the wrong line item.&lt;/p&gt;

&lt;p&gt;The real leak is &lt;em&gt;architecture&lt;/em&gt; — and it's the difference between a token bill that scales with value and one that scales with chaos. Here's what we see shipping agentic systems in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hidden multiplier: agent loops
&lt;/h2&gt;

&lt;p&gt;A "2-minute task" is never one call. An agent fires 30–60 tool calls per run, and most frameworks stuff the &lt;em&gt;entire&lt;/em&gt; conversation history into every prompt. So a job you'd estimate at ~4K tokens becomes 40 calls × 8K context = 320K tokens — billed at frontier rates.&lt;/p&gt;

&lt;p&gt;Frontier pricing &lt;em&gt;per call&lt;/em&gt; looks cheap. Multiplied by agent-loop iterations, it quietly becomes the largest line in your cloud bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 80/20 of inference
&lt;/h2&gt;

&lt;p&gt;Not every call needs a frontier model.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;~80% of agent traffic is routing, extraction, formatting, classification, summarization. Trivial. Leading efficient models — including top China models — handle these at near-parity.&lt;/li&gt;
&lt;li&gt;~20% is genuine reasoning, open-ended generation, ambiguous planning. That's where frontier earns its price.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Route the 80% to efficient models and reserve frontier for the 20%. &lt;strong&gt;Same output quality. A fraction of the bill.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A unified gateway beats a drawer of API keys
&lt;/h2&gt;

&lt;p&gt;The trap most teams hit: they wire 4 providers with 4 clients, then let a naïve router "roam" between them. On failover it loses cache affinity, re-embeds context, and your 1.5x cost target drifts back toward ~1x — or worse.&lt;/p&gt;

&lt;p&gt;A single &lt;strong&gt;OpenAI-compatible endpoint&lt;/strong&gt; across OpenAI + Gemini + leading China models fixes this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One client, one code path.&lt;/li&gt;
&lt;li&gt;Provider pinning holds cache locality; it only fails over on hard error, not price drift.&lt;/li&gt;
&lt;li&gt;Your application code never changes when you swap a model.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  In SEA, "PDPA-aligned" is the baseline, not a premium
&lt;/h2&gt;

&lt;p&gt;For Malaysia and SEA teams, inference isn't just a cost question — it's a compliance one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PDPA requires 72-hour breach notification and a designated DPO.&lt;/li&gt;
&lt;li&gt;In-region data residency (SG-hosted) is now the default expectation, not a paid add-on.&lt;/li&gt;
&lt;li&gt;The adoption gap is real: ~93% of the workforce uses GenAI, but ~73% are stuck at L1 (experimenting, not in production). The blocker is almost always cost + compliance friction — not the models.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compliance stops being a tax and becomes table stakes when your gateway is PDPA-aligned by design.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;In our pricing analysis, frontier output runs on the order of &lt;strong&gt;100x&lt;/strong&gt; the cost of efficient China-model output per million tokens. Route the easy 80% there and blend:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Up to 90%+ cheaper&lt;/strong&gt; on the routine 80%&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;70%+ lower blended bill&lt;/strong&gt; overall&lt;/li&gt;
&lt;li&gt;Quality on the 20% that matters: unchanged&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The fix is architecture, not negotiation
&lt;/h2&gt;

&lt;p&gt;You don't fix a 5x token bill by begging your provider for a discount. You fix it by routing, caching, and unifying — then letting compliance be the default instead of the exception.&lt;/p&gt;

&lt;p&gt;We break down agent cost architecture weekly. If you're shipping agents and your bill is climbing faster than your usage, come find us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Discord: discord.gg/rxEtWG897V&lt;/li&gt;
&lt;li&gt;Site: tokenlat.com&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>costoptimization</category>
      <category>agents</category>
    </item>
  </channel>
</rss>
