Gallery

Contacts

405 W. Greenlawn Ave Lansing, Michigan 48910

contact@techjacksolutions.com

+1-616-320-4064

OPENCODE

How to Use OpenCode: Setup, Providers & Models 2026

How to use OpenCode: install the terminal agent, connect a bring-your-own-key provider, and run the build and plan agents

If you want to know how to use OpenCode, the workflow comes down to four moves: install the tool, connect a model provider, let it create an AGENTS.md file for your project, then drive the build and plan agents. OpenCode is an open-source AI coding agent that lives in your terminal, built by Anomaly and released under the MIT license. It runs as a terminal interface, a desktop app in beta, and an IDE extension, with a built-in agent that reads your repository, edits files, and runs commands. The part that surprises newcomers is the model: the tool ships none of its own and charges nothing for tokens. It is bring-your-own-key, so you connect a provider you already pay for, and all model spend goes to that provider, not to the agent itself. This guide walks the full path: installing it, connecting a provider with opencode auth login, configuring opencode.json and an AGENTS.md file, using the build and plan agents, running parallel sessions, and adding MCP servers.

Before anything else: OpenCode the software is free and open-source. There is no subscription to use it and no inherent model cost. Because it is bring-your-own-key, your only spend is what your chosen LLM provider charges for the tokens you use. We make that cost model explicit throughout, so you do not expect a single flat fee.


MIT
Open-Source License
75+
Supported Providers
$0
Tool Cost (BYO Key)
~175k
GitHub Stars (Vendor-Reported)

How to Use OpenCode: What You Need First

Learning how to use OpenCode takes two decisions, not one. First you install the tool, which is quick. Then you decide which model provider to point it at, because the agent does not come with a model. That second decision is where the real choice lives, and it is worth settling before you open your first session rather than mid-task.

Setup Checklist
A terminal you work in – OpenCode is a terminal-first tool. On macOS and Linux any shell works; on Windows the documentation recommends running it under WSL.
A model provider and key – Decide where your model will come from: a provider API key you bring yourself, OpenCode Zen, or an existing ChatGPT, GitHub Copilot, or GitLab Duo subscription you link.
A repository to open – Have a project folder ready. OpenCode initializes an AGENTS.md there and works against the files in that repo.
An understanding of the cost model – The tool is free; your tokens are not. Know that model usage is billed by your provider so a long session does not surprise you.

One thing to settle early: OpenCode is privacy-first and, per its own documentation, does not store your code or context data. Even so, the model provider you connect has its own data and retention terms. Pick a provider whose handling you are comfortable with before you run the agent against private code.


Install OpenCode

There are several ways to install OpenCode, and the right one depends on your platform and the tools you already use. The install script is the simplest path on macOS and Linux, but package managers give you a route that fits your existing toolchain.

Install script (macOS / Linux)curl -fsSL https://opencode.ai/install | bash

If you would rather install through a package manager, OpenCode is published to the common ones. Pick whichever matches how you manage other developer tools.

Platform How to install
Node / npmInstall the package with npm, Bun, pnpm, or Yarn, whichever you already use
macOSHomebrew via the OpenCode tap, or the install script above
Arch LinuxAvailable through the AUR with an AUR helper such as paru
WindowsRun under WSL (recommended), or use Chocolatey, Scoop, Mise, or Docker
DesktopA desktop app is in beta for macOS, Windows, and Linux

On Windows: the documentation recommends running OpenCode under the Windows Subsystem for Linux. The native package-manager and Docker routes exist, but a WSL environment most closely matches the Unix terminal the tool is designed around.

Once it is installed, you launch OpenCode by running opencode inside a project folder. The first thing it will need is a model provider, which is the next step.


Connect a Provider

OpenCode does not ship a model. Instead it connects to providers you choose, through the AI SDK and the Models.dev catalog, which covers more than 75 providers including Anthropic, OpenAI, DeepSeek, Google Vertex, Amazon Bedrock, and Groq, as well as local models run through Ollama, LM Studio, or llama.cpp. That is the source of the tool's flexibility, and the reason cost is entirely a function of which provider you pick.

Adding a provider

You connect a provider in one of two equivalent ways. From inside the terminal interface, run the /connect command. From a shell, run the auth command directly.

Connect a provider from the shellopencode auth login

Either route walks you through selecting a provider and entering its credentials. Those credentials are written to an auth.json file, by default at ~/.local/share/opencode/auth.json. Treat that file like any other secret on your machine.

The three routes to a model

Beyond a raw provider key, OpenCode gives you a couple of managed options. Which one fits depends on whether you already pay for an AI subscription and how hands-on you want to be about model choice.

Route What it is and what it costs
Bring your own keyAdd an API key for any of the 75+ supported providers. You pay that provider directly for the tokens you use.
OpenCode ZenA curated set of coding models that the OpenCode team has tested, billed pay-as-you-go. The default helper model, gpt-5-nano, is served through Zen.
OpenCode GoA low-cost subscription option for those who prefer a flat-rate plan over per-token billing.
Link a subscriptionConnect an existing ChatGPT Plus or Pro, GitHub Copilot, or GitLab Duo subscription at no extra cost beyond what you already pay.
BYO key
Because OpenCode has no model cost of its own, your bill is whatever your chosen provider charges. A bring-your-own-key setup means you control the spend, but it also means there is no flat OpenCode fee to cap it. Watch your provider's usage dashboard the way you would for any API.

Configure and Init AGENTS.md

With a provider connected, the next step is letting OpenCode learn your project. When you run it in a repository, it can create an AGENTS.md file: a plain-text record of your project's conventions and context that the agent reads before it works. Think of it as the place to write down the things you would otherwise repeat in every prompt, such as how the project is structured, which commands to run, and the conventions you expect code to follow.

Configuration lives separately, in an opencode.json file at the project root, or globally in ~/.config/opencode/opencode.jsonc. This is where you set defaults such as the model to use, provider options, and other behavior, so you do not have to pass them on every run.

If you already use Claude Code: OpenCode reads existing Claude Code configuration, including .claude files, CLAUDE.md, and skills, so an existing setup carries over. You can turn that behavior off with the OPENCODE_DISABLE_CLAUDE_CODE environment variables if you would rather keep the two separate.

For a first session you do not need to hand-write either file. Let OpenCode create the AGENTS.md, look it over, and add a line or two about anything specific to your project. The configuration file can stay empty until you have a setting you actually want to change.


Build and Plan Agents

OpenCode ships with a small set of built-in agents, and the two you will use day to day are build and plan. The build agent is the default. It has full access: it can read your code, edit files, and run commands, and it is what you use to actually make changes. The plan agent is read-only. It can analyze the codebase and propose an approach without touching anything, which makes it the safer way to ask what would you do here before you let the agent act.

You switch between them inside the terminal interface with the Tab key. A general subagent is also available for delegated work, and you can define your own with opencode agent create when you have a repeatable task that deserves its own configuration.

The editing loop

Working with the build agent is a loop of asking, reviewing, and adjusting. Two commands make that loop forgiving. /undo steps a change back, and /redo reapplies it, so you can experiment without fear of losing a good state. The interface also accepts drag-and-dropped images, which is useful when the task is easier to show than to describe, such as a screenshot of a layout bug.

OpenCode is also LSP-enabled: it auto-loads the language servers for your project, so the agent has the same structural understanding of your code that your editor's tooling does, rather than treating files as plain text.

Step What You Do
1. InstallInstall OpenCode with the script or a package manager and run it in your repo
2. ConnectRun opencode auth login or /connect to add a model provider
3. InitLet OpenCode create an AGENTS.md and note any project conventions
4. PlanSwitch with Tab to the read-only plan agent to scope a change first
5. BuildUse the build agent to make the change, reviewing with /undo and /redo
Guide Progress
0 of 8 sections complete

Sessions and Editing

OpenCode organizes work into sessions, and it can run more than one in parallel. That lets you keep several independent lines of work going at once, the way you might keep separate terminal tabs open, rather than serializing everything through a single conversation.

Two flags shape how sessions relate to each other. You can --continue a previous session to pick up where you left off, or --fork one to branch from its current state into a new thread without disturbing the original. Sessions can also be exported and imported as JSON, which is how you hand one off, archive it, or move it between machines.

For a first session, keep it simple: one session, one well-scoped task. Ask the build agent to make a small, contained change you can read through in a few minutes, review what it did, and accept or undo. Parallel sessions and forking earn their place once you trust the basic loop and have more than one thing in flight.

A practical habit: use the plan agent in one session to think through a larger change while a build agent in another session handles a small, unrelated fix. Because OpenCode keeps sessions separate, the read-only analysis and the live edits do not interfere with each other.


Add MCP Servers

Once the core loop feels comfortable, you can extend OpenCode beyond the repository. It supports the Model Context Protocol, an open standard for giving an AI tool access to external systems and data sources. Connecting MCP servers lets the agent pull in context and act on tools beyond the files in front of it, reaching the services you already use.

Add and list MCP serversopencode mcp add opencode mcp list

The opencode mcp add command registers a server, and opencode mcp list shows what is connected. Once a server is wired in, its tools become available to the agent during a session, the same way the built-in file and command tools are.

You do not need any of this on day one. Start with the editor loop and a single provider, then add MCP servers when a specific need comes up, such as reaching an issue tracker or a documentation source, rather than wiring everything before you have a reason to.

Where to go next: that is the short version of how to use OpenCode end to end, from install to MCP. If you want the background on what the project is, who maintains it, and where it sits among coding tools, read our companion breakdown, What Is OpenCode?


Troubleshooting

When people first work out how to use OpenCode, the same handful of questions come up. Here is the practical answer for each.

The OpenCode software is free and open-source under the MIT license, with no inherent model cost. Because it is bring-your-own-key, your bill is whatever your chosen provider charges for the tokens you use. If you would rather not manage a raw API key, OpenCode Zen offers curated models pay-as-you-go and OpenCode Go is a low-cost subscription, or you can link an existing ChatGPT, GitHub Copilot, or GitLab Duo subscription at no extra cost. There is no single flat OpenCode fee, so plan around your provider's pricing.
Yes. The documentation recommends running OpenCode under the Windows Subsystem for Linux, which gives the Unix-style terminal the tool is built around. Native routes also exist through Chocolatey, Scoop, Mise, and Docker, and there is a desktop app in beta for Windows. If you hit unexpected behavior on native Windows, try the WSL path first.
Credentials added through opencode auth login or the /connect command are written to an auth.json file, by default at ~/.local/share/opencode/auth.json. Project and global settings live separately in opencode.json or ~/.config/opencode/opencode.jsonc. Treat the auth.json file as a secret and keep it out of version control.
The build agent is the default and has full access: it reads, edits, and runs commands. The plan agent is read-only, so it can analyze your codebase and propose an approach without changing anything. Switch between them with Tab. Use plan to scope a change safely, then switch to build to carry it out, and lean on /undo and /redo to step changes back and forth as you review.
Fact-checked against vendor documentation and official sources, June 2026. Verify current install and provider details at opencode.ai/docs before relying on them.
OpenCode is an open-source project maintained by Anomaly, distributed under the MIT license. This article is an independent editorial resource by Tech Jacks Solutions. Not affiliated with or endorsed by Anomaly.
Before You Use AI
Your Privacy
OpenCode states that it is privacy-first and does not store your code or context data. Because it is bring-your-own-key, however, your prompts and code are sent to whichever model provider you connect, and that provider applies its own data, retention, and training policies. Review the terms of the provider you choose, and prefer enterprise or no-training options before running the agent against proprietary repositories.
Mental Health & AI Dependency
An autonomous coding agent like OpenCode makes it easy to accept changes you have not fully read and to delegate more judgment than you intend. The model behind it can also produce confident, wrong answers. Treat generated code as a draft to review and test, keep the read-only plan agent in your workflow for risky changes, and notice if the tool is replacing rather than supporting your own understanding. If you are experiencing distress:
  • 988 Suicide & Crisis Lifeline: Call or text 988
  • SAMHSA Helpline: 1-800-662-4357
  • Crisis Text Line: Text HOME to 741741
AI systems can produce plausible-sounding but incorrect guidance. For mental health, medical, legal, or financial decisions, always consult a qualified professional.
Your Rights & Our Transparency
Under GDPR and CCPA, you have the right to access, correct, and delete your personal data held by AI service providers. Tech Jacks Solutions maintains editorial independence from all vendors covered on this site. Some links may be affiliate links, which help fund independent research at no extra cost to you. The EU AI Act classifies AI systems according to their intended use and risk level.