Insights/Engineering
2 MIN READ4 MARCH 2026Engineering

Cost-routing prompts across providers (without the framework).

A tiny router that decides which model handles each prompt, by latency, cost and an eval gate. 90 lines of Go. Six months in production.

AK
Anantha Krishnan G
Software Engineer

We were sending prompts to our most expensive model that didn't need it. We were also hitting rate limits at the worst times. The fix wasn't a framework. It was 90 lines of Go.

What the router does.

Every prompt has metadata: importance, max latency, max cost. The router picks the cheapest model that meets all three, with a fallback chain if the chosen provider is degraded.

The eval gate.

Before any prompt template goes live, we run it against a frozen eval set on each candidate model. The router only routes to models that pass, for that specific template.

What it cost to build, and what it saves.

Two engineer-days. It saves around $150 a day of routed model spend on average across our products. Plus a latency benefit we didn't predict: sending the 80% of prompts that don't need the largest model to a smaller one halves the wall-clock time.

Why not an off-the-shelf framework?

Because we don't need the surface area. The router is 90 lines, six months in production, zero dependencies. We'd rather own the code than learn an abstraction.

Want to talk about something you read?

Aria is in the bottom-right corner, or just send the team an email.

Email the team