Multi-Model Integration for Office Platforms: Technical Selection and Practice
This article explains how to move from a fixed model list to runtime model selection in office applications. It covers a three-tier capability abstraction (lightweight, general, and reasoning), a model gateway with routing, degradation, retry, and schema validation, plus observability metrics and governance practices for cost and latency. The approach is vendor-neutral and can be applied to your own office platform.
1. Why Office Scenarios Need Multiple Models at Once
A cloud platform’s all-in-one office capability launched ten models at once, spanning general flagship, lightweight-response, and reasoning-enhanced tiers from several major Chinese model vendors. On the surface this is just a longer model list; in practice it reflects a clear engineering trend: office applications can no longer be served by a single model.
The distribution of office tasks is highly uneven. Short-text rewriting, field extraction, and summary polishing are high-concurrency, low-latency, low-difficulty tasks. Cross-document comparison, metric attribution, long-document structuring, and table reasoning are low-frequency, high-latency, high-difficulty tasks. If one model carries all traffic, you inevitably hit a three-way bind: too expensive, too slow, or not smart enough. The point of running multiple models side by side is to turn model selection from a product configuration item into a runtime decision.
2. Capability Tiers: Abstracting the Model List into Three Pools
Given a long list of model names, engineers should not memorize them one by one. Abstract them into three capability pools instead:
- Lightweight tier: optimized for time-to-first-token and unit cost; suited to classification, extraction, rewriting, and formatted output.
- General tier: balanced overall capability; suited to most everyday Q&A and document processing.
- Reasoning tier: optimized for multi-step reasoning and long-context stability; suited to complex analysis, solution generation, and code or data reasoning.
The benefit is that business code depends only on the abstract contract of a “capability tier,” so changes to the model list do not affect callers. Vendor model names change far more often than business code iterates, and hardcoding model names is one of the most common sources of technical debt.
3. Integration Architecture: A Unified Abstraction Layer and Routing Strategy
The recommended approach is to insert a model gateway between business logic and models, with five responsibilities: protocol adaptation, routing decisions, rate limiting and circuit breaking, logging, and cost accounting.
from dataclasses import dataclassfrom enum import Enumclass Tier(str, Enum):LIGHT = "light" # Lightweight tierGENERAL = "general" # General tierREASON = "reason" # Reasoning tier@dataclassclass TaskProfile:tier: Tiermax_latency_ms: intmax_tokens: intneed_json: bool = Falsedef route(profile: TaskProfile, registry: dict) -> str:"""Select candidate models by capability tier + latency budget + output constraints, and return primary/backup order"""candidates = [m for m in registry[profile.tier]if m.max_latency_ms <= profile.max_latency_ms]candidates.sort(key=lambda m: (m.cost_per_1k, m.max_latency_ms))return candidates[0].name if candidates else registry[profile.tier][0].name
For routing, “rules first, statistics as fallback” is recommended: first narrow the candidate set with deterministic rules (task type, context length, whether strict structured output is required), then adjust weights dynamically using near-line statistics (success rate, P95 latency, rate-limit hits). Avoid starting with complex model scoring on day one; without a stable baseline, it tends to amplify jitter.
4. Stability Design: Degradation, Retries, and Result Consistency
Multiple models bring redundancy, but also new failure modes. Three paths must be designed explicitly:
- Same-tier degradation: after a reasoning-tier timeout, fall back to the general tier and mark the response as degraded, so users do not misjudge the confidence of the conclusion.
- Cross-tier retries: retry only idempotent tasks, using exponential backoff with jitter to prevent retry storms.
- Result consistency checks: validate structured output against the schema and at the field level; on failure, regenerate with another model rather than passing the result through.
def generate(profile: TaskProfile, payload: dict, gateway) -> dict:order = gateway.plan(profile) # Primary model + backup sequencelast_err = Nonefor name in order:try:out = gateway.call(name, payload, timeout_ms=profile.max_latency_ms)if profile.need_json and not gateway.validate_schema(out, payload["schema"]):raise ValueError("schema mismatch")return {"data": out, "model": name, "degraded": name != order[0]}except Exception as e:last_err = eraise RuntimeError(f"all candidates failed: {last_err}")
5. Cost and Performance Governance: Observability First
Cost optimization for a multi-model system cannot rely on guesswork. Three categories of metrics need to be online at the same time: unit cost per request broken down by task type, P50/P95 latency and failure rate broken down by model, and degradation rate broken down by routing decision. An abnormally high degradation rate usually signals a capacity or rate-limiting problem rather than a model quality problem.
Governance measures include: introducing a semantic cache for high-frequency repeated requests; segmenting long documents and compressing key points before sending them to the reasoning tier; scheduling batch offline tasks and online interactive tasks in separate pools; and setting a hard context limit for the lightweight tier so small models are not dragged down by long text.
6. Common Pitfalls
- Treating model names as capability: names iterate quickly, capability tiers are relatively stable.
- Testing only average latency: the office interaction experience depends on P95 and time-to-first-token.
- Missing degradation markers: users cannot judge how trustworthy a conclusion is, and later complaints are hard to attribute.
- Skipping validation of structured output: downstream parsing errors often surface only at the end of the chain.
7. Conclusion
Running ten models side by side is not a matter of choice overload; it hands the choice back to the engineering system. A practical path is: first establish capability tiers and a unified abstraction layer, then layer on rule-based routing, degradation fallbacks, and end-to-end observability, and finally calibrate weights continuously with real traffic. In its practice combining general model services with cloud-native observability, message queues, and object storage, Baidu AI Cloud follows the same tiering and fallback approach. This method is vendor-independent and can be ported directly to your own office platform.
