📖 Introduction
OpenCode is an open-source AI coding agent. It provides terminal interface, desktop application, and IDE extension usage modes, allowing you to flexibly choose the workflow that best suits your needs.
OpenCode supports multiple LLM providers, and you can configure different API keys according to your needs.
⚙️ System Requirements
| Component | Requirement | Notes |
|---|---|---|
| Terminal Emulator | WezTerm / Alacritty / Ghostty / Kitty, etc. | Modern terminal recommended |
| API Keys | API keys from LLM providers | Supports multiple providers |
🖥️ Choose Your Platform
One-line Install Script (Recommended)
Terminal
curl -fsSL https://opencode.ai/install | bashInstall via Homebrew
Terminal
# Recommended: Use OpenCode tap (faster updates)
brew install anomalyco/tap/opencode
# Or use official Homebrew formula
brew install opencodeInstall via npm
Terminal
npm install -g opencode-ai
# Or using Bun
bun install -g opencode-ai
# Or using pnpm
pnpm install -g opencode-aiConfigure and Run
Terminal
# Navigate to project directory
cd /path/to/project
# Run OpenCode
opencode
# Initialize project
/initInstall via Chocolatey
PowerShell (Administrator)
choco install opencodeInstall via Scoop
PowerShell
scoop install opencodeInstall via npm
PowerShell or CMD
npm install -g opencode-aiInstall via Mise
Terminal
mise use -g github:anomalyco/opencodeRun with Docker
Terminal
docker run -it --rm ghcr.io/anomalyco/opencode💡 Tip
Installing via Bun on Windows is still in development. We recommend using the other methods listed above.
One-line Install Script (Recommended)
Terminal
curl -fsSL https://opencode.ai/install | bashArch Linux (pacman/AUR)
Terminal
# Stable version
sudo pacman -S opencode
# Latest version (AUR)
paru -S opencode-binInstall via Homebrew (Linux)
Terminal
brew install anomalyco/tap/opencodeInstall via npm
Terminal
npm install -g opencode-aiConfigure and Run
Terminal
# Navigate to project directory
cd /path/to/project
# Run
opencode
# First time use, initialize project
/init🔧 Configure API Providers
OpenCode supports multiple LLM providers. You can use the /connect command to configure:
Using OpenCode Zen (Recommended for Beginners)
- Run the
/connectcommand - Select "opencode"
- Visit opencode.ai/auth to get your API key
- Paste your API key
Using BeeHears Service
Configure environment variables to use BeeHears as the API gateway:
Terminal
# Set OpenAI-compatible API
export OPENAI_API_KEY="your-beehears-api-key"
export OPENAI_BASE_URL="https://api.beehears.com/v1"
# Run OpenCode
opencode🚀 Basic Usage
Common Commands
/init- Initialize project, creates AGENTS.md file/connect- Configure LLM provider/undo- Undo recent changes/redo- Redo undone changes/share- Share current conversation
Work Modes
- Build Mode - Default mode, can directly modify code
- Plan Mode - Only suggests changes, doesn't actually modify (press Tab to switch)
Example Usage
Query Examples
# Ask questions about the codebase
How is authentication handled in @packages/functions/src/api/index.ts
# Add a feature
We need to add authentication to the /settings route
# Undo changes
/undo