跳到正文
北京时间
原文
TensorZero:实验与工程博客·· 2026-04-16精选AI 评分67

TensorZero:别只比每百万 token 单价,LLM API 的隐性成本差距可达 5.3 倍

Stop comparing price per million tokens: the hidden LLM API costs

AI 导读

TensorZero 测量发现同一输入在不同厂商的 token 计数相差可达 2.65 倍,按每百万 token 单价比较 LLM API 成本会产生误导。

推荐理由

作者用各家官方 token 计数 API 实测同一输入的成本差异,给出可复用的比价方法,提醒只看每百万 token 单价会误判。

正文
  • Token pricing is misleading: the same input produces 2.65x+ more tokens depending on the model. We got wildly different token counts from identical content using OpenAI, Anthropic, and Google’s official token counting APIs.

  • Token efficiency varies by content type. Text, JSON, YAML, and tool definitions all tokenize differently. The cheapest provider changes depending on what you’re sending. The only way to know what you’re actually paying is to measure it.

  • OpenAI has the most efficient tokenizer. On tool-heavy workloads, claude-opus-4-7 costs 5.3x more than gpt-5.4 despite list prices being only 2x apart.

Most engineers know they need to evaluate models on their specific task because performance varies. But so does cost: the same input can cost several times more on one provider than another, even when their list prices look similar.

The typical metric for comparing LLM API costs is price per million tokens ($/MTok). Here’s what the major providers charge today:

Model$/MTok (input)
gemini-3.1-pro-preview$2.00
gpt-5.4$2.50
claude-sonnet-4-6$3.00
claude-opus-4-6$5.00
claude-opus-4-7$5.00

But not all tokens are equal! Different providers use different tokenizers, so the same input produces wildly different token counts.

What is a tokenizer?

A tokenizer splits text into smaller units (tokens) that the LLM processes. Different tokenizers split the same text differently, producing different token counts.

For example, gpt-5.4 uses the tokenization below:

We sent identical inputs through each provider’s official token counting API and normalized against OpenAI’s:

Grouped bar chart showing token counts normalized to OpenAI across content types
ModelTextYAMLJSONTools
gpt-5.41.00x1.00x1.00x1.00x
gemini-3.1-pro-preview1.06x1.18x1.11x1.82x
claude-sonnet-4-61.17x1.25x1.22x2.06x
claude-opus-4-61.17x1.25x1.22x2.06x
claude-opus-4-71.57x1.53x1.70x2.65x

Details about the input data

We used the following input data for this experiment:

TypeSource
TextThe Iliad
JSON & YAMLCloudflare’s OpenAI Spec (trimmed to 2 million characters)
Tools100 synthetically generated tools (name, description, schema)

Multiplying list price by tokenizer efficiency gives you what you actually pay to process the same input.

Grouped bar chart showing effective price per million input tokens adjusted for tokenizer differences
ModelTextYAMLJSONTools
gpt-5.4$2.50
(1.00x)
$2.50
(1.00x)
$2.50
(1.00x)
$2.50
(1.00x)
gemini-3.1-pro-preview$2.12
(0.85x)
$2.36
(0.94x)
$2.22
(0.89x)
$3.64
(1.46x)
claude-sonnet-4-6$3.51
(1.40x)
$3.75
(1.50x)
$3.66
(1.46x)
$6.18
(2.47x)
claude-opus-4-6$5.85
(2.34x)
$6.25
(2.50x)
$6.10
(2.44x)
$10.30
(4.12x)
claude-opus-4-7$7.85
(3.14x)
$7.65
(3.06x)
$8.50
(3.40x)
$13.25
(5.30x)

The differences are dramatic. On tool-heavy workloads, claude-opus-4-7 costs 5.3x more than gpt-5.4 even though their list prices are only 2x apart. The rankings also flip depending on what you’re sending: Gemini is the cheapest option for text and structured data, but becomes 46% more expensive than OpenAI on tool definitions.

This analysis only considers base input token prices. In practice, cost comparisons get even more complex when you factor in prompt caching discounts, long-context pricing tiers, output tokens, and thinking tokens.

When choosing the right model for your task, you should compare both performance and cost in a real setting. A model that looks cheaper on paper might cost several times more once you account for how it counts tokens.


The only way to know what you’re actually paying is to measure it.

Our 11.5Kopen-source LLM gateway tracks real-world token usage and cost across providers. You can configure multiple variants and track usage and costs side by side.

来源:TensorZero:实验与工程博客 · tensorzero.com