📖 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 | bash

Install via Homebrew

Terminal
# Recommended: Use OpenCode tap (faster updates) brew install anomalyco/tap/opencode # Or use official Homebrew formula brew install opencode

Install via npm

Terminal
npm install -g opencode-ai # Or using Bun bun install -g opencode-ai # Or using pnpm pnpm install -g opencode-ai

Configure and Run

Terminal
# Navigate to project directory cd /path/to/project # Run OpenCode opencode # Initialize project /init

Install via Chocolatey

PowerShell (Administrator)
choco install opencode

Install via Scoop

PowerShell
scoop install opencode

Install via npm

PowerShell or CMD
npm install -g opencode-ai

Install via Mise

Terminal
mise use -g github:anomalyco/opencode

Run 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 | bash

Arch Linux (pacman/AUR)

Terminal
# Stable version sudo pacman -S opencode # Latest version (AUR) paru -S opencode-bin

Install via Homebrew (Linux)

Terminal
brew install anomalyco/tap/opencode

Install via npm

Terminal
npm install -g opencode-ai

Configure 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)

  1. Run the /connect command
  2. Select "opencode"
  3. Visit opencode.ai/auth to get your API key
  4. 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