Skip to main content
OpenCode is distributed as pre-built binaries for macOS, Linux, and Windows. Choose your preferred installation method below.

Prerequisites

OpenCode requires Go 1.24.0 or higher if building from source. For binary installations, no prerequisites are needed. The install script is the fastest way to get started with OpenCode. It automatically downloads the latest version for your platform and adds it to your PATH.
curl -fsSL https://raw.githubusercontent.com/opencode-ai/opencode/refs/heads/main/install | bash
The script will:
  1. Detect your OS and architecture (linux/mac, x86_64/arm64)
  2. Download the appropriate binary to ~/.opencode/bin
  3. Add ~/.opencode/bin to your PATH in your shell config file
  4. Display installation success message
After installation, restart your shell or run source ~/.bashrc (or equivalent) to use OpenCode immediately.

Homebrew (macOS and Linux)

If you use Homebrew, you can install OpenCode from our tap:
brew install opencode-ai/tap/opencode
To upgrade to the latest version:
brew upgrade opencode

AUR (Arch Linux)

Arch Linux users can install OpenCode from the Arch User Repository using their preferred AUR helper:
yay -S opencode-ai-bin

Go install

If you have Go 1.24.0 or higher installed, you can install OpenCode directly:
go install github.com/opencode-ai/opencode@latest
Make sure $GOPATH/bin (usually ~/go/bin) is in your PATH.

Build from source

For development or if you want the latest unreleased features:
1

Clone the repository

git clone https://github.com/opencode-ai/opencode.git
cd opencode
2

Build the binary

go build -o opencode
3

Run OpenCode

./opencode
Optionally, move the binary to a directory in your PATH:
sudo mv opencode /usr/local/bin/

Verify installation

After installation, verify that OpenCode is available:
opencode --version
You should see the version number printed to the console.

Setup API keys

Before using OpenCode, you need to configure at least one AI provider. OpenCode supports multiple providers and will automatically detect which one to use based on available API keys.
OpenCode checks providers in this order: GitHub Copilot → Anthropic → OpenAI → Gemini → Groq → OpenRouter → AWS Bedrock → Azure OpenAI → VertexAI

Set environment variables

The simplest way to configure providers is through environment variables:
export ANTHROPIC_API_KEY="sk-ant-..."
Add these exports to your shell configuration file (~/.bashrc, ~/.zshrc, etc.) to make them permanent.

Configuration file

For more control, create a configuration file at ~/.opencode.json or ~/.config/opencode/.opencode.json:
{
  "providers": {
    "anthropic": {
      "apiKey": "sk-ant-...",
      "disabled": false
    },
    "openai": {
      "apiKey": "sk-...",
      "disabled": false
    },
    "gemini": {
      "apiKey": "...",
      "disabled": false
    }
  },
  "agents": {
    "coder": {
      "model": "claude-4-sonnet",
      "maxTokens": 5000
    }
  }
}

Next steps

Quickstart guide

Run your first AI assistant session

Configuration

Learn about all configuration options

Build docs developers (and LLMs) love