CH 04 · Model-Provider Abstraction and Multi-Model Strategy · 01/15
Read as one pageModel-Provider Abstraction and Multi-Model Strategy
Decoupling an agent from one model provider takes an adapter pattern and a validated registry. Covers tiering models by task and cost.
15 slides · 14 min read
In this chapter
- 01Why decouple
- 02What makes providers hard to abstract
- 03Real code: pi rewrites a turn from another model
- 04The adapter pattern
- 05Real code: one interface every provider implements
- 06Keep the adapter thin and domain-free
- 07A model registry and validation
- 08Real code: LiteLLM reads the provider from the name
- 09Model tiering: the multi-model strategy
- 10Real code: a small model writes the chat title
- 11Reasoning/thinking as a per-call decision
- 12Real code: Anthropic maps one reasoning level
- 13What you gain
- 14Read the source yourself
The model you build on today will not be the best model in six months, and the best model for one task is rarely the best for another. Both facts point to the same architectural decision: decouple your agent from any specific model provider. This chapter explains why, how to do it cleanly, and how to route work intelligently across model tiers.
Finished this idea?
Your learning progress stays in this browser.