Part 1 of 5 · 1 min read
Overview
In this module you will
- Explain why an app should not call a provider's SDK from everywhere.
- Design neutral request, response and error types.
- Write an adapter that translates both ways, and test it without a network.
- Route between providers with a fallback that knows when not to fall back.
Providers disagree on small things: where the system prompt goes, whether max_tokens is required, what the reply looks like, how errors are shaped, and what "stopped because of length" is called. If those differences leak across your code, switching or adding a provider means editing everything, and a fallback to a second provider (module 5) is hard to write cleanly. A thin layer keeps the differences in one small place.
About the examples
The two "providers" are imitations (wire.py). Their formats are simplified illustrations of the general shapes real chat APIs use. Real field names, limits and error bodies differ, so when you write a real adapter, copy the shapes from the provider's current documentation, not from here. No real API was called.