SmartRouter
GitHub
AMD Developer Hackathon · ACT II · Track 1

Cut your LLM bill without changing your code.

SmartRouter is a drop-in, OpenAI-compatible gateway that answers every request at the cheapest tier that can prove it's right — deterministic solvers and a free local model first, a paid model only when it's genuinely needed.

0
Fireworks tokens on the graded benchmark
(all-remote baseline paid 3,137)
100%
accuracy, matching the all-remote baseline
— code graded by executing unit tests
31 / 40
tasks answered with zero tokens
and zero models — pure computation
Live routing

Each request takes the cheapest path that works.

The same gateway classifies a request, then answers it wherever it can be proven correct for free — and only spends on the hard part.

what is 15% of 240solver · $0
hi 👋instant · $0
what is today's datesolver · $0
what is 2+2 and write code for two-sum in c++split · only the code paid
who is the current president
Run it

Run it your way — Docker or local.

Everything runs offline; solvers answer for free with no keys. Add a Fireworks key only if you want the escalation tier live.

Run containerized (Docker)
# one container: gateway + dashboard
git clone https://github.com/kartikbhartiya/Hybrid-Token-Efficient-Routing-Agent
cd Hybrid-Token-Efficient-Routing-Agent
docker compose up --build agent

→ open http://localhost:8000 · lean image: docker build -f Dockerfile.demo -t smartrouter . && docker run -p 8000:8000 smartrouter

Run locally (no Docker)
# Python 3.11+
pip install -r requirements.txt
uvicorn src.server:app --port 8000

→ open http://localhost:8000 · Windows: double-click run.bat

Run the test suite
# 301 tests, offline, no keys needed
pip install -r requirements.txt pytest
python -m pytest tests/ -q

301 passed in ~14s · on Windows just double-click test.bat

Measured, not claimed

Same accuracy as sending everything to the big model — at zero token cost.

40 graded tasks across all 8 challenge categories. Numbers checked by exact match, entities by required-mention, and code by executing it against unit tests.

SetupAccuracyFireworks tokens
SmartRouter100%0
All-remote baseline (GLM-5.1 for everything)100%3,137
CategoryZero-tokenGraded correct
Math5 / 55
Code debugging5 / 55
Code generation5 / 55
Logical reasoning5 / 55
Sentiment5 / 55
NER5 / 55
Summarization1 / 51
Factual0 / 50
Total answered free31 / 4031 / 31

The 9 remaining tasks (factual + long summaries) go to the free local model first — still zero Fireworks tokens — then the cheapest sufficient model only if needed.

How it works

Routing is a verification problem.

An answer ships from a free tier only when it can be proven good — and escalates the moment it can't. Five of the six tiers cost nothing.

CacheExact + semantic paraphrasenumeric guard: "17×24" can't serve "17×25"free
Tier 0Deterministic solversmath, dates, units, primes, logic riddles, sentiment, NERfree
Tier 0.5Program repairclassic bug archetypes patched by AST, proven by testsfree
Tier 0.75Code templatesclassic functions, executed against self-tests before shippingfree
Tier 1Local Gemma 3 via Ollamaconfidence-gated: refusals and hallucinations escalatefree
Routing intelligence

It picks the cheapest tier — and the cheapest model.

Cheapest sufficient model

Ranks the allowed Fireworks models cheap→strong and stops at the first whose answer clears free verification.

Compound decomposition

what is 1+3 and write two-sum → the arithmetic is free, only the code half is paid.

Freshness routing

Time-sensitive facts (current leaders, prices, records) go to the stronger tier; stable facts stay free.

Semantic cache

Paraphrased repeats served free at ≥0.92 cosine — with a numeric guard so the numbers must match exactly.

Understanding & small talk

Strips filler ("i'm confused, what is 2+2?"), answers greetings and "what's today's date" for free.

Adaptive & budget-aware

Learns from live traffic (promote/demote categories) and degrades to free tiers instead of failing when a budget runs out.

Verified

301 tests, all green, no network needed.

Every routing decision, solver, cache, and the grading contract are covered by offline tests with stubbed clients.

$ python -m pytest tests/ -q
........................................ [ 40%]
........................................ [ 80%]
....................                     [100%]

301 passed in 14.2s

$ python scripts/coverage_report.py
TOTAL     31/40 zero-token · 31/31 correct
Deterministic solvers80
Classifier & routing75
Understanding & decomposition36
Sentiment / NER / summaries25
Program repair19
Pipeline orchestration16
Adaptive policy15
Code templates14
Grading contract12
Semantic cache9