How to set up OpenCode
# How to set up OpenCode OpenCode is an open-source coding agent that runs in your terminal. It supports 75+ LLM providers, features a built-in terminal UI (TUI), and lets you edit code, execute commands, and manage sessions from natural language prompts. This guide takes you from installation to a working OpenCode session in Warp in about 5 minutes, then shows you how to get the most out of it. ## Prerequisites * **An LLM provider account** — OpenCode connects to any supported provider (Anthropic, OpenAI, Google, and others) via API key, or use OpenCode Zen for a curated model list. See [OpenCode configuration](https://opencode.ai/docs#configure) for details. * **macOS, Linux, or Windows (via WSL)** — WSL is recommended for the best experience on Windows. See [OpenCode docs](https://opencode.ai/docs) for full platform details. ## 1. Install OpenCode Follow the [official OpenCode installation guide](https://opencode.ai/docs#install) to install OpenCode. The install script is the fastest method: ```bash curl -fsSL https://opencode.ai/install | bash ``` You can also install via npm or Homebrew: ```bash npm install -g opencode-ai ``` ```bash brew install anomalyco/tap/opencode ``` See the [OpenCode docs](https://opencode.ai/docs#install) for additional installation methods including Homebrew taps, platform-specific binaries, and Docker. When you launch OpenCode inside Warp, Warp auto-detects the agent session and surfaces integrated controls, including rich input, code review, vertical tab metadata, and more. ## 2. Authenticate OpenCode supports multiple LLM providers. Run the `/connect` command inside OpenCode's TUI to configure a provider, or set API keys as environment variables: ```bash # For Anthropic models export ANTHROPIC_API_KEY=YOUR_API_KEY # For OpenAI models export OPENAI_API_KEY=YOUR_API_KEY # For Google Gemini models export GEMINI_API_KEY=YOUR_API_KEY ``` Outside the TUI, run `opencode auth login` from the command line for interactive provider setup. Credentials are stored locally in `~/.local/share/opencode/auth.json`. ## 3. Start your first session Navigate to any project directory and launch OpenCode: ```bash cd ~/your-project opencode ``` OpenCode starts its TUI. Try giving it a task, for example: ``` Explain the architecture of this project ``` Or something more hands-on: ``` Add input validation to the user registration endpoint ``` OpenCode reads the relevant files, proposes changes, and asks for confirmation before modifying anything. Use the `Tab` key to switch between Plan mode (read-only suggestions) and Build mode (applies changes). ## 4. Configure for your project Initialize OpenCode for your project by running `/init` inside the TUI. This analyzes your codebase and creates an `AGENTS.md` file at your project root: ``` /init ``` The `AGENTS.md` file teaches OpenCode your project's structure and conventions. You can also create or edit it manually: ```markdown # My Project ## Stack - Backend: Python 3.12, FastAPI, SQLAlchemy - Frontend: React, TypeScript, Vite - Database: PostgreSQL 16 ## Commands - `npm run dev` starts the dev server - `pytest -v` runs the test suite - `npm run lint` checks code style ## Conventions - Use async/await for all database operations - Type hints on all function signatures - ESM imports only (no require()) ``` Commit the `AGENTS.md` file to Git so your team shares the same project context. ## 5. Set up agent notifications Warp supports agent notifications for OpenCode through a plugin. If the plugin isn't installed, Warp displays an installation chip in the terminal when you run OpenCode, with setup steps you can follow directly. For manual installation and configuration, see [OpenCode in Warp (docs)](/agent-platform/cli-agents/opencode/#setting-up-notifications). ## Productivity tips * **Use voice to prompt OpenCode** — Dictate complex instructions instead of typing them. Warp supports [voice transcription](/agent-platform/local-agents/interacting-with-agents/voice/) that works with any CLI agent, including OpenCode. * **Attach images as context** — Paste screenshots of bugs, designs, or error messages into your prompt. Warp's [images as context](/agent-platform/local-agents/agent-context/images-as-context/) feature lets OpenCode see what you see. * **Review diffs visually** — After OpenCode makes changes, open Warp's [Code Review panel](/code/code-review/) (`⌘+Shift++`) to see a visual diff. You can leave inline comments and send them back to OpenCode for corrections. * **Run OpenCode alongside other agents** — Use [vertical tabs](/terminal/windows/vertical-tabs/) to run OpenCode and Claude Code or Codex side by side on the same task. Compare their approaches and pick the best output. * **Compose richer prompts** — Press `Ctrl+G` to open Warp's rich input editor for OpenCode, giving you a full text editor experience instead of raw CLI input. {/* If a standalone summary feels valuable, add a ## Recap heading above this paragraph. */} ## Next steps You installed OpenCode, authenticated with a provider, started your first session, and configured it for your project. OpenCode is now set up as a working coding agent in Warp. Explore related guides and features: * [Set up Ollama for local models](/guides/external-tools/how-to-set-up-ollama/) to run OpenCode with local models * [Code Review panel](/code/code-review/) — review and refine agent-generated code * [OpenCode in Warp](https://warp.dev/agents/opencode) — overview of OpenCode support in Warp * [OpenCode in Warp (docs)](/agent-platform/cli-agents/opencode/) — full reference for OpenCode's Warp integration, including notification setup * [Third-party CLI agents](/agent-platform/cli-agents/overview/) — all supported agents and Warp's universal agent features * [OpenCode documentation](https://opencode.ai/docs) — official reference * [opencode-warp plugin](https://github.com/warpdotdev/opencode-warp) — notification plugin source and updatesSet up OpenCode in Warp, configure it for your project, and learn productivity tips for faster AI-assisted coding workflows.
OpenCode is an open-source coding agent that runs in your terminal. It supports 75+ LLM providers, features a built-in terminal UI (TUI), and lets you edit code, execute commands, and manage sessions from natural language prompts. This guide takes you from installation to a working OpenCode session in Warp in about 5 minutes, then shows you how to get the most out of it.
Prerequisites
Section titled “Prerequisites”- An LLM provider account — OpenCode connects to any supported provider (Anthropic, OpenAI, Google, and others) via API key, or use OpenCode Zen for a curated model list. See OpenCode configuration for details.
- macOS, Linux, or Windows (via WSL) — WSL is recommended for the best experience on Windows. See OpenCode docs for full platform details.
1. Install OpenCode
Section titled “1. Install OpenCode”Follow the official OpenCode installation guide to install OpenCode. The install script is the fastest method:
curl -fsSL https://opencode.ai/install | bashYou can also install via npm or Homebrew:
npm install -g opencode-aibrew install anomalyco/tap/opencodeSee the OpenCode docs for additional installation methods including Homebrew taps, platform-specific binaries, and Docker.
When you launch OpenCode inside Warp, Warp auto-detects the agent session and surfaces integrated controls, including rich input, code review, vertical tab metadata, and more.
2. Authenticate
Section titled “2. Authenticate”OpenCode supports multiple LLM providers. Run the /connect command inside OpenCode’s TUI to configure a provider, or set API keys as environment variables:
# For Anthropic modelsexport ANTHROPIC_API_KEY=YOUR_API_KEY
# For OpenAI modelsexport OPENAI_API_KEY=YOUR_API_KEY
# For Google Gemini modelsexport GEMINI_API_KEY=YOUR_API_KEYOutside the TUI, run opencode auth login from the command line for interactive provider setup. Credentials are stored locally in ~/.local/share/opencode/auth.json.
3. Start your first session
Section titled “3. Start your first session”Navigate to any project directory and launch OpenCode:
cd ~/your-projectopencodeOpenCode starts its TUI. Try giving it a task, for example:
Explain the architecture of this projectOr something more hands-on:
Add input validation to the user registration endpointOpenCode reads the relevant files, proposes changes, and asks for confirmation before modifying anything. Use the Tab key to switch between Plan mode (read-only suggestions) and Build mode (applies changes).
4. Configure for your project
Section titled “4. Configure for your project”Initialize OpenCode for your project by running /init inside the TUI. This analyzes your codebase and creates an AGENTS.md file at your project root:
/initThe AGENTS.md file teaches OpenCode your project’s structure and conventions. You can also create or edit it manually:
# My Project
## Stack- Backend: Python 3.12, FastAPI, SQLAlchemy- Frontend: React, TypeScript, Vite- Database: PostgreSQL 16
## Commands- `npm run dev` starts the dev server- `pytest -v` runs the test suite- `npm run lint` checks code style
## Conventions- Use async/await for all database operations- Type hints on all function signatures- ESM imports only (no require())Commit the AGENTS.md file to Git so your team shares the same project context.
5. Set up agent notifications
Section titled “5. Set up agent notifications”Warp supports agent notifications for OpenCode through a plugin. If the plugin isn’t installed, Warp displays an installation chip in the terminal when you run OpenCode, with setup steps you can follow directly.
For manual installation and configuration, see OpenCode in Warp (docs).
Productivity tips
Section titled “Productivity tips”- Use voice to prompt OpenCode — Dictate complex instructions instead of typing them. Warp supports voice transcription that works with any CLI agent, including OpenCode.
- Attach images as context — Paste screenshots of bugs, designs, or error messages into your prompt. Warp’s images as context feature lets OpenCode see what you see.
- Review diffs visually — After OpenCode makes changes, open Warp’s Code Review panel (
⌘+Shift++) to see a visual diff. You can leave inline comments and send them back to OpenCode for corrections. - Run OpenCode alongside other agents — Use vertical tabs to run OpenCode and Claude Code or Codex side by side on the same task. Compare their approaches and pick the best output.
- Compose richer prompts — Press
Ctrl+Gto open Warp’s rich input editor for OpenCode, giving you a full text editor experience instead of raw CLI input.
Next steps
Section titled “Next steps”You installed OpenCode, authenticated with a provider, started your first session, and configured it for your project. OpenCode is now set up as a working coding agent in Warp.
Explore related guides and features:
- Set up Ollama for local models to run OpenCode with local models
- Code Review panel — review and refine agent-generated code
- OpenCode in Warp — overview of OpenCode support in Warp
- OpenCode in Warp (docs) — full reference for OpenCode’s Warp integration, including notification setup
- Third-party CLI agents — all supported agents and Warp’s universal agent features
- OpenCode documentation — official reference
- opencode-warp plugin — notification plugin source and updates