OpenCode: The Open-Source Coding Agent That Runs on Your Own Hardware
An open-source alternative to Claude Code and GitHub Copilot. OpenCode is a 195k-star AI coding agent you can run locally with any model.
If you have used Claude Code or GitHub Copilot, you know how useful an AI coding agent can be. It reads your codebase, understands your context, writes code, runs tests, and fixes errors in a tight feedback loop. The problem with commercial coding agents is that they send your entire codebase to a third-party API. Every file, every function, every secret gets processed on someone else's server. OpenCode fixes this by being fully open source and capable of running entirely on your own hardware with any model you choose. No code leaves your machine unless you configure it to.
What OpenCode Is
OpenCode is a command-line AI coding agent with 195,000 GitHub stars and an MIT license. It works like Claude Code or GitHub Copilot's agent mode: you describe what you want to build or fix, and the agent reads your code, plans the changes, writes the code, runs tests, and iterates until it works. It has access to your file system, your terminal, and your development tools. It can search your codebase, read documentation, run shell commands, and apply edits directly.
OpenCode includes two built-in agents. The build agent has full access for development work: it can read, write, edit files and run commands. The plan agent is read-only for analysis and code exploration: it cannot edit files and asks permission before running commands. You switch between them with the Tab key. There is also a general subagent for complex searches and multi-step research tasks.
OpenCode runs as a terminal application (TUI) or as a desktop app. It supports any model through OpenAI-compatible APIs, Ollama for local models, and direct integrations with Anthropic, OpenAI, and other providers. You can use GPT-4 when you need frontier reasoning on a complex problem, and switch to a local Mistral model for routine work that should not leave your machine.
Running OpenCode with Ollama (Fully Local, Zero Cost)
Install Ollama:
curl -fsSL https://ollama.com/install.sh | sh
ollama pull mistral:7bInstall OpenCode:
npm i -g opencode-ai@latest
# or: brew install anomalyco/tap/opencode
# or: brew install opencodeRun OpenCode pointing at your local Ollama:
export OPENAI_API_BASE=http://localhost:11434/v1
export OPENAI_API_KEY=ollama
opencode --model mistral:7bOpenCode is now running entirely on your machine. No data leaves your computer. No API keys are sent to external servers. No usage limits. No per-token pricing. You can ask it to refactor a module, write tests, or explain a legacy codebase, and it works entirely offline if you have the model downloaded.
When to Use OpenCode vs. When to Use a Commercial Agent
OpenCode with a local 7B model handles routine development tasks well: adding features to a known pattern, writing unit tests, refactoring for readability, and explaining existing code. For complex architectural decisions, debugging subtle race conditions, or implementing novel algorithms, a frontier model like Claude or GPT-4 will produce better results. The pragmatic approach is to use both: OpenCode with a local model for everyday work where privacy matters, and a commercial agent for the hard problems where reasoning quality justifies sending code to an external API.
For a business, the privacy argument is compelling. Your proprietary codebase is a business asset. Sending it to an external API for every development task creates a data exposure that is hard to quantify and impossible to reverse. OpenCode on your own hardware eliminates this exposure entirely for routine work while still giving you the option to use external models when needed.
VPS1 deploys Ollama with Open WebUI and OpenCode on your own infrastructure. We set up the models, configure the tools, and give your development team a private AI coding environment. Your code stays on your hardware.
More articles
How to Deploy BTCPay Server: Accept Bitcoin Payments with Zero Platform Fees
BTCPay Server lets you accept Bitcoin and Lightning payments with no platform fees. Only standard Bitcoin network fees apply. Here is how to deploy it with Docker Compose.
Self-Hosted Crypto Payment Processors: BTCPay Server, Bitcart, and SHKeeper Compared
Accept Bitcoin and cryptocurrency payments directly with no platform fees, no intermediaries, and no KYC. Here is how BTCPay Server, Bitcart, and SHKeeper compare.
How to Deploy SHKeeper: Accept Crypto Payments with WooCommerce in 30 Minutes
SHKeeper supports Bitcoin, Ethereum, USDT, USDC, and 19+ cryptocurrencies with a free WooCommerce plugin. Zero platform fees -- only standard network fees apply.