Thursday, 3 Dec 2026 Global Edition
Live Wire
AI Today Daily AI journalism & intelligence
Front Page Tips & Tutorials Baca versi Indonesia

Not Every Prompt Costs the Same: Building a Model-Routing System to Keep Your API Bill Sane

Most daily tasks don't need the priciest model. Build a simple routing table, send light work to mini models, and keep your API bill sane.

Not Every Prompt Costs the Same: Building a Model-Routing System to Keep Your API Bill Sane

API bills surprise people like electricity bills do: unremarkable for months, then suddenly several times higher, with nobody feeling wasteful. If you opened the OpenAI, Anthropic, or Google dashboard and found a number that made you wince, the cause is almost never volume — it is the habit of pointing the most expensive model at everything, from classifying a three-word sentiment to drafting an email subject line.

Yet not every delivery needs a container truck. Most routine work in an app — classification, extraction, reformatting, tagging — can be handled by small models that cost an order of magnitude less, with practically indistinguishable quality. The frontier model should be reserved for work that genuinely demands reasoning. This guide walks you through a model-routing system: simple rules deciding which prompts climb to the expensive tier and which drop to economy class. Setup takes an hour or two, and the impact often shows up as 40-60 percent off the next monthly bill.

Dissect the Bill Before You Swap Any Model

Before routing anything, know where the money actually flows. Open the usage page in your provider's dashboard and export the last 30 days as CSV. Two things matter. First, cost has two components: input tokens and output tokens — and output is typically priced several times higher. Second, APIs are stateless: every turn re-sends the entire history from the beginning, so a long chat pays for the same tokens again and again.

Group it per feature: almost always, two or three features account for most of the bill, and most of their prompts are light tasks. Paste the CSV into your favorite AI chat and ask for an autopsy.

Attachment: usage-export-30days.csv (columns: timestamp, feature, model, input_tokens, output_tokens, cost_usd)

Break this down:
1. Cost per feature, sorted, with share of total.
2. For the top three, estimate cost if switched to a mini-class tier (assume 10x cheaper).
3. Flag anomalies: requests above 20,000 input tokens or 2,000 output tokens.

Classify Every Task: Light, Medium, Heavy

Routing on gut feeling fails. Use a three-tier taxonomy:

  • Light — classification, tagging, field extraction, reformatting, raw summaries, title generation. Mini-class models (Gemini Flash-Lite, GPT-5 mini/nano, Claude Haiku, DeepSeek) handle these smoothly at a tenth of flagship prices.
  • Medium — internal email drafts, structured summaries, document Q&A, small non-critical code. Mid-tier models (Gemini Flash, GPT-5, Claude Sonnet) are enough.
  • Heavy — multi-step reasoning, complex data analysis, production code, final texts headed for publication. This is where flagships (Gemini Pro, GPT-5 with high reasoning, Claude Opus/Sonnet) earn their price.

The rule runs one way: start at the lowest tier, move up only if the quality audit shows failures. The reverse — start with a flagship, downgrade "when there is time" — never happens, because nobody ever has time.

Write the Routing Rules Once, Use Them Everywhere

Turn the taxonomy into a written contract: a routing table in one file the whole team can see, plus a small function that reads it.

ROUTING = {
    "light": "gemini-flash-lite",  # classification, extraction, tagging
    "medium": "gemini-flash",      # drafts, structured summaries
    "heavy": "gemini-pro",         # reasoning, production code
}

def pick_model(category: str) -> str:
    if category not in ROUTING:
        return ROUTING["heavy"]  # safe default: never silently go cheap
    return ROUTING[category]

If you would rather not write it yourself, have AI set it up for your stack:

I have a Python app calling an LLM API for 6 features: (1) ticket classification, (2) invoice extraction, (3) email drafts, (4) meeting summaries, (5) financial analysis, (6) support chat.
Deliver: (a) a light/medium/heavy routing table with specific models from [my provider], (b) a pick_model() function with an upgrade fallback on failure, (c) a short rationale per decision.

Let an Automatic Router Do the Picking

If a manual table feels like a chore, use a model gateway. OpenRouter, for example, offers an automatic router (the openrouter/auto slug) that reads your prompt and picks the destination model dynamically. You change one string in your code; selection is delegated to a system trained on thousands of daily prompt patterns.

A second approach: build your own cheap router — a mini-class model reads the task description and returns a light/medium/heavy verdict, costing a handful of tokens. Whatever the method, log every routing decision. Without logs you never know which model processed which prompt, and the quality audit becomes impossible.

Trim the Tokens Hiding in Every Request

Routing picks the right model; this step keeps that model from being overfed.

  • Cut the history. Do not re-send the full log every turn; compress older turns into a short handoff note.
  • Reference, do not re-paste. A 50-page document pasted into the first prompt is paid for again on every turn; attach only the relevant excerpt.
  • Slim system prompts. 3,000 tokens of instructions the model never uses is a permanent tax on every request.
  • Cap the output. Output tokens cost more than input tokens. Ask for concise answers, prefer structured formats, and set max_tokens so rambling is impossible.

Close each big conversation with this compression prompt:

Summarize our conversation into a handoff note of at most 300 tokens: (1) the task goal, (2) key decisions made, (3) facts and numbers to preserve, (4) next steps. Strict bullets, no filler. This note replaces the entire history on the next turn.

Set Budget Alarms and Audit Quality on a Schedule

Savings that end in collapsed quality are not savings; they move the cost onto your users. Two guardrails are needed.

First, alarms: a hard monthly limit and a threshold alert (say, 80 percent) in your provider's dashboard. Use separate API keys per feature, so a spike immediately reveals the culprit.

Second, a weekly audit: keep 20 real production cases, run them on the cheaper tier and the flagship, then compare. This prompt builds the rubric:

Create a 5-criteria rubric (accuracy, completeness, format, tone, safety), scored 1-5, for the task "[feature name]".
Then build a comparison table: small-model output vs flagship output, per-criterion scores, total, and a decision column: KEEP SMALL / MOVE UP.

A category that passes two consecutive audits stays put; one that fails moves up — and the decision is recorded in the table.

Start small: dissect this week's bill, find the priciest feature, move it to the mini tier. Routing is not a grand architecture project — one table, one small function, a 15-minute weekly audit habit. But the effect compounds: every prompt that drops a tier stops paying flagship rent, and next month's bill finally feels like a decision instead of a surprise.

References

Partner Spotlight Explore today’s curated technology offers