LLM Token Counter & API Cost Calculator with Prompt Caching
Count prompt tokens locally, check context limits, and compare cache-aware monthly API bills across OpenAI, Claude, Gemini, DeepSeek and Llama.
Reviewed·$0 · No login
TL;DR
Sogoh’s calculator counts prompt tokens locally with OpenAI’s o200k_base tokenizer (exact for text using that GPT encoding, including the GPT-4o/GPT-5 family) and prices 14 models across OpenAI, Anthropic, Google, DeepSeek and Meta with provider-specific cache rules. At 10,000 input + 500 output tokens, 1,000 requests/day, 90% cacheable at a 90% hit rate, GPT-6.1 Terra falls from $375 to $150.90 a month — 59.8% saved; Claude Sonnet 5.5 falls from $750 to $301.80. Claude, Gemini, DeepSeek and Llama token counts are labelled estimates because their tokenizers are not public.
Exact tokens · context limits · cache-aware bills
1. Paste your prompt
Drop a text file here, or use the upload button. File contents are inserted as-is.
Runs entirely in your browser. Your prompt is never uploaded, logged, or sent to a model.
Exact · o200k_base
Exact for OpenAI text using the selected encoding. Claude, Gemini, DeepSeek and Llama tokenize differently, so their table rows are marked as estimates. Counts cover the pasted text; chat APIs add a few structural tokens per message.
Cache hit 1,701 · miss 425 · uncached 532 tokens per request.
Your bill for this model
GPT-6.1 Terra · 1.05M Context · Pass
3. Compare every model
Sorted by cached monthly cost by default. “No cache → cached” pairs show the same request before and after prompt caching. Claude, Gemini, DeepSeek and Llama token counts are proxies; costs use the same token count.
Model comparison with context window, token prices, cache prices, per-request cost, monthly cost and savings
Model
Context
Input $/1M
Output $/1M
Cache read / write $/1M
Cost / request
Monthly (30d)
Savings
Context status
DeepSeek V4.1 FlashDeepSeekest.
1.05M
$0.051
$0.567
$0.018 / $0.051
$0.00042$0.00036
$12.57$10.89
+$1.68 (13.4%)
Pass
GPT-6 LunaOpenAI
1.05M
$0.10
$0.50
$0.01 / $0.125
$0.00052$0.00037
$15.47$11.20
+$4.27 (27.6%)
Pass
Claude Haiku 5.5Anthropicest.
1.00M
$0.10
$0.50
$0.01 / $0.125
$0.00052$0.00037
$15.47$11.20
+$4.27 (27.6%)
Pass
DeepSeek V3.2DeepSeekest.
164K
$0.26
$0.38
$0.13 / $0.26
$0.00088$0.00066
$26.43$19.80
+$6.63 (25.1%)
Pass
DeepSeek V4 ProDeepSeekest.
1.05M
$0.82317
$1.5393
$0.20 / $0.82317
$0.00296$0.00190
$88.73$56.93
+$31.80 (35.8%)
Pass
Llama 3.3 70B InstructMetaest.
131K
$0.59
$0.79
—
$0.00196$0.00196
$58.90$58.90
Cache not supported
Pass
GPT-6.1 TerraOpenAI
1.05M
$1.00
$5.00
$0.05 / $1.25
$0.00516$0.00365
$154.74$109.45
+$45.29 (29.3%)
Pass
Gemini 4 HydrogenGoogleest.
1.05M
$1.50
$7.50
$0.075 / $1.50
$0.00774$0.00531
$232.11$159.39
+$72.72 (31.3%)
Pass
Gemini 4 CarbonGoogleest.
1.05M
$2.00
$10.00
$0.10 / $2.00
$0.01032$0.00708
$309.48$212.52
+$96.96 (31.3%)
Pass
GPT-6.2 SolOpenAI
1.05M
$2.00
$10.00
$0.10 / $2.50
$0.01032$0.00730
$309.48$218.90
+$90.58 (29.3%)
Pass
Claude Sonnet 5.5Anthropicest.
1.00M
$2.00
$10.00
$0.10 / $2.50
$0.01032$0.00730
$309.48$218.90
+$90.58 (29.3%)
Pass
Gemini 4 NeonGoogleest.
1.05M
$3.00
$15.00
$0.15 / $3.00
$0.01547$0.01063
$464.22$318.77
+$145.45 (31.3%)
Pass
Claude Opus 5.5Anthropicest.
1.00M
$4.00
$20.00
$0.20 / $5.00
$0.02063$0.01459
$618.96$437.79
+$181.17 (29.3%)
Pass
GPT-6.2 AstraOpenAI
1.05M
$8.00
$40.00
$0.40 / $10.00
$0.04126$0.02919
$1,237.92$875.58
+$362.34 (29.3%)
Pass
How we calculate this
Every number is reproducible from these formulas and the prices below.
Uncached input
prompt × (1 − cacheable%)
Cache hit
prompt × cacheable% × hit%
Cache miss
prompt × cacheable% × (1 − hit%)
Input cost
(uncached × input + hit × cache read + miss × cache write) ÷ 1,000,000
Output cost
output × output price ÷ 1,000,000
Monthly bill
(input + output) × requests/day × 30
Savings
monthly without cache − monthly with cache
GPT-6.1 Terra at your inputs: input $0.00115 + output $0.00250 = $0.00365 per request; $109.45/month with caching.
Cache misses are billed at the provider’s cache-write price in every request. Real explicit caches write once per prefix per TTL, so this is conservative for stable prompts. Below the provider’s minimum cache size, caching is ignored. Taxes, batch discounts, long-context surcharges, tool fees, retries, explicit cache storage and DeepSeek peak/off-peak rates are excluded.
Share
Email updates
Told when this page’s prices change
The formula stays the same. Prices do not. When a plan changes, one short email with the difference.
✓Email updates
Check your inbox to confirm
We sent a confirmation email to . Click or open the link in the email and your subscription is active.
This email is already confirmed, so there is no need to confirm again.
OpenAI text uses o200k_base (GPT-4o/GPT-5 family and the o-series; GPT-6 rows assume the same GPT encoding) or cl100k_base for older GPT-4/GPT-3.5 models. Both run locally with gpt-tokenizer. Claude, Gemini, DeepSeek and Llama use different, non-public tokenizers, so the tool reuses the OpenAI count as a labelled proxy instead of pretending it is exact.
02
Check the window with output included
A request needs room for the input and the reserved output. The status compares prompt tokens + expected output tokens with the model window: green below 80%, amber from 80%, red above 100%. Leave extra headroom for tool results, RAG passages and the few structural tokens chat APIs add per message.
03
Model a real month, not one call
Enter output tokens per request, requests per day, the share of input that is stable enough to cache, and the expected hit rate. Monthly totals are × 30 days. Cacheable input is usually the system prompt, RAG documents or few-shot examples; the user’s fresh message is not cacheable.
04
Read the cache rules, not just the discount
Anthropic bills cache writes at 1.25× input and reads at 0.1× (5-minute TTL). OpenAI and DeepSeek use automatic caching with read discounts; Gemini uses implicit caching. Every miss is billed at the provider’s write price in this model, so a low hit rate can make caching more expensive. Below the provider minimum cache size, caching is ignored.
FAQ
Is the token count exact?
Exact for OpenAI text under the selected encoding: o200k_base for the GPT-4o/GPT-5 family and o-series, cl100k_base for older GPT-4/GPT-3.5. GPT-6 rows assume OpenAI keeps the GPT/o200k encoding; if a model ships a new tokenizer, use the provider count endpoint. Claude, Gemini, DeepSeek and Llama do not publish compatible local tokenizers, so their rows are estimates based on the OpenAI count. The count covers the pasted text; chat APIs add a few structural tokens per message.
How does prompt caching change the bill?
Cacheable input is split into hits and misses by your hit rate. Hits are billed at the cache-read price; misses at the provider’s cache-write price; the rest of the input at the normal input price. Anthropic’s 5-minute cache writes at 1.25× and reads at 0.1×; OpenAI and DeepSeek use automatic caching with read discounts; Gemini uses implicit caching. At a low hit rate, write premiums can make caching cost more, and the badge turns red instead of hiding it.
Why is my invoice different from this estimate?
This is a list-price planning model. Taxes, batch discounts, long-context surcharges, tool-call fees, retries, explicit cache storage, negotiated rates and DeepSeek peak/off-peak pricing are excluded. It also assumes a 30-day month and charges every cache miss at the write price, which is conservative for a stable prefix that is written once. Check the provider’s invoice line items before treating the number as a budget.
What counts as cacheable input?
Stable text that repeats across requests: the system prompt, policy documents, RAG passages, tool schemas and few-shot examples. Do not count the user’s fresh message, timestamps, order numbers or anything that changes per request. Providers also enforce a minimum cache size (often 1,024–2,048 tokens); below it, caching is not applied.
Is my prompt uploaded or logged?
No. Tokenization and every calculation run in your browser. The tokenizer library is served from this site and loads on demand; no prompt text is sent to Sogoh, an LLM provider or an analytics service. Shared links contain only the model and billing settings, never the prompt.
Is there a Python package or VS Code extension?
This is a browser tool, not an extension. For scripts, use OpenAI’s tiktoken in Python or gpt-tokenizer on npm; both implement the same OpenAI encodings. For editor-side counts, use an extension that wraps one of those encodings, and keep the same caveat: Claude, Gemini and other providers may tokenize differently.
Essential storage keeps the site working. Optional analytics is on by default outside the EEA, UK and Switzerland; here you choose. If you decline or ignore this banner, analytics runs without cookies and without identifying you.Read our privacy policy