Week 06 / Model APIs · private credentials · output checks
Add one AI capability.
The idea
A model API can classify or summarize input, but its output can be wrong. Keep API credentials on the server, send only the data needed, and validate the response before another part of your program uses it.
Validate structured output
import json
def parse_summary(raw):
result = json.loads(raw)
if not isinstance(result.get("summary"), str):
raise ValueError("Expected a summary string")
return result["summary"]Build it
Work through these steps in your own project. Check them off as you go; your checklist stays in this browser.
What could the model get wrong, and how does your program detect or contain that?
Notes save in this browser.