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
Worker Isolation
Each request gets a fresh deep copy of your agent:
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.
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:
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
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!
