Skip to navigation

Is Your LLM API Billing Extra Tokens? Audit It Yourself

In short: LLM API token billing audit: count your own tokens, learn which overhead is legitimate, and run a two-probe test on a free model. Sources read 27 Nov 2026.

Published 30 min read
On this page

Most guides on this topic tell you to “compare your token count with the bill” and stop there. This one gives you the rest: a local script that counts a chat the way the OpenAI cookbook does, a table of the overhead that is legitimate with its size and source, a two-probe calculator that tells a constant surplus from a proportional one, and a free test you can run today against a :free model on One AI API Key. We publish this post and we sell a gateway, so we use our own records as the example and say where they cannot prove anything. The sources were read on 27 November 2026.

What does “billed tokens” actually mean?

A billed token is a token as counted by the model provider’s tokenizer, on the prompt as the provider renders it, not on the text you typed. Your characters go in; the provider wraps them in a chat template, appends tool definitions, maybe its own instructions, runs its own tokenizer, and reports the total back in a usage object. The cost is that total multiplied by a per-million rate. If you want the full chain, the gateway explainer shows where a gateway sits in it, and the billing documentation shows how a request is priced from the figures.

Four numbers matter in that object. Prompt tokens (input), completion tokens (output), the cached part of the prompt, and the reasoning part of the completion. OpenAI’s own API reference describes the last one in a revealing sentence: reasoning tokens are “still counted in the total completion tokens for purposes of billing, output, and context window limits”. They are inside the completion figure, they are charged at the output rate, and in most APIs you never see their text.

So an audit is a reconciliation, not a hunt for one wrong number. You need an independent count for the prompt side, a visible count for the output side, a list of the additions the provider is allowed to make, and a rule for what is left over. The rest of this post builds each part, and a cost calculator turns the result into dollars when you want to see what a gap is worth.

Why will your own count never match to the digit?

Because three things differ between your script and the provider: the tokenizer, the framing, and what else is in the request. Start with the tokenizer. The same text can cost a different number of tokens under different encodings. We counted a few strings on 27 November 2026 with tiktoken 0.14.0, using the two encodings the OpenAI cookbook lists for its chat models.

Text Characters o200k_base cl100k_base
Reply with the single word OK. 30 7 7
Explain a 429 error in two sentences. 37 9 10
2 + 2 = 4 9 7 7
A Japanese greeting (9 characters) 9 8 9
def add(a, b): return a + b on two lines 32 12 12
A small JSON tool definition 193 49 49

For plain English the two encodings are close, which is why a local count is a useful baseline. They are not identical, and the cookbook shows the same effect: for one long sample word it lists five tokens under r50k_base and six under both cl100k_base and o200k_base. Move to a model from another family and the gap widens. Anthropic’s token counting page says models from Claude Opus 4.7 onward use a newer tokenizer, and that the same input text produces about 30 percent more tokens than on earlier models, with the exact increase depending on content. If you carry a count measured on one model to another, you are comparing two different rulers.

Open-weight models add a second layer. A chat model never sees your list of messages, it sees one token sequence, and the template that turns messages into that sequence belongs to the model. Hugging Face’s guide to chat templates shows two models fine-tuned from the same base wrapping the same conversation in different control tokens, and says different models may use different formats even from the same base. So an exact baseline for an open model is the model’s own tokenizer plus its own chat template, which apply_chat_template produces, not a generic count of your text.

That is why the first rule of an audit is to expect a small constant gap and to stop treating it as evidence. The verification guide makes the same point for model identity: one clean number proves little, and a pattern across several probes proves a lot.

Which extra tokens are legitimate?

More than most people expect. The table below lists the additions we can document from vendor pages, with the size where the vendor gives one. Read the third column as the answer to “would I see this in my own prompt?”.

Source of extra tokens Size, where documented Visible in your prompt? Where it is documented
Message framing 3 tokens per message plus 3 for the reply primer, for gpt-4o-class chat models No OpenAI cookbook, which calls it an estimate
Role and name fields Counted as text in the cookbook formula, plus 1 per name Partly Same page
Tool definitions Names, descriptions and schemas count as input; the cookbook adds fixed per-function and per-property constants You wrote them Same page, and Anthropic tool use
A built-in tool-use system prompt 286 to 675 tokens depending on the Anthropic model, when tools are present No Anthropic tool use page
Provider instructions and hidden system content Not sized; OpenAI lists “OpenAI-provided instructions” as part of a cacheable prefix No OpenAI prompt caching guide
A different tokenizer About 30 percent more tokens for the same text on newer Anthropic models No Anthropic token counting page
A chat template (open models) A handful of control tokens per message, model-specific No Hugging Face chat templates
Chat history Every earlier turn is sent and billed again on each call Yes, if you stored it Measured below
Earlier thinking blocks Count as input on models that keep them across turns No Anthropic token counting page
Reasoning tokens Billed as output; the count appears in a details field when reported No OpenAI API reference
Cache writes 1.25 times the input rate for a five-minute write on Anthropic, and for GPT-5.6 and later on OpenAI’s default lifetime No Both caching pages
Images and documents Counted as tokens; Anthropic’s own example of one image plus “Describe this image” counts 1,028 input tokens No Anthropic token counting page

Two of those rows deserve a number. For tools, Anthropic’s own counting examples show the scale: a request with the system text “You are a scientist” and the user text “Hello, Claude” counts 14 input tokens, while a short weather question with one small tool definition counts 403. Almost all of the difference is the tool. For the built-in tool prompt, the numbers differ by model, as the chart below shows from the vendor’s table read on 27 November 2026.

Tool-use system prompt tokens added when tools are present (tool_choice auto)

  • Opus 5.5, Sonnet 5.5, Haiku 5.5286
  • Opus 4.8290
  • Sonnet 5354
  • Opus 4.6, Sonnet 4.6497
  • Opus 4.7675the largest in the vendor table
From Anthropic's tool use pricing table. These tokens are added to your normal input and output tokens, and the vendor says they count toward the cost. With no tools, and a tool choice of none, the extra is 0.

The takeaway is not that any of this is hidden. It is documented. The takeaway is that a prompt of 30 tokens with a tool attached can legitimately bill hundreds of input tokens, so the right baseline for a tool request includes the vendor’s own count of the tool, not just your text. If a vendor offers a counting endpoint, use it for that part. If you use a gateway’s endpoint, check how it counts first, because it may be a rough estimate, as ours is.

How much does a chat grow turn by turn?

Faster than the text in it. We built a five-turn support chat, one system message, five short questions and five short answers, and counted the prompt of each call with the cookbook formula on 27 November 2026. The script is below. Run it and you should get the same numbers, since it counts with a fixed encoding and no network.

count.py: expected prompt tokens for a five-turn chat
import tiktoken

enc = tiktoken.get_encoding("o200k_base")  # the encoding the OpenAI cookbook lists for gpt-4o-class models


def count_messages(messages):
    """Prompt tokens for a chat request, following the OpenAI cookbook formula for gpt-4o-class models."""
    total = 3  # every reply is primed with a few control tokens
    for m in messages:
        total += 3  # per-message framing
        for value in m.values():  # role and content both count
            total += len(enc.encode(value))
    return total


system = "You are a support agent for a shop. Answer in plain English and cite the policy number."
questions = [
    "Explain a 429 error in two sentences.",
    "Now explain a 402.",
    "And a 401?",
    "Which of those should I retry?",
    "Give me a retry rule in one line.",
]
answers = [
    "A 429 means too many requests were sent in a given time. Wait and retry after the delay the server names.",
    "A 402 means payment is required: the balance is empty. Retrying will not help until credit is added.",
    "A 401 means the key is missing or wrong. Fix the key, do not retry.",
    "Retry 429 and 5xx with backoff. Do not retry 401 or 402.",
    "Retry 429 and 5xx with backoff, never 401 or 402.",
]

history = [{"role": "system", "content": system}]
per_turn = []
for q, a in zip(questions, answers):
    history.append({"role": "user", "content": q})
    per_turn.append(count_messages(history))
    history.append({"role": "assistant", "content": a})

print("expected prompt tokens per turn:", per_turn, "sum:", sum(per_turn))

It prints 39, 77, 113, 147 and 184 prompt tokens for the five calls, a sum of 560. The answers add 24, 23, 19, 20 and 18 tokens, 104 in all. The unique text in the whole conversation, the system line, the five questions and the five answers, is 159 tokens. You were billed on 560 plus 104, which is 664, or about 4.2 times the text anyone wrote.

Expected prompt tokens on each call of the five-turn chat

  • Call 139
  • Call 277
  • Call 3113
  • Call 4147
  • Call 5184about 141 of these are text, the rest is framing and role words
Counted locally with tiktoken 0.14.0, o200k_base and the cookbook formula, on 27 November 2026. These are expected counts, not a bill; a real endpoint will differ by its own tokenizer and template.

Call 5’s 184 tokens break down exactly. System line 19 tokens, five questions 36, four earlier answers 86: that is 141 tokens of text. The other 43 are framing: ten messages at 3 each, ten role words at 1 each, and the 3-token primer. That is the arithmetic of a legitimate surplus, and it is why a chat or an agent loop costs more than the length of the last message. It is also why a runaway loop gets expensive fast, and a per-key spend limit is the cheap insurance, as the guide to one key per project with spend limits shows. To keep a long history cheap, the guide to reducing LLM API costs lists trimming and summarising tactics, and prompt caching, covered below, changes the price of the repeated part.

How do you reconcile one request?

Work in five steps, in this order. The point of the order is that each step removes one legitimate cause before you decide the rest needs explaining.

The reconciliation ladder

Count your own textthe model tokenizer, local and freeAdd the known framingper message, tools, template: documentedSend it, read usageprompt, cached, completion, reasoningCompare as a gapbilled minus expected, per requestFit two probesa constant gap or a multiplier?
Steps 1 and 2 are on your machine. Steps 3 to 5 need only a handful of requests, which on a free id cost nothing.

1. Count your own text with the right tokenizer. The cookbook function above works for OpenAI-style models. For an open-weight model, load its tokenizer and call apply_chat_template with the same messages. If the vendor documents a counting endpoint on its own API, that is a better baseline than any library, and Anthropic’s page states that its endpoint is free to use, with its own request limits.

2. Add the documented framing. Three per message and three for the primer, the tool constants, the vendor’s tool-use system prompt. Write the additions down as numbers, so you can show later which part of a gap you explained.

3. Send the request and read the whole usage object. Not just prompt_tokens. Copy the request id from the X-Request-Id header too, because it is the handle for support and for the usage page. The headers reference lists it.

curl: one probe, read the request id and the usage
curl -sS -D - https://api.oneaiapikey.com/v1/chat/completions \
  -H "Authorization: Bearer $ONEAIAPIKEY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "z-ai-glm-5.3:free", "max_tokens": 8, "temperature": 0,
       "messages": [{"role": "user", "content": "Reply with the single word OK."}]}'
# Read two things in the output: the x-request-id header, and "usage": {"prompt_tokens": ..., "completion_tokens": ...}

4. Compare as a gap, never as a percentage of the bill. Gap equals billed prompt tokens minus expected prompt tokens. On a 14-token prompt a gap of 10 is 71 percent. On a 928-token prompt the same gap is about 1 percent. Short prompts make small constants look huge, so a percentage on a single short request misleads in both directions.

5. Repeat with a prompt of a very different length and fit the two points. That is the step most guides skip, and it is the one that identifies the cause.

What does the two-probe test tell you?

If the provider adds a fixed block of text to every request, the gap is the same on a short and a long prompt: a constant. If it counts with a different tokenizer, or inflates counts by a rate, the gap grows with the prompt: a multiplier. Two requests give you two points on a line, and the line has a slope and an intercept. The slope is billed tokens per token you counted. The intercept is what is added to every request.

Here is the arithmetic. With expected counts e1 and e2 and billed counts b1 and b2, slope equals (b2 minus b1) divided by (e2 minus e1), and intercept equals b1 minus slope times e1. We used a short probe of 14 expected tokens (“Reply with the single word OK.”, one user message) and a long probe of 928, the same sentence about the gateway repeated 40 times. Those expected counts are real, from the script. The billed counts below are illustrative, constructed to show what each cause looks like.

Case Billed on short Billed on long Slope Intercept
Clean, same tokenizer 14 928 1.00 0
Hidden prefix of 140 tokens 154 1,068 1.00 140
Counts inflated by 15 percent 16 1,067 1.15 about 0
Another tokenizer, 12 percent denser, plus 9 template tokens 25 1,048 1.12 about 9

Read the last two rows together. A provider inflating counts by a rate and an honest model whose tokenizer is denser than the one you used look the same from outside: a slope above 1. The slope alone cannot tell them apart. What separates them is the baseline. Swap in the model’s own tokenizer, or the vendor’s counting endpoint, and an honest model returns to a slope of about 1.00 with a small intercept. A model that stays above 1.00 against its own tokenizer has a proportional surplus that needs an explanation. A hidden prefix is easier: a constant that survives the tokenizer swap, as in row two, shows up as the intercept either way. Try your own numbers below.

Two-probe gap test

Slope: billed per counted token
1.00
Intercept: tokens added to every request
140
Reading
Constant extra tokens on every request
Extra input tokens a month from the constant
2,800,000
Cost of the constant a month at that rate
$1.40

The defaults are the hidden-prefix row of the table above, with the real expected counts and illustrative billed counts. The 3 percent and 8 token thresholds are our own rules of thumb, not a standard. The price is an example, not a listed rate.

Be honest with the result. Two points are a screening test, not a verdict. Real endpoints add noise from cache hits and routing, so run the long probe twice and take the lower number, and add more lengths if the two disagree. The probe script further down fits six points by least squares instead of two. And a constant that is small, under about 8 tokens, is a template. The reseller risks guide covers what a large, constant, unexplained prefix has been reported to look like in other people’s tests, and the verification guide shows how to check token counts together with the model-identity probes.

What do reports of mismatched bills actually show?

Three real cases, because they show how often the cause is boring and how a ledger check settles it. We cite them as reports, with dates, and we draw no conclusion about any service from them.

A varying cost on an aggregator. On 6 October 2026 a user posted to r/SillyTavernAI that the cost of the first message of a chat on OpenRouter varied between about $0.02 and $0.04 (3 points and 5 comments when we read it). The top reply listed four causes to check in the activity page: a different provider behind the same model, reasoning tokens billed as output, an extension making a second request per message, and cache hits. All four are in this post’s table, and none of them is a billing fault. We are a competitor of OpenRouter and publish this post, so weigh our reading accordingly; the useful part is the list, which is a fair checklist for any gateway, ours included. The OpenRouter alternatives guide compares seven options if you are choosing between them.

Native versus normalized counts. An engineer measured on 14 July 2026 that the token counts returned by an aggregator were not the counts it billed: one model matched to the cent, the other was off by 1.7 times, and the same factor applied to prompt and completion. The write-up, dated 23 August 2026, explains that counts were normalised onto a common scale while billing used each provider’s native tokens. By that date, the author checked and found the aggregator’s usage accounting documentation said counts use the model’s native tokenizer, so the behaviour had changed. We read that page on 27 November 2026 and it still says so. The lesson is the author’s and it is a good one: when the same multiplier appears on both input and output and the prices are right, the counts you see are not the counts being billed. Take the provider’s own cost field as the source of truth, and treat your formula as an estimate.

A reseller disputed caching and reasoning charges. On 21 September 2026 a user reported in r/SillyTavernAI that a reseller’s staff had said, in their group chat, that caching and reasoning tokens were not charged, then denied saying it when the user’s tokens drained faster than expected (24 points, 6 comments when we read it). It is one account of a dispute, and the reseller’s side is not in the thread. We did not test that service and say nothing about it. What the report shows is a precise way these disputes begin: nobody agreed in writing which token types are billed. The post on cheap reseller risks and our honest review of what the service does and does not give show what to ask before paying anyone.

Can you audit reasoning tokens you never see?

Not fully, and the research is candid about it. A 2025 position paper, Invisible Tokens, Visible Bills, argues that users are billed for internal steps they cannot observe, verify or contest. It names two risks, quantity inflation and quality downgrade, and says an auditor must work from what is observable: the prompt, the final answer, billing metadata and the declared service identity. It also reports that a regression network could not accurately predict the number of reasoning tokens from the length of the prompt and the answer, which is the honest reason a simple “expected reasoning tokens” rule does not exist. A companion paper, CoIn, says hidden reasoning tokens often account for the majority of the cost and proposes a verification framework that, deployed as a trusted third-party auditor, detected inflated counts with a success rate of up to 94.7 percent. That is a research result about a framework you would have to deploy. It is not a script you can point at an endpoint tonight.

What you can do tonight is smaller and still useful. Check four things, all from public fields.

  1. The details field exists and adds up. Where the provider reports it, completion_tokens_details.reasoning_tokens plus your count of the visible answer should equal completion_tokens, within a few tokens. Our reasoning documentation says the reasoning count is already inside the completion figure.
  2. The number moves when the effort moves. Send the same prompt at a lower reasoning effort, or to a non-reasoning model, and the reported figure should fall. A reasoning count that stays constant while the setting changes is a question to ask.
  3. The number is stable across a few repeats. Reasoning length varies run to run, as the paper’s own regression result implies. A band is normal. A wall of identical large numbers is not.
  4. The documented behaviour matches the invoice. If the provider says reasoning is billed as output, the cost of a request should equal input cost plus reasoning and visible output at the output rate. The recompute calculator below checks that arithmetic.

Anthropic-format thinking works the same way here: thinking tokens are billed as output tokens. The documentation for streaming adds a catch for audits: without stream_options asking for usage, a streamed OpenAI-format reply carries no usage chunk, though the request is still metered and billed, and the counts remain on the usage page.

How do cached tokens change the arithmetic?

They split one number into several, and the total depends on the API format. This is the most common reason a correct bill looks wrong.

In the OpenAI format, prompt_tokens includes the cached part, and prompt_tokens_details.cached_tokens says how much of it was a cache read. Our prompt caching documentation says the same for requests through this gateway. In Anthropic’s format the figures are separate. Anthropic’s caching page says input_tokens is only the part after the last cache breakpoint, and that total input is the sum of cache_read_input_tokens, cache_creation_input_tokens and input_tokens. Its worked example is 100,000 tokens read from the cache plus 50 in the user message after the breakpoint: a total of 100,050, with input_tokens reading just 50. A dashboard that treats both APIs the same way will misreport one of them. When both cache fields are 0, Anthropic’s page says the prompt was not cached, often because it was under the model’s minimum length, which it lists as 512 to 4,096 tokens depending on the model.

Prices differ per category, so the sum is not the bill. Anthropic’s page says a five-minute cache write costs 1.25 times the base input price and a read 0.1 times, with listed exceptions on some models. OpenAI’s caching guide gives the same multipliers for GPT-5.6 and later, and a clean worked case: with writes at 1.25 times and reads at 0.1 times, one write and nine full reads of a prefix cost 2.15 times its ordinary input cost, against 10 times without caching. We can check that on a 10,000-token prefix. The write is 12,500 units, nine reads at 1,000 units each are 9,000, and the total of 21,500 is 2.15 times 10,000. The saving is real, and so is the first-request premium, which is why a one-off call that writes a cache it never reads costs more than an uncached call.

Use this to recompute any charge from the numbers in the response. The calculator takes the three rates a priced model lists on its page, and it follows the formula in our cost control documentation: fresh input at the input rate, cached input at the cached rate, output including reasoning at the output rate, rounded to the nearest $0.000002.

Recompute one charge

Fresh input tokens
400
Charge in millionths of a dollar
1,140
Rounded to the nearest 0.000002 (millionths)
1,140
Charge in dollars (4 decimals)
$0.0011

A rate quoted per million tokens, times a token count, gives millionths of a dollar directly: 400 fresh tokens at 0.50 is 200, 800 cached at 0.05 is 40, 450 output at 2.00 is 900, total 1,140. The rates here are examples, not listed prices; use the ones on the model's page.

What can you check on a gateway like ours?

Here is how this plays out on One AI API Key, with the limits stated.

What the record holds. Each request leaves one usage record with the time, the key name, the model id you sent, input, output and cached tokens, the cost, the duration, the time to first token for streams, a stream flag and the request id. The usage page filters by date range, model and key, and exports a view as CSV. Prompts and answers are not stored; the record holds counts, as the routing and privacy documentation and the privacy guide set out.

Field in the record What to compare it with What a match proves
Input, output, cached tokens usage in the reply you received That the record copies the provider’s figures
The same tokens Your own tokenizer count (this post) That the provider’s figures are plausible
Cost Tokens times the model page rate, rounded to $0.000002 That the charge follows the published price
Request id The X-Request-Id header you logged That the row is your request
Row count The number of calls your code made, retries included That nothing was billed twice

What it does not prove. The token figures come from the provider’s report; we do not run a second tokenizer over your prompt. So a match between the record and the reply is a check on our copying, and the independent check is yours. We say this because the other direction is a trap: a gateway that quotes you its own count endpoint as evidence has told you nothing if that endpoint estimates. Ours does estimate, at roughly four characters per token, and says so in a response header. The transparency page states the same boundary for everything else we monitor.

How a request is charged. The billing documentation says the cost is input tokens at the input rate plus output tokens, reasoning included, at the output rate, with cached input at the cached rate. A request that fails before the model produces anything is not charged, a stream you stop early is charged for what was produced, and when a retry or a fallback model answers, only the attempt that answers is billed. Before a request runs, the gateway reserves an estimate of its cost, so a request in flight can briefly make the balance look lower, and the balance on screen is rounded down to the cent. Compare your arithmetic with the per-request cost on the usage page, not with the balance.

A client-side trap. The official SDKs retry on 429, 5xx and connection errors. When a reply is lost after the provider already produced it, the retry is a second request with its own row. Count rows against calls; the guide to 429 errors separates the causes, and the uptime and fallback guide shows how retries and fallbacks are meant to behave.

Free ids bill $0. The free lane has 48 ids ending in :free that share 100 requests and 3,000,000 tokens a day per account, with no card. Most bill nothing per token, so a free call is the right place to test token counts and the wrong place to test whether a balance moves. For that, send one request to a priced id from the $10 sign-up credit, and recompute it. The models page lists which priced ids are served today, and the free-tier comparison sets our limits next to others.

How do you run the audit for free?

The probe script below does the whole of steps 3 to 5 against a free id. It sends six requests, a short sentence and the long sentence repeated 5, 10, 20, 40 and 80 times, reads usage.prompt_tokens and the request id from each, prints the gap, and fits the line through all six points. The six requests carry about 3,700 tokens together, a small fraction of one percent of the 3,000,000-token daily allowance.

probe.py: six requests, gap per request, slope and intercept
import os, sys
import tiktoken
from openai import OpenAI

client = OpenAI(base_url="https://api.oneaiapikey.com/v1", api_key=os.environ["ONEAIAPIKEY_API_KEY"])
MODEL = sys.argv[1] if len(sys.argv) > 1 else "z-ai-glm-5.3:free"
enc = tiktoken.get_encoding("o200k_base")  # swap in the model's own tokenizer when you have it

BASE = "The gateway checks the key, the balance and the limits, then sends the request on and writes one usage record. "
probes = ["Reply with the single word OK."] + [BASE * r for r in (5, 10, 20, 40, 80)]


def expected(text):
    # one user message: 3 framing + 3 reply primer + the role word + the text
    return 3 + 3 + len(enc.encode("user")) + len(enc.encode(text))


def fit(xs, ys):
    n = len(xs)
    mx, my = sum(xs) / n, sum(ys) / n
    slope = sum((x - mx) * (y - my) for x, y in zip(xs, ys)) / sum((x - mx) ** 2 for x in xs)
    return slope, my - slope * mx


xs, ys = [], []
for text in probes:
    raw = client.chat.completions.with_raw_response.create(
        model=MODEL, max_tokens=8, temperature=0,
        messages=[{"role": "user", "content": text}],
    )
    reply = raw.parse()
    e, b = expected(text), reply.usage.prompt_tokens
    xs.append(e)
    ys.append(b)
    print(f"expected {e:5d}  billed {b:5d}  gap {b - e:+5d}  request id {raw.headers.get('x-request-id')}")

slope, intercept = fit(xs, ys)
print(f"slope {slope:.3f}  (tokens billed per token you counted)")
print(f"intercept {intercept:.1f}  (tokens added to every request)")

Set it up in three steps. Sign in with Google on the sign-up page, create a key under Keys, and put it in an environment variable; the authentication guide covers the key and the quickstart shows a first call. Then install the two libraries with pip install openai tiktoken and run python probe.py.

How to read the output, honestly. The free ids run models from several families, so the local o200k_base count is a baseline for OpenAI-style tokenizers and an approximation for the rest. Do not expect a slope of exactly 1.00. What you can check is that the intercept is small and the slope is steady: a model whose own tokenizer is a little denser than o200k_base gives a slope like 1.05 to 1.2 and an intercept near the template size. To tighten it, load the model’s tokenizer from Hugging Face, apply its chat template, and replace the expected function. If the intercept is in the hundreds, that is a constant worth a question, and the verification guide puts this check next to five others, including identity probes and long-context recall.

Then close the loop on our side. Open the usage page, find the six rows by request id and confirm that the input tokens match what the script printed and that the cost reads $0. That confirms the record copies the figure. It does not confirm the figure, and you now know why.

For the billing half, use a priced id. Send one short request, note its usage, recompute the cost with the calculator above and the rates on the model’s page, and compare the result with the exact cost on the usage page. If you have not added credit, this uses the sign-up credit and nothing else. The pricing page and the prepaid credit guide explain how credit is added later, by email today.

What do you do when the numbers disagree?

Match the pattern to the cause before you contact anyone. Pick the closest case below.

What does your gap look like?

Small constant, same on both probes

A few tokens, equal on the short and the long prompt, is a template or framing difference. Add the documented framing from the table above and it should close. No action needed beyond noting it.

Large constant, same on both probes

A hundred or more tokens on every request, unchanged by prompt length, is added text. Check first whether you attached tools, a system prompt you forgot, or an SDK feature that adds instructions. If you did not, ask the provider to name the added block and its token count in writing. See the reseller risks guide for what to ask, and the privacy policy for what happens to the request itself.

Proportional: slope above 1

First swap in the model's own tokenizer and chat template. Most slopes above 1 are a denser tokenizer. If the slope stays above 1 against the right tokenizer, you have a proportional surplus, and the native-versus-normalized case above is the first thing to rule out: ask which count is billed and which is returned.

Gap grows only on later turns

Check history and caching. Count the whole conversation as sent, including earlier tool results and thinking blocks, and read the cache fields separately. A growing gap with cache reads present usually means you added the cached part twice, or the format excludes it from the input figure.

Only requests with tools or reasoning

Count the tool definitions with the vendor's counting endpoint and add the built-in tool prompt for that model. For reasoning, use the four checks above: details field, effort sensitivity, stability and recomputed cost.

If the pattern survives all of that, write to the provider with evidence: request ids, the model id, your count and method, and the usage figures. That is the useful package whichever service it is, ours included. On this gateway, write to somdutt777@gmail.com with a genuine concern; each case is reviewed one by one, and the transparency page says what we can see.

A checklist you can keep

Tick what you have done. The score is a guide to how far your audit would stand up if someone asked you to show your work.

Token billing audit

0 of 10 done

Not started

Start with the local count and one probe; that alone catches a large constant.

Where does this fit with choosing a gateway?

A token audit is one test among several. A provider that passes it can still serve a different model, go down, or log more than it says, and a provider that fails it may only have an ordinary template. Use the audit alongside the 12-point provider checklist, the verification guide and the live status page, which shows the probes behind our own uptime claims.

If you are comparing us with others, the numbers are public and dated. The fee comparison shows what other gateways add on top of token prices, the gateway comparison sets nine options next to each other, and the post on flat-price plans does the arithmetic on why a flat monthly price needs scrutiny. If you run the proxy yourself, the LiteLLM alternatives guide and the self-hosting comparison put numbers on the effort. If you currently use a log-only layer, the Helicone alternatives post explains how observability tools differ from a gateway. For a team, the cost calculator, the guide to estimating a monthly LLM bill and the glossary of tokens, context windows and caching are the companion reading. If an agent drives your spend, the guide to setting up a coding agent key shows how to scope it, and the cost-control documentation shows per-key limits, so a bug stops at a ceiling.

We would rather you audit us than trust us. The rankings page publishes exact token counts per model from our own logs, the status page shows probes, and the model list shows every rate, so a charge can always be recomputed. What we do not publish is a claim that our counts are the provider’s: they are the provider’s counts, copied. That is the honest scope, and it is the reason the first half of this post exists.

Run the six-request audit on a free model

Sign in with Google, create a key and run probe.py against a free id: 48 free models share 100 requests and 3,000,000 tokens a day, and the $10 sign-up credit pays for a priced check. No card.

Frequently asked questions

Can an LLM API bill more tokens than I sent?
Yes, and most of the time it is legitimate. Every chat message carries framing tokens, tool definitions are counted as input, some providers add their own instructions to tool requests, chat history is sent again on every turn, and reasoning tokens are billed as output even when you never see them. The audit in this post separates those documented additions from a surplus nobody can explain.
How do I count tokens before I send a request?
Use the tokenizer that belongs to the model. For OpenAI-style models that is the open-source tiktoken library; for open-weight models it is the tokenizer and chat template published on the model card, which Hugging Face's apply_chat_template applies. Anthropic offers a free counting endpoint on its own API. Treat every local count as an estimate and add the documented framing.
Why does my count differ from the usage field by a few tokens?
A few tokens per message is normal: control tokens that wrap each message, the role name, and the primer that starts the reply. The OpenAI cookbook itself calls its message-counting function an estimate that may change from model to model. A gap that is the same small constant on a short and a long prompt is almost always a template difference.
Does the gateway re-count my tokens?
No. On One AI API Key the token figures in a usage record are the numbers the model provider reports for the request, and the cost is those tokens times the published rate. That means the record can only confirm that we copied the provider's figures correctly. The independent check is your own tokenizer, which is why this post builds one. The routing documentation lists every field in the record.
Is the token counting endpoint on a gateway a good baseline?
Not on ours. The Anthropic-format count endpoint here is a local estimate of about four characters per token plus four per message, and the reply says so in an X-Count-Method: estimate header. Use it for rough sizing, and use the usage of a real reply or your own tokenizer when you audit a charge.
How do I audit reasoning tokens I cannot see?
You cannot prove them from the outside, and the research says so plainly. You can bound them: read completion_tokens_details.reasoning_tokens when it is present, count the visible answer yourself, and check that completion tokens equal visible plus reasoning. Then repeat the same prompt at a lower reasoning effort, or on a non-reasoning model, and see that the reported number falls. The reasoning documentation shows where the fields appear.
Can I test billing on the free models?
You can test token counts on them, but not balance movement. Free ids bill $0 per token, so your balance never moves, and they share 100 requests and 3,000,000 tokens a day. To watch a balance move, send one request to a priced id with the $10 sign-up credit, recompute the charge by hand, and compare it with the cost on the usage page. The models page shows which priced ids are served today.
What should I send support if I find a gap?
The request ids (from the X-Request-Id header), the model id, your own token count and how you made it, and the usage figures you received. Write to somdutt777@gmail.com with a genuine concern; each case is looked at one by one. The transparency page says what we can and cannot see on our side.
More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
Claim $10 credit →