OpenCode: External Server Backend via REST
The OpenCode backend connects to an external OpenCode server via REST API. It’s a lightweight option for teams that already run OpenCode as a separate service.
Overview
- Status: Beta
- Provider support: External server (model managed by OpenCode)
- Built-in tools: Server-managed (no PocketPaw-side tool definitions)
- MCP support: No
- Architecture: HTTP client — communicates with a running OpenCode server
Prerequisites
Install and start the OpenCode server:
# Install the OpenCode Go binarygo install github.com/opencode-ai/opencode@latest
# Start in server modeopencode --serverThe server runs on http://localhost:4096 by default.
Configuration
export POCKETPAW_AGENT_BACKEND="opencode"Backend-Specific Settings
| Setting | Env Variable | Default | Description |
|---|---|---|---|
opencode_base_url | POCKETPAW_OPENCODE_BASE_URL | "http://localhost:4096" | OpenCode server URL |
opencode_model | POCKETPAW_OPENCODE_MODEL | "" (server default) | Model override |
opencode_max_turns | POCKETPAW_OPENCODE_MAX_TURNS | 0 (unlimited) | Max turns per query |
How It Works
- PocketPaw creates a session via
POST /session→ receives a session ID - Messages are sent via
POST /session/{id}/message - Responses stream as NDJSON (newline-delimited JSON)
- PocketPaw parses the NDJSON stream into
AgentEventobjects - A health check (
GET /) verifies the server is reachable before each request
API Endpoints Used
| Method | Endpoint | Purpose |
|---|---|---|
POST | /session | Create a new session |
POST | /session/{id}/message | Send a message and stream response |
GET | / | Health check |
When to Use
Choose OpenCode when:
- You already run OpenCode as a separate service
- You want a backend where the model and tools are managed externally
- You prefer a thin client architecture with PocketPaw as the frontend
Related
Claude Agent SDK
The recommended backend with native tools and MCP integration.
Copilot SDK
Another multi-provider backend with built-in git tools.
All Agent Backends
Compare all six backends side by side with capability badges.
Self-Host PocketPaw
Deploy PocketPaw on your own infrastructure.
Was this page helpful?