Token Pricing
Input vs output pricing, cached tokens, and estimating unit economics for AI features.
In plain words
You pay for the words you send and the words you get back, and the words you get back cost more.
Think of it like…
A taxi meter with different rates for the waiting time and the distance driven: you pay for how much you tell the driver (input) and how much the driver talks back (output), and the longer the route, the more the meter runs.
Where you’ve seen it
A support copilot handles 200,000 chats a month. Each request sends 3,000 input tokens (system prompt, history, retrieved articles) and gets 300 output tokens. With illustrative prices of $3 per million input and $15 per million output, a request costs 0.009 + 0.0045 = $0.0135, or about $2,700 a month. Caching the 2,000-token stable prefix at a 90 percent discount, and trimming history, brings it near $1,500, without changing the user experience.
Words you’ll hear
- Input vs output tokens
- Prompt tokens are cheaper; generated tokens usually cost 3 to 5 times more.
- Cached input
- Repeated prefix tokens billed at a discounted read rate.
- Batch API
- Asynchronous processing at a discount (often around half price) for non-urgent work.
- Unit economics
- Cost per request, user, resolved ticket or other business unit versus the revenue or value it creates.
Visual diagram
Theory & deep dive
Estimating cost per request and per month
Cost per request = (input tokens × input rate) + (output tokens × output rate), minus savings from cached input. Multiply by request volume for a monthly figure, then add the costs that are easy to forget: retries and fallbacks, embedding and retrieval calls, evaluation runs, agent loops (each step is another call whose history grows), and reasoning tokens. Instrument real usage from API response fields rather than estimating from the prompt template.
Report cost against value, not alone: cost per resolved ticket, per generated report, per active user. A feature costing $0.02 per request is cheap if it saves a support agent two minutes, and expensive if users trigger it ten times per session for a free tier. Prices differ widely across model sizes, often by 10 to 50 times between a small and a frontier model, which is why model choice is the biggest lever.
5,000 users × 20 requests a month × (2,500 input + 400 output tokens) with $2/$10 per million rates: input 250M tokens = $500, output 40M tokens = $400, total about $900 a month, or $0.18 per user.
Levers for reducing cost
In rough order of impact: use the smallest model that meets your quality bar (route easy requests to cheaper models); cut input by trimming history, retrieving fewer and shorter chunks, and compressing prompts; cache stable prefixes; cap output length and ask for concise formats; use batch APIs for offline work; avoid redundant calls with response caching; and reduce retries by using structured outputs. For self-hosted models, cost shifts to GPU hours and utilisation, where batching and quantisation are the main levers.
Set guardrails: per-user and per-tenant budgets, max-token limits, alerts on spend anomalies, and dashboards of cost per feature. Run cost into your evaluation loop, comparing quality-per-dollar when you change models or prompts, because a 2 percent quality gain at 4 times the cost is rarely a good trade.
Route 70% of requests (simple FAQs) to a small model at one tenth the price, keep 30% on the large model, and cache the system prompt: blended cost falls by more than half while a held-out evaluation shows no measurable drop in resolution rate.
How it works, step by step
Step 1 of 41. Measure tokens per request
Log input, cached, output and reasoning tokens from every API response, by feature.
- Source
- API usage fields
When to use it & trade-offs
What it is
LLM APIs bill per token, with separate rates for input (prompt) and output (generated) tokens, usually quoted per million. Output tokens cost several times more than input tokens because each is generated one at a time. Variations include cheaper cached input, discounted batch processing, premium rates for long contexts, extra charges for images or audio, and billed reasoning tokens. Unit economics means turning those rates into cost per request, per user and per business outcome.
Why it matters: An AI feature that delights users can still lose money on every call. Product and engineering decisions, such as which model, how long a prompt, how many retries, whether to cache, depend on cost per task, and prices change often, so you need a method rather than memorised numbers. Interviews and design reviews ask you to estimate monthly cost and say how you'd cut it.
When to reach for it
- Forecasting monthly cost before launch
- Choosing models by quality per dollar
- Setting per-tenant budgets and limits
When to avoid or be careful
- Estimating from word counts or a single sample prompt
- Ignoring retries, agent loops and reasoning tokens
- Optimising cost without a quality evaluation
Cost-control approaches
Strengths: Often the largest saving.
Watch out: Needs a router and quality evaluation.
Strengths: Same quality, lower input cost, faster responses.
Watch out: Requires prompt restructuring.
Strengths: Discounted rates or fixed GPU cost.
Watch out: Latency, or the operational burden of GPUs.
Interview signals & numbers to know
When this topic comes up
- “Estimate the monthly cost of this feature”
- “Why are output tokens priced higher?”
- “How would you cut LLM costs by 50%?”
- Unit economics
- Batch vs real-time
Benchmarks & rules of thumb
- ≈ 3 – 5×
- output price relative to input price
- ≈ 50%
- common batch API discount
- 10 – 50×
- price gap between small and frontier models
Common mistakes & follow-ups
Common interview mistakes
- Pricing an agent as one request when each step re-sends a growing history.
- Forgetting that reasoning tokens are billed as output and can dwarf the visible answer.
- Switching to a cheaper model without an evaluation and later discovering it hurts resolution rate.
Likely interviewer follow-ups
- How would you estimate the monthly cost of a support chatbot?
- What's the single biggest lever to reduce LLM cost?
- How do you stop one tenant from running up the bill?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Token Pricing with generative AI interview Q&A and hands-on practice.