Generative AI & Agents
This course moves from calling a model to building software around it. You will write an LLM app with proper error handling, stream and batch requests, give a chatbot memory that fits in the context window, let a model call your functions, wrap that in an agent loop with stop conditions, add human approval for risky actions, and evaluate the whole thing like an engineer. Every core idea runs offline with simulated models, and each lesson shows the live API version too.
What is generative AI?
Models that produce new content — text, code, images, audio — by learning the patterns in large datasets. In this course “the model” means a large language model (LLM) that takes text (and optionally images) in and produces text out.
A program that uses an LLM as one component: your code prepares the input, calls the model, checks the output, and decides what happens next. The model generates; your application is responsible for everything else.
An LLM application in which the model decides, step by step, which actions to take — which tools to call and with what arguments — to reach a goal, observing each result before choosing the next step.
Most valuable AI products are not fully autonomous agents. They are well-engineered applications that use a model for the parts that need language understanding, and plain code for everything that needs to be reliable. This course teaches you both — and how to choose.
From prompt to agent
| Level | What the model does | Example |
|---|---|---|
| Single call | Answers one prompt | Summarise an email |
| Chat app | Answers with conversation history | Support chatbot |
| Workflow | Fills fixed steps that your code orchestrates | Classify a ticket, then route it, then draft a reply |
| Tool-using app | Requests function calls; your code runs them | “What's the status of order A-1001?” |
| Agent | Chooses tools in a loop until the goal is met | Research a question across several documents and cite sources |
Each level adds capability and risk. A wrong answer from a chatbot is text; a wrong decision from an agent can be an email sent, a row deleted, or money charged. That is why the later lessons focus on stop conditions, approval, and evaluation.
What you will learn
| Lesson | What you learn |
|---|---|
| Your first LLM app | Clients, configuration, a reusable ask() function, token and cost tracking, retries, and error handling. |
| Streaming and batch | Streaming tokens to users, time to first token, concurrent requests with asyncio, and the Batch API for offline jobs. |
| A chatbot with memory | Message history, trimming to a token budget, summary memory, persistence, and long-term memory. |
| What are AI agents | Agents vs workflows, the agent loop, common workflow patterns, and when not to build an agent. |
| Tool calling | Tool schemas, the request–execute–respond cycle, a tool registry, validation, and error handling. |
| ReAct agents | The reason–act–observe loop, a complete agent from scratch, stop conditions, and budgets. |
| Human in the loop | Risk tiers, approval gates enforced in code, editing actions, audit logs, and pause/resume. |
| Evaluating LLM apps | Eval sets, output and trajectory checks, LLM-as-judge, tracing, and regression gates. |
| Project: a research agent | A complete agent that searches, reads, and answers with citations under a step budget. |
Prerequisites
- Comfortable Python: functions, classes, dicts, JSON, and basic
asyncio(Python for AI Developers). - Messages, roles, tokens, and temperature (LLM Fundamentals).
- Helpful: structured outputs (Prompt Engineering) and retrieval (Building RAG Systems).
python -m pip install openai python-dotenv
Key terms
| Term | Meaning |
|---|---|
| Client | The SDK object that sends requests to a model provider's API. |
| Streaming | Receiving the reply token by token as it is generated, instead of all at once. |
| Memory | Information from earlier turns or sessions that the app sends back to the model. |
| Tool (function) | A function your code exposes to the model with a name, description, and JSON Schema for its arguments. |
| Tool call | A structured request from the model to run a tool with specific arguments. |
| Agent loop | Repeat: model chooses an action → code runs it → result goes back to the model, until done. |
| Trajectory (trace) | The full record of an agent run: every model call, tool call, argument, and result. |
| Human in the loop (HITL) | A design where a person must approve, edit, or reject certain actions before they happen. |
Code in this course uses small simulated models — plain Python functions that return what a model would — so you can run every example offline and see exactly how the surrounding application behaves. Where a live API version differs, it is shown separately and labelled.
Course syllabus
Work through the lessons in order. Your progress is saved in this browser as you mark lessons done.
Syllabus