Skip to content

Announcing token brokering for cost control in Tetrate Agent Router Enterprise

Learn more

Token Optimization: How Engineering Leaders Control AI Token Costs

How engineering leaders track AI token spend by team, set budgets that hold, and decide who needs a Claude Code subscription, from one AI gateway.

Token Optimization: How Engineering Leaders Control AI Token Costs

By David Wang, Head of Product, Tetrate

Most engineering organizations know their monthly AI total and cannot decompose it. They cannot say which team, which model, or which person produced it, and they cannot say what a unit of finished work cost. When the number doubles, the only available response is to ask everyone to use less.

This guide covers the three decisions that move that number: understanding where spend goes, setting team budgets that hold, and deciding who needs a coding-agent subscription. Every screenshot comes from Tetrate’s own Agent Router Enterprise deployment, showing real traffic from an internal Tetrate engineering team. No customer data appears in this post. Names, emails, and team names are blurred, and the figures are unaltered.

Why AI cost measurement belongs at the gateway

An agent harness governs one thing well: itself. Claude Code, Codex, and Cursor each hold their own context and see only their own sessions. Controls at that level, including per-session spend caps, are scoped to one session on one machine.

Cost accrues across sessions, models, and people. The layer that spans all of them is the meta-provider, the path beneath the harness that unifies every model and tool an agent reaches and governs that traffic in one place (The AI Gateway Is the Meta-Provider for Your Agent Harness).

The agent stack: developer and agents drive a meta-harness above the harness, and the meta-provider, Tetrate Agent Router Enterprise, unifies models, tools, and guardrails below it
A meta-harness composes agents above the harness. The meta-provider unifies models, tools, and guardrails below it.

Every request crosses that boundary on the way to a provider, so it is the one place where token counts, resolved model, cost, and caller identity land in the same record, for every team, without asking any team to instrument anything.

Part 1: Understand your organization’s AI spend

Token usage vs. cost: why the two diverge

Usage → Analytics opens on a chart named Cost vs. Token Over Time. Cost is drawn as stacked bars against the left axis, total tokens as a line against the right. The two are plotted together because reading either alone produces a wrong answer.

Agent Router Analytics, Cost tab at organization scope, showing the Cost vs. Token Over Time chart with cost bars and a token line, summary cards, and a per-key table
Organization scope, last 24 hours: $642.50 across 7.6K requests and 767.8M tokens.

The table beneath ranks API keys by cost, with the user and team each key belongs to. The top three keys show 140.7M tokens for $132.80, 100.3M tokens for $124.70, and 65M tokens for $85.90: effective cost from $0.94 to $1.32 per million, on the same day in the same organization.

Keys whose owner is not mapped to a team show as No team, which is its own audit: unmapped users are spend no cost center currently owns. The group-to-team mapping determines whether the team dimension can be trusted, since a user counted in the wrong team is spend charged to the wrong cost center.

Find which models drive your AI bill

Filtering to one team and grouping by model narrows the same view to a model mix.

Agent Router Analytics filtered to one team and grouped by model, with a per-hour cost tooltip and a table of requests, tokens, and cost per model
One team, last 24 hours: $173.80 across five models.
ModelRequestsTokensCostEffective $/M tokens
claude-sonnet-4-61.4K79.4M$59.80$0.75
claude-opus-4-851245.3M$53.20$1.17
claude-sonnet-51.5K132.8M$47.30$0.36
claude-opus-4-71203.7M$7.40$2.00
claude-opus-5536M$5.70$0.95

The heaviest model by token volume is the third heaviest by cost. A model carrying 1.4% of this team’s tokens accounts for 4% of its spend at $2.00 per million. Rank these five by tokens and by cost and the orders do not match, which is why a token quota is a poor instrument for controlling a bill.

Find which users and teams drive AI spend

Grouping by user answers who to talk to.

Agent Router Analytics grouped by user, with a tooltip decomposing one hour into per-user cost and a table of users with team, API key count, requests, and cost
The tooltip decomposes the 8 PM hour: $54.01 total, of which the top consumer accounts for $30.12 and the remaining 16 users combined account for $5.62.

Each row carries the user’s team, their API key count, requests, and cost. The key count is the detail worth noticing. The top consumer holds 13 keys and spent $149.80; the second holds one key and spent $132.80. A user with one key is a user whose spend cannot be decomposed further, which is the argument for issuing one key per purpose instead of one key per person (Onboard developers and issue keys).

Measure cache hit rate and cached token share

The Tokens tab reports tokens in four classes rather than two, and the two cache classes price differently.

Token classWhat it isHow it prices against standard input
InputContext read fresh, with no cache hitBaseline
Cache creationContext written into the provider’s cache on first useA premium above baseline
Cache readContext served from cache on a later callA fraction of baseline
OutputTokens the model generatesSeveral times baseline
Agent Router Analytics, Tokens tab at organization scope over 30 days, showing 42B total tokens split into input, cache read, cache creation, and output, with a per-user table carrying the same four columns
Organization scope, last 30 days: 42B tokens, of which 37.6B are cache reads, 2.2B cache creation, 2B fresh input, and 228.7M output.

Cache read share: 89.5%. Nine of every ten tokens read come from cache. That is why claude-sonnet-5 ran at $0.36 per million in the model table above.

Cache reuse ratio: 17.1 to 1. Cache read divided by cache creation gives the number of times each cached token was read back. Because writing to cache carries a premium, a ratio near 1 means paying that premium and collecting no discount. At 17 reads per write, this organization is well past break-even.

Output share: 0.54%. The organization reads about 182 tokens for every one it produces, which is normal for coding agents. Shortening completions saves nothing worth measuring.

The per-user columns show how widely the ratio varies between people doing the same kind of work:

Rank by tokensTokensAPI keysFresh input shareCache reuse ratio
19.7B194.4%15.7 to 1
26.4B10.8%21.3 to 1
35.1B80.7%28.2 to 1
42.8B11.2%22.6 to 1
52.6B20.6%25.6 to 1

The largest consumer is the least cache-efficient, at just over half the third-ranked user’s ratio, and reads over six times as much fresh input as a share of total tokens. The adjacent column suggests why: 19 API keys against one or two for everyone else, so likely many workloads whose prompt prefixes never hold still. This view raises that question without settling it, which makes it one for the team owning those keys.

Turn the readings into cost decisions

What you seeWhat it meansThe move
A model low on tokens and high on costPremium capacity serving work a smaller model handlesShift a weighted share with traffic splitting and read the quality data before committing
One person far above the restA heavier workload, or a less efficient oneRead their reuse ratio before assuming either
High fresh input, low reuse ratioThe prompt prefix moves too often to be cacheablePut variable content after the stable system prompt and tool schemas, and batch related calls
Keys showing as No teamSpend with no cost centerFix the identity-provider group mapping

Both figures are computed on these screens already, so a monthly review costs nothing beyond the review itself (Catch spend drift early).

Part 2: Set AI spend budgets and limits by team

Review every team budget in one list

Usage → Budgets holds every ceiling in one list, with a rollup across the portfolio.

Agent Router Budgets list, Team Budgets tab, with rollup cards for spend across team budgets, active count, near limit, and over limit, above a table of budgets
Eight budgets, six of them team budgets. $136 of $7.1K budgeted, 1.9% utilization, nothing near or over its limit.

The four cards are the review surface: spend against total budgeted, active budgets against dormant ones, and counts near and over limit. Two of the six team budgets here are inactive, which is the state a ceiling sits in during a renegotiation.

Choose a budget scope: team, per-member, or individual

ScopeWhat the limit coversWhen it fits
Whole teamOne shared limit pooled across all membersA cost center with a single ceiling, where one member’s heavy month offsets another’s light one
Each teammateThe same limit applied to every member individuallyA per-person allowance that holds regardless of what the rest of the team spends
One personA limit on a single userAn individual bounded independently of any team

Limits are entered in dollars, with presets at $100, $500, $1,000, $5,000, and $10,000, and reset at the start of each calendar month in UTC. Scopes coexist and the most restrictive applicable limit governs, so a team can carry a pooled ceiling while members carry tighter ones underneath it. Size the ceiling from the ranked user view in Part 1 instead of from guesswork: comfortably above normal consumption, well below the level that would be a problem (Keep each team’s spend inside an agreed ceiling).

Read budget burn before the ceiling hits

Budget detail view for a per-member team budget, showing seven of seven members within limits, total billed, total allotted, per-member cap, a passthrough usage line, and a ranked member list
A per-member budget: $200 per person per month across seven members, $1,400 allotted, $64.33 billed with six days left.

A pooled budget leads with a single meter, $260.75 of $5,000.00 · monthly, plus Used, Remaining, and Days left, with Top contributors ranking members by share. Read Used and Days left together: 80% used with 20 days left is a conversation to have this week.

A per-member budget leads with membership health instead. 7 of 7 members within limits breaks into over, near, and healthy. Total allotted is the per-member cap multiplied by the member count. The member list sorts by spend, so exceptions surface at the top, and the near rows are the ones worth a message before they cross (See budget exhaustion coming).

Budgets alert, rate limits block

BudgetRate limit
ControlsCumulative spend over a monthThroughput over a short window
ScopeTeam, each teammate, or one personModel, API key, user, or group
EnforcementAlerts only. Requests continue to be servedInline at the gateway. Requests over the ceiling get a 429
CatchesA slow overrun across weeksA retry storm or fan-out burst happening now

Budget spend is evaluated on the management plane against aggregated request logs, so a budget is a forecasting and accountability control, and the alert has to reach someone who will act. Rate limits come in three forms, capping tokens per minute, requests per minute, and requests in flight at once. The working pattern is budgets on production keys, where a false-positive block is worse than an overrun, and rate limits on research, evaluation, and CI keys, where a runaway is worse than a rejection (Stop runaway workloads, Choose the right cost control).

Budgets are mutable in place, so a ceiling can be raised mid-period when growth is agreed and funded, or paused during a renegotiation, with each change recorded in the audit trail. Any view exports as CSV for showback and chargeback, grouped by user, team, or model (Bill AI spend back to the teams that incur it).

Part 3: Decide who needs a Claude Code subscription

How passthrough mode works

A developer on a Claude Max or Pro plan can point Claude Code at the gateway and keep paying the flat subscription fee. Anthropic still authenticates them with Claude Code’s stored OAuth token, and the gateway routes and observes the traffic without putting those tokens on Agent Router billing. Agent Router calls this passthrough mode, and it sits alongside two other modes.

Agent Router Analytics, Tokens tab grouped by mode, showing passthrough, managed, and BYOK rows with token class columns
The same team grouped by mode: 3.7K passthrough requests carrying 268.5M tokens, against 5 managed requests carrying 272.1K tokens.
ModeWho pays the providerCounted toward budget
PassthroughThe developer, through a flat subscriptionNo, shown alongside for scale
ManagedThe organization, through provider credentials on the gatewayYes
BYOKThe team, through its own provider accountNo, attributed to that account directly

The gateway meters passthrough traffic and prices it at standard API rates anyway, which sets up the comparison below.

Comparing subscription cost against à la carte usage

The same budget detail view with the passthrough tooltip open, explaining that passthrough usage is not billed to the budget, comes through subscription plans, and is priced at standard API rates for scale only
The product explains the line in place: subscription traffic priced at standard API rates, shown for scale, excluded from limits and alerts.

Under the meter sits passthrough usage (not counted toward budget) ≈ $13,535.17, against $64.33 of billed spend. Same seven people, same period, a ratio of roughly 210 to 1. The per-member rows carry both figures side by side:

Rank by billedBilledPassthrough at API ratesRank by passthrough
1$26.41≈ $6,218.571
2$17.35≈ $1,998.733
3$9.70≈ $3,470.552
4$4.63≈ $267.086
5$4.53≈ $0.497
6$1.17≈ $790.894
7$0.53≈ $788.865

Only the top member holds position across the two rankings. The person ranked fifth on billed spend is last on actual consumption, at 49 cents of passthrough, because their work runs through metered API calls. The two ranked sixth and seventh climb to fourth and fifth, because theirs runs almost entirely on a subscription.

Decide which subscription seats to keep

The passthrough column is a per-person estimate of what a seat is worth. Compare it against the current list price of the subscription and the decision falls out.

Passthrough per monthReadAction
Far above the seat priceThe subscription is saving money every monthKeep the seat, and confirm the volume is necessary before celebrating it
Near the seat priceRoughly break-evenLeave it in place and re-read next cycle
Far below the seat priceNot enough usage to justify a flat feeMove to metered access and reclaim the seat
Near zero, with billed spendAlready working à la carteNo seat needed

On the team above, one seat is carrying more than $6,000 of monthly work and another is carrying 49 cents. Both pay the same flat fee. Reallocating the second seat is a decision no provider console can support, because no single provider sees both the subscription traffic and the metered traffic for the same person.

Two cautions. The passthrough figure is an estimate at list prices, so treat it as a scale comparison and not an invoice (Read the shadow bill). And a low figure can mean low usage or a person who has not been pointed at the gateway yet, so confirm the routing before reclaiming anything.

Get started with Agent Router Enterprise

Tetrate Agent Router Enterprise is now available as a fully managed offering on a monthly subscription, built for teams that need to understand and control what their AI costs. Tetrate runs both the management plane and the data plane, so there is nothing to install. Trial licenses are issued within 24 hours.

Request a trial

FAQ

What is token optimization?

Making AI spend decomposable by team, model, and person, then acting on the figures that move it: effective cost per million tokens, cache hit rate, and what a unit of finished work costs. It is a measurement problem before it is a tuning problem.

Why do AI token usage and cost not move together?

Cached input, model choice, and prompt length change cost per token independently of volume. In one 24-hour window, the heaviest model by token count ranked third by spend, and effective cost ranged from $0.36 to $2.00 per million tokens across five models on the same team.

What is a cache reuse ratio?

Cache read tokens divided by cache creation tokens, which gives the average number of times each cached token was read back. Because writing to cache carries a price premium, a ratio near 1 means paying that premium without collecting the discount.

Do AI spend budgets block requests?

In Tetrate Agent Router Enterprise, budgets alert rather than block. Spend is evaluated on the management plane against aggregated request logs, so requests continue to be served past the ceiling. A rate limit is the control that rejects requests inline at the gateway with a 429.

What is passthrough mode?

Passthrough mode lets a developer route Claude Code through the gateway while still paying a flat Claude Max or Pro subscription fee. The gateway observes and prices that traffic at standard API rates for comparison, and it never draws down a budget.

How do I decide who needs a Claude Code subscription?

Compare each person’s passthrough figure against the current seat price. Passthrough far above the seat price means the subscription is saving money. Far below means that person is cheaper on metered API access and the seat can be reclaimed.

Product background Product background for tablets
Building AI agents

Agent Router Enterprise provides a managed AI Gateway, MCP Gateway, and AI Guardrails in your dedicated instance. Graduate agents from prototype to production with consistent model access, governed tool use, and runtime supervision — built on Envoy AI Gateway by its creators.

  • AI Gateway – Unified model catalog with automatic fallback across providers
  • MCP Gateway – Curated tool access with per-profile authentication and filtering
  • AI Guardrails – Enforce policies, prevent data loss, and supervise agent behavior
  • Learn more
    Replacing NGINX Ingress

    Tetrate Enterprise Gateway for Envoy (TEG) is the enterprise-ready replacement for NGINX Ingress Controller. Built on Envoy Gateway and the Kubernetes Gateway API, TEG delivers advanced traffic management, security, and observability without vendor lock-in.

  • 100% upstream Envoy Gateway – CVE-protected builds
  • Kubernetes Gateway API native – Modern, portable, and extensible ingress
  • Enterprise-grade support – 24/7 production support from Envoy experts
  • Learn more
    Decorative CTA background pattern background background
    Tetrate logo in the CTA section Tetrate logo in the CTA section for mobile

    Ready to enhance your
    network

    with more
    intelligence?