Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 0.4 — Why "Just Call the API" Fails in Production
LLM Engineering · Example 1 of 2

The demo, replayed against real-world responses

A scripted fake API replays five kinds of real responses. The demo code has no guards.

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.

01

Write is_retryable(status) that returns True for 408, 429 and any 5xx status, and False otherwise.

02

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

01

List five ways a model call can fail in production, split into loud and quiet failures.

02

Why can a feature pass every manual test and still fail daily in production?

03

Which errors should you retry, and which shouldn't you?

The demo, replayed against real-world responses
Sign in to run this example in your browser.

Expected output

request 1: positive
request 2: CRASH (rate limited, HTTP 429)
request 3: CRASH (reply was not valid JSON)
request 4: CRASH (timed out)
request 5: neutral
3 of 5 requests crashed the demo