Analytics cookies only (Google Analytics, PostHog). No ad networks, no cross-site tracking. See our privacy policy.
Self-host OpenCode
updated Nov 2026deployed by usprices checked · Jul 2026Install verified on Ubuntu 26.04 · Nov 2026 · how we test
We earn commissions when you shop through the links below. Full disclosure →
An open-source AI coding agent that runs in a terminal, a desktop app or, with opencode web, in your browser. It supports 75 or more LLM providers through the AI SDK and Models.dev, including local models, with sessions you can resume. The web server can be protected with HTTP basic auth, and a terminal can attach to the same sessions with opencode attach.
Pick OpenCode when you want a terminal-style coding agent that you can also open in a browser on your own server: `opencode web` serves the same sessions over HTTP, protected with basic auth through `OPENCODE_SERVER_PASSWORD`, and a terminal can attach to the running server with `opencode attach`. It is an MIT-licensed TypeScript project that uses the AI SDK and Models.dev to support 75 or more providers, including local models, so you choose and pay for the model yourself. Our snippet runs the official `ghcr.io/anomalyco/opencode` image pinned to 1.19.5 (released 2026-10-28), starts `web` on port 4096 and mounts `./workspace` as the agent's working directory and `./data` for sessions and credentials. We did not find an upstream RAM minimum, so our 1024 MB floor is an estimate; the idle container used about 200 MB on our test run. In the catalog, OpenHands is a heavier control centre that can also run third-party agents, bolt.diy generates web apps from a prompt inside the browser, and PR-Agent only reviews merge requests; OpenCode is closest to a coding assistant you drive session by session.
What you need
Any VPS with at least 1024 MB of RAM
A domain you control — most self-hosted setups need HTTPS in front of them
OpenCode's 1.19 web, permissions and server docs flag these before you rely on it:
non-negotiableThe docs caution that without OPENCODE_SERVER_PASSWORD the server is unsecured, which is fine for local use but not for network access. Our snippet generates a password into .env; the username defaults to opencode, and the browser prompts for HTTP basic auth. Anyone with that password can run an agent that reads and edits the mounted workspace, so keep port 4096 off the open internet and put TLS in front of it.
non-negotiableIt needs a provider before it can answer. Credentials you add are stored in auth.json under ~/.local/share/opencode, which our snippet maps to ./data, so back that directory up and keep it private. Hosted providers bill you directly.
non-negotiableIn 1.19, permissions are per action as allow, ask or deny, and --auto approves everything that is not explicitly denied. Inside the container the agent can only touch what you mount, which is the point of this setup: it will not see the rest of the VM, but it also cannot reach tools that are not in the image, so check what a task needs before relying on it.
non-negotiableUpstream is mid-transition. The web docs carry an "OpenCode v2 is now available" banner and v2.x images and releases (2.2.6 on 2026-11-06) sit beside the 1.19.x line the opencode-ai npm package still publishes. We pinned 1.19.5, which we confirmed serves opencode web; the 2.x CLI has a different command set (a background service and a --server option), and the live CLI and permissions docs on opencode.ai already describe v2, so this caveat and the permissions one above follow the 1.19 docs; re-read them before moving to a newer tag.
non-negotiableThe container runs as root and bind-mounted files in workspace and data end up owned by root on the host. The web interface is also reachable by anyone on the same network if you bind it to 0.0.0.0, as our snippet does so that you can reach it from outside; firewall it or bind it to localhost and tunnel in.
OpenCode used 182 MB of RAM at idle on GCP e2-standard-2 · Ubuntu 26.04 LTS · Docker 29.9.3 (first boot, measured Nov 2026). We list a minimum of 1024 MB.
Is the OpenCode install snippet verified?
The OpenCode install snippet is marked verified on Ubuntu 26.04 (Nov 2026).