OpenCode vs Codex: any model, or OpenAI's own agent
OpenCode 2.3.2 and Codex 0.171.0 compared: licence, models and ChatGPT plans, sandbox, config, MCP and skills, headless runs, and phone access.
Both are free and open source: Codex is OpenAI’s agent under Apache-2.0, and OpenCode is a model-neutral one under MIT. The two real differences are models and guardrails. Codex is built for OpenAI’s models on a ChatGPT plan or an OpenAI API key, and it runs every command in an operating-system sandbox with the network off. OpenCode connects to almost any provider, a ChatGPT Plus or Pro sign-in included, and does not sandbox anything: by default it runs commands and edits files without asking. Pick Codex if you use OpenAI’s models and want the guardrails built in; pick OpenCode if you want to switch between labs’ models, or to reach a session from a browser or phone with no desktop app. As of November 22, 2026: Codex 0.171.0, OpenCode 2.3.2.
Side by side
| Codex 0.171.0 | OpenCode 2.3.2 | |
|---|---|---|
Made by | OpenAI | The OpenCode team (anomalyco on GitHub), tied to no model lab |
Licence | Apache-2.0 | MIT |
Models | OpenAI’s; Ollama, LM Studio, Bedrock, Google Cloud and custom endpoints by config | Any provider you connect, local models included |
ChatGPT sign-in | Yes, the main route | Yes, for Plus or Pro, by its docs |
Sandbox | bubblewrap and seccomp on Linux, Seatbelt on macOS, network off | None |
Default approvals | Asks only to leave the sandbox | Asks only before reading .env files |
Config | ~/.codex/config.toml | ~/.config/opencode/opencode.json |
Scripted runs | codex exec, read-only by default | opencode run, under the normal rules |
Always-on server | None by default; an experimental app server | A background service per account, with a web interface |
Phone | The ChatGPT app, through a Mac or Windows desktop host | OpenCode’s own app or any browser, paired to the server |
OpenCode has a second line still published: version 1, as opencode-ai 1.19.6 on npm, released November 17, which is why GitHub’s releases page marks a 1.x release as Latest above the newer 2.3.2. Its notes say “OpenCode 1 now offers the upgrade to OpenCode 2.0.” Everything on this page is about version 2 (@opencode/cli), which OpenCode’s install script now installs, and many older comparisons describe version 1.
Models and what you pay
Codex comes with ChatGPT. OpenAI’s Codex pricing page says it is included in “your ChatGPT Free, Go, Plus, Pro, Business, Edu, or Enterprise plan”, with Plus at $20 a month, and that “API-key sessions use separate API pricing, not your ChatGPT allowance.” Which ChatGPT plans include Codex has what each plan gets. Away from OpenAI, Codex reserves built-in providers for Ollama, LM Studio, Amazon Bedrock and Google Cloud, runs a local model with --oss, and takes other endpoints as [model_providers.<id>] tables in your own config, by its advanced config page. The tool is shaped around OpenAI’s models, and the other routes are there for when you need them.
OpenCode has no home provider. You run /connect, pick one and give it a key or a sign-in. Its providers page covers OpenAI through ChatGPT (“Use a ChatGPT Plus or Pro plan instead of an OpenAI API key”), GitHub Copilot by device sign-in, OpenRouter, Azure, Bedrock, Vertex and xAI by key, and Ollama, LM Studio and vLLM found on their usual local ports. OpenCode also sells model access itself: Go at $10 a month with usage limits, and a pay-as-you-go catalogue billed per token, both in the OpenCode pricing guide. It has no Claude sign-in of its own: Claude goes through an Anthropic key, a gateway, or its Claude Agent provider, which drives a Claude Code you have installed and signed in (a Claude plan in other agents covers what Anthropic says of that).
On a ChatGPT plan the two draw from the same pool. OpenAI’s Sign in with ChatGPT page lists OpenCode among its “Open-source integrations” and says “App usage counts toward your existing plan limits” and “Connecting an app does not add a new allowance”. A ChatGPT plan used in OpenCode buys GPT models in a different harness, not more of them. OpenCode’s docs name only Plus and Pro for that sign-in; Codex itself takes every plan from Free up.
Sandbox and approvals
This is where they differ most. Codex sandboxes the commands its model runs: on Linux with bubblewrap plus seccomp, on macOS with Seatbelt, and “By default, the agent runs with network access turned off.” In a Git repository it starts in Auto, free to edit the folder and run commands in it, and asks before a write elsewhere or a network call. Outside version control it starts read-only. You loosen it with --sandbox workspace-write or danger-full-access, and turn the questions off with -a never. On Ubuntu 24.04 that sandbox needs an AppArmor profile before it works at all, which Codex on a Linux server sets up.
OpenCode’s security policy says “OpenCode does not sandbox the agent”, that its permission system “is not designed to provide security isolation”, and “If you need true isolation, run OpenCode inside a Docker container or VM.” Its default rules allow every action, paths outside the project included, and ask only before reading .env files; a shell command “runs with the host user’s filesystem, process, and network authority.” You can make it stricter, with rules that ask for or deny shell commands by pattern, and a deny rule holds even in a run that cannot ask. What you cannot add from inside OpenCode is a boundary the model’s commands cannot cross; that comes from the machine or container you run it in.
Neither default is wrong. On a laptop with your SSH keys and browser sessions on it, Codex’s sandbox is protection you get without thinking. On a disposable server or a container that holds only the project, OpenCode’s defaults spare you the prompts, and Codex gets the same with --sandbox danger-full-access -a never, letting the machine be the boundary.
Config, instructions, MCP and skills
Each keeps a user file, a project file and a machine-wide file. Codex reads TOML: ~/.codex/config.toml, a project’s .codex/config.toml and /etc/codex/config.toml, with profiles and -c overrides on top, and it loads a project’s .codex/ layer “only when you trust the project”. OpenCode reads JSON or JSONC: ~/.config/opencode/opencode.json, then opencode.json or .opencode/opencode.json in the folders above where you start it, with /etc/opencode winning over both. The detail is in Codex’s config.toml and OpenCode’s opencode.json.
- Instructions. Both read
AGENTS.md. Codex also readsAGENTS.override.md, caps the total at 32 KiB by default, and takes other names only if you list them inproject_doc_fallback_filenames. OpenCode’s instructions page falls back toCLAUDE.mdin any folder without anAGENTS.md, so a repository written for Claude Code works as it is. - MCP servers. Both speak stdio and streamable HTTP, and both sign in to servers that use OAuth (
codex mcp login,opencode mcp auth). Codex adds a server withcodex mcp add <name> -- <command>as an[mcp_servers.<name>]table; OpenCode withopencode mcp add <name> --url <url>for a remote one, undermcp.servers. - Skills. Both follow the Agent Skills format and both read
~/.agents/skillsand a project’s.agents/skills, so one copy there serves both. OpenCode also reads.claude/skillsand its own.opencode/skills; Codex ships skill-creator and skill-installer and reads/etc/codex/skills. You call one with$namein Codex and@namein OpenCode. - Plugins. A Codex plugin is “an installable bundle that can include skills and Model Context Protocol (MCP) servers”, and can carry lifecycle hooks, from a directory it shares with ChatGPT. An OpenCode plugin is TypeScript or JavaScript code that adds tools, hooks, commands or agents, loaded from npm or
.opencode/plugins/; plugins written for OpenCode 1 need updating for 2.
On a server, and without a terminal
For scripts and cron, both have a one-shot mode with JSON output, and they start from opposite ends. OpenAI’s page: “By default, codex exec runs in a read-only sandbox.” A job that edits needs --sandbox workspace-write, it refuses to run outside a Git repository without --skip-git-repo-check, and CODEX_API_KEY set for one run bills that run to an API key. opencode run runs under your normal permission rules, which by default let it edit and run commands; it cannot stop to ask, so anything a rule would have asked about is turned down and the run carries on, unless you pass --auto, which approves everything not explicitly denied.
codex exec --sandbox workspace-write --json "fix the failing test"
opencode run --format json "fix the failing test"CopiedThe bigger difference is what stays running. OpenCode 2 is built around a background server for your account, on 127.0.0.1:49374 on Linux, behind a password. The terminal interface talks to it, a run uses it when it is up (--standalone starts a private one instead), and it serves a web interface. opencode pair prints a link that works once, expires in five minutes, and signs a browser or OpenCode’s phone app (Google Play, and TestFlight on iPhone) in for 30 days. OpenCode on a remote server covers reaching it over a private network, and the background service guide its commands and failures.
Codex has no such server by default. The phone route is the ChatGPT app, which pairs with the ChatGPT desktop app, and OpenAI’s remote connections page says “Remote access supports hosts running the ChatGPT desktop app on macOS and Windows” and that the setup cannot start from the CLI. A Linux server joins in as an SSH host that desktop app opens. The CLI has experimental codex app-server and codex remote-control commands for the same machinery, set out in Codex remote control. On a headless server with no Mac or PC in the loop, Codex is a terminal you keep alive in tmux; OpenCode is a terminal or a web page.
Does the harness change the result?
The one public test that runs the pair on the same model finds no gap. In OpenBench, one developer’s harness benchmark, a July 2026 table runs both on GPT-5.5 at medium effort: each solved 9 of 9 tasks, in about 55 seconds on average. Nine tasks is a small sample, and its author says to “treat cross-harness gaps as real only when the intervals separate.” The model you run matters more than which of the two runs it, and OpenCode vs Claude Code sets out what the larger benchmarks say about that.
Which to pick
If you pay for ChatGPT and want GPT models, Codex is the simpler choice: it is OpenAI’s own client for the plan, it works on every plan including Go and Business, and it arrives with a sandbox, so on your own laptop it is the safer default. If you want Claude, Gemini, open-weight or local models beside GPT, or want to change model mid-project, OpenCode is the one built for that. For an agent left on a server and reached from a phone, OpenCode’s background server and pairing links work on Linux alone, where Codex’s phone route needs a Mac or Windows desktop in the chain; Codex’s read-only codex exec is the safer default for unattended jobs.
You do not have to choose once. Each installs with one command (curl -fsSL https://chatgpt.com/codex/install.sh | sh and OpenCode’s installer), update themselves with codex update and opencode upgrade, read the same AGENTS.md and .agents/skills, take the same MCP servers, and can share one ChatGPT plan. Against Claude Code, see Codex vs Claude Code.