Skip to content

OpenCode

OpenCode is an open-source terminal coding agent with BYOK (Bring Your Own Key).

TypeCLI
Open SourceYes
Best ForBYOK, customization, self-hosting
  • BYOK — Use any API provider
  • Agentic — File editing, terminal commands
  • MCP Support — External tool integration
  • Customizable — Extensive configuration options
  • Session Management — Resume conversations
Terminal window
# npm
npm install -g opencode
# Or run directly
npx opencode

OpenCode is open source and BYOK. There is no vendor subscription layer; your access terms come from whichever provider or local runtime you connect.

SettingValue
Open SourceYes (auditable)
TrainingNone (BYOK)
Data StorageLocal only
JurisdictionYour API provider
  • OpenAI
  • Anthropic
  • Google (Gemini)
  • AWS Bedrock
  • Azure OpenAI
  • Ollama (local)
  • Any OpenAI-compatible endpoint
Terminal window
# Set API key
export ANTHROPIC_API_KEY=sk-...
# Start in your project
cd your-project
opencode
# Or with specific provider
opencode --provider anthropic --model claude-sonnet-4-5

Create opencode.config.json:

{
"provider": "anthropic",
"model": "claude-sonnet-4-5-20250514",
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-filesystem"]
}
}
}

OpenCode supports MCP servers for extended capabilities:

Terminal window
# Add GitHub integration
opencode --mcp github
# Add database access
opencode --mcp postgres
CommandAction
/clearClear context
/session listShow saved sessions
/session load <id>Resume session
/compactSummarize and compress context
  • Use Ollama for 100% local, offline operation
  • Configure MCP servers for extended capabilities
  • Use /compact to manage long conversations
  • Session management enables pausing/resuming work