lesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costslesson 2 of 4 · read the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costsread the token bill — what your llm feature actually costs
Checkpoint
One last thing before we move on. pass this to mark the lesson done, or skip and keep moving. hop to the next when you're ready.
Final drill. You're about to ship a feature that runs once per user message. Before you click deploy, you want a monthly cost projection grounded in representative prompts and outputs — not a back-of-envelope guess.
Build project_monthly_cost(prompts, expected_outputs, daily_volume, in_rate, out_rate, days=30) that:
- Pairs each prompt with its expected output (same length lists).
- Computes the per-call cost for each pair using
estimate_tokens(chars / 4) and the input/output rate formula. - Averages those per-call costs to get a representative cost per call.
- Returns a dict
{"avg_cost_per_call": <float>, "daily_spend": <float>, "monthly_spend": <float>}with all values rounded to 4 decimals (monthly to 2).
One scenario runs for you — a triage bot sampling three real prompt shapes (summarize, classify, extract). Expected output:
avg cost/call: $0.0009
daily spend: $4.35
monthly spend: $130.50