OpenCode — Getting Started
Install and configure OpenCode, the multi-provider AI coding agent. Covers installation, LLM provider setup, Zen/Go pricing, and first session walkthrough.
OpenCode — Getting Started
OpenCode is a terminal-based AI coding agent that works with 75+ LLM providers. Unlike Claude Code (Anthropic-only) or Gemini CLI (Google-only), OpenCode lets you choose your model, pay what you want, and customize every aspect of the agent.
Installation
# Via npm
npm install -g @opencode-ai/cli
# Via Homebrew
brew install opencode/tap/cli
# Verify
opencode --version
Provider Setup

OpenCode supports any OpenAI-compatible endpoint. Choose your provider:
Quick Setup — Common Providers
# Anthropic (via API key)
export ANTHROPIC_API_KEY="sk-ant-..."
# OpenAI
export OPENAI_API_KEY="sk-..."
# Google Gemini
export GOOGLE_API_KEY="..."
# DeepSeek (95% cheaper than Anthropic for coding)
export DEEPSEEK_API_KEY="sk-..."
# OpenRouter (300+ models, one API key)
export OPENROUTER_API_KEY="sk-or-..."
Configure in ~/.config/opencode/opencode.json or opencode.json (project root):
{
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"providers": {
"anthropic": {
"apiKey": "${ANTHROPIC_API_KEY}",
"baseUrl": "https://api.anthropic.com/v1"
},
"openai": {
"apiKey": "${OPENAI_API_KEY}"
},
"deepseek": {
"apiKey": "${DEEPSEEK_API_KEY}",
"baseUrl": "https://api.deepseek.com/v1"
}
}
}
Pricing Plans
| Tier | Price | What You Get |
|---|---|---|
| Free | $0 | Bring your own API key, 30+ providers, community skills |
| Zen | $10/mo | Priority support, provider management, feedback loop |
| Go | $20/mo | SOC2 compliance, audit logs, custom model training |
First Session
cd my-project
opencode
On first run, OpenCode asks which provider and model to use:
⚡ Welcome to OpenCode!
Choose a provider:
> 1. Anthropic (recommended for complex coding)
2. OpenAI
3. DeepSeek (budget-friendly)
4. Google Gemini (1M context)
5. OpenRouter (300+ models)
1. Anthropic
Choose a model:
> 1. claude-sonnet-4-20250514 ($3/M tokens)
2. claude-opus-4-20250514 ($15/M tokens)
>
Essential Slash Commands
| Command | What it does |
|---|---|
/help | Show all slash commands |
/provider <name> | Switch LLM provider mid-session |
/model <name> | Switch model mid-session |
/skill <name> | Load a skill into context |
/plan | Enter plan mode (scoped analysis) |
/clear | Clear conversation history |
/cost | Show token usage and cost for this session |
/export | Export conversation to a markdown file |
Project Configuration: AGENTS.md
Like Claude Code's CLAUDE.md, OpenCode reads AGENTS.md every session. Create it at your project root:
# AGENTS.md
## Commands
- `npm run dev` — Start development server at localhost:3000
- `npm run build` — Production build with type checking
- `npx vitest run` — Run all tests
- `npx eslint .` — Lint check
## Project Architecture
- Next.js 14 with App Router and React Server Components
- TypeScript strict mode with path alias @/
- SQLite via better-sqlite3 — no ORM, raw SQL
- Zero API dependencies for now
## Code Style
- Use async/await in server components for data fetching
- Extract business logic from components into lib/ immediately
- Tests go next to the file they test (co-location)
Provider Selection Strategy
| If you need... | Use... |
|---|---|
| Best reasoning for complex tasks | Anthropic (Claude Sonnet/Opus) |
| Budget coding (95% cheaper) | DeepSeek V4 |
| Massive context (1M+ tokens) | Google Gemini |
| Flexibility (300+ models) | OpenRouter |
| Self-hosted / air-gapped | Ollama (local) |
OpenCode's key advantage: switch providers mid-session with /provider. Debug with Sonnet, then switch to DeepSeek for less demanding work.
Related Pages
- Prompt Engineering in OpenCode — AGENTS.md patterns, /slash commands
- OpenCode Configuration Reference — opencode.json, MCP, skills
- Tool Comparison — OpenCode vs Claude Code vs Gemini CLI vs Cursor vs Copilot
- OpenCode Guide (Blog) — In-depth setup and configuration walkthrough
Related Articles
GitHub Copilot — Configuration Reference
Configure GitHub Copilot for your project. copilot-instructions.md, .vscode/settings.json, .github/ conventions, model settings, and integration with Copilot Chat and Agent mode.
Claude Code — Configuration Reference
Complete Claude Code configuration reference. Covers claude.json settings, MCP server setup, hook scripts, .claude/ directory conventions, and environment variable overrides.
AI Coding Tools — Prompt Engineering & Configuration
Complete guides for Claude Code, OpenCode, Gemini CLI, Cursor, GitHub Copilot, and more. Tool-specific prompt patterns, configuration files, and setup guides for every major AI coding assistant.