Inside Hanzo's inference unit economics: 4-class token billing, per-thread adaptive tier shifting in adaptive_route.go, NVIDIA NIM + 1M OpenRouter frontier ladders, and the honest trade-offs of upstream capacity vs. local hardware.
On this page #
Most AI companies treat inference unit economics like a trade secret because the underlying math is embarrassing: charge a flat subscription, pin every agent turn to a single expensive frontier endpoint, ignore cache-read billing classes, and hope volume eventually brings a discount.
That model breaks the moment users run long-horizon coding or operational agents. An agent session is not a single chat completion; it is twenty to eighty sequential turns carrying a growing system prompt, tool schemas, file contents, and test logs. If you do not engineer pricing, routing, and margin protection from first principles, power users invert your gross margin overnight.
Here is the exact architecture that runs in production across hanzoai/universe (charts/app/files/enso/catalog.yaml and charts/app/files/zen/catalog.yaml) and hanzoai/ai (controllers/adaptive_route.go and controllers/rates.go)—with exact numbers, worked arithmetic, and an honest accounting of where upstream dependencies still sit.
1. Why four-class token billing matters #
A single "price per million tokens" hides the real cost shape of agentic software. Every priced rung in Enso's catalog declares four explicit token classes per million tokens:
- Fresh input (
in) — uncached prompt tokens sent for the first time. - Output (
out) — generated completion and reasoning tokens. - Cache read (
cache_read) — prefix tokens served from provider KV cache across multi-turn sessions. - Cache write (
cache_write) — tokens written into the prefix cache on the first miss.
In charts/app/files/enso/catalog.yaml, every priced rung is required to declare all four rates. If a rung omits cache_read or cache_write, the engine must bill that class at the full input rate—which destroys economics on agent workloads where 80% or more of billed input volume is repeated prefix context (system instructions, MCP tool schemas, repository index, and prior conversation turns).
Look at how starkly four-class pricing changes a 1,000,000-token agent session (worked arithmetic, not a claimed fleet-wide average) split across 80% cache reads (800k), 15% fresh input (150k), and 5% output (50k):
| Billing profile | Input / Output / Cache Read ($/1M) | 800k cache read | 150k fresh in | 50k out | Session total |
|---|---|---|---|---|---|
enso-flash (4-class retail) |
$0.33 / $1.65 / $0.033 |
$0.0264 |
$0.0495 |
$0.0825 |
$0.1584 |
enso-pro (4-class retail) |
$2.365 / $11.825 / $0.11825 |
$0.0946 |
$0.3548 |
$0.5913 |
$1.0406 |
enso-pro if cache reads billed at input rate |
$2.365 / $11.825 / $2.365 |
$1.8920 |
$0.3548 |
$0.5913 |
$2.8380 |
Ignoring the cache-read class nearly triples the session cost ($2.84 vs. $1.04). Worse, if an upstream model charges more for cache_read than your tier's retail cache_read rate, every cached agent turn leaks cash even when input and output rates look profitable.
That exact invariant shapes Enso's catalog. In enso/catalog.yaml, moonshotai/kimi-k3.1-pro lists a cache_read cost of $0.20/1M, which exceeds enso-pro's $0.11825/1M retail cache-read rate. Rather than accepting a silent loss on cached turns, kimi-k3.1-pro is excluded from enso-pro and placed only in enso-max ($0.25/1M cache read) and enso-ultra ($0.30/1M cache read).
2. The strictly monotonic Enso ladder #
Enso exposes four priced tiers—enso-flash, enso-pro, enso-max, and enso-ultra—plus the enso-auto router (enso / hanzo/enso). Every tier's retail price is derived class-by-class from the highest standard-endpoint cost among its priced rungs, multiplied by the tier's margin, ensuring a strictly monotonic ladder (Flash < Pro < Max < Ultra) in all four token classes:
| Tier | Reasoning default | Margin | Retail In / Out / Cache Read / Cache Write ($/1M) | Priced OpenRouter overflow rungs (cost per 1M In / Out / Cache Read) |
|---|---|---|---|---|
enso-flash |
low |
3.0× |
$0.33 / $1.65 / $0.033 / $0.4125 |
openai/gpt-6-luna (900k,$0.11 / $0.55 / $0.011 ; >272k$0.20 / $0.75 / $0.02 ),tencent/hy4-flash (1M,$0.07 / $0.281 / $0.003 ),deepseek/deepseek-v4.1-flash (1M,$0.04 / $0.144 / $0.0016 ) |
enso-pro |
medium |
1.075× |
$2.365 / $11.825 / $0.11825 / $2.95625 |
google/gemini-4-argon (1M,$2.20 / $11.00 / $0.11 ),openai/gpt-6.1-sol (272k,$2.20 / $11.00 / $0.11 ), plushy4-flash &deepseek-v4.1-flash |
enso-max |
high |
1.25× |
$2.75 / $13.75 / $0.25 / $3.4375 |
google/gemini-4-argon (1M),openai/gpt-6.1-sol (272k),moonshotai/kimi-k3.1-pro (1M,$2.00 / $10.00 / $0.20 ), plus 1M flash rungs |
enso-ultra |
max |
1.5× |
$3.30 / $16.50 / $0.30 / $4.125 |
Same frontier ladder ranked by suitability ( 98 > 96 > 92 > 82 > 80 ) at maximum reasoning effort |
Two structural guardrails keep this ladder solvent at all times:
- The Margin Guard (
controllers/rates.go): Before dispatching a request, the gateway checks every arm in a model's live route against the billed price acrossall four token classes , including long-prompt surcharge tiers (abovethresholds, such as GPT-6 Luna's 272k step-up) and any reseller fee. If any arm can cost more than the tier bills in any class, the guard refuses the route rather than serving negative-margin traffic. A post-hoc check (answered()) flags any drift and immediately invalidates the cached route table. - The Nano-Dollar Cost Ledger (
controllers/rates.go): Every completed request writes an accounting record with exactcost_nano,billed_nano,margin_nano,loss_nano,failovers, andfallback_sharekeyed by(model, served_arm, vendor). The ledger is a report, never a dynamic price override—customers see one predictable list price per tier while operators audit real realized margin per upstream arm down to the nano-dollar.
Two additional catalog rules prevent silent quality or margin leaks:
- Pre-call capability and context filtering: Before calling any upstream,
hanzoai/enginefilters out rungs that lack a requested modality (vision,audio,video) or whose context window is smaller than the prompt (256kon hosted NIM vs.1Mon OpenRouter overflow), avoiding wasted failover round-trips. - No dynamic
:freewildcard in Enso: Unlike the free Zen chat lane, Enso deliberately omitslive: openrouter/free, so small or weak free endpoints can never sneak into a paid Enso tier. Fast mode (fast: true/X-Fast: 1) routes directly to prepaidpremiumrungs with throughput sorting and bills prepaid cash at2×(auto/flash),3×(pro/max), or4×(ultra).
3. Two funding classes: zero-cash frontier first, paid overflow second #
Every Enso tier spans two funding classes (X-Hanzo-Classes):
ours(zero-cash frontier): 1. NVIDIA NIM on Hanzo's developer credits (integrate.api.nvidia.com/v1), running three keys in a single paced ring at**40 rpmper key =120 rpmtotal** . The pacer (pace.rs) picks the key whose slot frees soonest and waits at most3 seconds (SLOT_WAIT); if all keys remain busy, it advances immediately to the next rung so callers never receive a429. Healthy frontier NIM rungs lead every tier:mistralai/mistral-large-4-1t-a52b(256k),nvidia/nemotron-3-ultra-550b-a55b(256k), andnvidia/nemotron-3.5-super-vl-120b-a12b(256k vision). Unhealthy NIM endpoints (kimi-k3.1-proreturning422andminimax-m3.1-flashstalling beyond 12 seconds) are explicitly excluded. 2. Two curated 1M-context frontier:freeendpoints on OpenRouter (nvidia/nemotron-3-ultra-550b-a55b:freeandnvidia/nemotron-3.5-super-vl:free) across Hanzo's 7-account OpenRouter key ring.premium(prepaid OpenRouter frontier): Ranked by explicit suitability score (Gemini 4 Argon 98>GPT-6.1 Sol 96>Kimi K3.1 Pro 92>GPT-6 Luna 84>HY4 Flash 82>DeepSeek V4.1 Flash 80). Paying callers walkours → premium → free; Free-plan callers walkfree → oursandnever touchpremium.
On the Zen side (charts/app/files/zen/catalog.yaml), free SKUs ( hanzo/zen, zen-coder, zen-bolt, zen-vl) run exclusively on zero-cash rungs ( nvidia + :free), while paid zen6 ($0.60 / $2.40 / $0.024) and zen6-flash ($0.15 / $0.60 / $0.008) walk NVIDIA NIM and curated 1M :free first before falling through to deepseek/deepseek-v4.1-flash-1017 ($0.15 / $0.60 / $0.008, 1M context) on OpenRouter. Embeddings ( zen-embedding) already run on Hanzo's own cluster CPU engine ( Qwen/Qwen3-Embedding-0.6B, ~180 tokens/s per replica, $0.01/1M).
The critical investor takeaway: zero-cash rungs boost realized gross margin, but the pricing table does not rely on them to avoid losing money. Even if 100% of a customer's traffic spills onto prepaid OpenRouter overflow, every single rung sits strictly below the tier's retail floor across all four token classes.
4. Per-thread adaptive routing: shrinking the frontier share #
Unit pricing protects margin per token; adaptive routing cuts the number of expensive tokens needed to finish a job.
In hanzoai/ai (controllers/adaptive_route.go), enso-auto inspects every incoming thread across OpenAI Chat Completions, Anthropic Messages, and OpenAI Responses formats with zero extra network hops, maintaining a bounded in-memory per-thread state (adaptiveCacheMax = 4096, adaptiveCacheTTL = 30m, keyed by org | thread_id or a SHA-256 fingerprint of the first user turn).
The core empirical observation documented directly in adaptive_route.go is straightforward: long-horizon coding and agentic sessions spend 70–85% of their turns on routine tool continuations (reading files, running greps, checking clean test output, applying straightforward edits) and calm follow-ups after an initial planning turn. Pinning all 40 turns of a coding session to enso-pro or enso-max burns 7×–10× more budget without improving outcomes.
applyAdaptiveRouting enforces three deterministic transitions whenever the caller uses enso-auto (explicit caller effort overrides are always respected):
- Smart turn-1 startup (
adaptive-initial): If turn 1 contains heavy systems cues (architecture,migration plan,security audit,race condition,deadlock,distributed consensus,formal proof) or a ≥1,200-character specification with tools attached, the thread starts one rung higher (enso-pro) so the initial plan is solid. - Aggressive shift-down (
adaptive-shiftdown): As soon as trailing turns are clean tool results (no error markers such aspanic:,exit status,--- fail:,compilation failed, while explicitly treatingexit status 0/exited with code 0as clean) or calm follow-ups (≤240 characters, no code blocks, no heavy systems cues), the router drops immediately to**enso-flash** ($0.33 / $1.65 / $0.033). - Dynamic escalation (
adaptive-escalate): One failing tool call is normal test-driven iteration;2 consecutive failing tool steps add+1to the target tier, and3+ consecutive failures add+2. User pushback, depth demands (think harder,root cause), or frustration cues score0..3. Combinedboost = frustration + strugglesteps the thread upflash → pro → max → ultra, and if a previously escalated tierstill hits struggle on the same thread, the cache automatically steps itone notch higher (prev.lastTierIdx + 1).
Using the same worked 1M-token session arithmetic (80% cache read, 15% fresh input, 5% output), compare pinning all turns to enso-pro versus an illustrative 80% enso-flash / 20% enso-pro adaptive split:
| Routing strategy (worked arithmetic) | Effective cost per 1M session tokens | Relative cost |
|---|---|---|
| Pinned `enso-pro` (100% turns) | `$1.0406` | `1.00×` |
| `enso-auto` (80%`enso-flash` , 20%`enso-pro` ) | `$0.3348` | **`0.32×` (68% lower)** |
| enso-auto whenours (NIM / curated:free ) absorbs 50% of calls | Retail billed $0.3348 ; upstream cash COGS drops proportionally | Gross margin expands without raising user price |
(Note: The 80/20 split above is worked arithmetic illustrating the mechanics of adaptive_route.go, not a claim about every customer's live traffic mix. Heavy single-turn reasoning or repeated build failures shift the ratio upward automatically—which is the point.)
5. Honest accounting: upstream dependencies and the hardware migration path #
An evidence-first unit economics analysis has to name its own fragilities clearly:
- NVIDIA NIM credits are finite and non-guaranteed. Three keys at
40 rpm(120 rpmaggregate) cover meaningful burst and steady-state volume today, but hosted developer credits are not an infinite datacenter lease. Upstream endpoints also churn without notice—zen/catalog.yamldocuments NVIDIA retiringglm-5.3with410 Goneon October 28, 2026, and our live health measurements excluded degraded NIM endpoints (kimi-k3.1-pro422s,minimax-m3.1-flashstalls). - OpenRouter
:freeaccounts are rate-capped. Free quota is per account (1,000 requests/day for a funded account holding $10 credit, 50/day unfunded), shared across Enso and Zen, with higher latency variance than dedicated endpoints. - Gateway vs. catalog synchronization is operational discipline, not magic. Because
controllers/rates.goenforces the gateway's fixed retail quotes whileenso/catalog.yamldefines the live zero-Anthropic rung list, any price update to an upstream model must stay synchronized across both files—which is why the Margin Guard refuses routes on mismatch rather than silently bleeding cash. - Prepaid overflow compresses margin at the Pro tier. At
1.075×margin onenso-pro($2.365over$2.20for Gemini 4 Argon / GPT-6.1 Sol), pure prepaid Pro overflow is intentionally priced near cost to stay dramatically cheaper than monolithic frontier APIs while relying on adaptive shift-down (enso-flashat3.0×margin) and zero-cash/owned compute to expand blended gross margin.
That brings us to the structural long-term answer: moving base-load and flash-tier tokens off third-party per-token meters onto owned and local hardware.
Every layer of our serving stack is built for that transition. Today, hanzoai/engine already runs open-weight checkpoints locally on unified-memory Apple Silicon, NVIDIA GB10, and AMD Strix Halo (gfx1151), while our cloud catalog routes seamlessly between zero-cash credits, OpenRouter overflow, and self-hosted engine services with zero client changes. As low-bit and ternary quantization push 27B–200B open-weight models comfortably onto compact unified-memory nodes, the floor cost of a million flash-tier tokens converges toward electricity and amortized silicon—not vendor API rent.
Read the next two pieces in this series to see how we verify every performance claim and how low-bit compression drives that hardware curve:
Read more #
Ternary Weights, Compression, and Efficient Intelligence
Why autoregressive LLM decode is memory-bandwidth-bound, how 1.58-bit ternary weights and 1-bit BitDelta compression shrink memory traffic on Apple Silicon, GB10, and Strix Halo, and the real kernel and accuracy limits we still have to solve.
Hanzo — A Collective Intelligence Civilization
Personal AI stalls in isolated silos and corporate clouds concentrate control behind single operators. Hanzo Mesh connects eight tiers of heterogeneous devices and human stewards under one signed manifest, universal Publish with Hanzo deployment, a constitutional DAO OS across 99 apps, and federated human-agent co-evolution.
How We Benchmark Hanzo — Including What 3.02× Does Not Cover
Why unverified marketing charts destroy engineering credibility, how HIP-1403 and HIP-1334 enforce prospectively frozen gates and clean-room replay, and the exact boundary conditions around our 3.02× repository-repair speedup and engine losses.