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 2 of 2

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.

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 same requests with three small guards
Sign in to run this example in your browser.

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