Building with AILesson 71 of 80

Module 8 · Cost, latency and running it in production

The cost model of a feature, line by line

In this lesson

  • 9 min read
  • 8 reading sections
  • Knowledge check
  • Lesson 1 of 10 in this chapter

This chapter’s goalProduce a cost and latency budget for an AI feature at a stated scale, defend each line of it with a measurement, and operate the feature through a provider outage, a model deprecation and a tenfold traffic increase without an unplanned bill or an unplanned outage.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
Where a turn’s money actually goesOutput: 300 tokens at$15/M4.5Uncached input: 1,000tokens at $3/M3Cached prefix: 1,500tokens at $0.30/M0.45dollars per 1,000 turnsThe largest block of tokens in the request is nearly free and the smallest is more than half the bill.That is why trimming answers from 300 tokens to 200 saves almost a fifth of the whole feature, and whythe harness treats a rise in output length as a regression.
The largest block of tokens in the request is nearly free and the smallest is more than half the bill. That is why trimming answers from 300 tokens to 200 saves almost a fifth of the whole feature, and why the harness treats a rise in output length as a regression.

Figure 8.1

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 9Free · no account needed
Lesson steps

From a call to a feature

The first module priced one request: input tokens at one rate, output at a higher one, cached input at a discount. A feature is that arithmetic multiplied by behaviour (how often people use it, how long their sessions run, how much context each turn carries) plus costs that do not scale with users at all. Write it as a spreadsheet before the feature exists, with guessed numbers, and replace each guess with a measurement from the traces as they arrive. The free path is any spreadsheet; the discipline is filling in every cell.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Python, from Zero, for AI exam.

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘The cost model of a feature, line by line’, in Building with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/building-with-ai/the-cost-model-of-a-feature (Accessed: 29 November 2026).