Join the Hanzo beta and get 20% off any paid plan

What a Million Tokens Actually Costs Hanzo

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:

  1. Fresh input (in) — uncached prompt tokens sent for the first time.
  2. Output (out) — generated completion and reasoning tokens.
  3. Cache read (cache_read) — prefix tokens served from provider KV cache across multi-turn sessions.
  4. 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 profileInput / Output / Cache Read ($/1M)800k cache read150k fresh in50k outSession 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:

TierReasoning defaultMarginRetail In / Out / Cache Read / Cache Write ($/1M)Priced OpenRouter overflow rungs (cost per 1M In / Out / Cache Read)
enso-flashlow3.0×$0.33 / $1.65 / $0.033 / $0.4125openai/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-promedium1.075×$2.365 / $11.825 / $0.11825 / $2.95625google/gemini-4-argon (1M, $2.20 / $11.00 / $0.11), openai/gpt-6.1-sol (272k, $2.20 / $11.00 / $0.11), plus hy4-flash & deepseek-v4.1-flash
enso-maxhigh1.25×$2.75 / $13.75 / $0.25 / $3.4375google/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-ultramax1.5×$3.30 / $16.50 / $0.30 / $4.125Same frontier ladder ranked by suitability (98 > 96 > 92 > 82 > 80) at maximum reasoning effort

Two structural guardrails keep this ladder solvent at all times:

  1. 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 across all four token classes, including long-prompt surcharge tiers (above thresholds, 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.
  2. The Nano-Dollar Cost Ledger (controllers/rates.go): Every completed request writes an accounting record with exact cost_nano, billed_nano, margin_nano, loss_nano, failovers, and fallback_share keyed 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/engine filters out rungs that lack a requested modality (vision, audio, video) or whose context window is smaller than the prompt (256k on hosted NIM vs. 1M on OpenRouter overflow), avoiding wasted failover round-trips.
  • No dynamic :free wildcard in Enso: Unlike the free Zen chat lane, Enso deliberately omits live: 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 prepaid premium rungs with throughput sorting and bills prepaid cash at 2× (auto/flash), 3× (pro/max), or 4× (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 rpm per key = 120 rpm total. The pacer (pace.rs) picks the key whose slot frees soonest and waits at most 3 seconds (SLOT_WAIT); if all keys remain busy, it advances immediately to the next rung so callers never receive a 429. Healthy frontier NIM rungs lead every tier: mistralai/mistral-large-4-1t-a52b (256k), nvidia/nemotron-3-ultra-550b-a55b (256k), and nvidia/nemotron-3.5-super-vl-120b-a12b (256k vision). Unhealthy NIM endpoints (kimi-k3.1-pro returning 422 and minimax-m3.1-flash stalling beyond 12 seconds) are explicitly excluded.
    2. Two curated 1M-context frontier :free endpoints on OpenRouter (nvidia/nemotron-3-ultra-550b-a55b:free and nvidia/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 walk ours → premium → free; Free-plan callers walk free → ours and never touch premium.

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):

  1. 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.
  2. Aggressive shift-down (adaptive-shiftdown): As soon as trailing turns are clean tool results (no error markers such as panic:, exit status , --- fail:, compilation failed, while explicitly treating exit status 0 / exited with code 0 as 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).
  3. Dynamic escalation (adaptive-escalate): One failing tool call is normal test-driven iteration; 2 consecutive failing tool steps add +1 to the target tier, and 3+ consecutive failures add +2. User pushback, depth demands (think harder, root cause), or frustration cues score 0..3. Combined boost = frustration + struggle steps the thread up flash → pro → max → ultra, and if a previously escalated tier still hits struggle on the same thread, the cache automatically steps it one 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 tokensRelative cost
Pinned enso-pro (100% turns)$1.04061.00×
enso-auto (80% enso-flash, 20% enso-pro)$0.33480.32× (68% lower)
enso-auto when ours (NIM / curated :free) absorbs 50% of callsRetail billed $0.3348; upstream cash COGS drops proportionallyGross 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 rpm aggregate) 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.yaml documents NVIDIA retiring glm-5.3 with 410 Gone on October 28, 2026, and our live health measurements excluded degraded NIM endpoints (kimi-k3.1-pro 422s, minimax-m3.1-flash stalls).
  • OpenRouter :free accounts 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.go enforces the gateway's fixed retail quotes while enso/catalog.yaml defines 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 on enso-pro ($2.365 over $2.20 for 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-flash at 3.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:

Comments

Sign in with your Hanzo ID to comment.

Loading comments…

Read more