Docshost()
host()
Make your agent accessible over the network. One function call. HTTP, WebSocket, and P2P relay.
Why host()? Turn local agents into network services. HTTP API, WebSocket, P2P relay - all with one function call.
60-Second Quick Start
Create an agent and call host(agent) - that's it:
host_agent.py
Python REPL
Interactive
What You Get
HTTP API → POST /input, GET /sessions, GET /health
WebSocket → Real-time streaming at /ws
Interactive UI → Test your agent at /docs
P2P Relay → Connect from anywhere via relay
Worker Isolation
Each request gets a fresh deep copy of your agent:
No shared state between concurrent requests
Stateful tools work correctly (browser, file handles)
Complete isolation - one request can't affect another
HTTP API
POST /input - Submit a Task
code
Python REPL
Interactive
Multi-turn Conversations
Pass the session from the response to continue:
main.py
GET /sessions/{session_id} - Fetch Results
code
Python REPL
Interactive
GET /sessions - List Sessions
code
Python REPL
Interactive
GET /health - Health Check
code
Python REPL
Interactive
GET /info - Agent Info
code
Python REPL
Interactive
WebSocket API
Real-time communication with streaming support:
JS
app.jsINPUT → Agent
Send prompts to the agent
OUTPUT ← Agent
Receive final results
STREAM ← Agent
Streaming chunks
ERROR ← Agent
Error messages
Trust & Access Control
Control who can access your agent:
Trust Levels
main.py
Access Lists
main.py
Natural Language Policy
main.py
Configuration
All Parameters
main.py
Development vs Production
Development
main.py
Production
main.py
API Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
| agent | Agent | required | The agent to host |
| trust | str | Agent | "careful" | Trust level, policy, or agent |
| blacklist | list | None | Addresses to always reject |
| whitelist | list | None | Addresses to always accept |
| port | int | 8000 | HTTP server port |
| workers | int | 1 | Number of worker processes |
| result_ttl | int | 86400 | Result storage TTL (24h default) |
| relay_url | str | production | P2P relay server URL |
| reload | bool | False | Auto-reload on code changes |
Deployment
With Uvicorn/Gunicorn
main.py
code
Docker
code
Docker Compose
code
systemd Service
code
code
Ready to Host Your Agents?
Just call host(agent) and your agent goes live!
