@@ -52,6 +52,29 @@ because the simple tasks don’t benefit from the more expensive model.
5252
5353The simplest approach. Define rules based on task type:
5454
55+ ``` python
56+ ROUTING_RULES = {
57+ " code_generation" : " claude-sonnet-4.6" ,
58+ " code_review" : " claude-sonnet-4.6" ,
59+ " summarization" : " gpt-5.2-mini" ,
60+ " translation" : " gpt-5.2-mini" ,
61+ " data_extraction" : " gpt-5.2-mini" ,
62+ " complex_reasoning" :" claude-opus-4.6" ,
63+ " math_proof" : " claude-opus-4.6" ,
64+ }
65+
66+ def route (task_type : str , fallback : str = " claude-sonnet-4.6" ) -> str :
67+ return ROUTING_RULES .get(task_type, fallback)
68+ ```
69+
70+ Rule-based routing works when you know your task types upfront and can
71+ measure which model performs best for each. The mapping is explicit,
72+ auditable, and cheap to evaluate. The downside: every new task type
73+ requires a manual decision. If your task taxonomy changes often, you
74+ spend more time maintaining rules than saving on inference.
75+
76+ Start here. Most teams never need anything more complex.
77+
5578** Architecture 2: Cascade Routing**
5679
5780Cascade routing is the most cost-effective routing strategy. Instead of
0 commit comments