Codex vs OpenCode
Both are open source terminal agents. Codex runs OpenAI models inside a sandbox by default. OpenCode runs almost any model and trusts the agent unless you add rules.
Codex and OpenCode are terminal coding agents. Each reads your repository, edits files and runs commands until a task is done. OpenAI builds Codex and includes it in ChatGPT plans. OpenCode is an MIT-licensed agent from Anomaly that connects to almost any model provider, including your ChatGPT plan. Facts on this page were checked against each tool's own docs, pricing page and repository as of December 4, 2026.
Decision Table
| Codex | OpenCode | |
|---|---|---|
| License | Apache 2.0 for the openai/codex CLI | MIT |
| Price | Included in every ChatGPT plan, from Free. Or an API key at API prices | Free. You pay your provider, or OpenCode Go at $10 per month |
| Models | OpenAI models, such as GPT-6.2 Astra and GPT-6.2 Sol | Any provider in the models.dev catalog, ChatGPT and GitHub Copilot sign-in, local models through Ollama |
| Default safety | Sandbox on. Writes limited to the workspace | No OS sandbox. Every action allowed except reading .env files, which asks |
| Surfaces | CLI, IDE extension, ChatGPT desktop and web, Codex Cloud | Terminal UI, desktop app, web app |
| Best for | People who pay for ChatGPT and want safe defaults | People who switch models or run local ones |
At a Glance
| Codex | OpenCode | |
|---|---|---|
| Pricing | ChatGPT Free, Go $8, Plus $20, Pro from $100, Business $25 per user billed monthly | Free client. OpenCode Go $10 and Go Plus $40 per month for a curated model list |
| Permissions | Sandbox modes read-only, workspace-write, danger-full-access. Approval policies on-request or never | Ordered allow, ask and deny rules per action and resource, per agent |
| Sandbox | Seatbelt on macOS, native sandbox on Windows, bubblewrap on Linux and WSL2 | None. Shell commands run with your user's filesystem, process and network access |
| Built-in agents | Subagents | build for full access, plan for read-only planning, general subagent |
| Project instructions | AGENTS.md | AGENTS.md, falling back to CLAUDE.md |
| Skills | Skills and plugins | Skills from .opencode/skills, .claude/skills and .agents/skills, plus plugins |
| MCP | Local and remote servers | Local and remote servers, with OAuth |
| Headless and CI | codex exec | opencode run |
Models and Cost
Codex runs OpenAI models. If you do not pick one, it uses a recommended model. OpenAI suggests GPT-6.2 Astra for demanding work and GPT-6.2 Sol for everyday coding. A custom provider works only if it exposes a Responses API endpoint.
OpenCode reads its provider list from models.dev and connects to almost any provider. You can sign in with a ChatGPT Plus or Pro plan, so one ChatGPT subscription can pay for either agent. OpenCode Go is an optional $10 subscription to a curated list of models tested for agentic coding, such as Kimi K3, GLM-5.4 and DeepSeek V4 Pro. Go Plus raises the limits for $40.
If you want a free plan with no API key, Codex works on ChatGPT Free. If you want Claude, Gemini or a local model in the same agent, pick OpenCode. Best LLM for Coding compares the models.
Sandboxing and Permissions
The defaults point in opposite directions. Codex starts in a sandbox. In workspace-write mode it edits files in the workspace, runs routine commands and pauses when it needs to go further. On Linux and WSL2 you install bubblewrap first.
OpenCode's build agent allows every action by default, including access outside the workspace. Only reading .env files asks first. Its docs warn that shell commands run with your user's full authority. You narrow that with deny and ask rules, or run OpenCode in a container or a cloud sandbox.
If you run an agent unattended, Codex needs no setup to stay inside the workspace. OpenCode needs rules or isolation first.
Instructions and Skills
Both agents read AGENTS.md, so one file serves both. OpenCode reads CLAUDE.md in any directory without an AGENTS.md. OpenCode also loads skills from .claude/skills and .agents/skills, so skills written for Claude Code or other agents work without copying.
When to Pick Which
- Pick Codex if you pay for ChatGPT, want a sandbox on from the start, use VS Code or JetBrains, or want to hand tasks to Codex Cloud.
- Pick OpenCode if you switch providers per task, run local or open-weight models, or want an MIT-licensed agent you can fork.
- Pick both if you have a ChatGPT plan. Use Codex for OpenAI models and OpenCode for everything else.
Alternatives
- Claude Code: Anthropic's agent for Claude models. See Claude Code vs Codex CLI and OpenCode vs Claude Code.
- Cursor, now Grok Build: an editor with an agent built in. See Codex vs Cursor and OpenCode vs Cursor.
- Cline: an Apache 2.0 agent for many providers that runs in your editor. See Codex vs Cline, OpenCode vs Cline and Claude Code vs Cline.
Running Several Agents at Once
To compare Codex and OpenCode on the same task, give each its own git worktree so their edits never collide. In Treq, each agent runs in its own workspace, and you review the results side by side.
Sources
Checked December 4, 2026:
- Codex pricing, Codex models, Codex sandboxing, Codex license
- OpenCode Go, OpenCode providers, Permissions, Agents, Instructions, Skills, CLI
Next Steps
- Best Coding Agent CLIs: every current terminal agent in one table
- Best Open-Weight Coding Models: models to run through OpenCode
- Parallel Coding Agents: why agents need separate workspaces