OpenCode
OpenCode is an open-source terminal coding agent with BYOK (Bring Your Own Key).
Overview
Section titled “Overview”| Type | CLI |
| Open Source | Yes |
| Best For | BYOK, customization, self-hosting |
Key Features
Section titled “Key Features”- BYOK — Use any API provider
- Agentic — File editing, terminal commands
- MCP Support — External tool integration
- Customizable — Extensive configuration options
- Session Management — Resume conversations
Installation
Section titled “Installation”# npmnpm install -g opencode
# Or run directlynpx opencodeAccess Model
Section titled “Access Model”OpenCode is open source and BYOK. There is no vendor subscription layer; your access terms come from whichever provider or local runtime you connect.
Privacy
Section titled “Privacy”| Setting | Value |
|---|---|
| Open Source | Yes (auditable) |
| Training | None (BYOK) |
| Data Storage | Local only |
| Jurisdiction | Your API provider |
Supported Providers
Section titled “Supported Providers”- OpenAI
- Anthropic
- Google (Gemini)
- AWS Bedrock
- Azure OpenAI
- Ollama (local)
- Any OpenAI-compatible endpoint
Getting Started
Section titled “Getting Started”# Set API keyexport ANTHROPIC_API_KEY=sk-...
# Start in your projectcd your-projectopencode
# Or with specific provideropencode --provider anthropic --model claude-sonnet-4-5Configuration
Section titled “Configuration”Create opencode.config.json:
{ "provider": "anthropic", "model": "claude-sonnet-4-5-20250514", "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@anthropic/mcp-filesystem"] } }}MCP Integration
Section titled “MCP Integration”OpenCode supports MCP servers for extended capabilities:
# Add GitHub integrationopencode --mcp github
# Add database accessopencode --mcp postgresKey Commands
Section titled “Key Commands”| Command | Action |
|---|---|
/clear | Clear context |
/session list | Show saved sessions |
/session load <id> | Resume session |
/compact | Summarize and compress context |
- Use Ollama for 100% local, offline operation
- Configure MCP servers for extended capabilities
- Use
/compactto manage long conversations - Session management enables pausing/resuming work