Decentralized P2P network for AI model hosting and inference
Project description
🐝 Bee2Bee: The Neural Consensus P2P Network
Bee2Bee is a decentralized, peer-to-peer neural consensus engine designed to make AI inference accessible, transparent, and resilient. It allows anyone to contribute compute to a global mesh and anyone to consume it through a unified, high-performance API.
🏗️ Architecture
Bee2Bee operates as a Decentralized Mesh where every node is both a consumer and potentially a provider:
- Neural Nodes: Host models (Ollama, HF, Transformers) and register via the Global Registry.
- Consensus Router: Intelligently routes requests to the lowest-latency, highest-reliability nodes.
- API Sidecar: Every node optionally hosts a FastAPI management layer for real-time telemetry.
🚀 Quick Start (Production)
1. Installation
pip install bee2bee
2. Launch a Worker Node (The Consumer/Provider)
Run a node that automatically joins the network and hosts a model:
# Deploys a Llama3 provider via Ollama with an API sidecar on port 8000
python -m bee2bee serve-ollama --model llama3 --api-port 8000
3. Connect to the Mesh
To join the global discovery map on the Chatit.cloud Dashboard:
python -m bee2bee config bootstrap_url ws://bootstrap.chatit.cloud:4003
🛠️ Developer Guide
Developing Solutions (Python)
Integrate P2P intelligence directly into your apps using our rich-ready SDK:
import asyncio
from bee2bee import P2PNode
async def main():
# Initialize P2P entrypoint
node = P2PNode()
await node.start()
# Discovery
providers = await node.discover_providers(model="llama3")
# Intelligent Request
response = await node.request_generation(
provider_id=providers[0].id,
prompt="Synthesize a response for decentralized governance."
)
print(f"P2P Intelligence: {response['text']}")
asyncio.run(main())
Interactive Learning
Check out our Jupyter Guide for a step-by-step walkthrough of the p2p architecture.
🌐 FastAPI Integration
Bee2Bee nodes now support a native FastAPI sidecar. This allows you to monitor your node health and peer list via standard HTTP requests:
- Health Check:
GET http://localhost:8000/ - Peers List:
GET http://localhost:8000/peers - Cloud Inference:
POST http://localhost:8000/chat
🤝 Community & Support
- Developer Support: [+201211268396]
- Dashboard: Bee2Bee Live Map
Built with ❤️ by the ConnectIT Team for a decentralized future.
🚀 Quick Start Guide
1. Main End Point (The Supervisor)
This runs the core API server. Every network needs at least one Main Point.
Run Locally:
# Starts the API on Port 4002 and P2P Server on Port 4003
python -m bee2bee api
Output:
- API:
http://127.0.0.1:4002(Docs:/docs) - P2P:
ws://127.0.0.1:4003
2. Desktop App (The Dashboard)
A modern UI to visualize the network and chat with models.
Prerequisites: Node.js 20+
Run Locally:
cd electron-app
npm install # First time only
npm run dev
Usage:
- Open the App.
- It connects to
http://localhost:4002by default. - Go to "Chat" to talk to available providers.
- See MANUAL_TESTING.md for detailed testing steps.
3. Worker Node (The AI Provider)
Run this on any machine (or the same machine) to share an AI model.
Step A: Configure (Tell the node where the Main Point is)
# If running on the SAME machine as Main Point:
python -m bee2bee config bootstrap_url ws://127.0.0.1:4003
# If running on a DIFFERENT machine (LAN/WAN):
python -m bee2bee config bootstrap_url ws://<MAIN_POINT_IP>:4003
Step B: Deploy Model
Option 1: Hugging Face (Default)
Uses transformers to run models like GPT-2, Llama, etc. on CPU/GPU.
# Deploys distilgpt2 (CPU friendly)
python -m bee2bee deploy-hf --model distilgpt2
Option 2: Ollama (Universal) Uses your local Ollama instance to serve models like Llama3, Mistral, Gemma, etc. Prerequisite: Install and run Ollama
# Serve a model (e.g., llama3)
python -m bee2bee serve-ollama --model llama3
Note: This creates a separate peer node on your machine.
Option 3: Remote Inference (Cloud) Execute models entirely on Hugging Face's servers via Inference API. No GPU required on your local machine!
# Deploys Zephyr 7B (Runs on Hugging Face Cloud)
python -m bee2bee deploy-hf --model HuggingFaceH4/zephyr-7b-beta --remote --token YOUR_HF_TOKEN
Note: The node acts as a proxy/gateway to the remote model.
4. Bee2Bee Cloud (Google Colab)
Run a powerful node on Google's free GPU infrastructure using our Hybrid Tunneling setup.
Notebook Location: notebook/ConnectIT_Cloud_Node.ipynb
How it Works (Hybrid Tunneling): To bypass Colab's network restrictions, we use two tunnels:
- API Tunnel (Cloudflare): Provides a stable HTTPS URL (
trycloudflare.com) for the Desktop App to connect to. - P2P Tunnel (Bore): Provides a raw WebSocket URL (
bore.pub) for other Worker Nodes to connect to.
Instructions:
- Open the Notebook in Google Colab.
- Run "Install Dependencies".
- Run "Configure Hybrid Tunnels" (Installs
cloudflared&bore).- Wait for it to output the URLs.
- Run "Run Bee2Bee Node".
- It automatically configures itself to announce the Bore address.
Connecting your Desktop App to Colab:
- Copy the Cloudflare URL (e.g.,
https://funny-remote-check.trycloudflare.com). - Open Desktop App -> Settings.
- Paste into "Main Point URL".
🛠 Advanced Configuration
Environment Variables
You can override settings using ENV vars:
| Variable | Description | Default |
|---|---|---|
BEE2BEE_PORT |
Port for P2P Server | 4003 (Worker) / 4003 (API) |
BEE2BEE_HOST |
Bind Interface | 0.0.0.0 |
BEE2BEE_ANNOUNCE_HOST |
Public Hostname (for NAT/Tunnel) | Auto-detected |
BEE2BEE_ANNOUNCE_PORT |
Public Port (for NAT/Tunnel) | Auto-detected |
BEE2BEE_BOOTSTRAP |
URL of Main Point | None |
Troubleshooting
- "Connection Refused": Ensure the
bootstrap_urlis correct and reachable (tryping). - "0 Nodes Connected": Check if the Worker Node can reach the Main Point's P2P address (WSS).
- Colab Disconnects: Ensure the Colab tab stays open. Tunnels change if you restart the notebook.
🤝 Contributing
Contributions are welcome! Please open an issue or PR on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bee2bee-3.3.15.tar.gz.
File metadata
- Download URL: bee2bee-3.3.15.tar.gz
- Upload date:
- Size: 47.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73268af3667b927392cb8b215cf232faa178a483e06025e683833f04d778706e
|
|
| MD5 |
8e0d3592cc4f10a2ef3ae43e67398244
|
|
| BLAKE2b-256 |
38fd1b63f64d1f5641897363267dadbf65bdb55dfef14d452cfe8c7de9ef4e6c
|
File details
Details for the file bee2bee-3.3.15-py3-none-any.whl.
File metadata
- Download URL: bee2bee-3.3.15-py3-none-any.whl
- Upload date:
- Size: 44.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e45aca08fe1968fef47017100045e3d2bc9e1f824e9995e766045426fd7d66d
|
|
| MD5 |
66e3cc5c6662a9a26a771fd37ebaa2ce
|
|
| BLAKE2b-256 |
1074e7ddd059dffd89b38ee620c45b4d6336a3c0496a222302002c08e46f7d38
|