lumo

Module 01 · Lesson 2 of 13Free

The AI application stack: from model to product

Level
Beginner
Topic
AI engineering fundamentals
Reading time
11 min

When you finish this page you can

  1. Name the three layers of an AI product, and say which one an AI engineer builds and which two are rented through a model API.
  2. List the parts of an application layer, from the product UI to evals and monitoring, and what each part keeps.
  3. Explain four habits AI engineering adds to full-stack work, using versioned prompts, evals, the price of each call and model retirement as examples.
  1. Introduction to AI engineering14 min

Video lesson · coming soon

Tomás’s prototype rests on work he didn’t do

Deskora is a made-up help desk app. A shop’s support team uses it to answer customer emails from one shared inbox. Each customer problem becomes a ticket: one customer’s whole conversation with the support team, message by message.

Priya is a support agent at a shop that uses Deskora. When she picks up a long ticket, she spends about five minutes reading it before she can reply. Tomás, an engineer at Deskora, has built a prototype that puts a short summary at the top. It is about 30 lines of Python, and the model call is five of them.

The model behind those five lines was trained by a provider, on huge amounts of text. It runs on the provider’s servers, on specialised chips called GPUs. Deskora owns none of that.

Soon 9,000 agents at 1,500 shops will use the feature, on some of Deskora’s 120,000 new tickets a day. Before launch, Tomás’s team lead asks him for a list: what Deskora has to build, and what it pays someone else for.

Check yourselfAnswer in your head first, then reveal
Before the first summary, how much does Deskora pay up front to train the model and buy the servers that run it?Show answerHide answer
Nothing. The provider paid for training and runs the servers. Deskora pays per call instead: about $0.0006 for a typical summary on Claude Haiku 5.5, as of October 2026. Not “a large licence fee”: the cost arrives a little at a time, with every call.

This lesson answers one question: which parts of an AI feature does Deskora build and own, which parts does it rent, and how does that change the way Tomás works?

Three layers, and Deskora owns only the top one

Every AI product sits on a stack of three layers. Each layer depends on the one below it.

Diagram not drawn yet: ai-stack-three-layers.svg

Three stacked bands. Top: the application layer, owned by Deskora, holding the ticket page, context and prompt, the model call code, output checks, evals and monitoring. A line labelled model API separates it from the two bands below. Middle: the model layer, rented from the provider, holding the trained model, for example Claude Haiku 5.5. Bottom: the infrastructure layer, rented from the provider, holding data centres, GPUs and serving software. An arrow down through the model API line is labelled prompt; an arrow up is labelled summary and token counts, about $0.0006 per typical summary.

Deskora builds the top layer and rents the two below it. The model API is the only line between them, and every call across it has a price.
  • The infrastructure layer is the hardware and software that run a model: data centres, GPUs and serving software that answers calls from many customers at once. Running a trained model to produce output is called inference.
  • The model layer is the trained model itself, such as Claude Haiku 5.5. Module 02 explains how a model is trained.
  • The application layer is everything that turns a model into a feature someone uses. For Deskora, that is the summary feature. It is Tomás’s job.

Chip Huyen’s book on AI engineering uses the same three layers.4

Layer For the ticket summary Who builds it How Deskora pays
Application Ticket page, prompt, checks, evals, monitoring Deskora Engineers’ time and Deskora’s own servers
Model Claude Haiku 5.5 The provider Inside the price of each call
Infrastructure GPUs and serving software The provider Inside the price of each call

The model API is the line between what Deskora rents and what it owns. Tomás reaches the two lower layers only through it. He picks a model id, sends a prompt and reads what comes back. Choosing a model shows how to pick between the models a provider offers.

Deskora still runs its own web servers, database and background jobs. In this stack, those belong to the application layer. The infrastructure layer means only the computers that run the model.

Some teams run an open-weight model on their own GPUs instead, which brings the infrastructure layer in-house; Hosted and open-weight models compares the two. Renting both lower layers is why Deskora’s prototype took one afternoon. It doesn’t remove the work, though. It moves all of it into the top layer.

Six parts make up Deskora’s layer

Introduction to AI engineering followed one summary through five steps. Those steps are one request’s path. The application layer adds two parts outside any single request: evals check a change before it ships, and monitoring watches every call in production.

Diagram not drawn yet: deskora-application-layer.svg

Deskora’s application layer. A request path from left to right: a background job loads the ticket; context and prompt builds the prompt from template summary-v7; the model call sends it to the model API, which sits outside the layer; output checks test the reply; the product UI shows the summary above the ticket with a flag button. Small numbers 1 to 5 mark where lesson 01’s five steps sit on this path. Above the path, an evals box runs 40 saved tickets through the same prompt and model before any change ships. Below the path, a monitoring box collects cost, time, stop reason and agent flags from every call.

The five steps are one request’s path. Evals and monitoring sit around it: one checks a change before it ships, the other watches every call after.
Part Its job for the summary What it keeps When it fails
Product UI Shows the summary, labelled as AI-written, with a flag button The page and agents’ flags A missing summary breaks the page; show the ticket alone
Context and prompt Picks what the model sees: the cleaned-up thread plus instructions The prompt template and its version An edit makes summaries skip promises
Model call Sends the prompt and waits Model id, output ceiling, timeouts, retries Errors, rate limits, slow replies
Output checks Rejects cut-off, empty or overlong summaries The rules A false statement still passes
Evals Score summaries of saved real tickets before a change ships The tickets and the facts each summary must keep Untypical tickets give a misleading score
Monitoring Records cost, time, stop reason and flags for every call Logs, dashboards, alerts Quality drops unnoticed for weeks

Most of this table is familiar web work: a page, a database, a background job, logs. Three things in it are new for a web team: the prompt, the eval and the bill. The provider adds a fourth.

The same tools, four new habits

Many engineers see AI engineering as full-stack work plus one API call. Half of that is right: Tomás uses the same Python, database, Git repository and code review.

Check yourselfAnswer in your head first, then reveal
Tomás changes one line: the model id, from claude-haiku-5-5 to claude-sonnet-5-5. All his unit tests pass. What else changed?Show answerHide answer
The daily bill, from about $38 to about $756, because both Sonnet 5.5 prices are 20 times Haiku 5.5’s, as of October 2026. The summaries change too, and only an eval shows whether they got better. Not “nothing, the tests pass”: unit tests check the code around the call, not the summaries.

One line changed the model, the price and the output at once. Ordinary web code rarely works like that, and four habits follow.

Diagram not drawn yet: code-change-vs-prompt-change.svg

Two panels. Left, a code change: edit code, unit tests, code review, deploy. Right, a prompt change from v7 to v8: edit the prompt file, unit tests pass, the eval scores 31 of 40 against v7’s 34 of 40, a cost check compares the daily cost before and after, code review, then deploy with the version saved on every summary, followed by monitoring. In this example v8 stops at the eval step, marked in red, and does not ship.

A prompt change goes through the same steps as a code change, plus an eval and a cost check. Here v8 stops at the eval.

Prompts get versions, like code

The prompt decides what every summary contains. Change “list every promise” to “mention key promises”, and 40,000 summaries a day change. So the prompt is treated as code: it is reviewed, it has a version, and every saved summary records which version made it.

Here is an example of what Deskora saves with each summary:

json
{
  "ticket_id": 5203,
  "summary": "Problem: lamp arrived with a broken shade.\nPromised: a new shade by Thursday.\nWaiting for: the tracking number.",
  "prompt_version": "summary-v7",
  "model": "claude-haiku-5-5",
  "input_tokens": 4163,
  "output_tokens": 377,
  "thinking_tokens": 296,
  "cost_usd": 0.000605,
  "created_at": "2026-10-28T09:14:03Z"
}

When Priya flags a bad summary, Tomás can see which prompt and which model made it, and what it cost. Where the prompt itself lives is a real choice.

Where should Deskora keep the summary prompt?

A string inside the summary function.

Easy to start. But there is no version id, so when a summary is wrong, nobody can tell which wording made it, or compare two wordings.

A prompt store, edited live outside the code.

Support leads can tune the wording without an engineer or a deploy. But one careless edit reaches every new summary at once, with no review and no eval, unless the store adds both.

Why this choice

Deskora has one prompt and one engineer who changes it. A file in the repository gives the prompt the same review, history and rollback as the rest of the code.

When the choice changes. If people outside engineering need to adjust prompts often, or each shop gets its own prompt, a prompt store pays off. Each edit must still get a version id and pass the eval before it goes live. Prompt templates and version control builds this.

Evals run next to unit tests

Unit tests still check the code around the call, such as whether the output check rejects a cut-off summary. They can’t judge whether a summary kept the promise made to the customer.

An eval does that: it runs the feature on many real tickets and scores each summary. Anthropic’s guide advises evals that mirror the real mix of inputs, edge cases included.3 It also advises grading them automatically where possible.3

Tomás’s prompt v7 keeps the key facts in 34 of 40 eval tickets. His v8 adds an instruction to quote order numbers. The unit tests pass, but the eval drops to 31 of 40: three summaries now leave out the promised delivery date. So v8 doesn’t ship.

The 40 tickets and both scores are example numbers.

An eval gives a score, not a pass or a fail. The team decides what score is good enough. Evals shows how to build one.

Every call has a price

In a web app, a code change almost never changes the monthly bill. Here, every call is billed by the token, a small piece of text. So the length of a prompt has a price.

Suppose v8 had also added 1,000 tokens of examples to the instructions. As of October 2026, Claude Haiku 5.5 costs $0.10 per million input tokens and $0.50 per million output tokens, for prompts up to 100,000 tokens.2

The formula

cost per call = input tokens × input price + (thinking + text tokens) × output price

One summary is one call. This leaves out retries and summaries made again after new messages. Thinking tokens, the hidden reasoning a model writes before its answer, are billed at the output price.

Typical ticket, prompt v7

4,150 × $0.10 ÷ 1,000,000 + (300 + 80) × $0.50 ÷ 1,000,000 = $0.000415 + $0.00019 = $0.000605

A 4,000-token thread plus a 150-token prompt. Assumed: 300 thinking tokens and an 80-token summary.

Typical ticket, v8 with 1,000 more tokens

5,150 × $0.10 ÷ 1,000,000 + 380 × $0.50 ÷ 1,000,000 = $0.000515 + $0.00019 = $0.000705

Assumed: the output stays the same length. The edit adds $0.0001 to every call.

Per day

40,000 summaries × $0.0001 = $4 more a day: about $38 becomes about $42

Long tickets pay the same $0.0001 extra, because their prompts stay under 100,000 tokens.

Estimates for this scenario: the thread sizes, the thinking tokens, and 40,000 summaries a day, 10,000 of them for long tickets.

One edit raised the bill by about 11%, so a cost check belongs in the review of every prompt change. The thinking counts are assumptions; each response reports the real number in usage.output_tokens_details.thinking_tokens. Module 10 covers ways to cut the bill, such as prompt caching and sending easy work to smaller models.

The provider retires the model you built on

A library pinned in a lockfile stays the same until you change it. A hosted model doesn’t last forever. Providers retire older models as new ones launch, and requests to a retired model fail.1 The model is a Deskora doesn’t control.

Anthropic gives at least 60 days’ notice before it retires a publicly released model.1 As of October 2026, its deprecations page lists Claude Sonnet 4.5 to retire on November 30, 2026, with Claude Sonnet 5.5 as the replacement.1 The earliest retirement date it lists for Claude Haiku 5.5 is October 7, 2027.

So one day Tomás will move the summary to a new model. The new model writes different summaries at a different cost. He treats the move like a prompt change: run the eval, compare the cost, then switch. Anthropic recommends testing newer models well before the retirement date.1 Model upgrades covers doing that safely.

Where this shows up

The next lesson, Calling a model API, looks closely at the line between the layers: what one call sends, what comes back and what it costs.

Common mistakes

  • Expecting the provider to own quality. The provider makes a general model. Deskora must measure whether it summarizes Deskora’s tickets well.
  • Shipping a prompt edit on unit tests alone. The tests can’t see the summaries. Run the eval too.
  • Saving outputs without their prompt version and model. When a bad summary appears, nobody can trace what made it.
  • Treating the model like a pinned library. Plan the move to a new model before the retirement notice arrives.

Check your understanding

Check yourselfAnswer in your head first, then reveal
A teammate says Deskora’s GPU costs will grow as more shops sign up. Is that right?Show answerHide answer
Not as GPU costs: Deskora rents the infrastructure layer and owns no GPUs. What grows is the model bill, because every call is billed by the token. Deskora’s own web servers and database are part of its application layer and are paid for separately.
Check yourselfAnswer in your head first, then reveal
Priya flags a summary that missed an agreed refund. Its record says prompt summary-v9 and model claude-haiku-5-5. Last week’s summaries used v8 with the same model. What does Tomás check first?Show answerHide answer
He runs the eval on v8 and v9 to see whether the new prompt drops refunds more often. Not the model: it didn’t change between the two weeks, but the prompt version did. The saved record is what makes this check possible.
Check yourselfAnswer in your head first, then reveal
Deskora gets a notice that its summary model retires in 60 days. Changing the model id is a one-line edit. Why is that not the whole job?Show answerHide answer
The new model writes different summaries at a different price. Tomás runs the eval and a cost estimate on the new model first, then switches. Not “the API stays the same, so nothing breaks”: the request format stays, but the output and the bill change.
Check yourselfAnswer in your head first, then reveal
A support lead wants to change the prompt wording every day without waiting for a deploy. What makes a live prompt store safe enough?Show answerHide answer
Each edit still gets a version id saved on every summary, and runs the eval before it goes live. Then a bad edit is caught before agents see it, and any summary can be traced to its wording. Without both, one careless edit reaches every new summary at once.

Summary

  1. An AI product has three layers: application, model and infrastructure. Deskora builds the application layer and rents the other two through the model API, paying per token.
  2. The application layer holds one request’s path (product UI, context and prompt, model call, output checks), plus evals before each change and monitoring on every call.
  3. Prompts are code: keep them in versioned files, review them, and save the prompt version and model with every output.
  4. Unit tests check the code around the call; an eval scores the outputs. Run both on every prompt or model change, and check the cost too.
  5. The provider retires models, so plan to move to a new one: run the eval, compare the cost, then switch.

Report a mistake

Tell us what’s wrong in this lesson and we’ll fix it.