Topic 5 of 5 · 5 min read
Deciding between on-device and cloud models
Goal: Write a routing rule that sends a feature to the device or the cloud and states its fallback.
A hybrid feature uses the device model for easy, private or offline work and a cloud model for hard work, with a written rule that says which runs when and what happens if the first choice fails.
Check yourself · 1 of 3
Which request should a hybrid app send to the cloud model?
Why it matters
Neither side wins everywhere. The device is private, fast to start, free per request and works offline, but it is small. The cloud is more capable but costs money per call, needs a connection and sends data to a server. Most products need both, and the risk is a vague boundary that users and engineers cannot predict.
The four routing inputs
- Task difficulty. Short extraction, rewriting and labelling go local. Long documents and multi-step reasoning go to the cloud.
- Privacy. Sensitive data stays local by default. If the cloud is needed, ask the user first, or do not offer the feature for that data.
- Connectivity. No network means the device model, or a clear message that the feature is unavailable.
- Cost. Every cloud call costs money. Send the cheap majority of requests to the device and the hard minority to the cloud.
Writing the rule
A good rule is short and testable:
- Try on-device if the device supports it and the input is under the limit.
- If the input is longer, or the local result fails a check, offer the cloud option and say what will be sent.
- If offline, use the local result or show a clear "needs a connection" message.
- If the device cannot run the model, use the cloud only with consent, or hide the feature.
Honest labels
Tell users where their data goes. A small label such as "Processed on this device" or "Sent to our cloud to handle this long document" is enough. Do not label a cloud call as local.
Before and after
Before: "The assistant uses the cloud when it feels like it."
Users cannot predict where their text goes, and costs are hard to forecast.
After: "Notes under the length limit are summarised on the device. Longer notes ask: 'Send to the cloud for a better summary?' Offline, the short summary still works."
What goes wrong
- Routing by gut feeling, with no written rule.
- Silent cloud fallback on private data.
- No fallback when both paths fail.
- A local label on a feature that sometimes goes to the cloud.
Examples
A routing rule for a notes app
Under the length limit: summarise on the device.
Over the limit: ask before sending to the cloud, naming what will be sent.
Offline: keep the short summary; show "needs a connection" for long notes.
Unsupported device: hide the on-device summary, offer the cloud one with consent.
Rule as code
function route({ chars, offline, supported, sensitive, consent }) {
if (supported && chars <= 4000) return "device";
if (offline) return "unavailable";
if (sensitive && !consent) return "ask";
return "cloud";
}
The 4000 limit is an example. Set yours from testing on the weakest supported device.
Key points
- A hybrid feature needs a written rule for when the device runs and when the cloud runs.
- Route by task difficulty, privacy, connectivity and cost.
- Sensitive data stays local by default, and a cloud send needs the user's clear consent.
- Every path needs a fallback, including what happens offline or when the device is unsupported.
- Labels must tell users truthfully where their data was processed.
Common mistakes
- Having no written routing rule, so behaviour is unpredictable.
- Sending sensitive data to the cloud without asking.
- Forgetting an offline path.
- Labelling a feature as local when it sometimes goes to the cloud.
Check yourself · 2 of 3
A user is offline and asks for a summary of a short note. What should a good hybrid app do?
Check yourself · 3 of 3
Why should a cloud fallback on private data ask the user first?
Practice items, not counted towards your mastery.
Start here
- Built-in AI (Chrome for Developers) (opens in a new tab)DocsFree
Lists Chrome's built-in AI APIs, their status and how to check availability before use.
- Foundation Models framework (Apple Developer) (opens in a new tab)DocsFree
Apple's documentation for calling the on-device language model from an app.
- Gemini Nano on Android (opens in a new tab)DocsFree
Google's overview of running Gemini Nano on Android devices and which features use it.