ProjectBuild an AI-Powered Digital Bank with RAG: the explanation · Module 11: Model routing: two models, one answer · part 13 of 20
Part 13 · Module 11: Model routing: two models, one answer
Module 11: Model routing: two models, one answer
22 min read·
About 35 minutes · Needs: Module 1 (kinds of questions) and Module 10 (the agent graph) · Code: backend/app/agent/router.py, backend/app/agent/llm.py, backend/app/observability/costs.py
Where this fits
The router sits between the guardrails and the agent (blue: this module's parts); its decision picks the model, and every call's cost lands in observability.
Every message passes the input guardrails and reaches the router before the agent calls any model. The router picks the model for this turn, the agent can change that mid-turn, each model has a fallback provider, and every call's cost lands in observability.
The rest of this project is yours to keep
This project is bought on its own, once, and stays readable afterwards, including the parts added to it later.