NeuroMesh

P2P Distributed AI Network

Intelligence partagée — Shared Intelligence

v5.2
🟢 MIT License 🐍 Python 3.12+ 🔗 100% Decentralized 🪶 17MB RAM
⚡ Get Started 📂 View on GitHub
0.16s
Startup Time
17MB
RAM Usage
4
Dependencies
Nodes Possible

Packed with Power

Everything you need for a distributed AI network — nothing you don't.

🤖

Multi-LLM Providers

Ollama, OpenAI, Anthropic, and any OpenAI-compatible endpoint. Bring your own key, share models across the P2P network automatically.

BYOK
🌐

P2P WebSocket

Real-time bidirectional sync via WebSocket. Gossip protocol propagates changes across all nodes. No central server — ever.

Gossip Protocol
🧠

Distributed Memory

CRDT conflict-free replication, vector clocks for causal ordering, gossip propagation, and TTL support. Memory that never conflicts.

CRDT + Vector Clocks
🔐

Decentralized Auth

Ed25519 identity keys, HMAC shared secrets, Web of Trust (PGP-like transitive trust), stealth mode for hidden nodes.

No Accounts Needed

Smart AI Routing

Local first → cloud on demand → peer failover. Ensemble consensus queries multiple models and returns the best answer. Circuit breakers protect the network.

Auto-Failover
📊

Sharing Quotas

Score-based limits: share more compute, earn more access. 1–200 queries/minute depending on your contribution. Fair by design.

Merit-Based
🔍

Auto-Discovery

Static config, Tailscale auto-discovery, or dynamic API registration. Nodes find each other — zero manual work on Tailscale.

Zero Config
🖥️

Interactive CLI

The neuromesh command with /status, /peers, /models, /quota, /ensemble, and more. Full control from your terminal.

Terminal-First
🪶

Lightweight

0.16s startup, 17MB RAM, 4 dependencies. Runs on a Raspberry Pi, a Core 2 Duo, or anything with Python 3.12+.

Minimal Footprint
🔌

OpenClaw Plugin

One command install: openclaw skill install neuromesh. Integrates with your OpenClaw agent seamlessly.

1-Click Install

Why This Exists

We're tired of AI as a service. Monthly subscriptions. API keys that expire. Rate limits you didn't ask for. Vendor lock-in. Data you don't control. Servers that go down and take your workflow with them.

NeuroMesh is the antidote. Your machines, your models, your memory. Connect them peer-to-peer. No middleman. No subscription. No "enterprise tier".

"If you can run Python, you can run a node. If you have two machines, you have a network. If your neighbor joins, it gets stronger. That's it. That's the whole pitch."

The network doesn't phone home. It doesn't meter your usage. It doesn't upsell you. It just works — locally, privately, and reliably.

Every node is equal. No master, no slave, no controller. Memory syncs via CRDT so there are never conflicts. Auth is decentralized — your keys, your trust. Add a node, and the whole network gains compute. Remove one, and the rest keeps running.

This is AI infrastructure for people who build things, not for people who buy things.

Quick Start

Running in under 2 minutes. Seriously.

1

Clone the repo

Grab the code and enter the directory.

bash
# Clone & enter
git clone https://github.com/NeuroMesh-ai/neuromesh.git
cd NeuroMesh
2

Run with default config

That's it. One command. Python 3.12+ required.

bash
python3 src/neuromesh_v5.py

# Or with a custom config
python3 src/neuromesh_v5.py --config config/bug.json
3

Connect your nodes

Set a shared P2P secret and add peers. They discover each other automatically.

json
{
  "node_name": "mynode",
  "port": 8080,
  "p2p_secret": "your-shared-secret",
  "peers": [
    {"name": "other-node", "host": "192.168.1.100", "port": 8080}
  ]
}
4

Query your network

Memory sync, model sharing, and real-time communication — all automatic.

bash
# Ping a node
curl http://localhost:8080/api/ping

# Query AI with auth
TS=$(date +%s)
SIG=$(echo -n "/api/query:$TS" | openssl dgst -sha256 \
  -hmac "your-secret" | awk '{print $NF}')
curl -X POST http://localhost:8080/api/query \
  -H "X-NeuroMesh-Auth: $SIG" \
  -H "X-NeuroMesh-TS: $TS" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"Hello!","model":"glm-5.1:cloud"}'

Architecture

Every node is identical. No master. No slave. Pure P2P.

┌─────────────────────────────────────────────┐
│                  Node (Bug)                  │
│  ┌─────────┐  ┌──────────┐  ┌────────────┐ │
│  │ HTTP    │  │WebSocket │  │  CRDT      │ │
│  │ REST API│  │  Server  │  │  Memory    │ │
│  └────┬────┘  └────┬─────┘  └─────┬──────┘ │
│       │            │              │         │
│       └──────┬─────┘──────────────┘         │
│              │                              │
│       ┌──────┴──────┐                       │
│       │   AI Router │◄──── Ollama (local)   │
│       └──────┬──────┘                       │
│              │                              │
│       ┌──────┴──────┐                       │
│       │  Peer Mgr   │◄──── Tailscale/Static │
│       └─────────────┘                       │
└──────────────┬──────────────────────────────┘
               │  WS + HTTP (gossip)
┌──────────────┴──────────────────────────────┐
│               Node (Pinky)                  │
│         (same architecture)                 │
└────────────────────────────────────────────┘

API Reference

REST + WebSocket. Simple, typed, authenticated.

MethodEndpointAuthDescription
GET/api/pingNoHealth check
GET/api/statusNoNode status, peers, memory stats
GET/api/memory/{key}NoRead a memory entry
POST/api/memory/setYesWrite a memory entry
POST/api/memory/pushYesPush memory entries (sync)
POST/api/queryYesQuery AI models
POST/api/brain/chainYesChain multiple AI queries
POST/api/trust/signYesSign a peer's key (Web of Trust)
GET/api/trust/{key}NoCheck trust score
GET/NoWeb dashboard

WebSocket Messages

Connect to ws://host:port/ws and send typed JSON:

json
{"type": "auth",  "hmac": "<signature>",  "ts": "<timestamp>"}
{"type": "ping",  "timestamp": 1234567890}
{"type": "query", "prompt": "What is AI?", "model": "glm-5.1:cloud"}
{"type": "memory_update", "key": "mykey", "entry": {"value": "mydata"}}

Interactive CLI

Full control from your terminal. The neuromesh command.

/status
Node health, uptime, peers
/peers
Connected peers & latency
/models
Available AI models
/quota
Your sharing score & limits
/ensemble
Multi-model consensus
/memory
CRDT memory browser
/trust
Web of Trust status
/discover
Find new peers