Token 计算器
估算文本 token 数量,对比多模型 API 调用成本
估算文本 token 数量,对比多模型 API 调用成本
在大语言模型(LLM)中,Token 是模型处理文本的最小单位。它不是一个字符,也不是一个单词,而是模型词汇表中的独立单元。例如,“ChatGPT”可能被拆分为 “Chat”、“G”、“PT” 三个 token。API 计费、上下文窗口限制全部以 token 数量为基准。
精确估算 token 数量有助于:
本工具根据字符数和语言比例进行近似估算。经验公式:
示例: 输入一段包含 200 个英文单词(约 1000 个字符)的文本。在 GPT‑4 中,英文系数为 3.5,估算 token ≈ 1000 ÷ 3.5 ≈ 286 tokens。同样的中文内容,由于中文系数为 1.8,估算 token ≈ 1000 ÷ 1.8 ≈ 556 tokens。这就是为什么中文提示词通常消耗更多 token。
我们的估算基于公开文档,误差通常在 5‑15% 以内。精确计数请使用官方 tokenizer(如 tiktoken)。
不能,但误差通常在 5‑15% 以内。精确计算需使用各模型的官方 tokenizer(如 OpenAI 的 tiktoken 或在线 playground)。本工具提供快速估算,适合开发早期评估成本。
中文字符在语境中的 token 占比更高,一个汉字通常对应 1.5‑2 个 token。我们已经按各模型的中文特性调整了系数。
输入文本后,费用会根据预设的输入价格($0.01/1K tokens)自动计算。你也可以根据实际 API 定价自行调整心理预期。
使用更简洁的提示词、用英文提问(比中文省约30% token)、限制输出长度(max_tokens)、善用系统提示减少纠正次数。
Estimate token count & API costs for popular LLMs
In large language models, a token is the basic unit the model processes. It can be a word, a subword, or a punctuation mark, depending on the tokenizer. API costs, context limits, and response latency all depend on token counts.
Our calculator uses a coefficient method: Tokens ≈ Total Characters ÷ Characters per Token. The coefficient varies by model and language.
Example: 1,000 English characters → GPT‑4 token count ≈ 1000 ÷ 3.5 ≈ 286 tokens. The same text in Chinese would use more tokens due to a lower coefficient (1.8).
Precision is within 5‑15%. For exact figures, use official tokenizers.
No, tokenization depends on the specific model. For precise counts, use official tools like tiktoken or the model's playground. Our estimates are accurate within 5‑15% for most use cases.
Chinese characters consume more tokens per character than English. We apply a model‑specific coefficient to account for this.
It calculates once you enter text. The cost multiplies estimated tokens by a default input price ($0.01/1K tokens). Adjust mentally based on your actual API tier.
Write concise prompts, prefer English over Chinese when possible, set a reasonable max_tokens, and use system messages to reduce corrections.