Getting Started
Install
Install OpenCode (2.x is the mainline distribution). The curl installer is the reliable path - on npm, the opencode-ai package’s latest tag still served V1 1.18.34 as of October 2026:
npm install -g opencode-ai@next # verify the version after install: opencode --version
Or with Bun:
bun install -g --trust opencode-ai
Tip: The curl installer (
https://opencode.ai/install) is the recommended path on Linux/macOS. Theopencodebinary name survives as a legacy alias from the beta side-by-side period; useopencode.
Prerequisites
- A modern terminal emulator (Ghostty, WezTerm, Alacritty, or Kitty)
- API keys for LLM providers you want to use
Connect a Provider
Run /connect in the TUI and select your provider:
/connect
Or configure providers in opencode.jsonc:
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-4-5",
"providers": {
"anthropic": {
"settings": {
"apiKey": "{env:ANTHROPIC_API_KEY}"
}
}
}
}
Use /models to browse available providers and models.
Start Coding
Launch the TUI in your project:
opencode
Common workflows:
How is authentication handled in @packages/functions/src/api/index.ts
When a user deletes a note, flag it as deleted in the database.
Create a screen that shows recently deleted notes.
/undo
Tip: Use
@to fuzzy search for files in the project. Give OpenCode plenty of context and examples for best results.
Config Locations
OpenCode loads config from these locations (lowest to highest precedence):
~/.config/opencode/opencode.json(c)- global<project-root>/opencode.json(c)- project root<current-dir>/opencode.json(c)- current directory.opencode/opencode.json(c)in any of the above - overrides direct configs
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-4-5",
"default_agent": "build"
}
Run as a Server
OpenCode can run as a server, allowing custom clients to connect:
opencode serve --hostname 127.0.0.1 --port 4096
Connect with the TypeScript client:
import { OpenCode } from "@opencode/client"
const client = OpenCode.make({ baseUrl: "http://localhost:4096" })
const session = await client.session.create({
location: { directory: "/workspace" },
})
await client.session.prompt({ sessionID: session.id, text: "Review changes" })