Token 计数器:写提示词前先算笔账
大模型 API 按 token 计费,而"token 是什么、一句中文算几个 token"没有直觉答案。这个计数器用按字符类型加权估算的算法(ASCII 字符、空格、符号、中日韩字符分别计权),给出与主流模型接近的 token 数,并按模型单价直接估算调用费用。
支持什么
- 模型单价:内置 GPT-4o、Claude 3.5、DeepSeek、Gemini 等主流模型的输入/输出价格。
- 双向估算:既可以数单段文本,也可以估算完整 prompt + 上下文的总量。
- 费用试算:输入、输出各按多少字估算,直接算出一次调用的成本。
为什么要用它
把一段提示词从 2000 token 压到 800 token,不只是省钱——上下文更短的请求响应更快。写 prompt 之前先数一数,是本地跑模型和调 API 都适用的好习惯。
Token Counter: count before you prompt
LLM APIs bill by token, and "what is a token, how many does my Chinese sentence use" has no intuitive answer. This counter uses a weighted estimate by character type (ASCII, whitespace, punctuation, CJK) to approximate real tokenizers, then estimates API cost directly using model pricing.
What's included
- Model pricing: built-in input/output prices for GPT-4o, Claude 3.5, DeepSeek, Gemini and more.
- Two-way estimate: count a single text or estimate a full prompt + context.
- Cost trial: set estimated input/output sizes and see a call's cost immediately.
Why it helps
Slimming a prompt from 2000 to 800 tokens saves money and makes the request faster. Counting before you prompt is a good habit whether you run local models or call APIs.