Server
Run OpenCode as a headless server for programmatic access.
Starting the Server
opencode serveFlags
| Flag | Purpose |
|---|---|
--port | Server port (default: 4096) |
--hostname | Listen address |
--mdns | Enable mDNS discovery |
--cors | Additional CORS origins |
Configuration
{
"server": {
"port": 4096,
"hostname": "0.0.0.0",
"mdns": true,
"cors": ["http://localhost:5173"]
}
}Web Interface
Start with web interface:
opencode webAttaching to Server
Connect TUI to running server:
opencode attach http://localhost:4096