TL;DR
  • Running a single LLM for every task is wasteful and slow — route requests to the right model based on complexity, latency requirements, and cost.
  • We run seven models in production across Logicbric products, orchestrated by a lightweight routing layer that classifies intent before dispatching.
  • The key is measurable routing criteria, not vibes — define what “good enough” means for each task class, then match models accordingly.

Context

When we first shipped AI features in PMS, every request hit GPT-4. It was accurate and impressive in demos. It was also slow and expensive when hundreds of property managers started using it daily. A simple intent classification — “is this a maintenance request or a lease question?” — was burning the same compute as a complex multi-document legal synthesis in WyseAgent.

We needed a routing layer. Not a theoretical framework, but a practical system that could evaluate incoming requests and dispatch them to the most appropriate model. This playbook documents the architecture we built, the mistakes we made, and the patterns that survived production.

Phase 01

Define your task taxonomy

Before you can route, you need to know what you are routing. We categorised every AI-powered interaction across our products into five task classes: classification (low complexity, high volume), extraction (structured output from unstructured input), generation (content creation), reasoning (multi-step inference), and orchestration (tool-calling agents). Each class has different requirements for accuracy, latency, and cost.

  • Audit every AI call in your system and tag it with a task class
  • Measure current latency, cost, and accuracy for each task class
  • Define minimum acceptable quality thresholds per class — not everything needs 95% accuracy
  • Identify which tasks are latency-sensitive (user-facing) vs. latency-tolerant (background processing)
Phase 02

Select and benchmark your model roster

We evaluated models across four dimensions: quality on our specific tasks (not generic benchmarks), latency at our expected concurrency, cost per thousand requests, and reliability (uptime and rate limits). Our current roster includes models ranging from small open-source classifiers running locally to frontier models for complex reasoning. The key insight: a well-prompted smaller model often matches a frontier model on narrow, well-defined tasks.

  • Build a benchmark suite using real production data — at least 200 examples per task class
  • Test each candidate model against every task class, not just its expected assignment
  • Measure p50, p95, and p99 latency, not just averages
  • Factor in rate limits and availability SLAs — a faster model that throttles under load is slower in practice
  • Document the cost per request at your expected volume for each model-task pairing
Phase 03

Build the routing classifier

The router itself is a lightweight classification model — in our case, a fine-tuned small model that takes the incoming request and outputs a task class and complexity score. The complexity score determines which model tier handles the request. Simple classification tasks go to a fast, cheap model. Complex reasoning tasks go to a frontier model. The router adds roughly 40ms of latency but saves hundreds of milliseconds (and significant cost) on the majority of requests.

  • Start with a rule-based router using heuristics (input length, keyword presence, endpoint) before investing in ML-based routing
  • Log every routing decision with the full context — you will need this for debugging and retraining
  • Implement fallback logic: if the assigned model fails or is too slow, automatically escalate to the next tier
  • Add a confidence threshold — if the router is uncertain about classification, default to a higher-capability model
Phase 04

Implement the orchestration layer

The orchestrator sits between the router and the models. It handles prompt templating per model (different models need different prompt formats), response normalisation (so downstream code does not care which model answered), retry logic, and circuit breaking. We built ours as a stateless service that reads routing config from a shared config store, making it easy to update model assignments without redeploying.

  • Abstract the model interface so your application code never references a specific model directly
  • Build prompt templates per model — what works for one model may perform poorly on another
  • Implement response validation to catch malformed outputs before they reach your application
  • Add circuit breakers per model endpoint to prevent cascade failures
  • Use connection pooling and keep-alive connections to reduce handshake overhead
Phase 05

Monitor, measure, and continuously re-route

Routing is not a set-and-forget system. Model capabilities change with new releases. Your traffic patterns shift. New task types emerge. We review routing performance weekly, looking at cost per task class, quality scores from automated evaluations, and latency distributions. When a new model drops that is faster or cheaper for a given task class, we benchmark it and update the routing config — usually within a day.

  • Build dashboards showing cost, latency, and quality per model per task class
  • Run automated quality evaluations on a sample of production traffic daily
  • Set up alerts for quality degradation — model providers sometimes change behaviour without notice
  • Review routing decisions weekly and adjust thresholds based on observed performance
  • Maintain a model evaluation pipeline so new models can be benchmarked against your tasks within hours