Originally published on the SandBase Blog .
If your support bot sends every message to a frontier model, most of the bill pays for questions like "how do I reset my password?". The fix is a two-step call: a cheap model answers first and flags the messages it should not handle, and only those go to a stronger model. This tutorial builds that in about 30 lines of Python against one OpenAI-compatible endpoint, then reports what a 10-message run actually cost. The routing logic is yours; SandBase supplies one key and one base URL for both models.
Key takeaway
Pattern: google/gemini-3.5-flash-lite answers first and returns JSON with an escalate flag. If the flag is true, the same message is re-asked to anthropic/claude-sonnet-5.5 .
In a 10-message run on 2026-11-22 (6 easy, 4 hard), routing cost $0.0205 against $0.0287 for sending everything to Sonnet 5.5, 29% less. The six easy messages cost 87% less.…