Free tutorial · 25 lessons
AI Engineering Tutorial
Build features on large language models: tokens and context windows, messages and system prompts, API calls, streaming, clear prompts and examples, structured output, tool calling, agent loops, MCP, embeddings, chunking, vector search and RAG, evaluations, guardrails, cost, caching and logging. Every example is Python you can run in the browser, with a stub model instead of an API key.
LLM Basics
- What Is AI Engineering? — What AI engineers build, how it differs from machine-learning research, and what this tutorial covers.
- Tokens and Context Windows — How models read text as tokens, what the context window limits, and why tokens drive cost and latency.
- Messages, Roles and System Prompts — How a chat request is structured: the system prompt, user and assistant messages, and how conversation history works.
- Calling an LLM API — What a real API call looks like, the parts of the response, and how to keep keys safe.
- Model Choice, max_tokens and Temperature — The few parameters that matter most: which model, how long the answer may be, and how random it is.
- Streaming Responses — Show answers as they are generated, so users see progress in under a second instead of waiting for the whole reply.
- AI Engineering: Origins & Evolution — How building with language models became its own engineering discipline: from the Transformer paper to APIs, retrieval, tool calling, agents and the Model Context Protocol.
Prompting
- Writing Clear Prompts — Prompts that work: context, a specific task, constraints and a defined output format.
- Examples in Prompts (Few-Shot Prompting) — Show the model two or three examples of input and ideal output; it copies the pattern more reliably than it follows a description.
- Structured Output and JSON Validation — Get JSON your code can use, and validate it, because model output is untrusted input.
- Prompt Templates and Variables — Keep prompts in versioned templates with clearly marked variables, and escape user input inside them.
Tools and Agents
- Tool Calling — Let the model ask your code to run functions (look up an order, search docs) and use the results in its answer.
- A Minimal Agent Loop — An agent is a loop: call the model, run the tools it asks for, send results back, repeat until done, with limits.
- MCP in Five Minutes — The Model Context Protocol lets any AI app discover and call tools from servers you write once.
- Retries, Timeouts and Rate Limits — LLM APIs fail sometimes: rate limits, overload and timeouts. Retry the right errors with backoff, and set timeouts.
Retrieval (RAG)
- Embeddings and Similarity — Embeddings turn text into vectors so that similar meanings are close together; cosine similarity measures how close.
- Chunking Documents — Split documents into chunks that each make sense on their own, keeping headings so every chunk has context.
- Vector Search From Scratch — Store chunk vectors, embed the question, return the top-k most similar chunks; then see why keyword search still matters.
- A Minimal RAG Pipeline — Retrieval-augmented generation end to end: retrieve chunks, put them in the prompt, ask for a grounded answer with citations.
Quality and Production
- Evaluating Outputs — Measure quality with a small evaluation set and graders, instead of trying a few prompts by hand.
- Guardrails: Checking Input and Output — Screen risky input, validate output, keep secrets out of prompts, and limit what the model can do.
- Estimating and Controlling Cost — Estimate cost per request and per month, and know the levers: model choice, context size, output length and caching.
- Caching: Prompts and Responses — Two kinds of caching: prompt caching inside the model API, and caching whole responses in your app, with care.
- Logging and Tracing LLM Calls — Log what you need to debug and to control cost: model, prompt version, tokens, latency, stop reason, tool calls.
- Where to Go Next — Courses, tutorials and practice to go deeper into AI engineering.