Requests enter a router that branches to small, medium, and large models, with fallback paths.
    Back to Blog
    AI SystemsApril 27, 2026

    Model Routing in Production AI Systems

    By Vishkar AI Engineering Team

    The most expensive mistake in LLM applications isn't a bad prompt. It's treating every query the same.


    A user asks your AI assistant: "What are your business hours?"

    Your system embeds the query, searches a vector index, assembles 3,000 tokens of context, and sends the whole thing to GPT-4o.

    For a question that could've been answered with a dictionary lookup.

    This is happening in production systems right now — at scale, on every query, across thousands of daily users. The fix is model routing: a classification layer that sends each query to the right model for the job. RouteLLM (LMSYS/UC Berkeley, ICLR 2025) achieved over 85% cost reduction on MT Bench while maintaining 95% of GPT-4 performance (LMSYS Blog, July 2024). That's not a micro-optimisation. That's a line item.

    TL;DR: Routing just 60% of queries to cheaper models cuts inference spend by over 50% with no quality loss. RouteLLM (LMSYS, ICLR 2025) achieved 85% cost reduction on MT Bench while maintaining 95% of GPT-4 performance. Three classifier approaches — rule-based, embedding, and LLM-based — cover every scale and budget for production systems.

    This post covers how to design, implement, and operate model routing in production — including the pitfalls most teams hit the hard way. For context on where routing fits in your overall cost picture, see the hidden cost of LLM applications.


    What Is Model Routing?

    Model routing is the practice of dynamically selecting which model handles a given query based on its complexity, intent, or required capability. Stanford's FrugalGPT research demonstrated that cascade routing approaches — reserving expensive models only for queries that need them — can achieve up to 98% cost reduction while matching or exceeding GPT-4 performance on real benchmarks (arXiv 2305.05176, TMLR 2024). The mental model is simple:

    Incoming query
          ↓
      Classifier
          ↓
    ┌─────────────────────────────────┐
    │ Simple    → GPT-4o-mini / Haiku │
    │ Moderate  → GPT-4o-mini         │
    │ Complex   → GPT-4o / Opus       │
    │ Sensitive → GPT-4o + guardrails │
    └─────────────────────────────────┘
    

    You're not replacing your best model. You're reserving it for queries that actually need it.


    Why Most Teams Skip This

    Model routing feels like premature optimisation when you're building. You have one model, it works, and adding a classifier layer is more code to write and maintain. The problem surfaces at scale — and by then you're already paying for it.

    FrugalGPT's analysis found that most production query sets contain a substantial fraction of requests answerable by smaller, cheaper models — the expensive model is consistently overkill for a large share of traffic (Stanford / arXiv 2305.05176, TMLR 2024). Here's what that looks like in practice.

    Take a system handling 50,000 queries per day. If the average query uses 2,000 tokens and you're on GPT-4o pricing:

    Before routing (all GPT-4o):
    50,000 queries × 2,000 tokens × $0.0025/1K = $250/day = $7,500/month
    

    Now route 60% of those queries — the simple, factual, low-complexity ones — to GPT-4o-mini:

    Simple  (60%): 30,000 queries × 2,000 tokens × $0.00015/1K = $9/day
    Complex (40%): 20,000 queries × 2,000 tokens × $0.0025/1K  = $100/day
                                                   Total        = $109/day
                                                                = $3,270/month
    

    You just saved $4,230 per month — 56% — without changing your product. That's what real April 2026 pricing looks like:

    ModelInput (per 1M tokens)vs GPT-4o
    GPT-4o$2.50—
    Claude Haiku 4.5$1.0060% cheaper
    GPT-3.5-turbo$0.5080% cheaper
    GPT-4o-mini$0.1594% cheaper

    Source: pricepertoken.com, April 2026


    Designing the Routing Layer

    Step 1 — Define Your Query Tiers

    Before writing any code, define what complexity means for your system. A useful starting framework:

    TierCharacteristicsExample Queries
    SimpleFactual, single-intent, short answer"What is your refund policy?" / "What are the hours?"
    ModerateSome reasoning, multi-step, medium context"Summarise this document" / "Compare these two options"
    ComplexDeep reasoning, long context, synthesis"Analyse this contract and flag legal risks"
    SensitivePII, compliance, high-stakes decisionsAnything touching medical, legal, financial advice

    The tiers will look different for every product. Spend time on this definition before you build the classifier — getting it wrong upstream means fixing it under production load.


    Step 2 — Build the Classifier

    There are three approaches, in increasing order of accuracy and complexity:

    Approach 1 — Rule-based routing (fastest to ship)

    def route_query(query: str) -> str:
        query_lower = query.lower()
        word_count  = len(query.split())
    
        # Simple intent keywords
        simple_patterns = [
            "what is", "what are", "when is", "where is",
            "how much", "opening hours", "contact", "price"
        ]
    
        # Complexity signals
        complex_patterns = [
            "analyse", "compare", "summarise", "explain why",
            "what are the implications", "review this", "contract"
        ]
    
        if any(p in query_lower for p in complex_patterns) or word_count > 50:
            return "gpt-4o"
    
        if any(p in query_lower for p in simple_patterns) and word_count < 20:
            return "gpt-4o-mini"
    
        return "gpt-4o-mini"   # default: mid-tier
    

    Fast to build, easy to debug. Breaks on edge cases. Good for v1.


    Approach 2 — Embedding-based routing

    Classify queries by semantic similarity to labelled examples:

    from sklearn.neighbors import KNeighborsClassifier
    import numpy as np
    
    # Labelled examples per tier
    training_queries = [
        ("What are your opening hours?",         "simple"),
        ("What is the refund policy?",           "simple"),
        ("Summarise this quarterly report",      "moderate"),
        ("Compare these two pricing plans",      "moderate"),
        ("Analyse this contract for legal risk", "complex"),
        ("Review these financial statements",    "complex"),
    ]
    
    # Embed training queries (using your existing embedding model)
    X = np.array([embed(q) for q, _ in training_queries])
    y = [label for _, label in training_queries]
    
    classifier = KNeighborsClassifier(n_neighbors=3)
    classifier.fit(X, y)
    
    def route_query(query: str) -> str:
        query_embedding = embed(query).reshape(1, -1)
        tier = classifier.predict(query_embedding)[0]
    
        routing_map = {
            "simple"  : "gpt-4o-mini",
            "moderate": "gpt-4o-mini",
            "complex" : "gpt-4o",
        }
        return routing_map[tier]
    

    More accurate than rules. Scales with more training examples. Requires maintaining your labelled dataset.


    Approach 3 — LLM-based routing (most accurate)

    Use a small, cheap model to classify before calling the main model:

    import openai
    
    ROUTING_PROMPT = """
    You are a query classifier. Classify the following query as one of:
    - simple: factual, single-intent, short answer expected
    - moderate: some reasoning required, multi-step
    - complex: deep analysis, synthesis, long context required
    
    Respond with ONLY one word: simple, moderate, or complex.
    
    Query: {query}
    """
    
    def route_query(query: str) -> str:
        response = openai.chat.completions.create(
            model="gpt-4o-mini",        # cheap model for classification
            messages=[
                {"role": "user", "content": ROUTING_PROMPT.format(query=query)}
            ],
            max_tokens=5,
            temperature=0,
        )
    
        tier = response.choices[0].message.content.strip().lower()
    
        routing_map = {
            "simple"  : "gpt-4o-mini",
            "moderate": "gpt-4o-mini",
            "complex" : "gpt-4o",
        }
        return routing_map.get(tier, "gpt-4o-mini")
    

    Most accurate. Adds ~100ms latency and a small classification cost. Worth it for high-volume systems.


    A router sends a query to a small model; a quality check either accepts the answer or escalates to a larger model.

    Step 3 — Handle Fallbacks

    Routing adds a failure mode: the classifier mislabels a complex query as simple, and the cheaper model produces a poor answer. Always build a fallback mechanism — and for a deeper look at how retrieval quality compounds these routing decisions, see the guide on production RAG architecture.

    def query_with_fallback(query: str, context: str) -> str:
        model    = route_query(query)
        response = call_llm(model, query, context)
    
        # Quality gate — check response confidence or length
        if is_low_quality(response) and model != "gpt-4o":
            print(f"Fallback triggered for query: {query[:50]}...")
            response = call_llm("gpt-4o", query, context)
    
        return response
    
    def is_low_quality(response: str) -> bool:
        # Simple heuristics — extend with your own evaluation logic
        if len(response.strip()) < 20:
            return True
        if "i don't know" in response.lower() and len(response) < 100:
            return True
        return False
    

    Log every fallback. If a particular query type is consistently triggering fallbacks, your routing logic needs updating for that pattern.


    What to Measure in Production

    Model routing without observability is flying blind. A fallback rate above 5% is a signal to retrain your classifier — at that point the routing layer is generating enough corrective GPT-4o calls to erode the cost savings you built it for. Instrument these metrics from day one:

    import time
    
    def tracked_query(query: str, context: str) -> dict:
        model      = route_query(query)
        start      = time.time()
        response   = call_llm(model, query, context)
        latency_ms = (time.time() - start) * 1000
    
        return {
            "query"      : query[:100],
            "model"      : model,
            "latency_ms" : round(latency_ms),
            "tokens_used": count_tokens(query + context + response),
            "fallback"   : False,
        }
    

    Dashboard metrics to track:

    MetricWhy It Matters
    Route distribution (% per tier)Are most queries hitting cheap models as expected?
    Fallback rateIs your classifier working? >5% fallback rate = retrain
    Cost per tierActual savings vs projected
    Latency per tierIs routing overhead worth it?
    Quality score per tierAre cheaper models degrading answers?

    Production Pitfalls to Avoid

    Routing on query length alone A short query can be deeply complex. "Is this merger legal?" is six words and needs your best model. Always combine signals — length, keywords, semantic similarity.

    No human review of routing decisions Log a sample of routed queries and review weekly. You'll find patterns your classifier missed — edge cases that don't surface in automated metrics until they've already caused degraded responses at scale.

    Skipping the fallback layer Even a 2% misrouting rate at 50,000 queries/day means 1,000 degraded responses. The fallback isn't optional.

    Using the same router for different query types A support chatbot and a document analysis tool have completely different complexity distributions. Build separate routing logic for each use case — a single shared classifier will be miscalibrated for at least one of them.


    Beyond Cost: Other Reasons to Route

    Cost reduction is the most obvious benefit of model routing. But routing also solves problems that have nothing to do with the bill.

    Latency control — GPT-4o outputs at 148 tokens/second. GPT-4o-mini runs at just 31 t/s — it's cheap but slow. Open-source models served on Groq or Fireworks can exceed 300 t/s (Artificial Analysis, April 2026). For real-time features, routing simple queries to fast-inference providers dramatically improves perceived responsiveness, independent of cost.

    Compliance routing — Route queries containing PII or regulated content to models hosted in specific regions, or to on-premise deployments. This isn't just a nice-to-have for enterprise — in healthcare and financial services it's often a hard requirement. Model routing is the architectural primitive that makes it achievable without forking your entire codebase.

    Provider redundancy — Route across providers (OpenAI, Anthropic, Google) to avoid single-provider downtime. What starts as a cost optimisation layer becomes your infrastructure resilience strategy. Talk to us if you're designing this for a regulated environment.


    The Full Picture

    Model routing isn't a micro-optimisation. It's a first-class architectural decision that affects cost, latency, quality, and reliability simultaneously.

    The teams running efficient LLM systems in production all share one pattern: they treat the model as one component in a larger system — not the system itself.

    A routing layer that directs 60% of traffic to cheaper models, with automatic fallback for low-quality responses, isn't complex to build. But it requires intentional design upfront.

    Build it before you need it. By the time your volume justifies it, you'll have already paid the cost of not having it.


    Quick Reference

    v1  → Rule-based routing       (1 day to ship, good enough to start)
    v2  → Embedding classifier     (1 week, more accurate)
    v3  → LLM-based classifier     (2–3 days, highest accuracy)
    
    Always add:
      → Fallback mechanism
      → Per-route observability
      → Weekly routing review
    

    Frequently Asked Questions

    What is model routing in LLM applications?

    Model routing is a classification layer that dynamically selects which LLM handles each incoming query based on its complexity or intent. Instead of sending every query to your most capable (and expensive) model, a router directs simple factual queries to cheap fast models and reserves GPT-4-class models for tasks that genuinely need deep reasoning.

    How much can model routing reduce LLM costs?

    Research shows 40–98% cost reduction depending on query mix and routing approach. RouteLLM (LMSYS/UC Berkeley, ICLR 2025) achieved over 85% cost reduction on MT Bench while maintaining 95% of GPT-4 performance (LMSYS Blog, 2024). In practice, routing 60% of queries to GPT-4o-mini (at $0.15/1M vs $2.50/1M for GPT-4o) produces 50–56% savings on typical production workloads.

    Which classifier approach should I start with?

    Start with rule-based routing — it takes a day to ship and gives you immediate savings on the most obvious simple queries (FAQs, factual lookups, short single-intent questions). Move to embedding-based routing once you have a labelled dataset of 50–100 query examples per tier. LLM-based routing gives the best accuracy and is worth the 100ms overhead for high-volume systems where misrouting is costly.

    What fallback rate means my router needs retraining?

    A fallback rate above 5% is the signal to retrain. At 50,000 queries/day, 5% fallback means 2,500 GPT-4o calls that were supposed to go to a cheaper model — enough to meaningfully erode your projected savings. Log every fallback with the query text and review weekly to identify the patterns your classifier is missing.

    Can model routing help with compliance requirements?

    Yes — compliance routing is one of the most underrated use cases. You can route queries containing PII, medical data, or regulated financial content to models deployed in specific geographic regions or on-premise infrastructure, while routing standard queries to cloud APIs. This makes data residency requirements achievable without maintaining two separate application stacks.


    About the Author

    Raj Kulkarni is a Senior Data Scientist specializing in production LLM systems and Generative AI at Vishkar.ai. He has designed and deployed model routing architectures, RAG pipelines, and LLMOps observability stacks for enterprise clients across fintech, legal, and SaaS verticals.

    Tags: LLM, Model Routing, AI Engineering, LLMOps, Cost Optimisation, GPT-4, Production AI, RAG

    Need help scaling your infrastructure?

    Vishkar delivers production-ready Cloud, DevOps & AI solutions for modern engineering teams.

    Schedule a Consultation