Quick answer: OpenCode is a free, open source AI coding agent that runs in your terminal. It supports leading models from Anthropic, OpenAI, Google and more, hooks into your CLI and editor, and is backed by an open codebase and a large community.

OpenCode is an open-source AI coding agent that turns your terminal into a pair-programming partner. It works with 75+ AI model providers, keeps your data private, and is free forever. This easy tutorial installs OpenCode, connects a model, and gets you coding with an AI helper in minutes.

What is OpenCode?

OpenCode is a free, open-source AI coding agent that runs in your terminal, as a desktop app, or as an IDE extension. You describe what you want in plain English and OpenCode reads your project, edits files, runs commands and shows you a diff — with no vendor lock-in and no AI platform forcing you into one model.

Why developers choose OpenCode

  • 100% open source — audit the code, self-host, or contribute to it (see the GitHub repo).
  • Any model, any provider — Anthropic, OpenAI, Google, local models, and more through the Models.dev provider list.
  • Built for privacy — OpenCode does not store your code or context on its own servers; conversation history lives locally.
  • Three surfaces — terminal TUI, desktop app, or IDE extension, whatever fits your workflow.
  • Team-friendly — share a conversation with one command, and define custom agents in markdown.
  • Zero subscription — the app is free; you only pay your chosen model provider (many offer free tiers).

Step 1: Install OpenCode

The quickest route is the install script (macOS and Linux):

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

Prefer a package manager? Pick the command for your system:

npm install -g opencode-ai        # any OS with Node.js
brew install anomalyco/tap/opencode   # macOS or Linux
choco install opencode               # Windows (Chocolatey)
scoop install opencode               # Windows (Scoop)

Windows tip: for the best experience, run OpenCode inside Windows Subsystem for Linux (WSL). Verify the install with:

opencode --version

Step 2: Connect a model provider

OpenCode needs a provider before it can think. Inside OpenCode, run:

/connect

Choose OpenCode Zen for the easiest start — a curated set of tested models with simple billing through opencode.ai/auth. Or pick any other provider from the list (Anthropic, OpenAI, Google, Groq, and local models like llama.cpp) and paste its API key. The key is stored only in your local config at ~/.local/share/opencode/auth.json.

Step 3: Start a project and initialize it

cd /path/to/your/project
opencode

The TUI opens. First, tell OpenCode to analyze your codebase:

/init

This creates an AGENTS.md file in the project root describing structure and conventions. Commit that file to Git — OpenCode reads it at the start of every session so it always understands your patterns.

Everyday commands you will use constantly

ActionHow
Ask about your codeType the question and use @ to fuzzy-search a file: how is auth handled in @index.ts
Plan before changesPress Tab to switch to Plan mode, describe the feature, then Tab back to Build
Undo a change/undo (repeatable) or /redo to restore
Reference an imageDrag and drop a screenshot straight into the terminal
Share a session/share creates a link to copy — useful for team reviews

Supercharge OpenCode

Once the basics click, level up with OpenCode’s configuration system:

  • Custom agents — define specialist assistants (code reviewer, tester, docs writer) as markdown files; pick them from the agent switcher.
  • Agent skills — reusable markdown instructions for repeated tasks.
  • MCP servers — connect your database, browser or internal API with one-line config.
  • Commands — your own slash commands with named arguments.
  • LSP support — real code intelligence while you edit.
  • Custom tools & plugins — extend anything, or run opencode serve to expose OpenCode over HTTP for your own tools.
  • Theme and keybinds — make the TUI feel like home.

OpenCode — quick FAQ

Is OpenCode free?

The app is free and open source. You only pay the provider that powers the model — and many providers, including OpenCode’s curated Zen models, have free tiers.

Which AI models can I use with OpenCode?

Practically any: Anthropic Claude, OpenAI, Google Gemini, Groq, OpenRouter and local models via Models.dev’s list of 75+ providers.

Can I use OpenCode on Windows?

Yes — via Chocolatey or Scoop, or npm. For the smoothest experience on Windows, install it inside WSL (Windows Subsystem for Linux).

How is OpenCode different from Claude Code?

OpenCode is open source and provider-agnostic — you choose the model. Claude Code is Anthropic’s terminal agent tied to Claude models. See our AI Coding Assistants guide for the full comparison.

Keep exploring: Claude Code, Google Antigravity and the free Freebuff. New to dev tools? Read the Web Development Roadmap and the Complete Guide to AI Coding Assistants.