100% Client-Side: Your files and tokens never leave your browser.

LLM Token Usage & Generation Speed Simulator

Count BPE tokens locally, model API costs per 1M input/output tokens, and visually simulate Time-To-First-Token (TTFT) and streaming generation speeds from 20 to 250 tokens/sec.

Input Tokens
0
BPE Approx (loading tiktoken...)
Words
0
0 tok/word
Characters
0
0 char/tok
Custom Total Cost
$0.0050
per request

Configurable Pricing ($ per 1M tokens)

Reference Pricing Tiers (Click to Apply)

How LLM Tokenization, Pricing & Streaming Latency Work

Large Language Models do not process raw characters or whole English words—they operate on subword tokens produced by Byte-Pair Encoding (BPE) tokenizers such as cl100k_base and o200k_base. Common English words typically map to a single token, while punctuation, JSON syntax, indentation whitespace, and non-English scripts often split into multiple tokens. As a rule of thumb, 1 token averages ~4 characters or ~0.75 English words, though dense JSON or source code can consume significantly more tokens per word.

API billing is split asymmetrically between input (prompt) tokens and output (completion) tokens, with output tokens typically priced 3x to 5x higher because autoregressive decoding is memory-bandwidth bound. Using DevPayload's client-side js-tiktoken counter lets you benchmark prompt compression, RAG chunk sizes, and per-10,000-request budgets without sending proprietary system prompts to external token counting APIs.

Beyond cost, perceived AI responsiveness depends on two latency metrics: Time-To-First-Token (TTFT)—the prefill delay before the first token streams—and decode throughput measured in tokens per second (t/s). The Generation Speed Simulator lets product engineers feel the exact UX difference between 25 t/s and 150 t/s before committing to a model tier.

API Cost & End-to-End Streaming Latency Formulas

Total request cost scales linearly with input and output token counts, while end-to-end streaming latency equals prefill TTFT plus sequential decode duration.

Total Cost ($)       = (InputTokens / 1,000,000) * InputPricePer1M
                     + (OutputTokens / 1,000,000) * OutputPricePer1M

Total Latency (sec)  = (TTFT_ms / 1000) + (OutputTokens / TokensPerSec)
Effective Throughput = OutputTokens / TotalLatencySec

Code Equivalents (Python & JavaScript / Node.js)

Python Count BPE tokens & estimate cost with tiktoken
import tiktoken

enc = tiktoken.get_encoding("cl100k_base")
prompt = "Summarize this Parquet schema in 3 bullet points."
input_tokens = len(enc.encode(prompt))
output_tokens = 300

# Example pricing: $2.50 / 1M input, $10.00 / 1M output
cost_usd = (input_tokens / 1_000_000) * 2.50 + (output_tokens / 1_000_000) * 10.00
print(f"Input tokens: {input_tokens}, Est. cost: ${cost_usd:.6f}")
JavaScript Count tokens & compute total stream latency in Node.js
import { getEncoding } from 'js-tiktoken';

const enc = getEncoding('cl100k_base');
const prompt = 'Summarize this Parquet schema in 3 bullet points.';
const inputTokens = enc.encode(prompt).length;

const ttftMs = 450;
const outputTokens = 180;
const tokensPerSec = 65;
const totalLatencySec = ttftMs / 1000 + outputTokens / tokensPerSec;

console.log({ inputTokens, totalLatencySec: Number(totalLatencySec.toFixed(2)) });

Frequently Asked Questions

Which tokenizer does the LLM Token Calculator use? +

It loads js-tiktoken's cl100k_base BPE vocabulary directly inside your browser for exact client-side counting, with an instant BPE heuristic active while the vocabulary initializes.

Why are output tokens more expensive than input tokens? +

Input tokens are processed in parallel during the prefill phase, whereas output tokens must be generated sequentially one token at a time while reading the full model weights and KV cache from GPU memory.

What is a good Time-To-First-Token (TTFT) and generation speed for chat UX? +

Users perceive TTFT under 500 ms as snappy. Reading speed averages 4–6 tokens/sec, so 30–50 t/s feels comfortable for prose, while 80+ t/s is ideal for code generation and structured tool calls.

Are my system prompts or RAG documents sent to OpenAI or any API? +

No. Tokenization and streaming simulation run 100% locally in your browser with zero outbound requests.