Tokens · Basics

How many tokens is my prompt?

There is no universal “characters divided by four” answer that holds across models and languages. For planning, combine rough heuristics with tokenizer tools or logged usage fields from your provider.

This page explains how to think about prompt tokens, when heuristics fail, and how to connect token counts to dollars using the calculator below.

Token calculation explanation

Tokenizers split text into subword pieces. Short common words may be one token; rare words may become several. Punctuation and whitespace also consume tokens.

Words-to-token examples (indicative)

English prose often lands near three to four characters per token, but JSON, code, and repetitive templates behave differently. Asian languages may produce different ratios than Latin scripts.

Illustrative patterns

  • “Hello world” may be two to four tokens depending on model.
  • A hundred-line JSON blob may explode versus natural language with the same character count.

Prompt optimization tips

Remove duplicate instructions, collapse whitespace, and prefer bullet constraints over prose when possible.

Token reduction techniques

Summarize stable reference material offline, deduplicate system prompts across services, and avoid sending full chat history when summaries suffice.

Context window explanation

Context limits cap how many tokens a model can consider at once. Approaching the limit increases latency and cost without guaranteeing better answers—curate what you include.

Real pricing examples

Once you estimate tokens, multiply prompt tokens by input price and completion tokens by output price, scaled to per-thousand rates in config/models.php.

Sample prompts by size

Scenario Prompt tokens Output tokens Model (est.) Cost / request
Short support reply scaffold 180 90 GPT-4o mini $0.0001
RAG bundle (5 chunks) 4200 200 GPT-4o $0.0125
Code file + instructions 6500 400 DeepSeek Coder $0.0010

Figures use rates from config/models.php; confirm against your provider before billing decisions.

FAQ: Counting prompt tokens

Short answers mirror the structured data on this page for search engines and readers.

Should I trust browser heuristics for billing?
Only for planning—use provider tokenizers or billing logs for invoices.
Why do two models count differently?
They use different tokenizers; do not assume parity when switching vendors.
Do hidden template tokens count?
Yes—everything sent on the wire counts, including tool schemas.
How do emojis affect tokens?
They often consume more tokens than plain ASCII text—test with samples.

Paste text into the token estimator

Use the heuristic estimator, then multiply by rates for a quick dollar check.

Prefilled for this page’s scenario. Pricing loads from config/models.php and /api/pricing.

Calculator

Cost = (prompt ÷ 1000 × Pin) + (completion ÷ 1000 × Pout), then × requests.

Usage presets

Multi-model comparison

Toggle models to compare the same workload. The cheapest option is highlighted.

Monthly cost simulator

Project from average daily requests (uses tokens above).

Uses primary model rates for projections.

Token estimator

Rough heuristic: ~4 characters ≈ 1 token for Latin text (indicative only).

Estimated tokens: 0 · Cost @ primary:

API budget planner

Set a monthly cap to see how many identical requests fit (primary model).

Max requests (approx):

Prompt optimization analyzer

Collapse whitespace and tighten wording to preview savings at the primary model.

Suggested shorter form:


                    

Token delta: 0 · Est. savings / 1k calls:

Fine-tuning cost sketch

Order-of-magnitude helper: training tokens × epochs × rate + storage.

Est. training + 1 mo storage:

Team usage calculator

Multiply per-person daily volume by team size (primary model).

Team monthly (22d):

Cost per feature

Price a single product surface (e.g., one chat turn or one generated article).

Uses prompt & completion tokens from the calculator for one invocation.

Cost per use: · Monthly @ that cadence:

Share & export

Serialize inputs in the URL hash or copy a text summary.

Calculation history

Stored in your browser only (LocalStorage).