M4: Ship your first AI app
This is the one you came for. Today you connect your Python to a real AI model and build a chatbot with its own personality, running in front of you, talking back. And because you built the last three modules, this won't be a magic black box: you'll understand every line, from the secret key to the reply on screen.
Today's win: a working AI chatbot you built and can read line by line, you give it a personality, and it remembers the conversation.
Today you will
- Get an API key, store it safely in
.env, and confirm it with one tiny call - Understand an LLM from a builder's view: you send messages, it sends a reply
- Build a minimal chatbot with a personality you choose
Run of show (~70 min)
| Time | What we do |
|---|---|
| 0:00 | Hook + the win we're chasing |
| 0:05 | The one idea: request → response, and what a key is (full read in notes.md) |
| 0:10 | Lab Part A: key → .env → confirm with a tiny call |
| 0:35 | Lab Part B: build and personalize the chatbot |
| 1:05 | Show: post a line of your bot's reply to the wins board |
| 1:10 | Wrap + take-home |
If you get stuck
- A red
AuthenticationErroralmost always means a key typo or a misnamed.env, re-read the API-key guide's troubleshooting box. Nothing here can harm your computer. - Your key is a paid secret. Keep it in
.env, never in your code, never in chat. If you ever paste it somewhere public, delete it in the Console and make a new one. - Re-read the You should now see line under each step. Compare with your breakout partner.
Instructor note: budget time for billing setup: students must add a little credit before any call works. Suggest everyone set a spend limit (a few dollars covers the whole course). The cheaper
claude-haiku-4-5model is a one-string swap for cost-sensitive practice (see notes).
Optional challenge
Give your bot a job: a patient Python tutor, a travel guide for one city, a pun machine. Change
only the SYSTEM text and watch its whole personality change, same code, different soul.