What is an AI Engineer? (AI Engg #1)
You are hired as an “AI Engineer” at a 200-person SaaS company. Day one, the CTO says: “Customers want to ask questions over their own docs, draft replies, and auto-triage tickets. Make it shippable in six weeks.” Nobody hands you GPUs. Nobody asks you to train a Transformer. They hand you an OpenAI key, a Postgres dump, and a Slack channel full of feature requests.
That is AI engineering. Not inventing intelligence — productizing it.
This chapter explains what the role actually is, how it differs from ML engineering and prompt hacking, what systems you own end to end, and the mental model this whole course runs on. By the end you will be able to draw the stack from memory, explain why context and evals beat model size, and scope a real feature into shippable parts.
The definition, precisely
AI engineering is the discipline of building production software whose core logic is performed by frozen foundation models (LLMs, embedding models, vision/audio models), composed with retrieval, tools, memory, and evaluation.
Unpack every word:
- Frozen foundation models. You do not train GPT-4, Claude, Gemini, or Llama from scratch. You call them. Training a frontier model costs tens of millions of dollars and a research lab. Calling one costs fractions of a cent. The economic fact defines the role.
- Core logic performed by the model. In classical software, an
ifstatement decides. In AI features, the model decides: which category, what summary, what SQL, what next action. Your code becomes scaffolding — preparing inputs, constraining outputs, handling failure. - Composed with retrieval, tools, memory, evaluation. A bare API call is a demo. Production is everything around it: fetching the right documents (RAG), giving the model functions it can call (agents, MCP), remembering state (context engineering), and proving it still works next month (observability, evals, regression tests).
If you remember one formula from this course, make it this one:
\[ \text{shipped value} = \text{model capability} \times \text{context quality} \times \text{eval coverage} \]
It is multiplicative. A state-of-the-art model with garbage context and zero evals ships zero value — confidently wrong answers, uncaught. A mid-tier model with excellent retrieval and 200 golden test cases ships real revenue. Your job, across all 18 chapters, is the two multipliers on the right.
\begin{tikzpicture}[font=\rmfamily, >=stealth,
b/.style={draw, thick, rounded corners=4pt, minimum width=2.6cm, minimum height=0.8cm, align=center},
a/.style={->, thick}]
\node[b, fill=blue!10] (u) at (0,0.5) {user + product};
\node[b, fill=orange!25] (e) at (0,-1.0) {AI engineer: glue + guardrails};
\node[b, fill=green!10] (m) at (-3,-2.6) {LLM API};
\node[b, fill=green!10] (r) at (0,-2.6) {retrieval};
\node[b, fill=green!10] (t) at (3,-2.6) {tools / MCP};
\node[b, fill=gray!10] (v) at (0,-4.0) {evals + traces + cost};
\draw[a] (u) -- (e);
\draw[a] (e) -- (m); \draw[a] (e) -- (r); \draw[a] (e) -- (t);
\draw[a, dashed] (m) -- (v); \draw[a, dashed] (r) -- (v); \draw[a, dashed] (t) -- (v);
\node[font=\rmfamily\small, text=black!65] at (0,-4.7) {everything wrapped in measurement};
\end{tikzpicture}
Read the diagram bottom-up: models, documents, and tools are interchangeable parts. The durable asset — the thing that survives a model swap from GPT-4o to Claude to Qwen — is the box at the bottom: your evals, traces, and cost dashboards.
AI Engineer vs ML Engineer vs Prompt Engineer
Titles are muddy, so let us fix them with a table and then with a story.
| Role | Trains models? | Main artifact | Typical stack | Hired when |
|---|---|---|---|---|
| ML Engineer | yes — trains/fine-tunes, runs GPUs | weights + training pipelines | PyTorch, CUDA, Ray, feature stores | you have data moats and need custom models |
| AI Engineer | no — composes frozen models | prompts + retrieval + agents + evals | OpenAI/Anthropic APIs, vector DBs, LangChain, MCP | you need LLM features in the product now |
| Prompt Engineer (narrow) | no | wording tricks | playground | never as a full-time role — it is a skill inside AI engineering |
Story: a support-ticket classifier.
- The ML-engineer answer (2019): label 50,000 tickets, train BERT, deploy on GPUs, monitor drift. Six months, needs labels and infra.
- The prompt-hacker answer (2023): paste three examples into ChatGPT, screenshot the answer. Ten minutes, unshippable.
- The AI-engineer answer (this course): define a JSON schema (
category, priority, summary), retrieve the customer’s plan + past tickets as context, call a cheap model with structured output, log every decision with its evidence, grade 200 goldens nightly, escalate low-confidence cases to a bigger model or a human. Six weeks, shippable, measurable.
Notice what the AI engineer did not do: no training loop, no GPU cluster. And what they did do that the prompt hacker skipped: schemas, retrieval, confidence routing, logging, evals. That gap — between demo and production — is the entire profession.
A word on “prompt engineering” as a job title: it is dissolving. By 2025–26 every roadmap (including roadmap.sh, which this course follows) demoted it from role to skill and promoted context engineering — curating everything the model sees — to the real work. Chapter 4 is devoted to it.
What you actually own: the full loop
Every AI feature you ship will walk the same loop. Learn it now; each chapter zooms into one box.
request → context assembly → model call → parse/validate → act → log → evaluate
Request. Who asked, with what permissions, under what tenant? You will attach end_user_id, tenant filters, and redaction before anything touches the model. Chapter 13 shows why: logs without scoping become leaks, and tools without scoping become privilege escalation.
Context assembly. The highest-leverage step. You gather system instructions, retrieved chunks, memory, tool schemas, conversation history — then fit them into a token budget (Chapters 3–4). Empirical law from Anthropic’s 2025 context-engineering guide and 2026 follow-ups: small context with the right tokens beats a 1M-token window stuffed with noise. You will learn retrieve → filter → compact → fit as a reflex.
Model call. Choosing open vs closed, cheap vs flagship, temperature and format (Chapters 2, 3, 5, 6). You will pin versions (gpt-4o-2026-05-01, not gpt-4o), set timeouts and retries, stream for UX, and cache static prefixes.
Parse and validate. Never trust raw text. Demand JSON Schema / function calls, re-try on schema failure, fall back deterministically. A one-line summary of this course could be: never eval() the model’s imagination.
Act. Write to the ticket system, send the draft, file the refund — through narrow, auditable tools (Chapters 11–12 on agents and MCP). Reads are free; writes need confirmation, idempotency keys, and dry-run modes.
Log and evaluate. Every run emits a trace: prompt hash, context IDs, model version, tokens, cost, latency, tool calls, score. Nightly evals compare against goldens; regressions page you like a 500 error (Chapter 13).
\begin{tikzpicture}[font=\rmfamily, >=stealth,
b/.style={draw, thick, rounded corners=4pt, minimum width=2.1cm, minimum height=0.7cm, align=center, font=\rmfamily\small},
a/.style={->, thick}]
\node[b] (q) at (-4.2,0) {request};
\node[b, fill=orange!20] (c) at (-2.1,0) {context};
\node[b, fill=blue!10] (m) at (0,0) {model};
\node[b, fill=green!10] (p) at (2.1,0) {parse};
\node[b] (ac) at (4.2,0) {act};
\node[b, fill=gray!10] (e) at (4.2,-1.5) {log + eval};
\draw[a] (q) -- (c); \draw[a] (c) -- (m); \draw[a] (m) -- (p); \draw[a] (p) -- (ac);
\draw[a, dashed] (ac) -- (e); \draw[a, dashed] (e) to[bend left=30] (c);
\node[font=\rmfamily\small, text=black!60] at (0,-1.5) {evals feed back into context};
\end{tikzpicture}
The dashed arrow matters most: evals rewrite context (better chunks, tighter prompts, new filters). Teams that close this loop weekly improve; teams that stare at dashboards do not.
The vocabulary you need on day one
You will meet these in every chapter. A first-pass definition now, depth later:
- Token. ~4 characters of English; the unit of pricing and fitting. Code and non-English inflate counts. Budgets are token budgets.
- LLM / foundation model. Next-token predictor at scale (Chapter 2). GPT, Claude, Gemini (closed); Llama, Qwen, Mistral, DeepSeek (open weights).
- Inference vs training. Training learns weights (millions of dollars). Inference runs them (your API bill). Fine-tuning is small continued training — good for style, bad for facts.
- Embeddings. Text → vectors where nearness means meaning (Chapter 8). The basis of semantic search.
- Vector database. Stores embeddings + metadata, answers filtered nearest-neighbor (Chapter 9). Chroma, FAISS, Qdrant, Pinecone.
- RAG. Retrieve evidence, then generate with citations (Chapter 10). The default cure for stale knowledge and hallucinations.
- Agent. A loop that picks tools until done (Chapter 11). ReAct, function calling, multi-agent teams.
- MCP. The 2026-standard plug for tools and data: host → client → server (Chapter 12).
- Observability / evals / regression tests. Traces, scores, and golden suites that catch semantic breakage when prompts, retrieval, or models change (Chapter 13).
\begin{tikzpicture}[font=\rmfamily, >=stealth,
c/.style={draw, thick, circle, minimum size=1.15cm, font=\rmfamily\small, align=center},
a/.style={->, thick, black!60}]
\node[c, fill=blue!10] (t) at (0,2) {tokens};
\node[c, fill=blue!10] (e) at (-2.4,0.4) {embed};
\node[c, fill=blue!10] (r) at (2.4,0.4) {RAG};
\node[c, fill=orange!20] (a2) at (-1.2,-1.6) {agent};
\node[c, fill=orange!20] (m) at (1.2,-1.6) {MCP};
\draw[a] (t) -- (e); \draw[a] (t) -- (r); \draw[a] (e) -- (r);
\draw[a] (r) -- (a2); \draw[a] (r) -- (m); \draw[a] (a2) -- (m);
\end{tikzpicture}
Open vs closed vs self-hosted: the decision you will revisit
- Closed APIs (OpenAI GPT, Anthropic Claude, Google Gemini): best reasoning and tooling today, per-token pricing, data leaves your network, versions drift. Default for prototyping and for hard reasoning.
- Open weights (Meta Llama, Qwen, Mistral, DeepSeek, Gemma): downloadable, fine-tunable, hostable in your VPC. Quality now rivals closed on many tasks; you pay in GPUs and ops instead of per-token bills.
- Small/local (3–8B quantized via Ollama / LM Studio): private, offline, ~$0 marginal cost. Perfect for PII-heavy drafts, classification, and dev loops.
The mature pattern is a router: cheap/small handles 80% (triage, drafts), flagship handles the uncertain 20%, with OpenRouter or your own gateway providing one API and fallbacks. Chapter 5 turns this into numbers; Chapter 6 gives you the local stack commands.
There is also a compliance axis people learn late: some contracts forbid customer text leaving your cloud. Know your data policy before you pick the model. Self-hosted open weights exist precisely for that row in the spreadsheet.
Your first ten lines (and what they hide)
Run this today. It is the seed every later chapter grows:
# day-one prototype: swap base_url/model to go local later (Chapter 6)
from openai import OpenAI
client = OpenAI() # or: OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")
resp = client.chat.completions.create(
model="gpt-4o-mini",
temperature=0.2, # low = factual; see Chapter 2
max_tokens=200,
messages=[
{"role": "system", "content": "You triage support tickets. Reply in 3 bullets."},
{"role": "user", "content": "Ticket #42: invoice is wrong, need fix before Friday!"},
],
)
print(resp.choices[0].message.content)
print(resp.usage) # tokens in/out — your bill starts here
What the snippet hides — your roadmap for the course:
- Where did the ticket’s history and plan come from? (Chapters 4, 9.)
- How do you guarantee 3 bullets as JSON, not prose? (Chapter 3.)
- What if the invoice number needs a database lookup? (Chapters 11–12.)
- How do you know Friday’s model update did not break it? (Chapter 13.)
- What did it cost × 100K tickets, and could Qwen-7B do it cheaper? (Chapters 5–7.)
How this course is organized
Eighteen chapters, one spine (mirrors roadmap.sh/ai-engineer.json, 279 nodes, plus the serving layer every production system needs):
- You are here — role, loop, vocabulary.
- How LLMs work — tokens, sampling, windows, fine-tuning.
- Prompt engineering — structure that controls output.
- Context engineering — the multiplier.
- Types of models — open/closed/self-hosted, routers.
- The open stack — Hugging Face, Ollama, LM Studio, OpenRouter.
- Serving at scale — prefill vs decode, KV cache, quantization, batching, prefix caching. 8–10. Embeddings → Vector DBs → RAG — the knowledge path. 11–12. Agents → MCP — the action path.
- Safety, observability, evals — the seatbelts.
- Multimodal — vision, audio, image.
- Dev tools + capstone — ship a graded project.
- System One models — typed, calibrated answers that cannot hallucinate.
- PageIndex — vectorless RAG: a document tree the model reasons over.
- DeepSeek — the papers, and what open weights changed about cost.
Each chapter ends with pitfalls (ways teams actually fail) and points forward. Exercises marked Try it need only Python + an API key or a laptop with Ollama.
Pitfalls (learned the hard way)
- Demo blindness. “It worked in the playground” is not shippable. No schema, no retrieval, no evals, no tenant scope — no launch.
- Model worship. Chasing the biggest model while context stays trash. Fix retrieval first; it is cheaper and usually sufficient.
- Evals later. Teams that postpone goldens past week two never add them. Write 20 on day one, 200 by launch.
- Unscoped everything. One shared index, one key, full history in prompts. Then a customer sees another customer’s docs. Scope tenants, redact PII, least-privilege tools from the start.
What is the AI engineer’s loop? Why is the value equation multiplicative? When would you choose a self-hosted 7B model over GPT-5?
ASolution
Request → context → model → parse → act → log/evaluate, with evals feeding back into context. Multiplicative because any zero (no context, no evals) zeroes the product regardless of model. Choose small/self-hosted when data cannot leave VPC, latency or marginal cost dominates, or the task is narrow enough that your goldens pass on 7B.
Next: How LLMs Work (AI Engg #2) — tokens, probabilities, and why temperature is not creativity juice.