
How to Install OpenCode and Code with AI, Step by Step
Published on:
Reading time: 5 min
Topic: Technology
Author: Leandro Valencia
Install OpenCode (CLI), connect it to a provider and run your first agent in your repo. Includes OpenCode Go with $5 in credit. Not a pricing post.
Table of Contents
Two names you shouldn't mix up
- OpenCode: the CLI. You install it once. It's free software, runs as
opencode. - OpenCode Go: the subscription (~$5 the first month, $10 after) with open models and usage ceilings. It's one provider you can connect. It's not required to install the CLI.
You can install OpenCode today and connect Anthropic's API, Z.ai or another. Go is the shortcut if you don't want to manage ten API keys.
Step by step
1. Install the OpenCode CLI
The official v2 doc gives these routes. Pick one:
npm install -g @opencode/cli
bun install -g --trust @opencode/cli
pnpm add -g --allow-build=@opencode/cli @opencode/cli
yarn global add @opencode/cli
curl -fsSL https://opencode.ai/v2/install | bash
The npm package uses a trusted postinstall script to download the native binary for your platform. That's why bun and pnpm ask for the --trust / --allow-build flag.
What not to use, according to that same doc: Homebrew, AUR, Scoop, Chocolatey or a loose .exe from a mirror. 2025 tutorials saying brew install opencode are outdated compared to v2.
Docker exists (ghcr.io/anomalyco/opencode with version tags) if your workflow is containers. For day one, npm or the script is enough.
2. Check that it runs
Close and reopen the terminal (the PATH sometimes doesn't refresh). Then:
opencode
It has to open the TUI, not command not found. If the curl script installed into a directory your shell doesn't load, open a new session or source your .bashrc / .zshrc.
No GPU needed. No need for opencode tui as some magic subcommand: the binary with no arguments launches the interface.
3. Connect a provider
Inside the TUI, the command is:
/connect
There you pick the provider. Reasonable paths:
- OpenCode Go: if you want the $10 plan and the open models. Create the account with the $5 link, complete billing, and connect Go from
/connect. The ceiling details (5 hours / week / month) are in the pricing post; here all that matters is that the session authenticates. - Z.ai / GLM: if you already have the Coding Plan, connect it as a custom provider with the coding endpoint. Don't mix in the generic chat key.
- Anthropic, OpenAI or another:
/connectand paste the key. OpenCode ships with several built in.
Without a provider, the TUI is an empty shell. The typical day-one error isn't "it won't install": it's opening opencode without having connected anything.
4. Enter a real repo
cd /path/to/your/project
opencode
The agent sees the files in that directory. If you launch it in $HOME, it'll want to opine about your entire disk. Don't do it.
If the project already has an AGENTS.md or an opencode.json, it respects them. If not, you can initialize later; it doesn't block the first prompt.
5. Send the first task
Ask for something you can verify without faith:
- "What does
src/auth.tsdo?" - "Write a test for this function and don't touch the rest."
If it edits the right file and the diff makes sense, the install is done. Only then is it worth talking about MCP, plugins and themes โ the customize doc exists for day 2.
If something fails
command not found: PATH. Reopen the terminal. With npm global, the npm prefix is sometimes missing from the Windows PATH.- npm's postinstall got blocked: that's the script that downloads the binary. On bun/pnpm you must have passed
--trust/--allow-build. - The TUI opens but the model doesn't respond: it's not the install, it's
/connect. Check the key and the provider. - Go runs out mid-afternoon: that's the usage ceiling, not a CLI bug. That's explained in the limits post.
Frequently asked questions
Are OpenCode and OpenCode Go the same thing?
No. CLI vs model subscription. You can use the CLI without Go.
Can I install it with Homebrew or Scoop?
Not according to the v2 doc. npm/bun/pnpm/yarn or the opencode.ai/v2/install script.
Do I need a powerful GPU?
Not for Go or for cloud APIs.
How do I get the $5 credit?
With the Go link. It's applied to usage limits.
In short
- Install the CLI through the official v2 route, not through some blog's brew.
/connectis the step people skip.- Launch
opencodeinside the repo. - Go is optional and cheap to try with the referral credit.
- Prices and ceilings: the other two posts.
๐ Try OpenCode Go with $5 in credit
If you already have the agent in your head and what's missing is "making it run on this machine", you don't need another comparison. You need an install the official docs still back.
โ Leandro Valencia
Step-by-step guide
Install the OpenCode CLI
npm, bun, pnpm, yarn or the official v2 script. Homebrew and Scoop are not supported.
Check that it runs
Open a new terminal and run opencode. It should open the TUI, not a PATH error.
Connect a provider
In the TUI, /connect. OpenCode Go is the $10 shortcut if you don't want to wrangle API keys.
Enter a real repo
cd into the project and launch opencode again. The agent works on those files.
Send the first task
Ask for something short and verifiable. If it edits the right file, the install is done.
Frequently asked questions
Are OpenCode and OpenCode Go the same thing?
No. OpenCode is the CLI/TUI (the program you install). OpenCode Go is a plan of about $10 a month that gives you access to open models to use *inside* that CLI. You can install OpenCode and connect Anthropic, OpenAI or another provider without paying for Go.
Can I install it with Homebrew or Scoop?
The official v2 documentation says Homebrew, AUR, Windows package managers and loose binaries are not supported. Use npm, bun, pnpm, yarn or `curl -fsSL https://opencode.ai/v2/install | bash`.
Do I need a powerful GPU?
No. Go's models and cloud providers run outside your machine. A terminal and a stable connection are enough. If you connect a local model (Ollama, etc.), that's when hardware comes in; that's not the path of this onboarding.
How do I get the $5 credit?
By signing up for OpenCode Go with the referral link. The credit is applied to your usage limits; it's not cash. It covers almost the whole first month, which comes out to $5 before moving to $10.
Related Posts
Keep exploring similar content that may interest you

OpenCode Zen and Go: what you can actually get done for $10 a month
A breakdown of OpenCode's Go plan: how it compares to Zen, real per-model limits, cost per agentic turn, and the workflow of drafting specs with Claude or Grok and running them with Go.
OpenCode Go Usage Limits in 2026: $10/Month and Is It Worth It?
The verdict on OpenCode Go: yes, it's worth it โ with caveats. $5 the first month, $10/month after โ which models it includes, how its usage limits really work, and when you shouldn't pay for it. Includes how to get an extra $5 in credit.

How to Use Z.ai (GLM): Sign-Up, Plan and First Prompt
Guide to signing up for Z.ai, activating the GLM Coding Plan, creating your API key and connecting Claude Code, Cline or OpenCode. Onboarding, not a review.
Partnerships
Tools I use every day, on better terms for this community.