Route Easy Questions to a Cheaper Model: A Cost-Aware LLM Router on Amazon Bedrock

Route Easy Questions to a Cheaper Model: A Cost-Aware LLM Router on Amazon Bedrock

Build a small-model router and prompt caching for a chatbot, then prove with your own numbers whether they save money without making the answers worse. Deploy, verify, and clean up included.

The problem

Most questions a support assistant gets are boring. "What's the minimum withdrawal?" "How many photos does a product need?" A small, cheap model answers those perfectly well. A few questions are hard: "A buyer paid Rp200,000 plus shipping with cash on delivery, what are my fees?" needs two rules and some arithmetic, and a small model is more likely to get it wrong.
If every question goes to the stronger model, you pay its price for the boring ones too. If every question goes to the small model, the hard ones suffer. The obvious fix is a router. The less obvious part is proving that the router saves more than it costs, because the router itself is an extra model call on every request.
In this post I build that router for a merchant assistant, add prompt caching for the long system prompt, and measure four setups against the same 30 questions:
  1. Everything to the primary model (baseline)
  1. Primary model + prompt caching
  1. Router
  1. Router + prompt caching
As a reference, I also run the same questions through Bedrock's own managed router, Intelligent Prompt Routing, to see whether building a router was worth it at all.
You'll end up with a deployed Lambda function that routes, caches, and reports the cost of every request as a CloudWatch metric, plus a script that tells you your router's break-even point.

The project: a merchant-support chatbot

I'm developing a support chatbot for the merchants of an e-commerce marketplace for small sellers: dried fish, kerupuk, sambal, woven crafts. Merchants ask about fees, payouts, shipping, and returns, in Indonesian, and every answer has to come from a ~2,500-token merchant guide, also in Indonesian. (The article is in English; the questions and answers in the examples are Indonesian, with translations.) The code, a sample guide, and the 30 test questions are in the  GitHub repo , so you can follow along and get your own numbers.
Why merchants and not buyers? Merchant questions split cleanly into easy lookups ("what's the minimum withdrawal?") and real multi-rule calculations (fees on a cash-on-delivery order), which is exactly what a router needs to prove itself. Buyer questions are mostly "where is my order?", which needs live order data and authentication: a different project.
Before putting a chatbot like this in front of real merchants, I wanted two numbers: what each question costs, and where a cheap model starts giving wrong answers.

Architecture

Architecture: a Lambda function calls a Nova Micro router, which sends simple questions to Nova Micro and complex ones (or router errors) to Nova 2 Lite. The merchant guide is a cached prefix. Every request reports its cost to CloudWatch, with an alarm on router fallbacks.

One Lambda function: a Nova Micro router picks the answering model, the merchant guide is a cached prefix, and every request reports its cost to CloudWatch.
Piece
Choice
Why
Primary model
Amazon Nova 2 Lite ( us.  cross-Region profile)
Good at multi-step rules and arithmetic for its price
Small model + router
Amazon Nova Micro
About 8.5× cheaper per input token than Nova 2 Lite ($0.035 vs $0.30 per 1M, us-east-1; check the pricing page before you publish)
API
Bedrock Converse
Same request shape for both models, tool use, and  cachePoint 
Runtime
AWS Lambda + SAM
Nothing runs (or costs) while idle
Switch
SSM Parameter Store
Turn the router off in production without a deploy
Observability
CloudWatch Embedded Metric Format
Cost per request becomes a metric with zero extra API calls

Why not Bedrock Intelligent Prompt Routing, or keyword rules?

Option
Pros
Cons
Bedrock Intelligent Prompt Routing
Managed, one endpoint, ~85 ms routing overhead (P90)
Two models from one family, from a fixed list (for Nova: Nova Lite and Nova Pro, not Nova Micro or Nova 2 Lite); optimized for English prompts, and my merchants write in Indonesian; you can't define what "hard" means for your domain
Keyword or length rules
Free, instant
Brittle with informal Indonesian ("brp", "gmn", "tf"); "Rp" doesn't always mean a calculation
Small-model router with a forced tool call (this post)
You define "simple" in plain language; easy to test
Costs one small call per request; can misroute
Intelligent Prompt Routing is the obvious first thing to try, so the experiment in Step 4 runs it on the same 30 Indonesian questions. If it does as well, you don't need the code in this post.

Prerequisites

  • AWS account, Region us-east-1
  • Permission to invoke Amazon Nova Micro and Amazon Nova 2 Lite (plus Nova Lite and Nova Pro for the Intelligent Prompt Routing comparison). Bedrock serverless models are enabled by default, so there's no model-access step; only IAM or SCPs can block them.
  • Python 3.13 (matches the Lambda runtime, which  sam build  uses), AWS CLI v2, AWS SAM CLI
Get the code and check that it runs offline first:
git clone https://github.com/ahakimx/bedrock-llm-router.git
cd bedrock-llm-router
python3.13 -m venv .venv && source .venv/bin/activate
pip install -r requirements-dev.txt
FAKE_BEDROCK=1 python -m pytest -q # offline check, no AWS calls

Step 1: The golden dataset

You can't tell whether routing hurts quality without a fixed set of questions with known answers.  data/golden.jsonl  has 30, all in Indonesian: 18 labelled  simple , 12  complex  (calculations, rules that depend on the day of the week, complaints, and a question that mixes two rules).
{"id": "q19", "label": "complex",
"question": "Pembeli pesan kerupuk Rp200.000 ditambah ongkir Rp20.000 dan bayar COD. Berapa total biaya yang saya bayar ke marketplace untuk pesanan ini?",
"expect": [["9500"]]}
("A buyer orders kerupuk for Rp200,000 plus Rp20,000 shipping and pays cash on delivery. How much do I pay the marketplace in fees?" The answer is 4% of the product price plus the Rp1,500 COD fee: Rp9,500.)
 expect  is a list of groups; every group must appear in the answer, and any alternative inside a group counts. Numbers are normalized first, so  Rp9.500 ,  Rp9,500 , and  9500  all match. It's crude, but it catches the failures that matter here: a wrong fee, a missing deadline, a rule the model made up.

Step 2: Prompt caching for the guide

The guide is the same on every request, so it's the perfect thing to cache. The rule: everything static goes before the  cachePoint , everything that changes goes after it.
def system_blocks(cache: bool) -> list:
blocks = [{"text": f"{INSTRUCTIONS}\n\n<merchant_guide>\n{GUIDE}\n</merchant_guide>"}]
if cache:
blocks.append({"cachePoint": {"type": "default"}})
return blocks

r = brt.converse(
modelId=model,
system=system_blocks(cache),
messages=[{"role": "user", "content": [{"text": question}]}], # after the checkpoint
inferenceConfig={"maxTokens": 300, "temperature": 0},
)
The usage block tells you whether it worked: the first call shows  cacheWriteInputTokens , the next ones within five minutes show  cacheReadInputTokens , and  inputTokens  drops to just the question.
On my run, the first two calls each wrote ~2,500 tokens to the cache (the second one came before the first write was usable) and every later call read them back:  inputTokens  fell from ~2,530 per question to about 10. Two things surprised me; they're in "What didn't work".

Step 3: The router

The router asks Nova Micro to call a  route  tool with  simple  or  complex . Forcing the tool call ( toolChoice ) means I always get structured output, never a chatty sentence to parse.
ROUTER_SYSTEM = (
"You route questions from marketplace merchants. The questions are in Indonesian. "
"Call the `route` tool exactly once.\n"
"simple = the answer is one fact or one rule from a policy (a number, a yes/no, a time, a limit).\n"
"complex = anything that needs a calculation, combines two or more rules, depends on a date or day of the "
"week, handles a complaint or an angry merchant, or might not be covered by the policy at all.\n"
"When unsure, choose complex.\n"
"Examples: 'Berapa lama moderasi produk?' = simple. "
"'Saya tarik saldo ke BCA dua kali hari ini, total biayanya berapa?' = complex."
)

r = brt.converse(
modelId=ROUTER_MODEL,
system=[{"text": ROUTER_SYSTEM}],
messages=[{"role": "user", "content": [{"text": question}]}],
toolConfig={"tools": [ROUTE_TOOL], "toolChoice": {"tool": {"name": "route"}}},
inferenceConfig={"maxTokens": 30, "temperature": 0},
)
Three decisions worth calling out:
  • The examples in the prompt are not from the test set. Otherwise the router would be graded on questions it has already seen. A test checks this.
  • "When unsure, choose complex." A misroute in that direction costs a little money. A misroute the other way costs a wrong answer. I'd rather pay.
  • Any router failure falls back to the primary model. Throttling, a timeout, an unexpected label: the request still gets answered, and a  RouterFallback  metric goes up.
def route(brt, question, enabled=True):
if not enabled:
return Decision("complex", PRIMARY_MODEL, "router-off", None)
try:
c = classify(brt, question)
except Exception:
log.exception("router failed, falling back to the primary model")
return Decision("complex", PRIMARY_MODEL, "router-error", None)
return Decision(c.text, SMALL_MODEL if c.text == "simple" else PRIMARY_MODEL, "classified", c)

Step 4: Run the experiment

export AWS_REGION=us-east-1
scripts/run-experiment.sh
This runs all 30 questions through the four setups, plus Intelligent Prompt Routing ( bedrock-ipr , Bedrock's default Nova router choosing between Nova Lite and Nova Pro; set  SKIP_IPR=1  to skip it), and prints the comparison. My results (November 15, 2026, us-east-1, list prices from  src/merchantbot/data/pricing.json ):

All to primary
Primary + caching
Router
Router + caching
Bedrock IPR
Cost per 1,000 questions
$0.889
$0.360
$0.468
$0.198
$2.821
Change vs. baseline
—
−59%
−47%
−78%
+217%
Golden pass rate
97% (29/30)
97% (29/30)
100% (30/30)
97% (29/30)
97% (29/30)
Latency p50 / p90
1.06 / 1.44 s
2.17 / 4.11 s
1.79 / 2.15 s
1.76 / 2.29 s
1.20 / 1.54 s
Answered by the cheaper model
0%
0%
60%
60%
0%
Misrouted (vs. golden label)
—
—
4
4
18
Compare Bedrock IPR with the Router column: neither uses prompt caching, and IPR picks between a different pair of models (Nova Lite / Nova Pro), so this answers "how far does the managed option get on Indonesian questions", not "which model pair is better".
What I read from it:
  • Caching is the biggest single lever (−59%): the guide is almost all of every request's input tokens.
  • The router adds another big cut on top (−78% together) without losing quality: Nova Micro answered 60% of the questions, and the pass rate stayed the same.
  • The router costs latency, about 0.7 s at p50, because it's a second model call before the answer. For a chat reply that was fine for me; for something interactive it might not be.
  • Intelligent Prompt Routing sent every question to Nova Pro, even "Berapa minimal penarikan saldo?" ("What is the minimum withdrawal?"), so it cost 3.2× the baseline and 14× the router + cache setup. That's consistent with the docs saying it's optimized for English prompts. On English traffic it may behave very differently, so test it on yours before you write your own router.
  • Of the 4 misroutes, 2 went the safe way (simple questions sent to Nova 2 Lite: a bit more cost) and 2 the risky way (complex questions sent to Nova Micro). One of those risky ones gave a contradictory answer that my grader still passed; more on that below.

When does the router pay for itself?

The router adds one Nova Micro call to every request. It only saves money if enough questions go to the small model:
break-even share = router cost per question / (avg primary answer cost − avg small answer cost)
 report.py  computes this from your run. On my data, an answer cost $0.00089 on Nova 2 Lite and $0.00012 on Nova Micro, and the router added $0.00002 per question, so the router pays for itself once 2.8% of questions go to Nova Micro. It sent 60%.
This is the number I'd look at before shipping any router. If most of your traffic is hard questions, or the two models are close in price, the router is pure overhead. Caching alone may be the better deal.

Step 5: Deploy it as a Lambda function

scripts/deploy.sh
# "What is the minimum withdrawal?"
scripts/ask.sh "Berapa minimal penarikan saldo?"
# "A buyer orders kerupuk for Rp200,000 plus Rp20,000 shipping and pays COD. What do I pay in fees?"
scripts/ask.sh "Pembeli pesan kerupuk Rp200.000 ditambah ongkir Rp20.000 dan bayar COD. Berapa biaya yang saya bayar?"
The first question should go to Nova Micro, the second to Nova 2 Lite.
{
"statusCode": 200,
"answer": "Minimal penarikan saldo adalah Rp50.000. ... (Aturan 3.2)",
"route": "simple",
"model": "us.amazon.nova-micro-v1:0",
"cost_usd": 0.00014368,
"latency_ms": 920
}
{
"statusCode": 200,
"answer": "... Biaya layanan marketplace: 4% dari Rp200.000 = Rp8.000. Biaya COD: Rp1.500 (ditanggung merchant) ...",
"route": "complex",
"model": "us.amazon.nova-2-lite-v1:0",
"cost_usd": 0.00108477,
"latency_ms": 1585
}
("The minimum withdrawal is Rp50,000 (rule 3.2)" and "Service fee: 4% of Rp200,000 = Rp8,000. COD fee: Rp1,500, paid by the merchant.") In a short session, simple questions cost $0.00006–0.00015 each and complex ones $0.0003–0.0011; the first call after a deploy is the most expensive because it writes the cache.
Terminal: ask.sh answers a simple question via Nova Micro with its cost

 ask.sh  against the deployed function: a simple question answered by Nova Micro, with the route, model, and cost of that one request.
The template keeps IAM tight. A cross-Region inference profile needs permission on the profile in your Region and on the foundation model in every Region the profile can route to, but only when the request comes through that profile:
- Effect: Allow # the two inference profiles in this Region
Action: bedrock:InvokeModel
Resource:
- arn:aws:bedrock:us-east-1:<account>:inference-profile/us.amazon.nova-micro-v1:0
- arn:aws:bedrock:us-east-1:<account>:inference-profile/us.amazon.nova-2-lite-v1:0
- Effect: Allow # the models behind them, in any US Region, only via a profile
Action: bedrock:InvokeModel
Resource:
- arn:aws:bedrock:us-*::foundation-model/amazon.nova-micro-v1:0
- arn:aws:bedrock:us-*::foundation-model/amazon.nova-2-lite-v1:0
Condition:
StringLike:
bedrock:InferenceProfileArn: arn:aws:bedrock:us-east-1:<account>:inference-profile/us.*

Verify

Every request writes one Embedded Metric Format line, so cost and latency show up as CloudWatch metrics under  MerchantAssistant , split by route:
CloudWatch bar chart: total CostUSD for Nova 2 Lite far above Nova Micro

Total  CostUSD  per route over one hour of test traffic (Sum, CloudWatch Metrics). Complex questions on Nova 2 Lite account for most of the spend; simple ones on Nova Micro barely register.
To see cost per model, run this in Logs Insights:
fields @timestamp, Route, model, CostUSD, LatencyMs, CacheReadTokens
| filter ispresent(CostUSD)
| stats count() as requests, sum(CostUSD) as cost_usd, avg(LatencyMs) as avg_ms by model
Logs Insights result: requests, total cost and average latency per model

Logs Insights on the deployed function after a short test session: 8 requests. Per question, Nova Micro cost about $0.00015 and Nova 2 Lite about $0.00091.
Turn the router off without a deploy. Within a minute (the function caches the flag for 60 seconds), the simple question goes to Nova 2 Lite too: the response shows  "route": "complex"  with the Nova 2 Lite model, and in CloudWatch the request is counted under  Route  =  router-off :
aws ssm put-parameter --name /merchant-assistant/router-flags --overwrite \
--value '{"router": false, "cache": true}'
Same question before and after router off: Nova Micro, then Nova 2 Lite

Same question before and after switching the router off in SSM: it moves from Nova Micro to Nova 2 Lite with no redeploy, at about 14× the cost. Note the small model's answer cites section 3.3; the rule is in 3.2. My keyword grader would pass it anyway.

What didn't work (and how I fixed it)

Every model got the same question wrong, because my guide was ambiguous. In the first run, q22 ("a buyer changed their mind about a jar of sambal; can they return it, and who pays shipping?") failed in all five setups, Nova Pro included. Every model said "yes, the buyer pays shipping". The guide said buyers pay return shipping for a change of mind "as long as the category allows it", but never said which categories allow it; the rule that food can't be returned that way sat in a separate paragraph. I added a "return for a change of mind" column to the category table and one line to the instructions: check every rule that applies, including exceptions. In the second run q22 passed everywhere.
The fix broke another question. After that change, q19 (the COD fee) failed in two setups: the answers started explaining what the buyer pays and lost the Rp9,500 total. Same golden set, one prompt change, a different failure. This is the reason the golden set exists: re-run all of it after every prompt change, not just the question you fixed.
The deployed function gave an answer my grader would have passed. Asked about the COD fee, it got Rp9,500 right, then added it to the buyer's total ("Rp200,000 + Rp20,000 + Rp9,500 = Rp229,500"). Fees come out of the merchant's payout; the buyer never pays them. The keyword check only looks for  9500 , so it can't catch this. I added "fees are paid by the merchant out of the payout; never add them to what the buyer pays" to the instructions. I only found it by reading answers.
Keyword grading fails both ways. Nova Micro answered q29 ("can I ship fresh fish to the next town with JNE?") with "fresh fish ships within the city only" and then suggested a courier to the next town. It passed. Nova Pro answered q24 correctly ("no, wait 24 hours") but didn't use the word I expected, and failed. Treat the pass rate as a smoke alarm, not a score.
Caching had two surprises. Each model keeps its own cache, and they count the same guide differently: about 3,320 tokens on Nova Micro, 2,520 on Nova 2 Lite. With the router on, both caches get written, and I saw a few extra cache writes mid-run, which fits requests landing in another Region through the cross-Region profile. Also, in both runs the caching-only setup was slower (p50 ~2.1 s vs ~1.1 s) while router + cache was not slower than router alone. I don't have a good explanation yet; with 30 questions, latency is noisy. Measure it on your own traffic before promising anyone faster responses.
Installing SAM CLI with Homebrew was slow and kept failing. AWS stopped maintaining its Homebrew formula in 2023; the  .pkg  installer from the SAM CLI releases page took a couple of minutes.

Production notes

  • Watch the fallback rate. If the router starts failing, everything silently goes to the expensive model. The template includes an alarm on  RouterFallback  (5 in 5 minutes).
  • Re-check the router on real traffic. 30 questions is a smoke test. Sample production questions weekly, label them, and re-run  evaluate.py ; the break-even point moves as your traffic changes.
  • Cap the blast radius. Set  maxTokens  per route, and consider reserved concurrency on the function so a traffic spike can't turn into a token bill.
  • The router sees raw user input. It only returns a label, so prompt injection can at worst cause a misroute, but keep it that way: never let the router's output reach the user.
  • Cache hits are not guaranteed. With cross-Region inference, a request can land in a Region with a cold cache. Measure  cacheReadInputTokens  over time, not on one call.

When not to use this

  • Most of your questions are genuinely hard, so the small model rarely gets traffic.
  • Your two models are close in price; the router call eats the difference.
  • You can't build a golden dataset. Without one you can't tell whether routing hurts quality.

Clean up

scripts/cleanup.sh
This deletes the function, IAM role, log group, SSM parameter, and alarm. Nothing in the stack costs money while idle.  sam deploy --resolve-s3  also created a bucket named  aws-sam-cli-managed-default-…  for build artifacts;  sam delete  removes this stack's objects, but the bucket stays. Delete it from the S3 console if you don't use SAM for anything else.

Wrap-up

Router + caching cut the cost per question by 78% on my 30 questions with the same pass rate, and the break-even point (2.8%) was far below what the router actually sent to the small model (60%). Bedrock's managed router, on Indonesian questions, did the opposite.
The code, golden dataset, and SAM template are on GitHub:  github.com/ahakimx/bedrock-llm-router .
What I'd do next:
  • Replace keyword grading with an LLM-as-a-judge pass on a sample, since both a wrong answer that passed and a right answer that failed showed up in 30 questions.
  • Grow the golden set from real merchant questions, and run it several times to get stable latency numbers.
  • Test whether Nova 2 Lite with extended thinking fixes the calculation questions, and whether it's worth the extra output tokens.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article