Build real, AI-powered Python applications by calling LLM APIs the right way — keys from environment variables, reusable prompt templates, structured JSON output, a chatbot loop, and an AI feature inside a Flask app. You will also make your app robust and safe with retries, prompt-injection guards, and token and cost logging. This is a practical, hands-on course that assumes you can already write intermediate Python.
Watch the free preview
Your first LLM API call — and keeping secrets safe — free to watch, no account needed.
What you'll learn
- Call an LLM API from Python with an openai-style client and keys loaded from environment variables
- Build reusable prompt-template functions and request structured JSON output your program can parse
- Implement a chatbot loop that maintains conversation state and a keyword retrieval step before the prompt
- Add an AI-powered summariser feature to a Flask application
- Guard against prompt injection, handle API errors with retries, and log token usage and cost
Syllabus
Calling LLM APIs from Python
Your first LLM API call — and keeping secrets safeFree preview
Prompt templates — reusable, parameterised prompts
Structured Output and Conversations
Structured JSON output your program can parse
A simple chatbot loop with memory
Retrieval and Flask Integration
Tiny retrieval before the prompt
Adding an AI feature to a Flask app
Robust and Safe AI Apps
Errors, retries and rate limits
Prompt-injection guarding and logging tokens and cost
Lab — 10 Programming Exercises & Solutions
Programming Exercises 1–5
Programming Exercises 6–10