LLM Token Counter & API Cost Calculator
Count tokens for GPT-5, GPT-4o, Claude and Gemini prompts, see the cost per request at current list prices and check how much of the context window you are using. OpenAI counts are exact (o200k_base / cl100k_base); Claude and Gemini are clearly labelled estimates. Nothing you paste leaves the browser.
Token Counter Workspace
Paste a prompt, pick a model and set the expected output length. The tokenizer table (≈1 MB) is downloaded once on first use.
560 of 400,000 context tokens (prompt + reply)
| Model | Tokens | $/1M in | $/1M out | Per req |
|---|---|---|---|---|
| 60 | $0.005075 | |||
| 60 | $0.001015 | |||
| 60 | $0.000203 | |||
| 60 | $0.00515 | |||
| 60 | $0.000309 | |||
| 63 | $0.000782 | |||
| 67 | $0.007701 | |||
| 67 | $0.005134 | |||
| 67 | $0.0385 | |||
| 63 | $0.005079 | |||
| 63 | $0.001269 | |||
| 63 | $0.000206 |
Why Builders Use the Agenvix LLM Token Counter
Budget prompts before they hit production.
Exact Where It Can Be
OpenAI publishes its tokenizers, so GPT-5, GPT-4o and GPT-3.5 counts match the API exactly. Other vendors do not publish theirs; those rows are marked as estimates with the calibration factor shown.
Real Cost Math
Input tokens × input price plus your expected output tokens × output price, per request and per 1,000 requests, for every model side by side.
Prices You Can Edit
List prices change and enterprise contracts differ. Edit any price inline and the comparison table updates - nothing is hard-wired.
Prompts Never Leave
System prompts and RAG context often contain customer data. Tokenisation runs locally in JavaScript; no request is made with your text.
Simple as 1-2-3
How the Counter Works
Byte-pair encoding in your browser.
Paste Your Prompt
System prompt, few-shot examples, retrieved documents - paste everything the model will read.
Tokenise Locally
The matching BPE vocabulary (o200k_base for GPT-5/4o, cl100k_base for older models and as the reference for estimates) splits the text into tokens.
Read the Budget
Token count, context-window usage, cost per request and the coloured token map update instantly.
Model Families & How They Are Counted
Accuracy you can expect per vendor.
| Feature / Specification | Best Use Case | Engine / Output Standard | Privacy & Security | Performance Rating | Action |
|---|---|---|---|---|---|
| GPT-5, GPT-5 mini/nano, GPT-4o | OpenAI Responses & Chat APIs | o200k_base (exact) | 200k vocabulary | Exact | |
| GPT-4 Turbo, GPT-3.5, embeddings v3 | Legacy OpenAI models | cl100k_base (exact) | 100k vocabulary | Exact | |
| Claude Sonnet / Opus / Haiku | Anthropic Messages API | cl100k × 1.07 (estimate) | Use count_tokens API for billing | ≈ ±10% | |
| Gemini 2.5 Pro / Flash | Google AI Studio / Vertex | cl100k × 1.0 (estimate) | Use countTokens for billing | ≈ ±10% | |
| Images, audio, tool schemas | Multimodal prompts | Not counted here | Vendor-specific rules | Out of scope |
Tokens, Context Windows and API Costs
1. What a token actually is
Language models do not read characters or words; they read tokens produced by a byte-pair-encoding (BPE) vocabulary. Common English words are usually one token, rarer words split into pieces (" Summ" + "ar" + "ize"), and code, JSON, non-Latin scripts and emoji cost more tokens per character. The rough rule "1 token ≈ 4 characters of English" is only an average - this tool shows the real split for the vocabulary your model uses.
2. Why Claude and Gemini are estimates
OpenAI open-sourced its tokenizers (tiktoken), so o200k_base and cl100k_base counts here are identical to what the API bills. Anthropic and Google have not published theirs; the only exact source is their count_tokens / countTokens endpoints, which need an API key and a server.
For those vendors this page applies a calibration factor to the cl100k_base count. Published community measurements range from about 1.05 to 1.35 for different Claude generations and 0.95 to 1.05 for Gemini, so treat the figures as planning numbers (typically within ±10% for English prose, less reliable for code and CJK text) and confirm with the vendor API before billing decisions.
3. Turning tokens into dollars
Cost = input tokens × input price + output tokens × output price, with prices quoted per million tokens. Output tokens are usually 4-8× more expensive than input, so a short prompt that triggers a long answer can cost more than a long prompt with a short answer. Cached-input discounts, batch APIs and long-context surcharges (for example Gemini 2.5 Pro above 200K tokens) are not modelled here - edit the prices if your tier differs.
4. Practical ways to cut token spend
Trim boilerplate from system prompts, move stable instructions into cached prefixes, send only the retrieved passages that matter, prefer compact JSON keys in tool schemas, and set a max_tokens limit that matches the answer you actually need. Measure before and after with this counter - a 30% shorter prompt at scale is a 30% smaller invoice.
Everything you need to know about counting tokens
Accuracy, encodings, pricing and privacy.
How accurate is the token count?
For OpenAI models it is exact - the same o200k_base and cl100k_base vocabularies the API uses run in your browser. For Claude and Gemini the count is an estimate derived from cl100k_base with a calibration factor; expect roughly ±10% on English text.
Which tokenizer does GPT-5 use?
GPT-5, GPT-5 mini/nano, GPT-4o and GPT-4.1 use o200k_base. GPT-4 Turbo, GPT-3.5 Turbo and the text-embedding-3 models use cl100k_base.
How do I count tokens for Claude exactly?
Use Anthropic's Messages count_tokens endpoint from your backend. This page gives you a quick local estimate for planning; the API is the source of truth for billing.
Are the prices up to date?
The table ships with vendor list prices as last reviewed on 19 October 2026 for standard, non-cached usage; the page shows that date and flags itself once a review is overdue. Prices change, so every value is editable - adjust them to your contract or the current pricing page, and your edits stay saved in this browser.
Does the counter include chat message overhead?
No. Chat APIs add a few tokens per message for role markers (typically 3-4 per message plus a per-reply constant). The counter reports the tokens of the text itself; add that overhead for precise budgeting.
Why is the first count slower than the rest?
The tokenizer vocabulary (about 1 MB compressed for o200k_base) is downloaded the first time you type. After that every count is instant and works offline.
Is my prompt sent to a server?
No. Tokenisation runs locally in JavaScript. Agenvix never receives your text.
Related Developer Utilities
Discover companion utilities engineered for zero-log speed and browser-side execution.
Word & Character Counter
Count words, characters, sentences and paragraphs with reading time, keyword density and platform limits.
Markdown to HTML Converter
Convert Markdown to clean HTML with live preview, GFM tables, task lists, heading IDs and a table of contents.
Case Converter
Switch text between UPPER, lower, Title, Sentence, camelCase, snake_case and kebab-case instantly.
Text Diff Checker
Compare two text blocks with LCS line matching, word level highlighting and similarity scoring.
Remove Duplicate Lines
Deduplicate, sort, trim and clean lists of lines with case-insensitive matching and instant statistics.
JSON Formatter & Validator
Prettify, format, repair syntax errors, and convert raw JSON data strings into trees.
More in Text & SEO
Specialized utilities within the same technical domain
