DEV Community

Daniel Dong
Daniel Dong

Posted on

I route 90% of my AI traffic to the cheapest model. Here's why your app should too.

Most devs pick one model and send everything to it. That's like
using a sledgehammer to hang a picture frame.

The wake-up call

My app had three types of requests:

  1. "Summarize this email" — 200 tokens in, 100 out
  2. "Is this sentiment positive?" — 150 in, 5 out
  3. "Debug this Python function" — 2000 in, 800 out

All three went to glm-4-plus at $7.10/M tokens.

The sentiment check cost me $0.001 per call.
The same call on deepseek-chat would cost $0.00003.

33x cheaper. Same accuracy. I was burning money on a yes/no answer.

The routing logic

It took 20 lines of code:

def pick_model(messages, task_type):
    # Cheap model for simple tasks
    if task_type in ("classify", "sentiment", "summarize_short"):
        return "deepseek-chat"          # $0.27/M

    # Mid-tier for general work
    if task_type in ("draft", "translate", "summarize_long"):
        return "qwen-plus"              # ~$0.40/M

    # Power model only when reasoning matters
    if task_type in ("debug", "reason", "analyze"):
        return "glm-4-plus"             # $7.10/M

    # Default: cheapest
    return "deepseek-chat"


# Same endpoint, different model string — no code changes
client.chat.completions.create(
    model=pick_model(msgs, task_type),
    messages=msgs,
)
Enter fullscreen mode Exit fullscreen mode

That's it. One function. One endpoint. The provider never knows
which model I'm using — the gateway handles it.

What changed

Metric Before (all glm-4-plus) After (routed)
Monthly cost $180 $34
Avg latency 1.4s 0.6s
Quality complaints 0 0

Quality didn't drop because the cheap model is plenty smart for
90% of requests. It's the long-tail reasoning tasks that need the
expensive brain — and those are only 10% of volume.

The counter-argument I hear
"But what if the cheap model gives a worse answer?"

Test it. Run the same 100 prompts through both models blind.
You'll be surprised how often the 0.27modelmatchesthe7 one.

The gap between "best model" and "good-enough model" has
collapsed. The gap between "good-enough model" and "your bill"
has not.

When NOT to route

  • Creative writing where you want the model's "voice"
  • Safety-critical medical/legal reasoning
  • Anything where 95% accuracy isn't acceptable

For everything else — chatbots, classifiers, summarizers, drafters,
translators — route to the cheap model and pocket the difference.

The setup

This only works if switching models is free. With direct provider
accounts, each switch means a new SDK, new auth, new billing.

With an OpenAI-compatible gateway, it's a string change:

client = openai.OpenAI(
    api_key="mb-xxx",
    base_url="https://aibridge-api.com/v1"
)

# Same call, 14 possible models, one bill
client.chat.completions.create(model="deepseek-chat", messages=msgs)
client.chat.completions.create(model="glm-4-plus", messages=msgs)
Enter fullscreen mode Exit fullscreen mode

Stop paying premium prices for yes/no answers.

aibridge-api.com — 14 models, one endpoint, free 500K tokens/month

1

2

3

5

6

Top comments (0)