Open-source AI coding agent that lives in your terminal · bring your own model (75+ providers) · MIT-licensed · runs as a TUI, desktop app, or IDE extension
opencode is a free, open-source (MIT) agent you run from the command line in your own project folder. The tool costs nothing — you only pay your model provider for the tokens a session uses. Two modes switch with one key: plan reads and proposes, build edits files. It's privacy-first: no code or context is stored server-side, so your project stays on your machine and only your provider's API sees data. Docs: opencode.ai/docs.
curl -fsSL https://opencode.ai/install | bashnpm install -g opencode-aibrew install anomalyco/tap/opencodescoop install opencode (Windows)sudo pacman -S opencode (Arch)
opencode auth login (or /connect inside the TUI) to add a provider key — or log in with an existing GitHub Copilot / ChatGPT Plus/Pro subscription and reuse it. No separate bill, no markup.opencode "Read anova_analysis.R, find the bug on line 34, and fix it."Run opencode alone to open the full-screen terminal UI (TUI), not a one-shot reply. Type your request in any language you like. Run /init once per project to set opencode up for that repo.
In the TUI
| Key / command | What it does |
|---|---|
Tab | Toggle plan ↔ build mode |
@ | Fuzzy-search files to add to context |
/connect | Configure an LLM provider key |
/init | Initialize opencode for this project |
/undo | Revert the changes the agent made |
/redo | Restore previously undone changes |
/share | Create a shareable link to this session |
From the shell
| Command | What it does |
|---|---|
opencode | Start the interactive TUI |
opencode run "…" | Non-interactive: pass a prompt directly |
opencode auth login | Add provider credentials |
opencode models | List models from your providers |
opencode session list | List your sessions |
opencode stats | Token usage & cost stats |
opencode upgrade | Update to the latest version |
Useful flags: -m provider/model pick the model · -c / --continue resume the last session · -s <id> continue a specific session · -f <file> attach a file · --share share the session.
"My R script anova_analysis.R throws an error on line 34. Read the file, find the bug, and fix it." — opencode greps and reads files to locate the right code, then proposes the edit."Read all CSV files in ./data/, merge them, remove duplicates by sample_id, fill missing numeric values with column medians, and save as cleaned_data.csv" — hand it the whole job and let it write and run the script."Explain how authentication flows through this codebase and outline the safest way to add password reset — don't change any files yet." Stay in plan mode, then press Tab to build."write unit tests for the parsing module." Session B: "update the README and fix the broken links." Give each a narrow, independent job so they don't collide.The two agent modes (toggle with Tab)
| Mode | What it does |
|---|---|
| plan | Read-only analysis — explores and explains without modifying files; bash execution is permission-gated. |
| build | Makes the actual code changes. The status bar (bottom of the TUI) always shows which mode you're in. |
Adding context & scaling out
@ to fuzzy-search and attach project files; or opencode -f <file> from the shell.The opencode tool is free and MIT-licensed — there's no markup on top of your model. With BYOK (bring your own key) token costs land directly on your provider bill (e.g. Anthropic API rates), so a long refactor can run a few dollars — monitor usage or cap spending. Reusing a Copilot or ChatGPT subscription means no new bill at all.
| Path | What you pay |
|---|---|
| Core tool | Free / open source — TUI, desktop app, and IDE extension all included. |
| BYOK | Pay your provider directly for tokens. 75+ providers (Anthropic, OpenAI, Google, Mistral) or a local Ollama model — switch without re-installing. |
| OpenCode Zen | Hosted models, pay-as-you-go per 1M tokens (no flat monthly plan). Free five-model tier: Big Pickle, DeepSeek V4 Flash Free, MiMo-V2.5 Free, North Mini Code Free, Nemotron 3 Ultra Free. |
Zen paid models & guardrails: range from DeepSeek V4 Flash $0.14 in / $0.28 out per 1M tokens up to Claude Fable 5 $10.00 in / $50.00 out (Claude Opus models ~$5.00 in / $25.00 out). Auto-reload tops up a default $20 when your balance drops below $5; set per-workspace / per-member monthly limits. Card processing adds 4.4% + $0.30 per transaction; team plans are free during beta.
• Always run from inside the project folder — opencode loads that directory as its context.
• Plan before you build. On unfamiliar code, start in plan mode, refine the approach in plain language, then Tab to build — planning first usually saves money by avoiding wrong edits you'd have to undo.
• BYOK has no spend cap. A long session bills straight to your provider — watch opencode stats, or use Zen's auto-reload + per-member limits for predictable spend.
• Parallel agents cost in parallel — two running sessions ≈ twice the tokens, so only fan out genuinely independent subtasks.
• Stuck? /share generates a link that reproduces the exact session for a teammate to inspect.
• You stay in control — opencode proposes edits; you decide whether they're applied. Use /undo to revert.