Skip to main content

AI Token & Cost Calculator

Count exact tokens and calculate real $ cost for GPT, Claude, and Gemini prompts.

Last Updated: July 26, 2026

Prompt & Model

Estimated Cost Exact
$0.000052

Input tokens

21

$0.000052

Output tokens

0

$0.0000

Context window

1,000K

0.00% used

Pricing verified 2026-07-26 directly from official provider docs. Providers change prices often — double-check before relying on this for budgeting. developers.openai.com/api/docs/pricing

What This Calculator Measures

The AI Token & Cost Calculator turns a prompt (and optional completion) into two numbers that actually matter when you're building with an LLM API: how many tokens it uses, and what that costs in dollars, model by model.

How Tokens Work

Language models don't read text character-by-character or word-by-word — they break it into tokens, chunks of text produced by a byte-pair-encoding (BPE) algorithm trained on huge amounts of text. A token is often a whole short word, a word fragment, or a punctuation mark. As a rough rule of thumb, 1 token is about 4 characters or 0.75 words of English text, but this varies a lot by language and content type (code and non-English text often use more tokens per character).

Why Accuracy Differs by Provider

  • OpenAI models (GPT-5.x, GPT-4.1, o-series) all use OpenAI's o200k_base BPE vocabulary. That vocabulary is public, so this calculator runs the exact same tokenizer algorithm entirely in your browser — no network call, no API key, and the count matches what OpenAI's own API would report.
  • Anthropic Claude and Google Gemini don't publish an offline tokenizer. The only way to get an exact count is to call the provider's own token-counting endpoint (Anthropic's /v1/messages/count_tokens, Google's countTokens). If you add your own API key in the calculator, we forward it to that endpoint for a single request (never stored) and show you the real number. Without a key, you'll see a clearly labeled estimate instead.

The Cost Formula

input cost  = (input tokens / 1,000,000)  × input price per million tokens
output cost = (output tokens / 1,000,000) × output price per million tokens
total cost  = input cost + output cost

If a model supports prompt caching and you mark the input as a cache hit, the calculator swaps in the discounted cached-input rate instead of the standard input price.

Worked Example

Say your prompt tokenizes to 1,200 tokens and the model replies with 400 tokens, using a model priced at $2.50 input / $15.00 output per million tokens:

  • Input cost: 1,200 / 1,000,000 × $2.50 = $0.003
  • Output cost: 400 / 1,000,000 × $15.00 = $0.006
  • Total: $0.009 per call

Multiply that by your expected calls per day to see your real daily spend.

Common Mistakes

  • Forgetting output tokens can dominate cost. Output pricing is usually 4-6x higher than input pricing, so a short prompt with a long answer can cost more than a long prompt with a short answer.
  • Assuming all providers tokenize the same way. The same sentence can produce different token counts on GPT vs. Claude vs. Gemini — always price with the actual model's count, not a generic estimate, when the difference matters to your budget.
  • Ignoring system prompts and tool definitions. If you're using function calling or a long system prompt, those tokens count too and should be included in what you paste into the calculator.

Frequently Asked Questions

Frequently Asked Questions

For OpenAI models (GPT-5.x, GPT-4.1, o-series) the count is exact — it runs the same o200k_base tokenizer OpenAI's own API uses, entirely offline. For Claude and Gemini, no public tokenizer exists, so the count is a labeled estimate unless you add your own API key, in which case we call the provider's real token-counting endpoint for an exact number.
No. If you add a key to get an exact Claude or Gemini count, it's used for that one request only and is never logged or saved anywhere.
Each provider sets its own price per million tokens for input and output, and some models charge extra for reasoning or long-context requests. The cost calculator uses each model's real, currently published rate.
Input tokens are what you send (the prompt); output tokens are what the model generates (the completion). Most providers charge more per token for output than input.
Every price shown links back to the provider's official pricing page along with the date it was last verified, so you can always confirm it's current.