Zero-dependency local mesh router & load balancer for LAN AI inference: aggregate Ollama, llama.cpp, and vLLM nodes with latency-aware routing, health probing, and transparent fallback.
Running open-weight AI models locally is fast, private, and customizable. However, modern home labs and office setups often feature fragmented local compute:
- A primary desktop workstation with an NVIDIA RTX GPU (fastest, but occasionally occupied, powered down, or rebooting).
- A secondary laptop or Apple Silicon Mac (highly available, moderate latency).
- A home-lab CPU server (backup, slower RTT).
Existing clients (Open WebUI, Continue, Cursor, CLI agents) typically connect to a single fixed endpoint (http://localhost:11434). If that machine sleeps or fails, requests fail, dropping the user's workflow.
LocalMeshAI solves this by introducing a transparent, zero-dependency mesh layer across your LAN:
- Exposes an unified OpenAI-compatible gateway at
http://localhost:11435/v1. - Continuously measures round-trip latency via Exponential Moving Average (EMA).
- Automatically routes inference requests to the fastest responsive node hosting the requested model.
- Provides hot transparent failover: if the primary GPU node disconnects or returns HTTP 5xx, the prompt is seamlessly re-dispatched to the secondary node before the stream starts, guaranteeing zero dropped requests.
🚀 Quick start
Run directly with npx (Node ≥ 22 required):
# 1. Discover local AI runtimes on your LAN (Ollama, llama.cpp, vLLM, LM Studio)
npx localmeshai scan
# 2. Run the verified two-runtime trial benchmark (built-in simulation)
npx localmeshai trial --runs 10
# 3. Start the mesh gateway on port 11435 using an example cluster config
npx localmeshai start --config localmesh.example.json
# 4. Check cluster status, throughput, and live node latency table
npx localmeshai statusOr install globally:
npm install -g localmeshai
localmesh --helpLocalMeshAI ships with a repeatable benchmark trial validating multi-node routing under active failure injection (localmesh trial):
| Trial Phase | Active Node | Latency (P50 / P95) | Success Rate | Telemetry Header |
|---|---|---|---|---|
| Phase 1: Baseline | Primary Workstation (RTX 4090) | 44 ms / 49 ms | 100% (6/6) | x-mesh-fallback: false |
| Phase 2: Node Failure | Primary node crashes / returns 503 | — | — | — |
| Phase 3: Mesh Failover | Secondary Laptop (M-Series CPU) | 91 ms / 98 ms | 100% (6/6) | x-mesh-fallback: true |
Observed Result: Zero requests dropped during failover; first switchover recovery executed in 125 ms.
{
"port": 11435,
"host": "0.0.0.0",
"strategy": "lowest-latency",
"probeIntervalMs": 15000,
"nodes": [
{
"id": "workstation-gpu",
"name": "Workstation RTX 4090",
"baseURL": "http://192.168.1.50:11434",
"priority": 20,
"models": ["llama3.2", "deepseek-r1:8b", "qwen2.5-coder:7b"]
},
{
"id": "laptop-m3",
"name": "MacBook Pro M3 Max",
"baseURL": "http://192.168.1.52:11434",
"priority": 10,
"models": ["llama3.2", "deepseek-r1:8b"]
}
]
}lowest-latency(default): Routes each request to the fastest responsive node with the lowest EMA latency.tier-aware: Prioritizes dedicated accelerator tiers (gpu-high>gpu-mid>gpu-low>cpu).priority-fallback: Prioritizes primary hardware (highestpriorityvalue), switching to secondary nodes only during outages.least-connections: Distributes heavy concurrent inference across nodes based on active in-flight requests.
- Zero Cloud Leakage: Prompts and completions strictly traverse your local LAN network. No external proxies or analytics.
- Header Telemetry: Inspect
x-mesh-node-id,x-mesh-latency-ms, andx-mesh-fallbackon any response. - Strict Single Source of Truth: Core is under 1,500 non-empty lines with zero external runtime dependencies.
See docs/ARCHITECTURE.md for data flow and internal router mechanics.
LocalMeshAI is free, open source, and developed independently. If this tool saves you time or empowers your local AI home lab, consider supporting ongoing development:
- 💖 GitHub Sponsors: MRJonam91
- ☕ Ko-fi: mrjonam
- 🍕 Buy Me a Coffee: mrjonam
- 💳 PayPal: https://paypal.me/manorollo
Distributed under the Apache-2.0 License. See LICENSE, NOTICE, and LICENSING.md for full terms.