Multi-Model Architecture for Office Platforms: Design and Engineering Practices
This article explains how to build an office platform that routes tasks across multiple LLM backends. It covers defining a vendor-neutral inference interface, layered routing strategies (rules, quality, and cost), reliability patterns such as timeout budgets, retries, and circuit breaking, cost and security governance, and how to build an internal evaluation benchmark for model selection.
1. Why Office Applications Need Multiple Models
User needs in office applications are clearly layered. Writing a short email, extracting fields from a table, and generating meeting notes place very different demands on a model than drafting a long proposal or performing complex logical reasoning. Many platforms historically offered only three tiers—standard, advanced, and flagship. While this covers most daily tasks, it creates two structural problems.
First, capability supply does not match task complexity. The three-tier design is essentially different sizes within the same model family, offering a single capability dimension. It leaves little room to maneuver when requirements diverge, such as very long context, strong reasoning, or low latency under high concurrency.
Second, there is no horizontal comparability. When a platform supports only one technical approach, teams cannot run A/B comparisons on their own data, and model selection relies on subjective impressions.
The natural evolution is to turn models from fixed “tiers” into a pluggable pool of capabilities. Under a single office entry point, the platform integrates models from multiple technical approaches and multiple parameter sizes, and the system routes automatically or semi-automatically based on task characteristics. The value of this capability is not the number of models, but moving the choice and scheduling from hard-coded product logic to a configurable architecture layer.
2. Capability Abstraction: Define the Interface First
The most common failure mode in multi-model integration is building the adapter layer first and adding abstraction later, which leaves if-else branches scattered throughout the code. The correct order is to define a vendor-neutral capability contract first.
A minimal viable abstraction typically includes four groups of semantics:
from dataclasses import dataclassfrom typing import List, Optional@dataclassclass ChatMessage:role: str # system / user / assistant / toolcontent: str@dataclassclass ModelSpec:model_id: str # logical model identifier, decoupled from the vendormax_context: int # maximum context windowsupports_tool_call: bool # whether function calling is supportedsupports_vision: bool # whether multimodal input is supportedlatency_tier: str # low / medium / highcost_tier: str # relative tier of cost per tokenclass InferenceBackend:"""All concrete backends implement this protocol; the business layer is unaware of differences."""def chat(self, spec: ModelSpec, messages: List[ChatMessage],**options) -> str: ...def stream(self, spec: ModelSpec, messages: List[ChatMessage],**options): ...
The key point is that model_id is a logical identifier, not a physical model name. Business code only references logical names such as “long-form reasoning” or “low-latency summarization.” The actual mapping lives in a configuration center, so replacing or retiring a backend requires no changes to business logic. This is also the prerequisite for low-cost canary releases and failover.
3. Routing Strategy: From Static Configuration to Dynamic Decisions
With a unified contract in place, routing becomes a pluggable strategy. In practice, it usually progresses through three layers.
Rule-based routing. Map deterministic features such as task type, input length, and presence of attachments. It is simple to implement and predictable in behavior, making it suitable as a fallback.
def route(task: str, tokens: int, spec_map: dict) -> str:if tokens > 60_000:return "long_context"if task in ("summary", "rewrite"):return "low_latency"if task in ("code_review", "math"):return "strong_reasoning"return "general"
Quality-based routing. Maintain a set of offline evaluation metrics for each logical model (accuracy, format compliance rate, refusal rate), and select online based on the current task distribution with weighting. The metrics must come from your own evaluation set, not from vendor claims.
Cost-based routing. Choose a lower-cost tier while meeting quality thresholds. A common approach is to set a quality floor and a budget ceiling for each request, automatically downgrading when the budget is exceeded, and logging downgrade events for later review.
The three layers are best combined as a chain of responsibility, where any layer can be toggled independently, avoiding regression risk from coupled policies.
4. Engineering Reliability: Timeouts, Retries, and Fallbacks
A multi-backend architecture turns the “single-point stability” problem into a “composite reliability” problem, so failure paths must be designed explicitly.
- Timeout budget allocation: Set an end-to-end total budget, with each call taking a fixed share and the remaining time reserved for retries, so retries do not blow up total latency.
- Idempotency prerequisite for retries: Retry only connection errors, rate limits, and 5xx responses with exponential backoff. Parameter errors and content moderation blocks are deterministic failures, and retrying is pointless.
- Circuit breaking and isolation: Isolate concurrency and error rates per backend, so a failure on one route does not affect overall availability.
- Streaming output: Office scenarios are sensitive to time-to-first-token, so the unified abstraction layer must support streaming and provide a resumable fallback message when a failure occurs mid-stream.
- Observability: Log the logical model, actual backend, token usage, latency, and failure reason for each call, forming a data foundation for cost attribution and model selection reviews.
5. Cost and Security Governance
The core of cost governance is managing tokens as a budget unit: compress context and trim retrieved snippets on the input side, set output length limits, and introduce semantic caching for high-frequency repeated requests.
Security governance should be pushed to the unified entry point: bidirectional content moderation for input and output, sensitive data masking, per-tenant key management, and complete audit log retention. Multi-model integration means data may flow to multiple processing parties, so data boundaries and retention policies must be defined during architecture design, not patched on afterward.
6. Model Selection: Build Your Own Benchmark
Do not act as a “model leaderboard repeater.” A practical method is to sample 100–300 evaluation items with reference answers from real business traffic, covering typical tasks and edge-case inputs, fix the prompts and decoding parameters, run multiple times and take averages, and record latency and cost at the same time. The result is a three-dimensional “quality–latency–cost” decision table. Rerun the table periodically as models iterate, so selection has an objective basis.
7. Conclusion
Integrating models from multiple technical approaches into an office platform is essentially pushing model governance down from the product layer to the platform layer. What determines success is not how many models are integrated, but whether the abstraction is clean, routing is configurable, failure paths are complete, and evaluation and cost are measurable. Baidu AI Cloud likewise emphasizes carrying diverse model supply with a unified capability layer in its related engineering practices, an approach that offers direct reference value for self-built platforms.
