Architecture overview
A hybrid local-cloud AI architecture has three layers:
- Application layer — your code sends prompts to a single AI endpoint
- Routing layer — inspects each request and decides local vs cloud based on rules
- Inference layer — local models on your hardware + cloud models via API
The key insight: both local and cloud paths expose the same OpenAI-compatible API. Your application code does not care which backend handles a request. The router makes that decision based on policy.
Routing rules and strategies
| Strategy | Route to local when | Route to cloud when |
|---|---|---|
| Data sensitivity | Prompt contains PII, secrets, or proprietary data | Prompt is public or low-sensitivity |
| Model capability | Task is simple (summarise, translate, classify) | Task needs frontier reasoning, complex code, or creative writing |
| Latency | Need sub-500ms response (autocomplete, chatbot) | Can tolerate 1-5s (analysis, batch processing) |
| Cost optimisation | High-volume, predictable workload | Low-volume, sporadic usage |
| Model specialisation | Arabic prompts → local Arabic model | General prompts → cloud multi-model |
| Compliance | Regulated data must stay in-region | No compliance restriction |
Code example
Here is a simple Python router using the OpenAI SDK:
# hybrid_router.py — routes prompts between local and cloud AI from openai import OpenAI import re # Configure both endpoints local = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama") cloud = OpenAI(base_url="https://api.plugsky.com/v1", api_key="sk-plugsky-...") def contains_sensitive_data(text): # Simple pattern check — in production use a classifier patterns = [r'\bSSN\d{3}-\d{2}-\d{4}\b', r'\b\d{16}\b'] return any(re.search(p, text) for p in patterns) def hybrid_complete(messages, model_local="qwen2.5:7b", model_cloud="plugsky-frontier"): prompt_text = " ".join(m["content"] or "" for m in messages) if contains_sensitive_data(prompt_text): client = local model = model_local elif len(prompt_text) > 2000: # complex → cloud client = cloud model = model_cloud else: client = local # simple → local model = model_local return client.chat.completions.create(model=model, messages=messages)
When hybrid wins
Hybrid local-cloud AI is the right choice when:
- Your data has mixed sensitivity. Some queries contain PII or trade secrets; most do not. Route sensitive queries locally, everything else to the cloud.
- You need real-time for some tasks and deep reasoning for others. Autocomplete and chat responses use local models for speed; complex analysis uses frontier cloud models.
- You want to optimise cost. Keep 80% of your volume on local hardware (near-zero marginal cost). Use cloud models for the 20% that needs frontier capability.
- You are migrating from local to cloud. Run both in parallel during the transition. Route gradually more traffic to cloud as you validate quality and reliability.
- You need regional data residency. Route sensitive queries to a local model in-region. Route general queries to any cloud region.
Tools you need
| Component | Local | Cloud | Router |
|---|---|---|---|
| Inference | Ollama, vLLM, LM Studio | Plugsky API, OpenAI API | Custom logic or gateway |
| API format | OpenAI-compatible | OpenAI-compatible | OpenAI-compatible |
| SDK | OpenAI Python / JS / Go | OpenAI Python / JS / Go | OpenAI Python / JS / Go |
| Gateway | n/a | n/a | LiteLLM, Plugsky Routing |
Because every component speaks the OpenAI API format, your routing logic is trivial — just change base_url and model. No SDK forks, no protocol translation, no compatibility layers.
How Plugsky enables hybrid
Plugsky is built for hybrid architectures:
- Multi-model routing: Plugsky's API can dispatch to different models based on rules you define — including routing to your own local models running on your infrastructure.
- Sovereign deployment: Deploy Plugsky within your own data centre or region. Cloud inference never leaves your control.
- Private endpoints: Run cloud models behind your VPC. Combine with local models for a fully private hybrid setup.
- One API key: All routing, local and cloud, goes through a single endpoint with a single API key. Your application code sees one AI service.
- Unified billing: Track local and cloud usage in one dashboard. No separate invoices for GPU electricity and API tokens.
The most common Plugsky hybrid pattern: local Ollama for development and sensitive data, Plugsky cloud for production and frontier models — all behind the same OpenAI-compatible API.
One API. Local and cloud. No compromises.
Plugsky unifies local and cloud AI behind a single endpoint. Route by data sensitivity, model capability, or cost — your application sees one AI service.
Start Free → Explore local AIFrequently asked questions
What is hybrid local-cloud AI?
Hybrid local-cloud AI routes sensitive or latency-critical prompts to a local model on your hardware, and general-purpose or complex prompts to a cloud API. Both paths use the same OpenAI-compatible interface, so your application code sees a single AI endpoint with intelligent routing underneath.
How do I route between local and cloud models?
You need a routing layer that inspects each request and decides where to send it. Routes can be based on data sensitivity (local for PII, cloud for marketing), model capability (local for simple tasks, cloud for complex reasoning), latency requirements (local for real-time, cloud for batch), or cost optimisation (local for high volume, cloud for occasional use).
What tools do I need for a hybrid setup?
At minimum: Ollama (local inference), a cloud API key (Plugsky or other), and a routing script using the OpenAI Python/JS SDK with configurable base_url. For production, add a gateway like LiteLLM or Plugsky's built-in routing. All of these expose the same OpenAI-compatible API.
Does Plugsky support hybrid deployment?
Yes. Plugsky's multi-model routing can dispatch to local models running on your infrastructure or to cloud models in Plugsky's network — all through a single API endpoint. Plugsky also offers sovereign deployment options for organisations that need cloud inference within their own data centre.
When should I use a hybrid approach instead of pure local or pure cloud?
Use hybrid when your workload has a mix of data sensitivity levels (some private, some public), when your latency requirements vary (some real-time, some batch), or when you want to optimise costs by keeping high-volume simple tasks local while paying only for complex cloud inference.