The same requests with three small guards
One retry, cutting JSON out of extra text, and a safe fallback. Phases 4 and 6 build the production versions.
A demo calls the model once and works. A product makes thousands of calls and meets rate limits, timeouts, broken formats, wrong answers, attacks and model updates. Each failure has a known engineering fix, and this course teaches them in order.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write is_retryable(status) that returns True for 408, 429 and any 5xx status, and False otherwise.
Write extract_json_object(text) that returns the parsed object from the first { to the last }, or None if that slice doesn't parse.
Explain it without notes
List five ways a model call can fail in production, split into loud and quiet failures.
Why can a feature pass every manual test and still fail daily in production?
Which errors should you retry, and which shouldn't you?
Expected output
request 1: positive
request 2: negative (retried after rate limit)
request 3: negative (cut JSON out of extra text)
request 4: positive (retried after timeout)
request 5: unknown (no JSON, used fallback)
0 of 5 requests crashed; 1 answered with the fallback