Multi-Model Architecture for an Office Platform: Design and Practice
This article explains how to build an office platform that supports multiple LLM models without coupling business logic to any single vendor. It covers a unified model access layer with capability abstraction and a declarative registry, three routing layers (explicit tiers, automatic routing, and policy-based orchestration), stability mechanisms such as same-tier and cross-tier fallback, retries with backoff, quota isolation and circuit breaking, plus observability, cost governance, offline evaluation and compliance. The goal is to keep a system with a dozen heterogeneous models controllable and transparent to upper-layer services.
1. Background: Why Office Scenarios Need Multiple Models
As intelligent office applications evolve quickly, one trend stands out: platforms no longer bind capabilities to a single model. Instead, they offer models from several technical approaches and let users choose. In the original information, an office platform launched more than ten models at once, covering general flagship, lightweight fast, and reasoning-enhanced types, and greatly expanded the selectable space beyond the existing three tiers of “standard / advanced / flagship.”
Three practical drivers sit behind this phenomenon.
First, task heterogeneity. Office tasks range from short text rewriting and summary extraction to long-document parsing, table structuring, and cross-document comparison. Their requirements for context length, response latency, and structured-output stability differ enormously, and a single model can hardly be optimal on all dimensions at the same time.
Second, differences in cost structure. Flagship models cost more per token, and expenses balloon quickly if every request goes to a flagship model. Lightweight models offer better cost-performance on tasks such as classification, extraction, and formatting.
Third, risk diversification. Betting business continuity on a single vendor and a single model version leaves the business side without a buffer once rate limiting, version retirement, or quality regression occurs.
Therefore, “multiple models to choose from” is not a marketing concept but an architectural question that engineering must answer: how to cleanly accommodate a dozen heterogeneous models in one system while keeping upper-layer business unaware of them.
2. Core Design: A Unified Model Access Layer
The first step toward multiple coexisting models is to decouple “models” from business code and abstract them into replaceable dependencies.
2.1 Capability Abstraction and a Unified Interface
Do not write a separate calling logic for each model. Define a vendor-neutral minimal interface that exposes only the semantics the business actually needs:
from dataclasses import dataclassfrom typing import List, Optional@dataclassclass Message:role: str # system / user / assistantcontent: str@dataclassclass ModelSpec:name: strcontext_window: intsupports_tools: booltier: str # flagship / balanced / fastclass ChatModel:def chat(self, messages: List[Message],tools: Optional[list] = None,max_tokens: int = 1024) -> str:raise NotImplementedError
Each concrete model implements an adapter that translates the unified request into its own calling protocol and normalizes the differing response structures into the same result object. The business layer depends only on ChatModel and ModelSpec. Adding a model means adding one adapter plus one registration record, a standard application of the open-closed principle.
2.2 Model Registry and Metadata
Maintain a declarative registry that makes non-functional attributes explicit for routing and governance:
models:- name: flagship-atier: flagshipcontext_window: 128000supports_tools: truerate_limit: 60- name: fast-btier: fastcontext_window: 32000supports_tools: falserate_limit: 300
The key point is that metadata such as context window, tool-calling support, and rate-limit thresholds must live in configuration rather than be hard-coded; otherwise every model adjustment requires a code change.
3. Routing Strategy: Turning “Selectable” into “Selected Correctly”
When a dozen models are placed in front of users without guidance, the selection cost shifts to the users. Engineering should provide three routing layers.
The first layer is explicit tiers. Keep coarse-grained options such as “standard / advanced / flagship” and map the dozen concrete models behind the tiers, so users need not understand model differences.
The second layer is automatic routing, which selects by task characteristics: short inputs with low-latency requirements go to the lightweight tier; long documents, tool calls, or multi-step reasoning go to the flagship tier. Illustrative logic:
def route(task, spec_registry):if task.tokens_in > 0.7 * spec_registry.max_context():return spec_registry.by_tier("flagship")if task.requires_tools and not spec_registry.fast_supports_tools():return spec_registry.by_tier("balanced")return spec_registry.by_tier("fast")
The third layer is policy-based orchestration. For high-value requests, use a two-stage approach of “lightweight answer first, flagship review second.” For extraction tasks, use multi-model voting: take the consistent result, and escalate to a flagship model for arbitration when results disagree.
4. Stability: Fallback, Retry, and Rate Limiting
The real value of multiple models lies in fault-domain isolation. The following must be implemented:
- Same-tier fallback: switch to a backup model in the same tier when the flagship is unavailable, keeping quality from collapsing;
- Cross-tier fallback: drop to the lightweight tier when the backup also fails, ensuring “there is a result” first;
- Retry with backoff: retry only idempotent requests, using exponential backoff with jitter to avoid a retry storm;
- Quota isolation: set token buckets per business line to prevent a single scenario from exhausting the global quota;
- Circuit breaking: short-circuit for a period after consecutive failures reach a threshold, with half-open probing for recovery.
for candidate in plan.candidates: # already sorted by tier and prioritytry:return candidate.model.chat(msgs)except RateLimited:continueexcept TransientError:sleep(backoff())continuereturn fallback_answer(msgs) # rule/template fallback
5. Cost and Observability
Multiple models amplify metering complexity, so observability must come first. Record the following uniformly for every call: model identifier, tier, input and output tokens, latency, whether fallback occurred, number of retries hit, and task identifier. These fields answer three questions: which tier has the lowest cost per task, whether the fallback rate is abnormal, and whether a model’s quality regression is amplified by routing.
For cost governance, set budgets and tier caps for different tasks, split and summarize long documents before sending them to the model, and introduce semantic caching for repeatable requests. These measures usually save more directly than switching models.
6. Evaluation and Compliance
Selectable models mean quality must be comparable. Build an offline evaluation set covering high-frequency office tasks (summarization, rewriting, information extraction, table restoration, multi-turn Q&A). Run a regression on every model or prompt change, and record baselines with unified metrics to avoid unnoticed quality drops after a model switch.
Compliance requirements include: keeping a trace of the call chain, masking sensitive fields before they enter the model, deciding the available model scope by data classification, and clarifying differences in each model’s data retention policy. These should be part of the registry metadata and adjudicated centrally by the gateway, rather than scattered across business code.
7. Summary
An office platform with coexisting multiple models is essentially an architecture problem rather than a selection problem. Decoupling models with a unified interface, driving routing with metadata, ensuring continuity with same-tier and cross-tier fallback, and supporting cost and quality governance with fine-grained instrumentation keep the system controllable when a dozen models are online at the same time. In related practice, Baidu AI Cloud also emphasizes building such an access layer with general model service categories together with foundational capabilities such as container platforms, log services, and monitoring alerts; this approach applies equally to self-built solutions.
