Lesson 01.08 · Phase 01 · LLM Foundations for Agents

Token budgets & cost math

Price is tokens times rate, latency is tokens divided by speed, and agents multiply both by the number of steps. Do the arithmetic before you pick a model, not after the bill.

Learning objectives

  • Compute the cost of a call, separating input, output and cached input.
  • Compute the cost of a multi-step agent run, and what prefix caching saves on it.
  • Measure a model's prefill and decode speeds, fit a latency model, and test its predictions.
  • Choose maxtokens from a latency deadline instead of guessing.

"This model costs $3 per million tokens" sounds cheap. Then an agent does eight steps, each re-sending a 3,000-token system prompt and tool list plus a growing history, and a "cheap" run costs thirteen cents. Run it a thousand times a day and it's $4,000 a month.

Loading the full lesson…