Stage 2 · Build · Intermediate
Build with LLM APIs
Call a language model from your own Python code and build features that hold up. Make your first API call, manage conversations and streaming, get validated structured output, give the model tools safely, handle errors and cost, and test and secure an LLM feature.
7 lessons · 13 hr 30 min · Free
You will learn to
- ▸Make a call to the Claude API with the official Python SDK, keep the key safe and set a spend limit
- ▸Build conversations, use system prompts, control length and effort, and stream responses
- ▸Get validated structured output with Pydantic and check it before using it
- ▸Give a model tools, run the tool loop and design tools that are safe to expose
- ▸Handle errors, rate limits and spend caps, log usage, set budgets and reduce cost
- ▸Unit test with a fake client, build a small eval, and defend against prompt injection and leaked secrets
Before you start
- ·Comfortable with Python, JSON and calling web APIs, as taught in Python and Data Essentials
- ·Recommended: Working with LLMs, for prompting and for checking model output
- ·Python 3.10 or newer, and an account with a small amount of credit for the Claude API
Syllabus
- 01Your first API callAccounts, keys, the SDK, reading a response, tokens and cost.1 hr 30 min
- 02Conversations, control and streamingHistory, system prompts, limits, effort, streaming and what no longer works.1 hr 30 min
- 03Structured outputPydantic schemas, validated results, checks and business rules.1 hr 30 min
- 04Tool useThe tool loop, safe tool design, approval gates and the tool runner.2 hr
- 05Reliability and costErrors, retries, spend caps, usage logging, caching and batches.1 hr 30 min
- 06Testing and safetyFake-client tests, small evals, prompt injection, secrets and privacy.1 hr 30 min
- 07Capstone: a support ticket assistantBuild, test and evaluate a triage and reply assistant.4 hr