lumo

Module 01 · Lesson 1 of 13Free

Introduction to AI engineering

Level
Beginner
Topic
AI engineering fundamentals
Reading time
14 min

When you finish this page you can

  1. Explain what AI engineering is and how its work differs from ML engineering and AI research.
  2. Name three ways a model call differs from ordinary code, and how each one changes a feature’s design.
  3. Estimate what a simple AI feature costs per day, including the model’s thinking tokens.
  4. Describe the five steps of an AI feature, from product input to what the user sees.

Video lesson · coming soon

Priya opens a 24-message ticket

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

Priya is a support agent at a kitchenware shop that uses Deskora. She starts her shift and picks up Halima’s ticket. Halima’s blender arrived cracked. The ticket has 24 messages, and two other agents have already replied. Priya needs about five minutes to read it before she can answer.

About 1,500 shops use Deskora. Between them, they have 9,000 support agents and get 120,000 new tickets a day. Many tickets are this long. So Deskora decides to build its first AI feature: a short summary at the top of each long ticket.

Tomás, an engineer at Deskora, builds a prototype in one afternoon. His code sends the ticket to a language model, a program trained on huge amounts of text that can follow instructions such as “summarize this”. A summary comes back in a few seconds, and it’s good.

Check yourselfAnswer in your head first, then reveal
Tomás sends the exact same ticket, with the exact same instructions, a second time. Does he get the same summary back?Show answerHide answer
Probably not word for word. The same request to a model can return different text each time. Most web engineers expect the same answer, because ordinary code given the same input always returns the same output.

The second summary used different words. It also left out the most useful fact: an earlier agent had promised Halima a replacement by Friday.

Diagram not drawn yet: ordinary-call-vs-model-call.svg

Two panels. Left: an ordinary Deskora endpoint is asked twice to load ticket 4817. Both times it returns the same JSON in about 10 ms, at almost no cost. Right: the summary call sends the same 24-message ticket to a model twice. Each call takes about 4 seconds and costs about $0.0006. Run 1 mentions the replacement promised by Friday; run 2 is worded differently and leaves it out.

Ask an ordinary endpoint twice and you get the same answer, fast and nearly free. Ask a model twice and you may get two different answers, each taking seconds and costing money.

The team are good web engineers, but none of them has shipped a feature built on a language model. So the question this lesson answers is: what does it take to turn one model call into a feature 9,000 agents can trust?

You build on a model someone else trained

That work has a name: AI engineering. It means building products on top of a pretrained model, usually by calling it through an API.

A pretrained model has already been trained on a very large amount of text before you use it.1 You don’t train it. A provider runs it on its own servers. Your code sends text to the provider’s API and gets text back, and you pay for each call.

Your work is everything around that call. You decide what to send, how to check what comes back, and how the product uses it.

Two other kinds of work also deal with models:

Diagram not drawn yet: three-kinds-of-model-work.svg

Three equal panels side by side. AI research starts from open questions about how models learn, runs experiments, and produces new methods and findings. ML engineering starts from a company’s own data, trains and serves a model for one task, and produces that model. AI engineering starts from a pretrained model behind an API, builds prompts, checks and screens around it, and produces a product feature such as Deskora’s ticket summary.

Three kinds of work with models: different starting points, different results. None is a step up from another.
  • AI research asks how models can learn or work better. It produces new methods and findings, through experiments.
  • ML engineering trains and runs a model for one task, using the company’s own data. For Deskora, that could mean training a model on two years of tickets to send each new ticket to the right team.
  • AI engineering builds product features on a model that already exists. The ticket summary is AI engineering.

Chip Huyen’s book on the field draws a similar line: AI engineering adapts and evaluates existing models, while ML engineering is more about developing them.4 These are different jobs that need different skills, not levels on a ladder. Many engineers move between them.

The first decision in any AI feature is which of these jobs it needs.

How should Deskora get a model that can summarize tickets?

Train its own summary model.

The team needs thousands of good summaries, written by people, to learn from. Deskora has none, and nobody on the team has trained a model. Months pass before Priya sees a summary.

Run a pretrained open-weight model on its own servers.

Ticket text never leaves Deskora’s servers. But the team must buy or rent GPU servers and keep the model fast at busy times, before anyone knows whether agents want summaries.

Why this choice

Language models can already summarize text.1 Deskora has no training data and no ML team. The cheapest way to learn whether agents want summaries is to call an API and try.

The choice changes if the monthly API bill grows larger than running servers would cost, or if a customer’s contract forbids sending ticket text to another company. Hosted and open-weight models compares these options.

From Tomás’s code, a model API looks like any other web API. That is where most surprises start.

A model call breaks three habits of web code

Many engineers believe a model call is one more HTTP request. The code does look the same. The behaviour doesn’t:

Ordinary endpoint: “load ticket 4817” Summary call
Same input twice Same output Possibly different text
Cost of one call Close to nothing A fraction of a cent, every time
Time for one call Milliseconds Seconds
How you know it works Unit tests pass An eval scores it on many real tickets

The same input can give a different output

Ordinary code is deterministic: the same input always gives the same output. A model’s output is non-deterministic. Anthropic’s documentation says identical inputs might produce different outputs across API calls.1

The reason is in how a model writes. It picks each next piece of text from several likely options, so two runs can take different paths. Module 02 shows how that works.

You can’t switch this off, so you design around it. If Deskora made a new summary every time someone opened the ticket, Priya and her teammate could read two different summaries of the same ticket.

Every call costs money, and thinking is billed

Providers charge by the token. A token is a small piece of text, often part of a word. Tokens shows how text is split into them. For now, an estimate is enough.

Many models also think before they answer. They write hidden reasoning first, then the answer you see. Those thinking tokens are billed as output tokens, even when you never see them.3 Claude Haiku 5.5 thinks by default.3

Check yourselfAnswer in your head first, then reveal
Tomás’s summary is 150 tokens long. Could the thinking Haiku does before writing it cost more than the summary itself?Show answerHide answer
Yes. Thinking is billed at the output price, and a model can easily think for more tokens than it writes. In the estimate below, the assumed 300 thinking tokens cost twice as much as the 150-token summary.

Here is the formula for one call:

Cost of one call=input tokens×input price+output tokens×output price
Output tokens = thinking tokens + the text you see. Prices are per million tokens.

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 One summary is one call. This estimate leaves out retries and new summaries after new messages arrive.

A typical long ticket

Input: 24 messages × 150 tokens + 200 tokens of instructions = 3,800 tokens. Output: 300 thinking + 150 summary = 450 tokens

The thinking count is an assumption. Each response reports the real number in usage.output_tokens_details.thinking_tokens.

One typical summary on Claude Haiku 5.5

3,800 × $0.10 ÷ 1,000,000 + 450 × $0.50 ÷ 1,000,000 = $0.00038 + $0.000225 ≈ $0.0006

Leave the thinking out and the estimate is about a quarter too low.

A very long ticket

Input: 80 × 150 + 200 = 12,200 tokens. Output: 1,000 thinking + 250 summary = 1,250 tokens. Cost: $0.00122 + $0.000625 ≈ $0.0018

More text to read usually means more thinking too.

Every summarized ticket, every day

30,000 typical × $0.000605 + 10,000 very long × $0.001845 ≈ $18 + $18 ≈ $36 a day

One summary per ticket. Retries and new summaries as tickets grow add to it, and it is paid again every day.

Estimates for this lesson: 150 tokens a message, 40,000 summarized tickets a day out of 120,000 (one in four of them very long), and the thinking token counts.

Diagram not drawn yet: one-summary-cost-breakdown.svg

One horizontal bar showing the cost of one typical summary on Claude Haiku 5.5, about $0.0006. Input, 3,800 tokens: $0.00038, about 63%. Thinking, 300 tokens: $0.00015, about 25%. Summary text, 150 tokens: $0.000075, about 12%. The thinking segment is twice as wide as the summary segment.

Where the money goes in one typical summary. The thinking you never see costs twice as much as the summary you read.

Every price on Claude Opus 5.5 is 40 times the Haiku price, as of October 2026.2 With the same token counts, the same summaries would cost about $1,440 a day. So cost is a design input from the first prototype. Estimating the cost and latency of a feature builds full estimates, and Module 10 covers the ways to cut them: prompt caching, batch processing and sending easy work to smaller models.

Every call takes seconds

Here is where the time goes when Deskora makes one summary:

Example timings, not measurements.

The model call is about 99.7% of the . Its time grows with the size of the model and the length of the prompt and the response.1 Thinking tokens are written too, so they add time as well as cost.

So the summary is made before Priya opens the ticket

All three habits point to the same choice. If the summary were made when Priya opens a ticket, she would wait about 4 seconds every time. Each open would cost another call. Two agents could read two different summaries.

Diagram not drawn yet: summary-on-open-vs-in-background.svg

Two panels. Left, on open: Priya opens a ticket, the server calls the model, and she waits about 4 seconds; a second agent opening the same ticket triggers another paid call and may see different text. Right, in the background: a new customer message arrives, a background job calls the model and saves the summary; when Priya opens the ticket, the saved summary loads at once and every agent sees the same text.

Making the summary in the background removes the wait, pays once per change instead of once per view, and shows every agent the same text.

So Tomás makes the summary in the background when a new message arrives, saves it, and shows the saved copy. The design lesson at the end of this module works through it in full.

Correct means “good enough, often enough”

Tomás writes a unit test. It summarizes one saved ticket and compares the result with an expected paragraph. It fails on the next run, even though the new summary is fine. The words changed; the facts didn’t.

So the team tries something else. Priya and two other agents pick 40 real long tickets. For each one, they write down what the next agent must know: what was promised, whether a refund or replacement was agreed, and the customer’s latest question. Then they check each summary for those facts.

The prototype passes 34 of 40, or 85%. Most of the six failures drop a promise, as with Halima’s Friday replacement.

The 40 tickets and the 34 passes are example numbers.

That process is an eval: run the feature on many realistic inputs and score each output. Now the team has a number to improve, not a feeling from one demo. When Tomás changes his instructions or the model, he runs the eval again. Unit tests still check the code around the call. Evals shows how to build one.

Try it yourself

You can see all three habits with one command. You need a Claude API key in ANTHROPIC_API_KEY; if you don’t have one, skip this. Run it twice:

bash
curl https://api.anthropic.com/v1/messages \
  -s -w "\nseconds: %{time_total}\n" \
  -H "content-type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2026-10-21" \
  -d '{"model": "claude-haiku-5-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "Summarize this support ticket in one sentence for the next agent. Customer: My blender arrived cracked. Agent: Sorry! We will send a replacement by Friday. Customer: Thanks. Can I have the tracking number?"}]}'

An example of what one run might return, shortened:

text
{"type":"message","role":"assistant","model":"claude-haiku-5-5",
 "content":[...,{"type":"text","text":"The customer's blender arrived cracked; a replacement was promised by Friday and they now want the tracking number."}],
 "stop_reason":"end_turn",
 "usage":{"input_tokens":71,"output_tokens":164,"output_tokens_details":{"thinking_tokens":131}}}
seconds: 2.3

Compare the two runs. The text will probably be worded differently. In usage, thinking_tokens shows how much of output_tokens was thinking, and you pay for all of output_tokens. The seconds line is far longer than a typical web request.

One run is under 100 input tokens and at most 1,024 output tokens, thinking included. On Claude Haiku 5.5, as of October 2026, that is at most about $0.0005.

An AI feature is five steps around one call

Tomás’s prototype was one call. The feature Priya uses has five steps, and the model call is only one of them.

Diagram not drawn yet: ai-feature-five-steps.svg

Five boxes from left to right. 1, product input: the ticket from Deskora’s database. 2, prompt and context: instructions plus the ticket text. 3, model call: the provider’s model API, about 4 seconds, which thinks and then writes. 4, check the output: not cut off, not empty, short enough. 5, show it in the product: the saved summary above the ticket, labelled as AI-written. A dashed arrow from step 4 shows the fallback: if the check fails, show the ticket without a summary. Steps 1, 2, 4 and 5 are grouped as Deskora’s code; step 3 sits outside as the provider.

Every AI feature has these five steps. Four of them are your own code.

The prompt is everything you send the model in one call. Here it is Tomás’s instructions plus the ticket text, which is the context the model needs.

Step What it does for the summary What can go wrong
1. Product input Loads the ticket and removes email signatures and quoted old replies A 400-message ticket is too long to send
2. Prompt and context Puts the instructions and the ticket into one prompt Vague instructions give summaries that skip promises
3. Model call Sends the prompt to the provider and waits Slow replies, errors, a cut-off answer
4. Check the output Rejects a summary that is cut off, empty or too long A summary states something the ticket never said
5. Show it in the product Saves the summary and shows it above the ticket A missing summary breaks the page

Step 3 has one trap worth knowing now. Each call sets a ceiling on output tokens, and thinking counts toward it.3 If the ceiling is too low, thinking can use it up before any summary is written. Step 4 catches that answer instead of showing it.

Here is the whole feature as a short sketch. Calling a model API explains each field of the call.

python
import anthropic

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY from the environment


def summarize_ticket(messages: list[dict[str, str]]) -> str | None:
    # 1. Product input: the ticket as plain text
    ticket = "\n".join(f"{m['author']}: {m['text']}" for m in messages)

    # 2. Prompt and context: instructions plus the ticket
    prompt = (
        "Summarize this support ticket for the agent who replies next. "
        "Use at most 5 short bullet points. Include every promise, refund "
        "or replacement already agreed, and the customer's latest question.\n\n"
        f"<ticket>\n{ticket}\n</ticket>"
    )

    # 3. Model call: max_tokens covers thinking and the summary together
    response = client.messages.create(
        model="claude-haiku-5-5",
        max_tokens=1024,
        messages=[{"role": "user", "content": prompt}],
    )

    # 4. Check the output: no summary is better than a cut-off or bloated one
    if response.stop_reason != "end_turn":
        return None
    text = "".join(b.text for b in response.content if b.type == "text").strip()
    if not text or len(text.split()) > 120:
        return None
    return text


# 5. Show it in the product: a background job saves the result, and the
# ticket page shows it, or shows the ticket alone when this returns None.

The model call is about five lines. The rest is ordinary engineering, and it decides whether agents can trust the feature.

Where this shows up

The diagram shows the model as one box at the provider. The AI application stack opens that box, from the model itself to the servers that run it and the code you write around it.

Common mistakes

  • Trusting one good demo. One good summary says little about the next thousand. Score the feature on many real inputs before launch.
  • Comparing exact text in tests. Good answers change wording between runs. Check facts, length and format instead.
  • Leaving thinking out of the estimate. Thinking is billed as output, so a typical-case estimate without it can be a quarter too low.
  • Setting a tiny output ceiling because the answer is short. Thinking shares that ceiling and can use it all. Leave room, and check for cut-off answers.
  • Showing raw output with no fallback. When the check fails or the call errors, show the ticket without a summary, not a broken page.

Check your understanding

Check yourselfAnswer in your head first, then reveal
A Deskora engineer trains a model on two years of labelled tickets so each new ticket goes to the right team. Is that AI engineering?Show answerHide answer
It is ML engineering, because the work is training and running a model on Deskora’s own data. The ticket summary is AI engineering, because it builds on a pretrained model the team didn’t train.
Check yourselfAnswer in your head first, then reveal
Tomás’s cost estimate counts 3,800 input tokens and the 150-token summary, and nothing else. Haiku thinks for about 300 tokens on each summary. Is his estimate too high or too low, and by how much?Show answerHide answer
Too low, by about a quarter: $0.000455 instead of about $0.0006 per summary. The 300 thinking tokens are billed as output tokens even though nobody sees them.
Check yourselfAnswer in your head first, then reveal
A teammate wants to make the summary each time an agent opens a ticket, so it is always fresh. Name two things that get worse.Show answerHide answer
Agents wait about 4 seconds on every open, and every open is another paid call. Two agents can also read differently worded summaries of the same ticket. Making it in the background when a message arrives keeps it just as fresh.
Check yourselfAnswer in your head first, then reveal
Some summaries come back empty, with a stop reason saying the output limit was reached. The ceiling is 150 tokens, the length of a summary. What happened?Show answerHide answer
The model’s thinking counts toward the same ceiling, so it used up the 150 tokens before any summary was written. Raise the ceiling to leave room for thinking, and keep the check that rejects cut-off answers.

Summary

  1. AI engineering turns a pretrained model into a product feature. To make one model call trustworthy, you build the input, the prompt, the check and the product step around it.
  2. AI research finds new methods and ML engineering trains models for a task. They are different jobs, not levels.
  3. A model call can return different text for the same input, costs money every time and takes seconds. Design for all three.
  4. Thinking tokens are billed as output and share the output ceiling, so every cost estimate on a thinking model includes them.
  5. You know an AI feature works when an eval scores it on many real examples, not when one demo looks good.

Report a mistake

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