A model running on a client's own GPU is great for data control and not great for uptime. Hardware gets rebooted, a driver update goes badly, a queue fills up. When that happens, the tempting fix is a fallback to a hosted model, and the tempting mistake is sending sensitive prompts there without anyone deciding it was allowed.
Failover for a self-hosted model needs one extra rule that normal failover doesn't: some requests must not fall back at all.
Why plain failover isn't enough
A standard retry-then-fallback loop treats every request the same. Try the primary, and if it fails, try the next one. That's fine when every endpoint is equally trusted.
On-site deployments exist because some data isn't allowed to leave. If the loop quietly moves a customer's contract text to a hosted model at 3 a.m., you've defeated the reason for running on site, and nobody will notice until an audit.
Failover is one piece of a larger architecture that includes gateways, permissions, logging and deployment boundaries. If you want the wider picture, this walkthrough of design patterns for production-grade agent systems covers how these parts fit together.
The fix for the failover piece is to attach a data class to each request and a trust flag to each endpoint. A sensitive request only sees endpoints marked local. If none of them is available, the request fails, and the caller decides what to do.
The pattern
The function below tries endpoints in order, skips any that aren't allowed for the request's data class, and gives each a short timeout. If nothing works, it throws a clear error.
I ran it in Node against two small local servers, one returning a 503 and one answering normally:
async function complete(prompt, endpoints, { sensitive = false, timeoutMs = 300 } = {}) { const candidates = endpoints.filter((e) => !sensitive || e.local); for (const ep of candidates) { try { const res = await fetch(ep.url, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ prompt }), signal: AbortSignal.timeout(timeoutMs), }); if (!res.ok) throw new Error(`status ${res.status}`); const data = await res.json(); return { text: data.text, servedBy: ep.name }; } catch { // try the next endpoint } } throw new Error("no endpoint available for this data class"); } With the on-site endpoint down, a normal request is served by the hosted one. A sensitive request fails with no endpoint available for this data class. That failure is the feature, not a bug.
Decisions hidden in the details
The timeout matters more than people expect. A model that is slow but not dead can hold up an entire conversation, so I'd keep the timeout tight for short tasks and generous only where long answers are normal.
The error shape matters too. Return something the agent can act on, such as a message telling the user the on-site model is unavailable and the request will be queued. Don't let it improvise an explanation.
Finally, log every failover with the endpoint used and the data class. A weekly count of fallbacks is a good early warning that the on-site model needs attention.
Who decides what counts as sensitive
This is a policy question, not a code question, and it deserves a written answer. I'd keep a short list agreed with the client's security team: customer personal data, contracts, internal financials, anything else they name. The data class is set by the caller based on that list, not guessed by the model.
When in doubt, treat the request as sensitive. A failed request is annoying. A leaked one is a different kind of problem.
Testing it
Three tests cover most of the risk. A normal request falls back when the primary is down. A sensitive request never reaches a non-local endpoint, even when everything else fails. And a slow endpoint gets skipped after the timeout instead of blocking forever.
Run them in CI, and rerun them whenever someone adds an endpoint. A new entry in the list with the wrong local flag is the easiest way to break the guarantee.
What I'd monitor
Track three numbers: how often the on-site model fails, how often requests fall back, and how many sensitive requests were refused. A rising refusal count isn't a problem with the code. It tells you the on-site model needs capacity or attention before users feel it.
Review the numbers weekly with whoever runs the client's servers. A short conversation about trends is cheaper than an incident.
How do you decide which requests may leave your network in an on-site deployment? I'm curious whether anyone has found a cleaner rule than a manual list.
Disclosure: I advise teams on this kind of deployment at AI Hive, where the platform can run on a customer's own servers, including through an AI agent platform built for enterprise scale.
