Shipping an AI app or agent? Security review in 1 working day: $149 / ₹13,900. Request a review →
AI Review Ready
Home / Free tools / Token counter and AI cost calculator
Free tool · runs in your browser

Token counter + API cost calculator

Estimate how many tokens a text is, then what a request costs on Claude or OpenAI models at published prices. Runs in your browser.

Cost per request

This is an estimate, not an exact count

Every model family has its own tokenizer, so the same text is a different number of tokens on different models. This page uses OpenAI's published rule of thumb for English: 1 token ≈ 4 characters ≈ ¾ of a word, so 100 tokens is about 75 words. Code, numbers, and languages other than English usually take more tokens per character.

For Claude, Anthropic says Claude 4.7 and later models use a newer tokenizer that produces about 30% more tokens for the same text than earlier Claude models. If you are moving from an older Claude model, recount rather than reusing old numbers.

Exact counts

  • Claude: the /v1/messages/count_tokens endpoint counts a request for the model you name. Anthropic's docs say it is free to use (with its own rate limits) and the result is itself an estimate that can differ slightly from billed usage.
  • OpenAI: the Tokenizer page, or the tiktoken library with tiktoken.encoding_for_model(model).
  • After the fact: every API response reports the real input and output tokens in its usage field. That is what you are billed for.

Which tokenizer does each model use?

  • OpenAI: tiktoken maps GPT-4o, GPT-4.1, GPT-5, o1, o3 and o4-mini to o200k_base, and GPT-4 and GPT-3.5 Turbo to cl100k_base.
  • Claude: Anthropic's token counting "counts under the tokenizer of the model you pass", so count against the exact model you will call.

What the cost calculator leaves out

  • Prompt caching: cached input is much cheaper (see the Claude and OpenAI price tables).
  • Batch processing: Anthropic's Batch API is 50% off input and output; OpenAI lists separate, lower Batch prices.
  • Thinking / reasoning tokens: billed as output tokens, and they don't appear in the visible answer, so real output is often larger than the reply you see.
  • Tools: web search and other tool calls cost extra; tool definitions add input tokens.

Prices checked on 29 Nov 2026 on the official pages: Claude API docs: Pricing · OpenAI API docs: Pricing. Prices change; the official page always wins. All prices in US dollars, before tax.

Related: Claude Code pricing · Claude API pricing · OpenAI API pricing · token counter + cost calculator · Ollama models · is Claude down? · is ChatGPT down?

Sources