How to Install OpenCode — the Open-Source, Model-Agnostic Coding Agent
OpenCode is an open-source, model-agnostic terminal coding agent. What it is, how to install it on macOS/Linux/Windows, and how to set up your first provider.
If you have looked at a "best AI coding agents" list lately, OpenCode is probably at or near the top, and you may be wondering whether the hype is worth a switch from whatever you use now. The decision rule is short: install OpenCode if you want a terminal coding agent that you fully control and can point at almost any model, and stay where you are if what you actually want is a polished graphical IDE. This guide explains what OpenCode is, why it has drawn so much attention, and exactly how to get it running — written so it still makes sense whether you are reading it the week it trended or a year later.
Picture the situation it was built for: you are in a terminal, you want an AI agent to read your codebase and make changes, and you do not want to be locked into one company's model or hit a usage wall you did not choose. That is the itch OpenCode scratches.
What OpenCode actually is
OpenCode is an open-source AI coding agent that runs in your terminal. "Coding agent" means it does more than autocomplete — it reads your project, plans changes, edits files, and runs commands on your behalf, through a TUI (a text user interface, the keyboard-driven app that lives in your terminal window). It is built by Anomaly, the team formerly known as SST, and released under the permissive MIT license, so anyone can read, fork, or self-host the code. There is also a desktop app in beta and an IDE extension, but the terminal is where it lives.
The feature that defines it is being model-agnostic. Instead of shipping a single built-in model, OpenCode is bring-your-own-provider: you supply an API key for whatever large-language-model provider you prefer, and OpenCode talks to it. It works across a wide range of providers — coverage puts the number north of 75 — and the project keeps a curated list it calls OpenCode Zen for people who do not want to choose. It also supports LSP, the Language Server Protocol that powers the same code intelligence your editor uses, so that — once configured for your language — the agent gets real language-server feedback such as diagnostics rather than guessing from raw text. The trade-off of bring-your-own-provider is the part to internalize early: OpenCode itself is free and open source, but the model behind it is not — you pay your provider for the tokens you burn.
Why it surged
The reason OpenCode ranks so high is worth understanding before you adopt it, because it tells you who it is really for. By mid-2026 the project had crossed 160,000 GitHub stars — the repository shows north of 170,000 — with an active user base that OpenCode and the coverage citing it report in the millions. A June 2026 AI dev-tool power ranking from LogRocket placed it at number one among coding agents, ahead of Cursor, calling it the most-adopted open-source coding agent built to date. Treat the star count as the one hard, checkable number, the user-base figure as a vendor-and-coverage estimate, and the ranking as one outlet's call.
What drove the climb is the same thing that makes it useful: it is open source and provider-agnostic at a moment when developers have grown wary of proprietary agents that can change pricing, throttle usage, or restrict access without much notice. When your agent is MIT-licensed and points at any provider you choose, none of those decisions are made for you — and that, more than any single benchmark, is the case its backers make for it.
How to install it
OpenCode runs on Linux, macOS, and Windows, though on Windows the project recommends running it under WSL, and on any platform it expects a modern terminal emulator such as WezTerm, Alacritty, Ghostty, or Kitty rather than an older default console. Pick whichever install path matches how you already manage tools:
- Install script (macOS/Linux):
curl -fsSL https://opencode.ai/install | bash - npm (any platform with Node):
npm i -g opencode-ai@latest - Homebrew (macOS/Linux):
brew install anomalyco/tap/opencode - Windows (Scoop or Chocolatey):
scoop install opencodeorchoco install opencode - Arch Linux:
sudo pacman -S opencode
One habit worth keeping with the first option: piping a script straight from the internet into bash runs whatever that script contains, so if you are at all cautious — and on a work machine you should be — open https://opencode.ai/install in a browser and skim it first, or use the package-manager route instead, which is easier to audit and to update later. The commands above are the official ones; the security caution is general good practice, not a knock on this project.
First run: pointing it at a model
Installing the binary is the easy half; the step people miss is that OpenCode does nothing until you give it a provider. After installing, run opencode inside a project directory. Your first move is to connect a model: run /connect, pick your provider from the list, and paste the API key when prompted — you can confirm it registered with opencode auth list, and project-level settings live in an opencode.json file. With a provider wired up, run /init, which scans the project and writes an AGENTS.md file the agent uses as standing context — the same file you will edit later to tell it about your conventions. Until a provider is connected, you have an empty cockpit. Once it is configured, OpenCode gives you built-in agents you switch between — a "build" agent for making changes and a "plan" agent for thinking through them first — by pressing Tab, so you can reason about a change before letting it touch files.
In practice the common mistake here is treating OpenCode like a finished product you just launch. It is closer to a chassis: powerful, yours to configure, and inert until you supply the model and a bit of context. Budget ten minutes for that first setup and it pays off; skip it and you will conclude, wrongly, that the tool does not work.
Who it fits — and when to skip
OpenCode is the better move if you live in the terminal, want to keep your model choice open, and would rather own and audit your tooling than rent it. It is especially worth it if you have been burned by a proprietary agent's limits and want an exit that does not lock you into a new vendor. The flexibility is real, and the price of the tool itself is zero.
It is the wrong tool, though, if you want the all-in-one graphical experience of an IDE like Cursor, with inline diffs and a plugin marketplace in a window — OpenCode is deliberately a terminal citizen, and forcing it to be something else will frustrate you. It is also a poor fit if you would rather not manage provider API keys and the metered cost that comes with them, since that overhead is the price of its flexibility. If you want to see how it stacks up against the other terminal agents before committing, our comparison of the AI coding CLIs walks through Claude Code, Codex, and Antigravity alongside the same trade-offs.
The short version: OpenCode earned its high ranking by being open, model-agnostic, and genuinely useful in a terminal — but the thing it asks of you is a provider key and a few minutes of setup. Install it with the command that matches your platform, run /init, point it at a model, and you will know within an afternoon whether the terminal-first, bring-your-own-model approach is how you want to work.