GeekHub Learn
Module

Token math and cost estimation

The single most important spreadsheet of your AI career is the cost-per-feature estimator. This lesson gives you the formula.

Calculating LLM cost is like calculating a phone bill. Per-minute price times minutes used, plus optional extras. Easy. People skip it and get shocked anyway.

Cost per request = (input_tokens / 1,000,000 * input_price) + (output_tokens / 1,000,000 * output_price).

Cost per feature per month = cost per request * requests per user per month * users.

Examples (illustrative 2026 prices):

ModelInput ($/M tok)Output ($/M tok)
GPT-4o mini0.150.60
GPT-4o2.5010.00
Claude Haiku-class0.251.25
Claude Sonnet-class3.0015.00
Gemini Flash0.0750.30

(Check live prices before committing. These change quarterly.)

Build the estimator in a spreadsheet with columns: model, input price, output price, avg input tokens, avg output tokens, requests/user/month, users, cost/user/month, total/month. Add a "buffer 30%" column for spikes. This is your monthly burn projection.

Visualize it

A stacked bar chart: per-feature monthly cost broken down by model. Useful for showing in a planning meeting.

Try it now

Estimate the cost of a chatbot used 10 times per day by 1,000 users, average 300 input + 500 output tokens per request, on GPT-4o-mini. Answer at end.

Hands-on lab

Build the estimator spreadsheet from scratch. Save it. You will use it for every project in this course.

Try it now

If switching from GPT-4o to GPT-4o-mini drops cost 90% but quality 10%, when is the switch worth it?

Common mistakes

  • Forgetting to include the system prompt token count (it ships every request)
  • Forgetting that long conversation history grows input tokens linearly per turn
  • Ignoring failed requests (retries cost too)

Debugging tip

If cost dashboards spike, check three things: prompt size grew, output is longer than expected, traffic spiked. Almost always one of those.

Challenge

Pick a hypothetical product and produce a one-page cost memo with three scenarios (low, expected, high) and a recommendation.

Where this shows up

  • Pricing your SaaS feature
  • Choosing between providers
  • Justifying a model switch to your team

From the field

The 2026 job title "AI cost engineer" did not exist in 2023. It now does. Anyone fluent in token math can become the highest-impact engineer on the team within a quarter.

Recap

Cost in LLM apps is deterministic if you count tokens. Build the spreadsheet, monitor it, and the bill never surprises you.

Interactive Element answer: per request = (300/1M * 0.15) + (500/1M * 0.60) = $0.000045 + $0.0003 = ~$0.000345. Per user/month = 10 * 30 * $0.000345 = ~$0.10. 1000 users = ~$100/month.


Quick recall

3 prompts · think before you flip

Prompt 1 of 3

How do you compute cost per request?

Quiz time

1 question · tap an answer to check it

  1. 1. To halve API spend with least quality loss, your first move is usually

Finished lesson 3.5?

Mark complete to update your module progress and unlock the streak.

Loading