Model Router

Wide Model Router diagram showing a task routed to Claude along a green path, with ChatGPT, Claude, Gemini, Llama and Mistral logos
CompletedOpen source

Summary

While we know that all of the AI labs are chasing to be the first to reach AGI, it is not a secret that certain models are better at handling certain tasks than others. Instead of trying to fit the task to just one model from one lab, this project explores the possibility of fitting the model to the task. This model router reads the task given to it and routes it to the model that is best equipped to completing the task at the lowest cost.

Problem

Every project I built was revolved around one model with one provider and I was unsure if I was using the correct one and if I was burning unnecessary tokens to accomplish the tasks.

How it works

Every call names a task (a “route”) instead of a model, and the router looks up which model and effort level that route runs on. The choice is made ahead of time and keeps getting checked against new models and real work.

  1. A public leaderboard (Artificial Analysis, with LMArena as a backup) narrows the field. A model moves on only if it ranks at or above the current model’s tier or costs less, and only the top two or three per task make the cut.
  2. Those candidates and the current model each answer five real examples of the task. I read the answers side by side and keep or drop each candidate.
  3. The one that survives runs next to live work. On a share of real requests it answers alongside the current model and both answers get graded, but the current model’s answer is still the one that gets used.
  4. Once there are enough graded pairs to tell the two apart, the router recommends a switch or a tie and writes the config change. Nothing changes until I approve it.

Stack

Python, Anthropic SDK, Claude Code CLI, SQLite, YAML, openpyxl, ReportLab, pytest