Production AI, lesson 14
Capstone: a service with routing, fallbacks and monitoring
Run an AI service that stays up and within budget.
This walkthrough uses ideas from across the module: routing, fallbacks, spending limits, caching, filters, monitoring and alerting. Each part has its own lesson, so if a step feels quick, the lesson with that name has the detail.
Part 1. The system on a normal day
Here's a support assistant for an online shop, about 3,000 questions an hour. About 70% are simple (opening hours, delivery times, how returns work) and go to a small model. The rest, mostly billing and order problems, go to a large one. Prices below are examples.
Example 1.1
The layers every question passes through
- gatewaysign-inper-user token bucketmonthly quota
The front door. Nobody can flood the system, and every request gets an id that follows it everywhere.
- input checkmask card numbersmoderationtopic check
The safety boundary on the way in.
- cachesexact→semantic (general questions only)
Repeated general questions are answered here, with no model call. Questions about a customer's own order skip the shared cache.
- routersmall: 70%large: 30%fallback chainretriescircuit breakersecond provider
Pick the model, and know where to go if it fails.
- output check→customerrecordslogmetricstrace
Check the answer before it's shown, and record everything about the call.
Your turn
Why does the cache sit before the router and the model, not after?
The injection lessons shaped it too. The model reads customer messages, which anyone can write, and order data, which is private. So its one tool, lookup_order, only returns orders on the signed-in customer's account, refunds go to staff for approval, and the chat window loads no outside images or links. There's no way out for stolen data, whatever text gets in.
Part 2. Following one question through
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- Following one question through
- A bad day: the main provider goes down
- What the records show afterwards
Production AI overviewSpotted a mistake? Tell us.