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.
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:
To upgrade to the latest version:

AUR (Arch Linux)

Arch Linux users can install OpenCode from the Arch User Repository using their preferred AUR helper:

Go install

If you have Go 1.24.0 or higher installed, you can install OpenCode directly:
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

2

Build the binary

3

Run OpenCode

Optionally, move the binary to a directory in your PATH:

Verify installation

After installation, verify that OpenCode is available:
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:
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:

Next steps

Quickstart guide

Run your first AI assistant session

Configuration

Learn about all configuration options