sagelearnai

Tokens, Cost and Latency: Estimating Before You Build

"What will it cost and how fast will it be?" comes up in every design review, client proposal and system design interview. You don't need exact prices; you need a method that gets within a factor of two in five minutes and shows which knob matters.

Learning objectives

  • Convert text volumes into tokens, including for non-English languages.
  • Estimate monthly model cost for chat, batch and agent workloads.
  • Break latency into its parts and estimate time to first token and total time.
  • Size capacity with requests per minute, tokens per minute and concurrency.
  • Name the levers that cut cost and latency, in order of effort.

Tokens in one minute

Models read and write tokens, chunks of text from a fixed vocabulary.

  • English: roughly 4 characters or ¾ of a word per token; 1,000 words ≈ 1,300–1,400 tokens.
  • Code, JSON and tables use more tokens per word than prose.
  • Many non-Latin scripts, including Hindi, Tamil and other Indic languages, can take two to several times more tokens for the same meaning, depending on the model's tokenizer. Measure with your model's tokenizer before quoting a cost for a multilingual product.

A request's input is everything sent: system prompt, tool definitions, conversation history, retrieved documents and the user's message. Output is what the model generates, including any reasoning tokens for reasoning models. Providers price the two separately, and output tokens usually cost several times more.

The cost formula

Monthly cost = requests per month × (input tokens × input price + output tokens × output price)

Prices are quoted per million tokens. The examples below use illustrative prices; always check the current price list.

Model tier (illustrative)Input per 1MOutput per 1M
Small / fast$0.15$0.60
Mid-size$0.50$1.50
Frontier$3.00$15.00

Worked example 1: customer chat

200,000 conversations a month, 4 turns each. Each turn sends ~2,500 tokens (instructions 600, history grows to ~900, retrieved context 1,000) and returns ~250.

  • Requests: 800,000 a month.
  • Mid-size model: 800,000 × (2,500 × 0.50 + 250 × 1.50) / 1,000,000 = 800,000 × 0.001625 = ≈ $1,300 a month.
  • Frontier model: 800,000 × (2,500 × 3 + 250 × 15) / 1,000,000 = 800,000 × 0.01125 = ≈ $9,000 a month.

The model choice is a 7× cost decision, so it must be justified by eval results, not taste.

Worked example 2: batch document processing

Extract 30 fields from 1 million insurance documents of ~3,000 tokens each, with ~400 tokens of output.

  • Small model: 1,000,000 × (3,000 × 0.15 + 400 × 0.60) / 1,000,000 = 1,000,000 × 0.00069 = ≈ $690 once.
  • Batch APIs typically discount around 50% for results within hours, so ≈ $350.
  • Frontier model at list price: ≈ $15,000. Test whether the small model meets the accuracy target first.

Worked example 3: an agent

An agent averages 6 model calls per task, each with ~5,000 input tokens (tools, history and observations accumulate) and 300 output, on a mid-size model: 6 × (5,000 × 0.50 + 300 × 1.50) / 1,000,000 ≈ $0.018 per task. At 50,000 tasks a month that's ~$900, but the variance matters more than the average: a task that loops 25 times costs four times as much. Step limits and per-task budgets are cost controls as much as safety controls.

Cost per successful task

Divide total spend by successful outcomes, not requests. A cheap model that fails 30% of the time and triggers retries or human handling can cost more than an expensive model that succeeds.

Latency, broken down

ComponentTypical rangeWhat drives it
Network and gateway20–150 msRegion, TLS, gateway checks
Retrieval (embed query + search + re-rank)50–400 msIndex size, re-ranker, filters
Time to first token (TTFT)0.2–2 sInput length (prefill), model size, load
Generationoutput tokens ÷ tokens per secondModel size; often 30–150 tokens/s per stream
Guardrails and post-processing10–500 msExtra model calls for checks

A 300-token answer at 60 tokens/s takes 5 s to generate. Streaming shows the first words after the TTFT, so users perceive ~1 s instead of 6. Without streaming, perceived latency is the total.

Agents multiply latency: six sequential calls at 2–3 s each is 12–18 s. That's acceptable for a background task, not for a chat turn. Parallel tool calls, smaller models for routing steps and fewer round trips are the fixes.

Capacity: rate limits and concurrency

Providers and self-hosted servers limit requests per minute (RPM) and tokens per minute (TPM). Estimate peak, not average:

  • Average 800,000 requests a month ≈ 18 a minute. Business-hours peaks are often 5–10× the average → ~150 requests/minute at peak.
  • Tokens at peak ≈ 150 × 2,750 ≈ 410,000 TPM. Check this against the quota for your model and region before launch; raising quotas can take days.
  • Concurrency (Little's law) = arrival rate × time in system. 150 requests/minute = 2.5/s; at 6 s each that's ~15 requests in flight. Self-hosted GPUs are sized from this number.

The levers, in order of effort

  1. Trim the prompt: shorter instructions, fewer and better chunks, summarised history. Often 30–50% of input tokens.
  2. Cap output: max tokens and "be concise" instructions; output is the expensive side.
  3. Cache: provider prompt caching for repeated prefixes (long system prompts, tool definitions), plus response caching for repeated questions.
  4. Route: a small model for easy requests, a larger one for hard ones, decided by a classifier or confidence check.
  5. Batch: offline work through batch APIs at a discount.
  6. Fine-tune or distil a small model for a narrow high-volume task.
  7. Self-host open-weight models once volume is high and steady enough to keep GPUs busy.

Module 7 covers each in depth.

Show the arithmetic

Say the formula out loud, round aggressively, and name the dominant term: "About 800,000 requests a month at roughly 2,500 tokens in and 250 out. On a mid-size model that's around $1,300 a month; on a frontier model about $9,000. Input tokens dominate, so trimming retrieved context is my first lever."

Self-check

Estimate the monthly model cost for a support chatbot, out loud.
  • State assumptions: conversations, turns, tokens in and out per turn, model tier and price.
  • Multiply: requests × (in × price + out × price) / 1M; give the result for two model tiers.
  • Name the dominant term and the first lever (usually input tokens → trim context; then routing and caching).
The business wants answers in under 2 seconds. Is that achievable?
  • Break it down: gateway, retrieval, TTFT, generation. With streaming, first words in ~1 s is realistic; full long answers in 2 s may not be.
  • Options: stream, shorter answers, smaller/faster model, cache frequent questions, run retrieval and guardrails in parallel.

Last reviewed 2026-11-05.