DevToolBox免费
博客

AI Token 计数器 — 免费计算 GPT、Claude、Gemini Token

计算 GPT-4、Claude、Gemini、Llama 等 AI 模型的 Token 数量并估算 API 费用。免费在线 LLM 提示词优化 Token 计数器。

0
Token 数
0
字符数
0
单词数
1
行数

各模型费用估算

模型上下文输入费用输出费用
GPT-4o128K$0.000000$0.000000
GPT-4o mini128K$0.000000$0.000000
GPT-4 Turbo128K$0.000000$0.000000
Claude 3.5 Sonnet200K$0.000000$0.000000
Claude 3 Haiku200K$0.000000$0.000000
Claude 3 Opus200K$0.000000$0.000000
Gemini 1.5 Pro1M$0.000000$0.000000
Gemini 1.5 Flash1M$0.000000$0.000000
Llama 3.1 70B128K$0.000000$0.000000
Mistral Large128K$0.000000$0.000000

* Token 数为近似值(英文约 4 个字符一个 Token)。实际分词因模型而异。价格为基于公开 API 定价的估算。

关于 AI Token 计数器

Token 是 AI 语言模型处理文本的基本单位。此工具可估算 GPT-4、Claude、Gemini、Llama 等流行模型的文本 Token 数量,并计算各模型的大致 API 费用。适用于优化提示词、估算 API 成本和控制上下文窗口限制。

𝕏 Twitterin LinkedIn

💬 User Feedback

Have suggestions or found a bug? Leave a message and we'll get back to you.
0/2000

评价此工具

4.5 / 5 · 176 人评价

保持更新

获取每周开发技巧和新工具通知。

无垃圾邮件,随时退订。

Enjoy these free tools?

Buy Me a Coffee

How to Use AI Token Counter

  1. Paste or type your text (prompt, system message, or document) into the input field
  2. View the estimated token count, character count, word count, and line count instantly
  3. Check the cost estimate table to see API pricing across GPT-4, Claude, Gemini, and other models
  4. Optimize your prompt to reduce token usage and lower API costs
  5. Compare input vs output costs to budget your AI API usage

Common Use Cases

  • Estimating API costs before sending prompts to GPT-4, Claude, or Gemini
  • Checking if text fits within a model's context window limit
  • Optimizing prompt length to reduce token usage and save costs
  • Comparing token counts across different AI models for cost efficiency
  • Budgeting AI API expenses for production applications

Frequently Asked Questions

What are tokens in AI language models?
Tokens are the basic units that LLMs use to process text. A token can be a word, part of a word, or a punctuation mark. In English, one token is roughly 4 characters or 0.75 words. For example, 'chatbot' is one token, while 'understanding' might be split into 'under' + 'standing'.
How many tokens can GPT-4 and Claude handle?
GPT-4o supports up to 128K tokens context window. Claude 3.5 Sonnet supports 200K tokens. GPT-4 Turbo supports 128K tokens. These limits include both input (prompt) and output (response) tokens combined.
How are AI API costs calculated based on tokens?
AI APIs charge per token, usually priced per 1 million tokens. Input tokens (your prompt) and output tokens (the response) are priced differently, with output tokens typically costing 3-5x more. This tool shows both input and output costs for each model.
Is the token count exact for all models?
The count is an approximation based on the average of ~4 characters per token for English text. Each model uses its own tokenizer (GPT uses tiktoken, Claude uses its own BPE tokenizer), so exact counts may vary slightly. The estimate is accurate enough for cost planning.
How can I reduce token usage to lower API costs?
Remove unnecessary whitespace and verbose instructions. Use concise prompts. Avoid repeating context. Use system messages efficiently. Consider shorter model responses by setting max_tokens. For large documents, use chunking or summarization before sending to the API.
Do different languages use different amounts of tokens?
Yes. English is the most token-efficient language for most LLMs. Chinese, Japanese, Korean, and other non-Latin languages typically require 2-3x more tokens per word because the tokenizers were primarily trained on English text. This significantly affects API costs for non-English use.
What is a context window in AI models?
The context window is the maximum number of tokens an AI model can process in a single request, including both the input prompt and the generated output. If your text exceeds the context window, it will be truncated or the API will return an error.
Does this tool send my text to any AI service?
No. Token counting is performed entirely in your browser using a local approximation algorithm. Your text is never sent to OpenAI, Anthropic, Google, or any other service.