Intermediate level · Module 2 of 6 · 16 guided hours
Working with AI Model APIs
Call large language model APIs from Python, control their behaviour, get structured outputs and manage cost.
Learning objectives
- Send messages to language model APIs and handle responses
- Request structured outputs and validate them
- Estimate and control cost, latency and rate limits
Topics
- chat message format and roles
- model parameters
- structured (JSON) outputs
- validation
- tokens, cost and latency
- provider choice and data policies
Lessons
-
Lesson 1 Calling a Language Model API
Send a conversation to a language model API and read its reply.
system messageuser and assistant messagesmodel parameterstoken usage
-
Lesson 2 Structured Outputs
Get machine-readable JSON from models and validate it before using it.
JSON schemastructured outputvalidationfallbacks
-
Lesson 3 Cost, Latency and Provider Choice
Estimate and control the cost and speed of AI applications, and choose providers responsibly.
token pricinglatencycaching and batchingdata policies and location
Practical activity
Build a script that turns free-text feedback messages into structured records (topic, urgency, location) with a language model API, validating every result and logging the cost.
Expected outcomes
- Working model API integrations
- Reliable structured outputs within budget
Assessment
Practical marked on correct API use, output validation and cost reporting.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.