Quickstart, V2 Architecture & Sessions
Install OpenCode v2, understand the shared background service, connect any LLM provider, and control sessions like Git branches.
1. Install & Verify (v2.4+)
OpenCode is MIT-licensed and provider-agnostic. Pick your package manager—the curl installer also exposes an opencode2 alias if you still have a 1.x binary installed.
# macOS / Linux (recommended)
curl -fsSL https://opencode.ai/v2/install | bash
# Homebrew or npm
brew install anomalyco/tap/opencode-v2
npm install -g @opencode/cli
# Verify binary & upgrade later
opencode --version
opencode upgrade --method npm # specify curl | npm | pnpm | bun | brew if needed
opencode serve --service) that owns sessions, permissions, MCP connections, and automations across all your terminals and apps. Use --standalone in CI for an isolated private process.2. Connect Models (5 Ways to Run)
Work out of the box without an account (e.g., DeepSeek V4.1 Flash Free, Big Pickle, Nemotron Lightning). Run /models inside the TUI to pick one.
Run /connect to link ChatGPT Plus/Pro, GitHub Copilot, or Claude Pro/Max (via Claude Agent).
Add OpenRouter, Anthropic, OpenAI, Gemini, or OpenCode Go ($10/mo). Keys also auto-load from env vars and project .env.
Auto-discovers local Ollama, LM Studio, and vLLM endpoints on your machine.
opencode auth login # Interactive provider setup
opencode auth login -p openrouter # Jump straight to a provider
opencode models # List exact provider/model strings
opencode -m anthropic/claude-sonnet-4-5#high # Launch with model + reasoning variant
3. Starting, Resuming & Managing Sessions
Every interactive CLI feature has a scripted twin. Launch the TUI in your project root, or fire one-shot prompts with opencode run.
opencode # Open interactive TUI in current directory
opencode ~/code/my-app # Open TUI targeting a specific project folder
opencode -c # Continue the most recent session
opencode -s <session-id> # Resume a specific session ID
opencode run "Explain auth" # Non-interactive scripted mode (streams to stdout)
opencode service stop # Stop the shared V2 background daemon
Tab to toggle between Build (edits files) and Plan (read-only planning). Use Ctrl+T to cycle model reasoning effort (low/medium/high).| Action | Shortcut / Command | What It Does |
|---|---|---|
| New Session | /new or Ctrl+X N | Starts a clean session (alias: /clear) |
| Switch Session | /sessions or Ctrl+X L | Pick & resume any previous session (aliases: /resume, /continue) |
| Undo / Redo | /undo (Ctrl+X U) · /redo (Ctrl+X R) | Reverts/restores the last turn AND its Git filesystem snapshot |
| Fork / Timeline | /fork · /timeline (Ctrl+X G) | Jump back to any message or branch into a parallel conversation |
| Compact Context | /compact or Ctrl+X C | Summarizes older turns into a checkpoint to reclaim context window |
| Queue Follow-Up | Ctrl+X Enter | Queues your next prompt while the agent is busy (Alt+Enter = newline) |
| Command Palette | Ctrl+P | Fuzzy-search every command, agent, model, and shortcut |