LLM Token Counter and API Cost Calculator Guide
Measure prompt tokens locally and compare estimated API input and output costs for GPT-4o, GPT-4o mini, Claude 3.5 Sonnet, Gemini Flash, and other listed models. Your prompt remains in the browser throughout the calculation.
GPT counts are calculated synchronously with gpt-tokenizer, a pure JavaScript BPE implementation compatible with modern OpenAI o200k_base tokenization. Other providers use proprietary tokenizers, so their billed count can differ. Price figures are estimates and should be confirmed before production billing decisions.
✨ Core Capabilities
- •Uses the browser-safe gpt-tokenizer BPE implementation with GPT-4o o200k_base encoding.
- •Updates token, word, and character counts as you type or paste.
- •Estimates total cost from a selectable response-length assumption.
- •Compares OpenAI, Anthropic, and Google model prices in one table.
- •Visualizes actual GPT token chunks with alternating highlights.
🚀 Step-by-Step Guide
- 1. Paste or type a prompt into the text area.
- 2. Read the live token, word, and character totals.
- 3. Set the anticipated output-to-input ratio to estimate total request cost.
- 4. Filter providers and enable Token Visualizer to inspect token chunks.
🔬Verified Input & Output Examples (Before / After)
Calculates exact BPE tokens (o200k_base) and compares estimated API cost across GPT-4o, Claude 3.5 Sonnet, and Gemini 1.5 Flash.
Analyze the following TypeScript function for potential memory leaks and optimize its big-O complexity from O(n^2) to O(n log n). Provide benchmark tests.
Tokens: 31 | Words: 24 | Chars: 161 • GPT-4o: $0.000078 (Input) | Est. $0.000390 (Total) • Claude 3.5 Sonnet: $0.000093 (Input) | Est. $0.000465 (Total) • Gemini 1.5 Flash: $0.000002 (Input) | Est. $0.000012 (Total)