
Hybrid Inference: The Client-Server Split
A client-side AI feature that has to serve every device and every task ends up needing a server path too. Here is how to route between them without the two implementations quietly drifting apart.
TL;DR: A client-side AI feature that has to serve every device and every task ends up needing a server path too — for devices that cannot run the model, requests too heavy for the client, or quality floors the local model cannot clear. The design question is not whether a server path exists but where the split sits, who decides per request, and how the feature avoids two implementations that quietly drift apart.
Why client AI features that serve every device end up hybrid
The arithmetic from the rest of this topic lands squarely here. The capability ladder this topic has already built has a server rung at the bottom for devices that cannot clear the local bar. The memory budget excludes some share of devices outright. The small-model quality ceiling excludes some tasks entirely. Put together, a purely client-side feature serves a subset of users and use cases — the server path exists to serve everyone else.
That reframes the design question. It is not whether a feature needs a server path — one that has to serve every device and every task does — but where the client-server split sits for this particular feature, and who or what decides, per request, which side handles it.
Two failure modes are worth naming up front, because this article exists specifically to prevent them. The first is drift: two independent implementations of the same feature, one client and one server, that quietly diverge in behavior over many rounds of separate iteration until users notice the feature works differently depending on their device. The second is dishonesty: a fallback that silently changes where the user's content goes without telling anyone — the on-device privacy claim quietly becoming false the moment the fallback fires.
Routing rules as an explicit artifact
The inputs that decide where a given request should run are enumerable: device capability (the verdict this topic's capability-detection discipline already produces), task weight (a short classification call versus a long synthesis job), the quality bar the task needs (a draft versus a final, user-facing output), context size (whether the input fits the local model's window), and connectivity (offline flips every other input on its head).
The routing table itself is a written artifact per feature — which input combinations go local, which go remote, which degrade to a lighter local path, and which decline outright. This is the same discipline as the capability ladder this topic already established, applied one level up at the feature-routing layer rather than the device-capability layer.
| Routing input | What it decides | Example threshold |
|---|---|---|
| Device capability | Local-eligible vs. server-only | Below the memory floor routes to server automatically |
| Task weight | Local-comfortable vs. server-preferred | Short classification stays local; long synthesis routes remote |
| Quality bar | Local-acceptable vs. server-required | Drafting accepts local; final output requires the remote model |
| Context size | Fits local window vs. needs remote | Local context ceiling exceeded routes remote |
| Connectivity | Offline changes every other row | Offline forces local-only or a queued state |
Latency and cost run in both directions honestly. Local wins on round-trip time and on privacy; remote wins on raw model quality and, counterintuitively, on first use — a server call does not wait for a model to download to the user's device, although a serverless endpoint can have a cold start of its own. A legitimate pattern is to route to the remote model on first use while the local model is still warming up, then hand off once it is ready.
Cost is worth stating structurally rather than as a slogan: every request routed local is a request that is not billed per call to an inference API. That single sentence is what turns the routing table from an architecture diagram into a line item an engineering team can actually reason about.
The routing table is worth writing down even for a feature that starts out simple, because the alternative is routing logic scattered across conditionals in the codebase with no single place that answers "why does this particular request go where it goes." A written table survives a team member leaving, survives a routing bug investigation long afterward, and gives a code reviewer something concrete to check a proposed change against — rather than trusting that whoever wrote the original routing logic remembered every input correctly.
The shared seam
The principle underneath all of this is that both paths implement one task interface, so the calling code never knows or cares where inference actually ran. A feature calls something like summarize(text), not "call WebLLM" or "hit this endpoint" — the routing decision lives entirely behind that one function.
A useful market-reality example of this seam, as of November 2026, is the OpenAI-compatible chat completions surface. WebLLM exposes it locally (WebLLM project), and server-side stacks such as vLLM and Ollama document OpenAI-compatible chat completions endpoints. That gives both sides of a hybrid feature a common request shape to build on, but support is not uniform — Ollama documents support for a subset of the OpenAI API, and WebLLM marks function calling as WIP, with preliminary support for the tools and tool_choice fields — so the seam still has to handle what one side lacks. This is named as a worked example of the pattern, not an endorsement of any single runtime.
// The calling code never branches on where inference runs —
// routing picks the client, and both implement the same shape.
// localClient / remoteClient are app-defined wrappers (a WebLLM engine and
// an OpenAI SDK client), each carrying the modelId it serves; route and
// collectStream are app helpers. In WebLLM v0.2.88, modelId must name an
// already loaded model_id.
async function summarize(text: string): Promise<string> {
const client = route(text) === 'local' ? localClient : remoteClient
const res = await client.chat.completions.create({
model: client.modelId,
messages: [{ role: 'user', content: `Summarize: ${text}` }],
stream: true,
})
return collectStream(res)
}The seam has to carry more than the happy path to be worth calling a seam at all. Streaming, cancellation, timeout behavior, and error taxonomy need to be identical on both sides — a shared interface that only unifies successful responses fails at exactly the moment routing matters most, which is when something goes wrong on one path and the feature needs to fall back cleanly to the other.
Where hosting that server side of the seam actually runs — a managed inference API, a serverless function, or self-hosted infrastructure — is a question for the web-hosting literature's own coverage of AI infrastructure, not this topic.
Building the seam this way has a payoff beyond tidiness. When the two paths share one interface, swapping the underlying local model or the remote provider becomes a change confined to the client or the server implementation of that interface — the calling code and every feature built on top of it stays untouched. Without the seam, a model swap on either side tends to ripple outward into every call site that assumed a particular request or response shape, which is exactly the kind of change that turns a routine model upgrade into a multi-team migration.
Quality divergence and disclosure
An honest fact underlies this whole article: when the local path and the remote path run different models — as they do whenever a small local model sits beside a larger remote one — they can produce different quality. Pretending they are equivalent produces user-visible inconsistency that reads to the user as the product being unreliable rather than as an architecture trade-off they never agreed to.
There are three legitimate postures for handling that divergence, chosen deliberately per feature rather than defaulted into. Parity by subtraction constrains the feature to only the capabilities the weaker path handles acceptably, so both paths genuinely produce equivalent results. Open tiering presents the difference honestly — a "fast" mode and a "pro" mode, say — rather than hiding it. Per-request quality routing sends higher-stakes requests to the stronger path based on the quality-bar input from the routing table above.
Disclosure is a design rule, not an implementation detail: when a fallback changes where the user's content is being sent, that switch needs to be visible to the user. The full disclosure framework — what exactly gets said and when — belongs to this topic's dedicated privacy coverage; the rule that applies at the routing level is simply that a silent change in data destination is not an acceptable default.
The evaluation tie-in closes the loop: both paths should run against the same task evaluation set, because "the fallback path is fine" is a claim, and a claim this topic's evaluation discipline can actually test rather than assume.
Offline and testing
Offline connectivity is a routing state to design for explicitly, not an error condition to catch. A feature built on a locally capable model keeps working when the network drops. A feature that genuinely requires the remote path declines honestly rather than hanging or silently failing. For tasks that are not interactive, queuing the request for when connectivity returns is a legitimate third answer that neither of the first two covers.
Both paths deserve first-class treatment in continuous integration, extending the forced-rung testing discipline this topic's capability-detection coverage already established: the remote path exercised with the local path disabled, and the local path exercised with the remote path disabled, on every relevant change. The path nobody tests is the path that quietly rots.
Configuration drift is the quiet killer underneath all of this. Model versions, prompts, and parameters need to be pinned and reviewed for both paths together, in the same pull request. A change that tunes the server-side prompt and forgets the client-side one is exactly the drift failure this article opened by naming — and it is invisible until a user on the untouched path notices the feature behaving differently than it used to.
A practical habit that catches this early is keeping both paths' configuration in one file or one small module rather than splitting them across separate parts of the codebase owned by different people. When a prompt change and its local-path counterpart live next to each other, a reviewer can see at a glance whether one was updated without the other — the drift becomes visible in the diff instead of requiring someone to remember, later on, that two configurations were ever supposed to match.