OpenCode Engine
The original multi-model AI coding engine. OpenCode runs as a local HTTP/SSE server and powers QuantumReef's foundational session management, tool calls, and model routing.
Overview
OpenCode is the reference engine in QuantumReef and the most feature-complete integration available. It ships as a standalone CLI binary that exposes a local HTTP server with Server-Sent Events (SSE) for real-time streaming. QuantumReef connects to it via the OpenCodeClient adapter, which implements the full EngineClient interface.
OpenCode supports every major model provider — Anthropic Claude, OpenAI GPT-4o, Google Gemini, AWS Bedrock, and local Ollama models — through a unified session API. All tool calls, permission prompts, and message streaming flow through a single consistent interface regardless of the underlying provider.
Default Engine
How It Works
When QuantumReef starts an OpenCode session, it spawns (or attaches to) the opencode process on a configurable port (default 4096). The process serves:
GET /v1/session— list all sessionsPOST /v1/session— create a new sessionGET /v1/session/:id/message— retrieve message historyPOST /v1/session/:id/message— send a prompt (streams via SSE)DELETE /v1/session/:id— abort a running sessionGET /v1/events— global event bus (SSE)
QuantumReef subscribes to GET /v1/events immediately on connection, receiving a live stream of all session state changes, tool executions, and permission requests across the entire OpenCode process — even sessions started from the terminal CLI.
Installation & Setup
Install OpenCode
# Install via npm (recommended)
npm install -g opencode-ai
# Or via Homebrew on macOS
brew install opencode
# Verify installation
opencode --versionConfigure in QuantumReef
Open Settings → Engines → OpenCode and set:
| Setting | Default | Description |
|---|---|---|
| Host | 127.0.0.1 | The address OpenCode listens on |
| Port | 4096 | The HTTP port. Change if another service conflicts. |
| Auto-start | true | QuantumReef spawns opencode if not already running |
| Working Directory | ~ | Root directory passed to the opencode process |
| Model | claude-opus-4-5 | Default model for new sessions |
You can also set these via environment variables — useful for CI or headless deployments:
QUANTUMREEF_OPENCODE_HOST=127.0.0.1
QUANTUMREEF_OPENCODE_PORT=4096
QUANTUMREEF_OPENCODE_AUTOSTART=trueProvider API Keys
OpenCode reads model provider credentials from your environment. Set the relevant key before launching:
# Anthropic Claude (default)
export ANTHROPIC_API_KEY=sk-ant-...
# OpenAI GPT-4o
export OPENAI_API_KEY=sk-...
# Google Gemini
export GEMINI_API_KEY=AIza...
# Local Ollama (no key needed)
export OPENCODE_MODEL=ollama/qwen2.5-coder:32bSession Management
QuantumReef maintains a session registry that mirrors the OpenCode process state. Sessions created from the terminal CLI, from another QuantumReef window, or from a mobile companion app are all discovered automatically via the SSE event bus.
Session Lifecycle
| State | Description |
|---|---|
| idle | Session exists but no prompt is running |
| running | A prompt is currently being processed; tools may be executing |
| completed | The last prompt finished successfully |
| error | The session encountered a non-recoverable error |
Session Persistence
OpenCode stores session data in ~/.opencode/opencode.db (SQLite). QuantumReef reads this database to restore session history after a restart, even if the opencode process was not running when QuantumReef launched.
Cross-platform sessions
Configuration File
Fine-grained OpenCode configuration lives in ~/.config/opencode/config.json(or the path set by OPENCODE_CONFIG). QuantumReef merges per-workspace overrides on top of this global config.
{
"model": "claude-opus-4-5",
"autoshare": false,
"theme": "dark",
"keybinds": {
"leader": "ctrl+a"
},
"mcp": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user"]
}
},
"providers": {
"anthropic": {
"apiKey": "${ANTHROPIC_API_KEY}"
}
}
}Strengths & Best Use Cases
| Strength | Detail |
|---|---|
| Broadest model support | 12+ providers including local Ollama — switch models per-session |
| MCP ecosystem | Native Model Context Protocol support; use any published MCP server |
| Stable SSE API | Versioned REST + SSE API; integrations never break between releases |
| Git-aware diffs | Built-in diff viewer shows file changes before applying them |
| Tool call transparency | Every tool call is visible in the QuantumReef MCP Tools Panel |
| Active community | Largest user base; most community plugins and skills |
When to choose OpenCode