# Switching models changes the tokenizer: how much does your bill move?

URL: https://infro.io/blog/switching-models-changes-the-tokenizer-how-much-does-your-bill-move
Author: INFRO Editorial (https://infro.io/blog/editorial)
Publisher: INFRO
Published: 2026-11-06
Last modified: 2026-11-06
Last reviewed: 2026-11-06 (next review due 2026-12-06)
Topic: Cost and FinOps
Format: Methodology

> Measure the same prompts and outputs with each target model's own counting method, take the ratio per workload slice, and weight it by the input and output share of the new cost. That weighted ratio is the correction factor to multiply into a list-price forecast.

Key takeaways:
- A list price per million tokens is a price per million of that model's tokens, so two models with equal rates can cost different amounts for the same text.
- Count the same real payloads with each target's own counting method, per workload slice, and keep input and output ratios separate.
- The correction factor is the input ratio and output ratio weighted by their shares of the cost at the new rates.
- Tokenizer drift is only one term: output length, caching and length-based price thresholds move the bill separately, so measure them as separate factors.
- Treat the pre-switch factor as a forecast and replace it with the factor computed from provider-reported usage after a canary.

## Why a list price per million tokens is not a unit price

A model-switch forecast usually looks like this: take last month's input and output token totals, multiply by the new model's rates per million tokens, compare to the current bill. The arithmetic is fine. The inputs are not, because last month's totals were produced by the current model's tokenizer, and the new model will cut the same text into a different number of tokens.

A token is a unit of a specific tokenizer. INFRO's earlier analysis of billing units cites Anthropic's pricing page for the statement that Claude 4.7 and later models use a newer tokenizer that produces approximately 30% more tokens for the same text, with the exact increase depending on content and workload shape.[1] Two models with identical published input rates are therefore not the same price per unit of your text if one of them cuts your text into more units. That article makes the point; this one supplies the measurement procedure it leaves open.

The goal is one number per workload: a **correction factor** you multiply into the naive list-price forecast. It is built from three measured quantities per slice of traffic: the input-token ratio, the output-token ratio, and the share of cost each side carries at the new rates.

## What to measure, and what not to fold in

The bill ratio between two models is a product of several separate effects. Mixing them makes the result impossible to debug later.

| Factor | What moves it | Measured by |
| --- | --- | --- |
| Rate ratio | New model's list rates against current effective rates | Rate tables, your contract |
| Tokenizer factor | Same text, different token counts | This method |
| Behavior factor | Different answer length, reasoning or thinking volume | A replay of real prompts on the candidate |
| Cache factor | Hit rate, write premium, read multiplier | Provider-reported cache fields |
| Threshold factor | Rates that change with prompt length | Distribution of counted prompt sizes |

Table: five terms that make up the bill ratio of a model switch. Only the second is a pure tokenizer effect.

Keep the tokenizer factor pure. It answers one question: if the candidate produced exactly the text the current model produces, and read exactly the payloads you send today, how many tokens would each side bill? Anything about the candidate writing longer or shorter answers belongs in the behavior factor, which needs real generations and is covered in [reasoning tokens and their cost](https://infro.io/blog/reasoning-tokens-cost).

## Step 1: build a corpus that carries the whole payload

Sample real requests and keep the full payload, not just the user text: system prompt, tool and schema definitions, message history, and any documents. Counting only the text a user typed underestimates input, because system prompts, tools and message framing are billable input too.[2]

Then partition the sample into slices that tokenize differently. A workable starting set:

- Short conversational turns with a large shared system prompt.
- Retrieval prompts with long prose context.
- Code in the languages you actually use.
- Structured data: JSON, tables, logs.
- Tool-heavy requests with many function schemas.
- Non-English text, per language that matters to your volume.

Store the observed output of the current model beside each prompt. You need it in step 3. Aim for slices large enough that the ratio stops changing when you add samples, and weight each slice by its share of last month's token volume when you aggregate.

Redact before you copy. The corpus is production prompts, so it falls under your [payload logging policy](https://infro.io/blog/llm-prompt-logging-policy), not under a convenience script.

## Step 2: count each payload with each target's own method

A local tokenizer counts plain text and misses roles, tools, images and files, so use each provider's counting endpoint on the exact payload you would send. INFRO's counting guide lists OpenAI's `POST /v1/responses/input_tokens`, Anthropic's `POST /v1/messages/count_tokens` and Gemini's `countTokens`.[2] Anthropic's endpoint accepts the same structured inputs as message creation, including system prompts, tools, images and PDFs, and returns the total input tokens.[3] Anthropic describes counting as a way to manage costs and make model routing decisions, which is the use here.[3]

Three cautions from the same sources:

- Anthropic says the real input count may differ by a small amount from the estimate.[2] Treat ratios as accurate to a few percent, not to the token.
- Anthropic's endpoint refuses some inputs: server tools, the MCP connector, and media given by URL or file id.[2] Slice those requests out and measure them from real usage instead.
- Counts belong to a model. Count against the exact model id you plan to use, and recount when a new generation appears.[2]

```python
from openai import OpenAI
import anthropic
from google import genai

oa, an, gg = OpenAI(), anthropic.Anthropic(), genai.Client()

def count_openai(model, payload):
    r = oa.responses.input_tokens.count(
        model=model,
        instructions=payload["system"],
        input=payload["messages"],
        tools=payload.get("tools_openai", []),
    )
    return r.input_tokens

def count_claude(model, payload):
    r = an.messages.count_tokens(
        model=model,
        system=payload["system"],
        messages=payload["messages"],
        tools=payload.get("tools_claude", []),
    )
    return r.input_tokens

def count_gemini(model, payload):
    r = gg.models.count_tokens(model=model, contents=payload["gemini_contents"])
    return r.total_tokens

COUNTERS = {"current": count_claude, "candidate_a": count_openai, "candidate_b": count_gemini}
# one row per payload: slice, tokens per target; ratios are computed per slice
```

Each provider wants its own request shape, so the corpus needs one adapter per target that maps the stored payload to that shape. Keep the adapters in version control; a wrong adapter silently drops tools or history and biases the ratio low.

## Step 3: count the outputs the same way

No endpoint counts generated output, because generation has not happened yet.[2] But the text of an output you already hold can be counted. Send the stored output of the current model to each target's counting method as a single message, then subtract the count of a one-character message to cancel the fixed framing. The remainder is the output-side token count for that text under that tokenizer, to within a token or two.

This gives an **output ratio** for identical text. It is a different number from the input ratio, because outputs are mostly prose or the structured format you asked for, while inputs carry system prompts and tool schemas. Do not assume one ratio covers both: the sections below keep them separate, and the weighting step depends on it.

If a candidate emits reasoning or thinking tokens, the stored text will not include them. That volume is the behavior factor, not part of this ratio.

## Step 4: compute ratios and the correction factor

For each slice, compute

- `r_in = tokens_in(candidate) / tokens_in(current)` over the slice's payloads.
- `r_out = tokens_out(candidate) / tokens_out(current)` over the slice's stored outputs.

Aggregate by volume weight. Then price both ways with the candidate's rates:

- Naive cost `N = T_in × P_in + T_out × P_out`, using last month's token totals `T` from the current model.
- Corrected cost `C = T_in × r_in × P_in + T_out × r_out × P_out`.
- Correction factor `CF = C / N = a × r_in + (1 − a) × r_out`, where `a = T_in × P_in / N` is the input share of the naive cost at the new rates.

The weight `a` is why the factor depends on the rate card as well as on the tokenizer. A model with expensive output makes `r_out` count for more; one with a cheap output rate makes `r_in` dominate.

> **Example: Worked example (illustrative numbers)**
> All figures here are made up to show the arithmetic. A workload runs 2,000 million input and 200 million output tokens a month on the current model. The candidate has a list rate of $2 per million input and $10 per million output.
> 
> Naive cost: 2,000 × $2 + 200 × $10 = $6,000.
> 
> Measured on the corpus: `r_in` = 1.28, `r_out` = 1.22. Corrected cost: 2,000 × 1.28 × $2 + 200 × 1.22 × $10 = $5,120 + $2,440 = $7,560.
> 
> Correction factor: 7,560 / 6,000 = 1.26. The input share at new rates is 4,000 / 6,000 = 0.667, and 0.667 × 1.28 + 0.333 × 1.22 = 1.26, which matches.
> 
> If a replay later shows the candidate writes 10% fewer output tokens than its tokenizer ratio implies, the output term becomes 200 × 1.22 × 0.9 × $10 = $2,196 and the total $7,316. That 0.968 adjustment is the behavior factor, kept separate from the 1.26.

Report the factor per slice as well as in total. If tool-heavy requests carry a ratio of 1.4 and short chats 1.1, finance can see which product feature absorbs the movement, and the engineers can see where trimming schemas pays.

## Step 5: check for threshold crossings

A token-count ratio above 1 does more than scale cost linearly. Some rates are set by prompt length, and a larger count can push a request across the line. Per Anthropic's rate table, Claude Haiku 5.5 is priced at $0.10 per million input tokens for prompts up to 100K tokens and $0.50 above that, with output at $0.50 and $2.50 respectively.[4] INFRO's earlier article lists similar thresholds at OpenAI above 272K input tokens and Gemini 3.1 Pro above 200K, and notes a request over the line is re-priced as a whole.[2]

So take the histogram of counted prompt sizes per slice, apply `r_in`, and count the share of requests that now land above a threshold on the candidate. A request that was 90K tokens on the old tokenizer and is 117K tokens on the new one changes price tier, not just count.

> **Warning: Limits you set in tokens change meaning too**
> A `max_tokens` chosen to bound an answer, a chunk size chosen to fit a retrieval window, or a per-request token budget in an agent loop is expressed in units of the old tokenizer. After a switch it can truncate answers or overflow a window with no error.[1] Convert each such constant using the slice's ratio.

## Step 6: normalize caching before you compare

If your corpus replays real usage, make sure the cache fields are normalized per provider before computing totals. Anthropic reports cache reads and writes outside `input_tokens`, so the total is the sum of three fields; OpenAI reports cached tokens as a subset inside the input total.[1] Add them wrongly and you double-count or drop the cached prefix, which changes `T_in` and every ratio built on it.

The counting endpoints give an uncached count. Apply the cache factor separately: your observed hit rate, the target's read multiplier, and its write premium. Anthropic's rate table shows how much these differ even inside one family: Sonnet 5.5 lists cache reads at $0.10 and writes at $2.50 per million against $2 input, while Opus 5.5 lists $0.20 and $5 against $4 input.[4] A cached prefix that grows 28% under a new tokenizer grows 28% in its write cost as well.

## Step 7: replace the forecast with a measured factor

The pre-switch factor is an estimate from a sample. After a canary on real traffic, compute the same ratios from provider-reported usage: tokens billed per request for the candidate, against the corpus's current-model counts for the same prompts. If the two factors differ by more than the sample's noise, the corpus is unrepresentative, and the usual cause is a slice you under-sampled.

INFRO records each request's token or unit counts and an estimated provider cost, as your provider reports it, and estimates what the provider will bill.[5] That per-request record, queryable by model and project, is the data for the post-canary factor; the estimate for a request before it is sent is documented under [billing](https://infro.io/docs/org/billing).[6] If your contract carries negotiated rates, enter them so the estimate uses them ahead of list rates, and reconcile against the provider's own cost reports so a persistent gap is attributed rather than guessed at. The tokenizer factor is a count-side correction; it does not replace a rate-side one. INFRO takes 0% of model spend, so none of this changes what your provider invoices.[6]

A checklist for the review:

- [ ] Corpus carries full payloads, with PII handled per policy.
- [ ] Slices cover prose, code, structured data, tools and each major language.
- [ ] Each target counted with its own method on its own request shape.
- [ ] Input and output ratios computed separately, per slice and volume-weighted.
- [ ] Correction factor computed with the candidate's rates, not the current ones.
- [ ] Threshold crossings estimated from the prompt-size histogram.
- [ ] Token-denominated limits converted.
- [ ] Behavior and cache factors reported as their own lines.
- [ ] A date set to recompute the factor from real usage after the canary.

For the broader question of what else a per-token estimate cannot produce, see [tokens are not the unit you are billed in](https://infro.io/blog/tokens-are-not-the-billing-unit); for counting mechanics, see [how to count tokens before you call the API](https://infro.io/blog/count-tokens-before-api-call).

## Questions

### Can I use one provider's tokenizer to approximate another's?

Only as a rough lower-bound sizing aid. The ratio between two tokenizers depends on your content: prose, code, JSON, non-English text and tool schemas each move differently, which is why the method measures per slice with each target's own counting method.

### How many prompts do I need in the sample?

Enough per slice that the ratio stops moving when you add more. Compute the ratio on growing subsets and stop when it is stable to the precision finance needs; a slice that stays noisy is a slice to sample more, not to average away.

### Does the correction factor apply to image, audio or video inputs?

Not as a tokenizer ratio. Those inputs are counted by each provider's own rules, so measure them with the counting endpoint on real files as their own slice, and check whether the target bills them in tokens at all.

## Sources

1. Tokens are not the unit you are billed in — INFRO. https://infro.io/blog/tokens-are-not-the-billing-unit (accessed 2026-11-06)
2. How to count tokens before you call the API: OpenAI, Claude, Gemini — INFRO. https://infro.io/blog/count-tokens-before-api-call (accessed 2026-11-06)
3. Token counting — Anthropic (Claude Platform Docs). https://platform.claude.com/docs/en/build-with-claude/token-counting (accessed 2026-11-06)
4. Plans & pricing (API rates) — Anthropic. https://claude.com/pricing (accessed 2026-11-06)
5. INFRO documentation overview — INFRO. https://infro.io/docs (accessed 2026-11-06)
6. Billing — Organizations — INFRO. https://infro.io/docs/org/billing (accessed 2026-11-06)
