OpenCode

An open-source AI coding agent built by Anomaly with TUI, CLI, IDE, desktop, and headless API modes. Over 7.5 million developers use it every month.

💻

Introduction

OpenCode is an open-source AI coding agent built by Anomaly that runs in your terminal, IDE, or desktop. With over 182,000 GitHub stars, 900 contributors, 14,782 commits, and 7.5 million developers using it every month, it is one of the most popular AI coding tools in the open-source ecosystem.

Unlike coding assistants that are tied to a single IDE or provider, OpenCode is designed to work everywhere: as a full-screen terminal user interface (TUI) with two built-in agents (build and plan), a headless CLI for scripting and automation, an IDE extension for VS Code, Cursor, and Windsurf, a desktop app (beta), and as a headless API server (Go mode) that other tools and frameworks can consume.

OpenCode is developed by Anomaly, a company focused on developer tooling and AI infrastructure. The project is MIT-licensed and hosted on GitHub at github.com/anomalyco/opencode. In addition to the open-source agent, Anomaly operates Zen, a curated API service that provides optimized, benchmarked coding models for agents, and Go, a headless API mode that lets external tools like Hermes Agent and OpenClaw use OpenCode as an LLM provider.

💻

Installation

Quick Install (curl):

curl -fsSL https://opencode.ai/install | bash

The install script respects: $OPENCODE_INSTALL_DIR, $XDG_BIN_DIR, $HOME/bin, or $HOME/.opencode/bin.

Package Managers

ManagerCommandPlatform
npmnpm i -g opencode-ai@latestAny
Homebrewbrew install opencodemacOS, Linux
Scoopscoop install opencodeWindows
Chocolateychoco install opencodeWindows
Pacmansudo pacman -S opencodeArch Linux
Nixnix run nixpkgs#opencodeNixOS
misemise use -g opencodeAny OS

Desktop App (Beta)

Available for macOS (Apple Silicon and Intel), Windows, and Linux (.deb, .rpm, .AppImage). Download from opencode.ai/download or the GitHub releases page.

brew install --cask opencode-desktop    # macOS
scoop install opencode-desktop          # Windows
🎮

Usage Modes

OpenCode offers multiple interfaces for different workflows. You can switch between them depending on whether you want a visual terminal experience, a scriptable CLI, or a full IDE integration.

ModeCommandUse Case
TUIopencodeFull-screen interactive coding session with two agents, file browsing, git integration
CLIopencode "prompt"One-shot prompts for scripting and automation
Webopencode webBrowser-based interface served on localhost
IDEVS Code / Cursor / WindsurfIn-editor coding assistant with context awareness
DesktopDesktop app (beta)Standalone graphical application
Goopencode goHeadless API server for external tools

Built-in Agents

OpenCode includes two built-in agents switchable with Tab:

  • build - Default, full-access agent. Can edit files, run commands, install packages, and manage git.
  • plan - Read-only agent for analysis and code exploration. Denies file edits by default, asks permission before running bash. Ideal for exploring unfamiliar codebases.
  • general - Subagent for complex searches and multistep tasks, invoked via @general.

Use opencode share to generate a shareable link for your current session.

Go Mode - Headless API

Go mode is OpenCode's headless API layer designed for programmatic access by external tools, frameworks, and agents. It is exposed as a REST API compatible with the OpenAI chat completions format, making it trivial to integrate into any system that supports standard LLM APIs.

API Endpoint:

https://opencode.ai/zen/go/v1

Authentication is via OPENCODE_ZEN_API_KEY or OPENCODE_GO_API_KEY environment variable. Keys are obtained through opencode.ai.

Available Models (Go API)

  • DeepSeek - deepseek-v4-pro, deepseek-v4-flash
  • Qwen - qwen3.7-max, qwen3.7-plus, qwen3.6-plus, qwen3.5-plus
  • Kimi (Moonshot) - kimi-k2.7-code, kimi-k2.6, kimi-k2.5
  • MiniMax - minimax-m3, minimax-m2.7, minimax-m2.5
  • GLM (Zhipu AI) - glm-5.2, glm-5.1, glm-5
  • MiMo (Xiaomi) - mimo-v2-pro

Running Go Locally

opencode go                # Start Go API server (default port)
opencode go --port 8080    # Custom port
opencode go --help         # Show Go-specific options
🖥️

Using in VS Code

OpenCode integrates deeply with VS Code, Cursor, Windsurf, and VSCodium through keyboard shortcuts, context awareness, and automatic extension installation.

Automatic Setup

  1. Open VS Code's integrated terminal (Ctrl+\` or Cmd+\`)
  2. Run opencode - the VS Code extension installs automatically

Ensure your editor CLI is in PATH: code (VS Code), cursor (Cursor), windsurf (Windsurf), or codium (VSCodium).

Keyboard Shortcuts

ActionmacOSWindows / Linux
Quick LaunchCmd+EscCtrl+Esc
New SessionCmd+Shift+EscCtrl+Shift+Esc
Insert File ReferenceCmd+Option+KAlt+Ctrl+K

Use @File#L37-42 syntax to reference specific files and line ranges in your prompts. Set export EDITOR="code --wait" for the TUI's /editor command.

🤖

Using with Hermes Agent

OpenCode serves as an LLM provider for Hermes Agent through its Go API endpoint. This allows Hermes to use OpenCode's curated coding models via the Zen platform, bypassing the need for separate API keys from each individual model provider.

Configuration

In Hermes Agent's config.yaml:

model:
  default: deepseek-v4-flash
  provider: opencode-go
  base_url: https://opencode.ai/zen/go/v1
  api_mode: chat_completions
export OPENCODE_ZEN_API_KEY="your-api-key-here"

Switch models mid-session: hermes config set model.default deepseek-v4-pro or use /model in chat.

Hermes discovers available models by querying /v1/models endpoint (OpenAI-compatible).

Benefits for Hermes Users

  • Single API key - Access multiple model families with one OpenCode subscription
  • Curated models - Only models tested and validated for coding agent tasks
  • OpenAI-compatible - Standard chat completions API, no special protocol needed
  • Fast switching - Change models mid-session without restarting Hermes
🦞

Using with OpenClaw

OpenCode can be integrated with OpenClaw as an LLM provider through the same OpenAI-compatible Zen/Go API endpoint.

OpenClaw Provider Configuration

In openclaw.json / claw.json:

{
  "provider": "opencode",
  "model": "deepseek-v4-flash",
  "api_key": "$OPENCODE_ZEN_API_KEY",
  "base_url": "https://opencode.ai/zen/go/v1"
}

You can also run OpenCode locally in Go mode and point OpenClaw to your local instance: opencode go --port 8080, then set base_url: http://localhost:8080/v1.

ACP Support

OpenCode supports the Agent Client Protocol (ACP), enabling it to interoperate with OpenClaw's agent sessions and participate in OpenClaw's agent ecosystem as a compatible client.

🎯

Zen - Optimized Coding Models

Zen is OpenCode's curated model API service, providing access to a handpicked set of AI models tested and benchmarked specifically for coding agents. It solves the problem of inconsistent performance across different providers by offering only validated, well-performing models.

CategoryModelsBest For
Flagshipdeepseek-v4-pro, qwen3.7-maxComplex reasoning, large refactors, architecture decisions
Fastdeepseek-v4-flash, qwen3.7-plusDaily coding, quick edits, code review, autocomplete
Specializedkimi-k2.7-code, glm-5.2Long-context tasks, multi-file analysis, documentation
Balancedminimax-m3, qwen3.5-plusGeneral-purpose coding, good cost/quality ratio

Zen is available through a subscription on opencode.ai. Enterprise plans available for teams requiring dedicated capacity and SLAs.

⚙️

Configuration

OpenCode is configured through a JSONC file at .opencode/opencode.jsonc in your project or home directory.

OptionDescription
ToolsEnable/disable specific tools available to the agent (file system, shell, MCP, etc.)
RulesCustom coding rules and conventions the agent should follow
ModelsSet default model, provider, and model-specific parameters
PermissionsControl which directories, files, and commands the agent can access
MCP ServersConnect MCP servers for extended capabilities
ACP SupportConfigure Agent Client Protocol for interoperability
PoliciesSafety and approval policies for dangerous operations

Environment Variables

VariablePurpose
OPENCODE_ZEN_API_KEYAPI key for OpenCode Zen and Go API
OPENCODE_GO_API_KEYAlternative API key for Go API
OPENCODE_INSTALL_DIRCustom installation directory
EDITORDefault editor for /editor and /export commands