Auditing Pay-Per-Token in Large Language Models

Ander Artola Velasco, Stratis Tsirtsis, Manuel Gomez Rodriguez

TL;DR

Cloud large language model (LLM) providers have a hidden financial incentive to overcharge users by exploiting the fact that text can be split into tokens in multiple ways. This paper introduces a martingale-based sequential auditing framework that can catch cheating providers in under 70 queries while guaranteeing a near-zero false-alarm rate for honest ones.

What Problem Does This Paper Address?

When you use a cloud-based LLM API (like OpenAI or Google Gemini), you are charged based on a de facto standard: a fixed price per token. However, the tokenization of a text string is rarely unique. For example, the phrase "Tangier, Morocco" could be tokenized efficiently into 4 tokens (|Tang|ier|,| Morocco|) or inefficiently into 7 tokens (|Tang|ier|,| |Mor|oc|co|). Both resolve to the exact same text output.

Because of this quirk, an asymmetric information problem arises. The provider observes the entire generation process, but the user only sees the final text string and the bill. This creates a "moral hazard" where a self-serving provider can intentionally report a less efficient tokenization to overcharge the user without changing a single character of the output. This paper introduces the first statistical auditing framework designed to detect this type of token misreporting.

Methods

The authors frame the audit as a sequential hypothesis test where a trusted third-party auditor sequentially queries a provider and aggregates statistical evidence over time.

The framework relies on two key innovations:

  1. Unbiased Length Estimator (EstimateLength): To know if a provider is cheating, the auditor needs to know the expected token length for a given output string under the true model distribution. The authors design a modified autoregressive process that masks out any tokens that deviate from the target string. They then apply importance sampling weights to mathematically debias this process, yielding an exact, unbiased estimate of the model's average token sequence length for that string.
  2. Martingale-Based Testing: The auditor tracks a test process, $M_i$, which multiplies over time based on the evidence gathered. If the provider is honest, $M_i$ is a mathematical martingale—it stays flat on average and is theoretically barred from crossing a safety threshold ($1/\alpha$) with high probability. If the provider is inflating token counts, $M_i$ grows exponentially, triggering an alert. This allows for "anytime-valid" inference, meaning the auditor can stop the test at any moment without inflating false positives.

Datasets

The framework was evaluated using:

  • LMSYS Chatbot Arena Platform Dataset (LMSYS-Chat-1M): A crowdsourced benchmark from which the authors sampled 4,000 English user prompts (filtered to 20–100 characters to avoid trivial or overly long inputs).
  • Models: The framework was tested across several open-weight model families, including Llama-3.2-1B-Instruct, Gemma-3-1B-It, and Ministral-8B-Instruct-2410, alongside their quantized counterparts (FP8, GGUF) to test robustness.

Key Insights and Ideas

  • Invisible Cheating: Unlike model substitution (where a provider secretly serves a cheaper, worse model), token misreporting leaves the text quality completely intact. Traditional behavioral evaluations cannot catch it.
  • Anytime-Valid Auditing: Traditional statistical tests require fixing the sample size in advance. By using martingale theory, the auditor can continuously monitor the provider. Honest providers are safe indefinitely, while cheaters are caught rapidly.
  • Historical Auditing: Because the test only requires the prompt and the reported token sequence, an auditor can run this test completely offline using historical billing logs saved by suspicious users.

Key Results

  • Zero False Alarms: When auditing faithful providers, the test process $M$ remains flat and never crosses the threshold, demonstrating that the probability of falsely accusing an honest provider is negligible in practice.
Auditing faithful providers across different LLM families.
  • Rapid Detection: If a provider uses a misreporting policy (either randomly splitting tokens or using a clever heuristic to pick plausible-looking alternative tokenizations), the framework successfully flags them in fewer than 70 queries.
  • Robustness to Quantization: In real-world scenarios, an auditor might only have access to a full-precision model, while the provider runs a quantized version (like FP8) to save compute. The experiments show that the framework is highly robust to these slight distribution shifts and does not trigger false positives.

Limitations and Future Work

  • White-Box Model Access: The framework's strong guarantees require the auditor to have access to the model's next-token probability distributions. While this aligns perfectly with forward-looking regulations like the EU AI Act (which mandates source-code and model access for compliance auditors), it is too restrictive for an individual end-user.
  • Future Directions: The authors note that a crucial next step is developing auditing tools that require weaker forms of access, such as relying solely on the model's tokenizer rather than its full probability distributions.

Summary updated

BibTeX
@inproceedings{velasco2026auditing,
  author = {Ander Artola Velasco and Stratis Tsirtsis and Manuel Gomez Rodriguez},
  title = {{Auditing Pay-Per-Token in Large Language Models}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2026},
  url = {https://openreview.net/forum?id=6lboj007YA},
}
Figure