Token 计数器工具界面截图

最近帮朋友看 API 账单,他一脸疑惑:明明只问了几十个问题,怎么按"百万 tokens"计的费用看着不太对?聊下来发现,他连 token 是什么都说不清楚。这其实是很多人用 AI 的盲区——计费单位都搞不明白,谈何控制成本。这篇就把 token 这件事一次讲透,最后教你怎么免费实测。

Token 不是字,也不是词

大模型并不直接阅读文字。你输入一段话之后,模型先把它切成一小段一小段的单元,每个单元叫一个 token。切分动作由分词器(Tokenizer)完成,常见的算法是 BPE(Byte Pair Encoding,字节对编码)。

一个 token 大概是 3~4 个英文字母,可能是一个完整单词,也可能只是单词的一半。比如:

文本切分方式Token 数
hellohello1
unhappinessun / happi / ness3
TokenizerToken / izer2
人工智能人工 / 智能约 2

经验规律:1000 个英文单词 ≈ 1300 个 token;1 个汉字 ≈ 0.6~0.7 个 token(不同分词器差异不小)。这也是为什么同样的内容,中文处理起来通常比英文更"占额度"。

为什么 token 决定了你花多少钱

主流大模型 API 的定价都是"元(或美元)/ 每百万 tokens"。以输入价格为例,差距可以非常大:

  • 便宜的小模型:0.3~1 元 / 百万 tokens
  • 主流旗舰:2~20 元 / 百万 tokens
  • 顶级推理旗舰:几十元 / 百万 tokens 也不罕见

同样的 1 万字提示词,喂给不同价位的模型,成本直接差出一个数量级。而且输入和输出分开计价,输出通常贵 2~4 倍——因为生成每个 token 都是一次完整的计算。

除了计费,token 还决定了另外两件事:

  • 上下文窗口:模型一次能"记住"的内容上限,比如 128K tokens ≈ 一本 10 万字的书
  • max_tokens:单次回复的最大生成长度,设置太小回复会被截断

动手实测:一个免费的小工具

与其背公式,不如直接量。我做了个 Token 计数器,把文本粘进去就出结果,还能按 GPT-4o、Claude 3.5、DeepSeek 等模型的单价直接估算费用:

Token 计数器:粘贴文本实时统计 tokens、字符与估算费用
粘贴文本,实时统计 tokens / 字符 / 词数,按模型单价估算费用

工具按字符类型加权估算(ASCII 约 0.22 token/字符、空格 0.33、汉字 0.55、符号 0.75),和官方分词器的结果会有几个百分点的出入,做预算完全够用。所有计算都在浏览器本地完成,文本不会上传。

三个省 token 的实用建议

  • 能用上下文缓存就用:Agent 场景里系统提示词每轮重复,各家缓存命中价比原价便宜 80%~95%,缓存命中率 90% 时总花费能砍一半以上(我在另一篇里专门算过这笔账)。
  • 提示词瘦身:把冗长的示例、重复的指令清一清,输入少 30%,费用直接少 30%。
  • 分层用模型:草稿、翻译、摘要这类活交给便宜模型,只在关键步骤用旗舰。价格差 10 倍以上的模型,能力差距往往没有 10 倍。

小结

Token 是大模型世界的"度量衡":计费按它、上下文按它、生成速度也按它(tokens/s)。理解了它,你看账单、选模型、写提示词都会心里有数。想体验"一个字一个字往外蹦"的生成过程,可以玩玩我们的 Token 流式模拟器,或者看看那篇流式输出原理

免责声明:文中价格与 token 估算基于 2026 年 8 月的公开资料整理,各厂商调价频繁,实际以官方页面为准。

API bills confuse a lot of people: "I only asked a few dozen questions — why is the bill measured in millions of tokens?" If you don't understand the unit you're paying for, you can't control the cost. This post explains tokens once and for all.

A token is neither a character nor a word

LLMs don't read raw text. Your input is first split into small units called tokens by a tokenizer (commonly BPE — Byte Pair Encoding). A token is roughly 3–4 English letters, sometimes a whole word, sometimes half of one:

TextSplitTokens
hellohello1
unhappinessun / happi / ness3
TokenizerToken / izer2

Rules of thumb: 1,000 English words ≈ 1,300 tokens; one Chinese character ≈ 0.6–0.7 tokens. The exact ratio varies by tokenizer.

Why tokens decide your bill

API pricing is quoted per million tokens, and the spread is huge: small models cost under $0.15/M, flagship models $2–3/M, top reasoning models even more. Input and output are priced separately — output typically costs 2–4× more because generating each token is a full forward pass.

Tokens also define two other things:

  • Context window: how much the model can "hold" at once (128K tokens ≈ a short book)
  • max_tokens: the cap on a single response; too small and replies get cut off

Measure it yourself

Instead of memorizing formulas, just measure. Our free Token Counter gives you token counts live and estimates costs using per-model prices. It weights characters by type (ASCII ~0.22 tokens each, spaces 0.33, CJK 0.55, symbols 0.75) — a few percent off official tokenizers, fine for budgeting. Everything runs in your browser; nothing is uploaded.

Three practical ways to save tokens

  • Use context caching: system prompts repeat every turn in agent workloads; cached input costs 80–95% less.
  • Slim your prompts: cut redundant examples and instructions — 30% fewer input tokens is 30% off the bill.
  • Route by task: give drafts and summaries to cheap models; save flagships for the hard steps. A 10× price gap rarely means a 10× capability gap.

Wrap-up

Tokens are the unit of measure for the LLM world: billing, context and generation speed (tokens/s) are all counted in them. Once you get tokens, bills and model choices make sense. To see token streaming in action, try the Token Stream Simulator or read how streaming works.

Disclaimer: prices and estimates reflect August 2026 public information; vendors reprice frequently — always check official pages.
返回文章列表