OpenCode: The Open-Source Terminal Coding Agent, Set Up Properly
27 November 2026 · Updated 28 November 2026 · 12 min read · by Yang Kai
What OpenCode is, how to install and configure it, how its provider model works, what its own Go and Console plans cost, and where it honestly differs from subscription coding agents.
Checklist inside: OpenCode first-week setup checklist
Contents
- OpenCode at a glance
- What you actually get
- What you need before you start
- Step 1: Install OpenCode
- Step 2: Connect a model provider
- Step 3: Generate and then edit AGENTS.md
- Step 4: Set defaults in opencode.json
- Step 5: Run one task the supervised way
- Step 6: Grow into custom agents and commands
- The three ways to pay for models
- Where OpenCode is weaker
- First-week setup checklist
- How we researched this
- Who should pick it
Most terminal coding agents sell you a bundle: their interface, their model, their monthly bill. OpenCode unbundles all three. The agent is free and open source, and the model is your problem — bring an API key, buy credits from OpenCode’s own Console, subscribe to its Go plan, or run a local model and pay nothing per token.
That freedom is the whole product, and also the whole workload. This guide covers what OpenCode actually ships, how to install and configure it, the three ways to pay for models (with prices checked in November 2026), and where it honestly loses to a tuned subscription agent. Everything below is drawn from OpenCode’s published documentation and pricing pages — this is a desk-researched guide, not a hands-on review.
OpenCode at a glance
| Question | Answer |
|---|---|
| What is it? | Open-source (MIT) terminal coding agent with a full-screen TUI |
| Who makes it? | Anomaly (the project formerly known as SST) |
| What does the software cost? | $0 — you pay only for model access |
| Which models? | 75+ providers via Models.dev, plus local models via Ollama |
| Built-in agents | Build (full access) and Plan (read-only), switched with Tab |
| Configuration | opencode.json files you own and can version-control |
| Instruction file | AGENTS.md, generated by /init |
| OpenCode’s own model plans | Console pay-as-you-go credits; Go from $10/month (checked Nov 2026) |
What you actually get
OpenCode ships as a terminal application with a conversation pane and a file-editing agent that can read, write, and run commands in your project. Two built-in agent modes are worth knowing by name: Build, the default full-access agent, and Plan, a read-only mode that explores and proposes without touching files. You switch between them with the Tab key inside the TUI.
That Plan/Build split is the feature worth stealing for every agent. The read-only pass costs little and catches the misunderstandings that are expensive to unwind after edits land.
Under the surface, three design choices matter more than the interface:
- Provider freedom is real, not a settings-page promise. OpenCode connects through the Models.dev catalogue and supports 75+ providers, plus any OpenAI-compatible endpoint. Your API keys live in
~/.local/share/opencode/auth.jsonafter you run the/connectcommand in the TUI oropencode auth loginin the shell. - Configuration is a file, not a dashboard. A project-level
opencode.json(or a global one in~/.config/opencode/) sets the default model, permissions, custom agents, and MCP servers. It is version-controllable, shareable with a team, and debuggable with a text editor — the same reason instruction files beat chat memory in every other tool. - It speaks AGENTS.md. Running
/initin a project generates anAGENTS.mdfile describing your codebase for the agent, following the cross-tool convention covered in AGENTS.md vs CLAUDE.md. If you already maintain one for another tool, OpenCode reads it as-is.
OpenCode also runs beyond the TUI — there are desktop and web surfaces and IDE extensions — but the terminal remains the reference experience the documentation is written around, and the one this guide sets up.
What you need before you start
- A machine running macOS or Linux, or Windows with WSL (the docs point Windows users at WSL, and the TUI assumes a Unix-style shell for the commands the agent runs)
- A git repository to work in, so every agent edit has a diff safety net
- One way to pay for models: a provider API key, an OpenCode Console account, or a local model runtime such as Ollama
- About 30 minutes for install, connection, and a first supervised task
Step 1: Install OpenCode
The documented install routes, checked November 2026:
# Official install script (macOS / Linux)
curl -fsSL https://opencode.ai/install | bash
# Or via npm
npm install -g opencode-ai
# Or Homebrew
brew install anomalyco/tap/opencode
You can also install it as a desktop app, but the terminal build is the one the docs lead with. Run opencode --version afterwards and confirm a version prints — that is your check that the install landed on your PATH before you go further.
Step 2: Connect a model provider
Open the TUI from inside a real project:
cd your-project
opencode
Then run /connect, pick your provider, and paste an API key or complete the provider’s login flow. Three connection shapes cover most readers:
- Your own API key (Anthropic, OpenAI, Google, or any Models.dev provider) — requests go straight to that provider at its published rates, with no OpenCode markup.
- OpenCode Console — OpenCode’s own pay-as-you-go service (the service formerly called Zen), covered in the pricing section below.
- A local endpoint — Ollama or another OpenAI-compatible server on your machine, at zero per-token cost.
Run /models after connecting and confirm which model is active before your first real task. The default depends on the provider you connected, and silent defaults are how people end up benchmarking the wrong model.
Step 3: Generate and then edit AGENTS.md
Run /init and OpenCode drafts an AGENTS.md from your codebase. Treat the output as a starting draft, not a finished instruction set. Delete anything generic (“write clean code”), keep facts the agent cannot guess (build commands, test commands, directory conventions, forbidden areas), and add the two or three mistakes you most want prevented.
The generated file follows the shared AGENTS.md convention, so the same file serves other tools that read it. Keep it short enough to re-read in one sitting; an instruction file nobody maintains becomes decoration, which is the failure mode the AGENTS.md field guide is written against.
Step 4: Set defaults in opencode.json
Four settings repay the ten minutes they take:
- Default model — the model a new session starts on, so the choice is deliberate rather than inherited.
- Small model — a cheaper model for lightweight jobs such as titles and summaries, where a frontier model is wasted money.
- Permissions — auto-allow reads, and prompt before shell commands that write or delete, until you trust the setup on your own repos.
- One MCP server — add a single server you already use elsewhere and test it in Plan mode first. The vetting rules in the MCP security checklist apply unchanged.
Because the file is plain JSON in your project or config directory, you can commit the project version and let a team share the same defaults — no dashboard, no per-seat settings drift.
Step 5: Run one task the supervised way
Pick a small, real task. Run it in Plan mode first and read the proposal: which files it names, which commands it wants to run, what it misunderstood. Correct the plan in plain language, switch to Build with Tab, and let it execute. Afterwards, read the git diff before anything else — the diff is the deliverable, not the chat transcript.
Note the session cost OpenCode reports when the task finishes. That number, multiplied by your weekly task count, is your real OpenCode budget, and knowing it early is what separates a cheap setup from a surprising one.
Step 6: Grow into custom agents and commands
Once the default loop feels predictable, two features repay setup time. Custom agents are named configurations — your own model choice, prompt, and permission set for a recurring job, such as a read-only reviewer or a test-writer that may edit only test files. Defining them in opencode.json means the reviewer you invoke in month three behaves like the one you tuned in week one, instead of depending on how you phrased things that morning.
Custom commands do the same for prompts you repeat: a /test or /review command stored as a file, with the exact wording settled once. Both features follow the same principle as the rest of OpenCode — anything you repeat belongs in a file you own. The parallel features in Claude Code are covered in the skills explainer; OpenCode’s versions are simpler, and for many solo builders simpler is the point.
The three ways to pay for models
OpenCode the software is free. The model bill arrives through one of three doors (prices checked November 2026):
| Route | What you pay | What stops you | Best for |
|---|---|---|---|
| Your own API key | Provider’s per-token API rates, no markup | Your provider balance | Builders who already hold API keys |
| OpenCode Console (pay-as-you-go) | Per-token prices on prepaid credits; top-ups carry a processing fee (4.6% + $0.31 per the billing docs) | Your credit balance | Light use, or Claude/GPT models without your own accounts |
| OpenCode Go | $10/month (Go Plus $40/month; Go Teams $20 per member/month) | Per-model dollar allowances inside 5-hour and weekly windows | Heavy use of open-weight models on a fixed budget |
Two details matter here. First, Go is a curated catalogue, not all models: it covers mostly open-weight models (plus a few small frontier ones), and each model gets its own monthly dollar allowance — roughly $15 of some models, more of others — with at most 20% spendable per 5 hours and 50% per week. Second, the old name Zen now refers to the Console’s pay-as-you-go models; pages still calling it a separate product are out of date.
A worked example makes the shapes concrete. A builder running ten supervised tasks a week on a frontier model through their own API key might spend anywhere from a few dollars to a few tens of dollars depending on codebase size and how much exploration each task needs — the variance is the point, and it is why the session-cost habit from Step 5 matters. The same builder on Go pays $10 flat, provided the work fits Go’s open-weight catalogue and per-model allowances. On a Claude subscription, the comparison point from the cost ladder is $20 flat for Pro with a usage window instead of a token meter. None of the three is cheapest in general; each is cheapest for a different work pattern.
The cost shape differs from a subscription agent in one more way: with your own keys there is no usage cap interrupting you, which means nothing interrupts a long session spending real money either. The discipline is the same one in the Claude Code cost ladder — match model price to task difficulty — except here you see the raw token bill with no subscription cushion. Routing cheap work to cheap models is the offsetting win: Plan-mode exploration on a small model, boilerplate on a local model, and frontier models reserved for the edits that justify them.
Where OpenCode is weaker
Provider freedom means provider variance. The agent loop is only as good as the model plugged into it, and smaller or local models follow multi-step instructions less reliably, call tools less cleanly, and recover from errors worse than the frontier models the subscription tools default to. OpenCode cannot fix that gap; it can only expose it honestly.
The second weakness is polish-by-integration. A vendor tool tuned around one model family has its prompts, context handling, and error recovery fitted to that model. OpenCode’s generality trades some of that fit away, and its configuration surface, while genuinely yours, is shallower than Claude Code’s hooks-and-skills system — the head-to-head is in OpenCode vs Claude Code.
Finally, “open source agent” does not mean “private by default.” Your code goes to whichever model API you connected, under that provider’s data terms. Only the local-model route keeps code on your machine.
First-week setup checklist
[ ] Install via script/npm/brew; confirm `opencode --version`
[ ] /connect one paid provider + Ollama (if local hardware allows)
[ ] /init, then hand-edit AGENTS.md down to true, specific facts
[ ] Set default model + a cheap "small model" in opencode.json
[ ] Add ONE MCP server you already use elsewhere; test it in Plan mode
[ ] Configure permissions: auto-allow reads, prompt before shell writes
[ ] Run one real task in Plan → review → Build; inspect the git diff
[ ] Note the session cost; decide your per-task spend ceiling
How we researched this
This guide is built from OpenCode’s official documentation, its Models.dev provider catalogue, and its published Console and Go pricing pages, all read in November 2026. OpenCode releases frequently, so treat version-specific details as a snapshot and check the changelog after updating. No hands-on testing is claimed; where the docs and older third-party pages disagree (the Zen-to-Console rename is the common case), the official docs win.
Who should pick it
Pick OpenCode if you already pay for API access, work across several model providers, want your agent configuration in a file you own, or want a local-model path no subscription tool offers. Stay with a subscription agent if you want one bill, one tuned model, and zero configuration decisions. Terminal-first readers often run the other comparison too: Cline vs Aider covers the two editor-and-terminal agents that predate this wave, and the three-way coding agents comparison maps the bundled side of the market.
FAQ
Is OpenCode free? The software is open source (MIT) and free. The models are not: you pay your chosen provider per token, buy Console credits, subscribe to Go from $10/month, or run local models at no per-token cost (prices checked November 2026). Budget for the model bill, not the tool.
What is the difference between OpenCode Go and the Console? Go is a flat subscription ($10/month, Go Plus $40/month) covering a curated set of mostly open-weight models, each with a dollar allowance inside 5-hour and weekly windows. The Console is pay-as-you-go: prepaid credits spent at per-token prices across a wider catalogue that includes Claude and GPT models. Go suits steady open-model use; the Console suits light use and frontier models.
Does OpenCode work with local models? Yes — it connects to Ollama and other OpenAI-compatible local endpoints. Expect weaker multi-step reliability than frontier cloud models; local models suit exploration, boilerplate, and privacy-sensitive drafts better than long autonomous tasks.
Can OpenCode use MCP servers?
Yes. MCP servers are configured in opencode.json, both local (command-based) and remote (URL-based), with per-server enable flags. Start with one server you trust.
What is the difference between Plan and Build mode? Plan mode is read-only: the agent explores the codebase and proposes an approach without editing files or running mutating commands. Build mode is the full-access default that executes. Press Tab in the TUI to switch.
Category: Claude Code & Context Engineering · Tags: #ai-coding #ai-agents #open-source #pricing #tutorial
Next step: this article is part of Claude Code guides, which covers the full topic from first setup to advanced use.