promptdojo_

Read the token bill — what your LLM feature actually costs — step 9 of 9

Checkpoint

One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.

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.0013
daily spend:   $6.53
monthly spend: $195.75

full-screen editor opens — close anytime to keep reading.