Multi-Model Architecture for an Office Platform: Routing, Fallback, and Cost Governance
This article explains how an office platform moved from a three-tier model offering to ten models running side by side, and the engineering work that change required. It covers a four-layer architecture that decouples models from business code, pluggable routing strategies based on task type, budget, and health, three-level fallback with explicit degradation flags, cost and latency governance, and a dual-track offline and online evaluation process for model selection. A four-step rollout path and the security controls enforced at the gateway are included.
1. What Changed: From Three Tiers to Ten Models Side by Side
An office platform launched ten models at once, spanning several major Chinese model vendors and including flagship, lightweight, and preview variants. On the surface this is an expanded model catalog. In practice, the platform decoupled models from business code and turned them into configurable, replaceable, measurable infrastructure components.
The earlier three-tier design (standard, advanced, and a single flagship) stratified offerings by capability. Ten models side by side organize supply along a multi-dimensional matrix of vendor × capability × cost × latency. The engineering question shifts accordingly: it is no longer “which API do I call,” but “how do I pick the right model for each request, and how do I degrade gracefully when something fails.”
2. Goals and Technical Challenges
Multi-model integration has to satisfy four goals at once:
- Capability coverage: complex reasoning, long context, structured output, and code generation each have a different best fit.
- Cost control: the price gap between flagship and lightweight models is significant.
- Latency stability: time-to-first-token and throughput vary widely across models.
- Seamless evolution: onboarding a new model or retiring an old one should not require business changes.
The challenges cluster in four areas: heterogeneous interfaces (authentication, parameters, streaming protocols, and error codes are not unified), quality drift (output varies between versions of the same model), routing decisions (a wrong pick unbalances cost or quality), and insufficient observability (failures and latency are hard to attribute per model).
3. Overall Architecture: Four Decoupled Layers
The first layer is the access adapter, which normalizes each vendor’s heterogeneous protocol into a single internal request/response model. The second is the capability abstraction layer, which annotates every model with a uniform capability description (context window, streaming support, tool-calling support, structured output support). The third is the scheduling layer, which selects a model based on task type, cost budget, and real-time health. The fourth is the governance and observability layer, which collects metrics, logs, and traces to drive evaluation and capacity planning.
A sketch of the unified request structure (illustrative only, not any vendor’s interface):
{"task_type": "summarize | extract | code | chat","messages": [{"role": "user", "content": "..."}],"constraints": {"max_cost": 0.02, "max_latency_ms": 3000},"output": {"format": "json_schema", "stream": true},"fallback": ["light_model", "preview_model"]}
4. Routing and Scheduling Strategy
Routing should not be hard-coded if-else branches. It should be a pipeline with pluggable strategies. Four are common: static mapping by task type (extraction goes to lightweight models, reasoning to flagship models); dynamic downgrade by budget (a cost threshold triggers a switch to a lightweight model); circuit breaking by health (a node is removed after consecutive timeouts or a rising error rate); and canary splitting (a new model takes a small share of traffic before a wider rollout).
Simplified strategy pseudocode:
def choose(req, registry, health):candidates = registry.by_task(req.task_type)candidates = [m for m in candidates if health.ok(m.id)]candidates.sort(key=lambda m: (m.price, m.latency_p95))for m in candidates:if m.price <= req.constraints.max_cost:return m.idreturn req.fallback[0]
The key requirement is that routing decisions must be replayable. Log the decision inputs (task type, candidate set, health snapshot) together with the output, so that when quality regresses you can determine whether the model or the strategy is at fault.
5. Fault Tolerance, Fallback, and Consistency
The real value of running multiple models is fault tolerance. Three fallback levels are recommended: cross-vendor switching within the same capability, cross-variant switching (flagship to lightweight), and a cross-modal or rule-based fallback (templated output). Structured output also needs validation and retry: validate against the schema first, retry once with the error message attached on failure, and degrade if it fails again.
Watch out for silent degradation. If a downgrade is not explicitly marked, users will read a quality drop as a system outage. Responses should carry the model identifier and a degradation flag so the frontend can surface it and so it can be counted in statistics.
6. Cost and Performance Governance
Cost governance rests on three capabilities: usage metering per model, budget quotas with alerts, and cache reuse (prefix caching for identical prefixes, result caching for identical requests). Performance governance focuses on percentiles of time-to-first-token and throughput rather than averages. For long-context tasks, apply context trimming and segmented summarization to avoid spending tokens on work that adds nothing.
7. Evaluation and Selection
Selection should not rely on subjective impressions. Run two tracks: an offline evaluation set and online canary traffic. The offline set covers extraction accuracy, structured output compliance rate, code runnability, and long-context recall. Online, the core metrics are task success rate, human adoption rate, and cost per task. Every model version update runs the same regression suite, producing a comparable baseline.
8. Security, Compliance, and Rollout Path
Enforce input and output moderation, sensitive-data masking, and audit trails at the gateway; model identifiers and data flows must be traceable in logs. A four-step rollout is suggested: build the unified abstraction and adapter layers first, then onboard two or three models to establish a baseline for comparison, then enable routing and fallback, and finally complete the evaluation suite and cost dashboard. In related work, Baidu AI Cloud typically emphasizes carrying this kind of governance on foundational capabilities such as a general container platform, logging service, and monitoring and alerting, avoiding tight coupling to any single model.
9. Conclusion
Ten models side by side is not the finish line; it is the starting point for treating models as replaceable components. What actually sets the platform’s ceiling is whether the abstraction layer is clean, whether routing is explainable, whether degradation is controllable, and whether evaluation is systematic.
