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:
What You Get
last_msg_id on CONNECT and gets back any events it missed during a WS dropWorker Isolation
Each request gets a fresh deep copy of your agent:
Publish Your Own HTTP Routes
Serve feeds and H5 APIs without an LLM round trip. The route group makes the audience visible in both code and the final URL.
| Group | URL | Audience |
|---|---|---|
| http.public | /public/* | Anyone |
| http.contacts | /contacts/* | Contacts, whitelist, admins |
| http.admin | /admin/* | Admins only |
Security is route metadata. The prefix explains the policy; Connectonion does not infer permission from a string.
Protected requests bind method, path, query, body digest, timestamp, request ID, and recipient. Signatures are one-use.
Do not embed an admin private key in browser JavaScript. Calendar clients cannot normally add signature headers, so subscription feeds should use public URLs.
HTTP API
POST /input - Submit a Task
Multi-turn Conversations
Pass the session from the response to continue:
Sending Images & Files
Both HTTP and WebSocket accept images and files alongside text prompts:
Images are passed directly to the LLM as visual content (multimodal).
Files are decoded from base64, saved to .co/uploads/, and the agent reads them via tools like read_file.
Limits: Default 10MB per file, 10 files per request. Configure in .co/host.yaml or via host() params.
GET /sessions/{session_id} - Fetch Results
GET /sessions - List Sessions
GET /health - Health Check
GET /info - Agent Info
The accepted_inputs field tells clients what input types the agent supports and file size limits.balance_usd is included only for agents running on managed co/* keys — agents on their own provider API keys omit it. It's also published in the ANNOUNCE profile sent to the relay for discovery.
WebSocket API
Real-time communication with streaming support:
CONNECT → Server
Authenticate + find/create session (one message for new and resume)
INPUT → Agent
Send prompts (after CONNECT)
OUTPUT ← Agent
Receive final results
STREAM ← Agent
Streaming chunks
ERROR ← Agent
Error messages
Trust & Access Control
Control who can access your agent:
Trust Levels
Access Lists
Natural Language Policy
Configuration
All Parameters
Development vs Production
Development
Production
host.yaml Configuration
Store configuration in a YAML file instead of code parameters. Generated by co init or co create.
Basic Setup
Configuration Priority
Settings are loaded in order (highest priority first):
host(agent, port=9000).co/host.yamlAgent Metadata
Used by /info endpoint and ANNOUNCE messages for agent discovery:
With the first ANNOUNCE of each relay connection, the host also publishes a display profile — name, tools, model, and project-level skills only (.co/skills/). Skills from ~/.co/skills and built-ins never leave the machine. The relay persists the profile and serves it with the agent record, so directories render name and skills even while the agent is offline.
Trust Levels
| Level | Behavior | Use Case |
|---|---|---|
| open | Accept all requests | Development |
| careful | Recommend signature, accept unsigned | Staging/Default |
| strict | Require valid signature | Production |
Advanced Trust Configuration
When a stranger's CONNECT hits the gate, the host sends ONBOARD_REQUIRED and stashes the CONNECT. After a verified ONBOARD_SUBMIT (invite code or payment), the host completes that CONNECT itself and sends CONNECTED — the client's pending input resumes automatically. No second CONNECT, no resend. See the protocol page for the full sequence.
Access Control Lists
Server Settings
File Upload Limits
Control file upload sizes for /input endpoint and /ws WebSocket:
Image Processing
Video Analysis
Document Processing
Complete Example
Best Practices
host.yaml to version controlhost.yaml — use .env insteadwhitelist.txt or blacklist.txt to gitAPI 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
Docker
Docker Compose
systemd Service
Ready to Host Your Agents?
Just call host(agent) and your agent goes live.
ConnectOnion