writing/blog/2026/06
BlogJun 24, 2026·6 min read

OpenCode: The Open-Source AI Coding Agent Supporting 75+ Models

OpenCode gives you a free, open-source terminal agent that works with 75+ LLM providers — Claude, GPT-5, Gemini, or local Llama via Ollama. Full setup guide inside.

OpenCode has quietly become the most-starred open-source coding agent of 2026, accumulating over 160,000 GitHub stars, 900+ contributors, and 13,000+ commits — all while remaining completely free to use. Its core premise is simple: give developers a Claude Code-style agentic terminal experience without tying them to any single AI provider.

With support for 75+ LLM providers — from Claude and GPT-5.5 to Gemini 3.1, DeepSeek, Mistral, and fully local models via Ollama — OpenCode lets you match the model to the task rather than the subscription to the workflow. Here is how to get started.

What Is OpenCode?

OpenCode is a terminal-native, open-source AI coding agent built by the Anomaly team. Unlike IDE extensions such as Cline or GitHub Copilot, or proprietary terminal tools like Claude Code, OpenCode runs as a TUI (terminal user interface) with a desktop app and IDE extension also available. It stores sessions in a local SQLite database and sends no code to external servers beyond your chosen LLM provider.

At its core, OpenCode does what every agentic coding tool does: reads your codebase, edits files, runs commands, manages git, and chains multi-step tasks. What sets it apart is provider flexibility, Language Server Protocol (LSP) integration, and a multi-agent architecture — all under the MIT license and completely free.

Installation

OpenCode supports every major package manager and operating system.

Universal install script:

curl -fsSL https://opencode.ai/install | bash

via npm / pnpm / Bun:

npm install -g opencode-ai
# or
pnpm add -g opencode-ai
# or
bun add -g opencode-ai

via Homebrew (macOS/Linux):

brew install opencode-ai/tap/opencode

via Docker:

docker run -it --rm ghcr.io/anomalyco/opencode

After installation, verify with:

opencode --version

Setting Up Your First Provider

OpenCode reads API keys from environment variables. Set the key for your chosen provider:

# For Anthropic (Claude)
export ANTHROPIC_API_KEY="sk-ant-..."
 
# For OpenAI (GPT-5.5)
export OPENAI_API_KEY="sk-..."
 
# For Google (Gemini 3.1)
export GOOGLE_AI_API_KEY="..."
 
# For local inference via Ollama (free, no API key needed)
ollama pull llama3.3

Then launch OpenCode in your project directory:

cd my-project
opencode

On first run, use /init to let OpenCode analyze your project structure. This generates an AGENTS.md file that helps the agent understand your codebase conventions, tech stack, and file layout — similar to a CLAUDE.md file.

Multi-Agent Architecture

OpenCode ships with three built-in agents you can switch between during a session:

Build agent (default) — Full codebase access with file editing, terminal execution, and git operations. Use this for all implementation work.

Plan agent — Read-only mode. The agent analyzes your code and proposes a plan but makes no changes until you approve. Use this before any large refactor to preview scope and risk.

General subagent — Handles complex multi-step searches and research tasks. Useful when gathering context from a large codebase before starting to code.

Press Tab to toggle between Build and Plan modes. The Plan-first workflow is a strong guardrail for production codebases where accidental edits carry real cost.

Key Commands

Inside the OpenCode TUI, the most useful slash commands are:

CommandWhat it does
/initAnalyze project and generate AGENTS.md
/undoRevert the last file change
/redoReapply a reverted change
/shareGenerate a shareable link to your session
/modelSwitch to a different LLM provider mid-session
/helpShow all available commands

LSP Integration: Self-Correcting Code Edits

One of OpenCode's most distinctive features is built-in Language Server Protocol support. After every file edit, OpenCode queries the LSP server for diagnostics — type errors, undefined variables, import issues — and feeds those back into the agent's next turn automatically.

This means the agent sees TypeScript compiler errors immediately after writing code and self-corrects before you notice. To enable LSP for TypeScript:

// opencode.json (project config)
{
  "lsp": {
    "typescript": {
      "command": "typescript-language-server",
      "args": ["--stdio"]
    }
  }
}

LSP support covers TypeScript, Python via pyright, Go via gopls, Rust via rust-analyzer, and more. Claude Code does not offer LSP integration by default — this is a meaningful differentiator for teams working in strongly typed languages.

OpenCode Zen: Curated Model Selection

Choosing among 75+ providers can be overwhelming. OpenCode Zen is a curated shortlist of tested, high-performing models with sane defaults. The current Zen lineup includes Claude Sonnet 4.6 for general coding, GPT-5.4 mini for fast low-cost tasks, DeepSeek V4 for cost efficiency, and GLM-5.2 for design and long-context work.

To use Zen models, open the /model picker — Zen picks appear with a star icon.

GitHub Actions Integration

OpenCode integrates with GitHub workflows via issue and pull request comments. Mention @opencode with a task in any issue or PR, and the GitHub Actions runner executes OpenCode in a sandboxed environment:

# .github/workflows/opencode.yml
name: OpenCode
on:
  issue_comment:
    types: [created]
jobs:
  run:
    if: contains(github.event.comment.body, '@opencode')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: anomalyco/opencode-action@v1
        with:
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

This pattern works well for async code reviews, automated triage, and CI-triggered refactoring tasks.

Cost Model: Pay Only for Tokens

OpenCode itself is free — you pay only the API tokens you consume with your chosen provider. On typical heavy agentic sessions with Claude Sonnet 4.6 (priced at $3 input / $15 output per million tokens), expect around $5–8 per day. Switching to DeepSeek V4 at $0.27/$1.10 drops that cost to under $1 per day for the same workload.

For zero-cost local inference, pull a capable model via Ollama:

ollama pull deepseek-coder-v2:16b
opencode
# then select Ollama > deepseek-coder-v2 in the /model picker

Local inference adds latency but costs nothing beyond electricity — a compelling option for privacy-sensitive environments or developers in regions with tight API budget constraints.

OpenCode vs. Claude Code vs. Cursor

FeatureOpenCodeClaude CodeCursor
Model providers75+Anthropic only10+
LicenseMIT (open source)ProprietaryProprietary
LSP integrationBuilt-inNot availableBuilt-in
CostAPI tokens only$20–200/mo$20/mo
Local inferenceVia OllamaNoLimited
Desktop appYesTerminal onlyYes (IDE)

OpenCode's strength is flexibility and zero lock-in. Claude Code's advantage is polish and deep Anthropic model optimization. Cursor wins on IDE-native UX. Your choice should follow your workflow, not marketing.

Getting Started Checklist

  • Install OpenCode via the curl script or your package manager
  • Set at least one provider API key, or install Ollama for local models
  • Run /init in your project to generate AGENTS.md
  • Try Plan mode before your next refactor
  • Configure LSP for your primary language
  • Explore OpenCode Zen for curated model recommendations

Conclusion

OpenCode has reached genuine parity with proprietary coding agents for most everyday development tasks — and surpasses them in flexibility. With 160,000 GitHub stars, MIT licensing, provider-agnostic architecture, and LSP self-correction, it is the strongest open-source alternative in the space. Whether you are cutting costs, avoiding vendor lock-in, or running models locally for data privacy, OpenCode earns a place in your developer toolkit today.