Servingcore
Cost per request & back-of-envelope maths
(input tokens × input price + output tokens × output price) × calls per request — then multiply by traffic.
What it is and why it exists
A request’s cost is the sum over its model calls (router, rewriter, main call, judges, agent steps) of tokens × price, plus embeddings, reranking and tools. Cached input is cheaper; reasoning tokens count as output; agents multiply everything by steps. Multiply by requests per day for the bill, compare with revenue per user for margin.
Quick prototype
Check the bill at the end of the month.
In production, at scale
A cost model per feature in a spreadsheet or calculator, validated against logged usage, with levers listed: smaller model, routing, prompt caching, shorter context, output caps, batch for offline work, semantic cache.
Vendors and tools
| Provider pricing pages | Per-million-token prices |
|---|---|
| LLM price comparison sites | Cross-provider comparisons |
On AWS: Bedrock on-demand per-token pricing, batch discounts, provisioned throughput; Cost Explorer for actuals.
How it fails
- Forgetting retries, judges and agent steps in the estimate
- Ignoring cached-token discounts that would change the design
What the interviewer asks next
Estimate: 50k conversations/day, 6 turns, 3k input and 300 output tokens per turn, $3/M in and $15/M out.
Per turn: 3,000 × 3/1M + 300 × 15/1M = $0.009 + $0.0045 = $0.0135. × 6 turns = $0.081 per conversation. × 50k = ~$4,050/day, ~$120k/month — before caching or routing.