# OpenCode vs Codex: speed, token cost and features compared

Benchmark scores, cost and time per task for OpenCode and Codex CLI from Artificial Analysis and Terminal-Bench, plus features, ChatGPT plans and pricing. Reviewed 2026-11-02.

- Canonical: https://replicas.dev/resources/opencode-vs-codex

## OpenCode vs Codex benchmark scores (Artificial Analysis)

| Agent and model | Coding Agent Index | Terminal-Bench 4.0 (%) | FrontierCode v1.1 (%) | SWE-Atlas-QnA (%) |
| --- | --- | --- | --- | --- |
| Codex + GPT-6 Astra | 55 | 56 | 49 | 59 |
| Codex + GPT-6.1 Sol | 54 | 53 | 49 | 60 |
| OpenCode + GLM-5.3 | 49 | 40 | 48 | 59 |

- Artificial Analysis ran every setup at maximum reasoning effort. It tested Codex with several OpenAI models and DeepSeek V4.1 Flash, and OpenCode with GLM-5.3 only, so each gap comes from the agent and the model together. [1](https://artificialanalysis.ai/agents/coding-agents/comparisons/codex-vs-opencode)
- The largest gap is on Terminal-Bench 4.0: 56% for Codex with GPT-6 Astra and 40% for OpenCode with GLM-5.3. On FrontierCode and SWE-Atlas-QnA, all three setups are within one point of each other. [1](https://artificialanalysis.ai/agents/coding-agents/comparisons/codex-vs-opencode)

## Cost, time and tokens per task

| Agent and model | Cost per task | Time per task | Tokens per task | Turns per task |
| --- | --- | --- | --- | --- |
| Codex + GPT-6 Astra | $7.04 | 24.8 min | 3.2M | 39.4 |
| Codex + GPT-6.1 Sol | $1.50 | 23.7 min | 3.9M | Not reported |
| OpenCode + GLM-5.3 | $5.23 | 56.2 min | 15.9M | 111.5 |

- OpenCode with GLM-5.3 cost less per task than Codex with GPT-6 Astra, but took more than twice as long and used about five times as many tokens. [1](https://artificialanalysis.ai/agents/coding-agents/comparisons/codex-vs-opencode)
- Most of those tokens were read from the cache. Artificial Analysis reports a 95% cache hit rate for OpenCode and 93% for Codex. [1](https://artificialanalysis.ai/agents/coding-agents/comparisons/codex-vs-opencode)
- Codex with GPT-6.1 Sol cost about a fifth as much as with GPT-6 Astra and scored one index point lower. [1](https://artificialanalysis.ai/agents/coding-agents/comparisons/codex-vs-opencode)

## Codex on Terminal-Bench 4.0, by model

| Agent and model | Trials solved | Run cost |
| --- | --- | --- |
| Codex + GPT-6.1 Sol | 58.2% | $634 |
| Codex + GPT-6 Astra | 58.2% | $3.3k |
| Codex + GPT-6 Sol | 49.4% | $1.5k |
| Codex + GPT-6 Luna | 16.4% | $72 |

- GPT-6.1 Sol and GPT-6 Astra both solved 58.2% of the 330 trials. The GPT-6.1 Sol run cost $634, about a fifth of GPT-6 Astra’s $3.3k. [2](https://www.tbench.ai/leaderboard)
- OpenCode has no entry on the Terminal-Bench 4.0 leaderboard, so the Artificial Analysis results above are the only independent benchmark we found that tests both agents. [2](https://www.tbench.ai/leaderboard)[1](https://artificialanalysis.ai/agents/coding-agents/comparisons/codex-vs-opencode)

## OpenCode pricing

OpenCode is MIT-licensed. You pay your model provider or one of OpenCode’s plans.

- **Your own API key (Provider rates):** 75+ providers through the AI SDK and Models.dev, including OpenAI, plus local models. [21](https://opencode.ai/docs/providers)
- **ChatGPT Plus or Pro (What you already pay):** Choose the ChatGPT Plus/Pro option when you connect OpenAI. GitHub Copilot and GitLab Duo also work. [21](https://opencode.ai/docs/providers)
- **Go ($10/mo):** Open models and GPT-6 Luna with usage caps. Go Plus is $40/month, and Go Teams is $20 per member per month. [22](https://opencode.ai/docs/go)
- **Pay as you go (Per request):** OpenCode’s own provider, billed per request from prepaid credits. It includes GPT-6.1 Sol and GPT-6 Astra. [23](https://opencode.ai/docs/zen)

## Codex pricing

Codex CLI is Apache-2.0 licensed. You sign in with a ChatGPT plan or an API key.

- **ChatGPT Plus ($20/mo):** Includes Codex. OpenAI estimates 15 to 160 local messages per five hours on GPT-6.1 Sol, depending on the task. [6](https://learn.chatgpt.com/docs/pricing)
- **ChatGPT Pro (From $100/mo):** Tiers at $100, $200 and $500 a month, with no five-hour limit for now. [6](https://learn.chatgpt.com/docs/pricing)
- **ChatGPT Business ($20/user/mo):** Billed annually for two or more users, or $25 billed monthly. Enterprise and Edu are priced through sales. [6](https://learn.chatgpt.com/docs/pricing)
- **OpenAI API key (API rates):** Billed per token instead of from plan credits, without cloud features such as GitHub code review. [5](https://learn.chatgpt.com/docs/auth)[6](https://learn.chatgpt.com/docs/pricing)
- **Other providers (Provider rates):** Azure, Amazon Bedrock and other providers in `config.toml`, or local models through Ollama or LM Studio with `--oss`. [7](https://learn.chatgpt.com/docs/config-file/config-advanced)

## GPT-6.1 Sol price per million tokens, by seller

OpenCode’s pay-as-you-go provider charges the same as OpenAI’s API for GPT-6.1 Sol, up to 272K tokens of context.

| Seller | Input | Output | Cached input |
| --- | --- | --- | --- |
| OpenAI API [3](https://developers.openai.com/api/docs/pricing) | $2.00 | $10.00 | $0.10 |
| OpenCode pay as you go, up to 272K tokens [23](https://opencode.ai/docs/zen) | $2.00 | $10.00 | $0.10 |
| OpenCode pay as you go, above 272K tokens [23](https://opencode.ai/docs/zen) | $4.00 | $15.00 | $0.20 |

## When to use OpenCode or Codex

- **You want to use many model providers — OpenCode:** 75+ providers and local models. OpenCode treats OpenAI as one provider of many, and keeps the same tools and agents when you switch. [21](https://opencode.ai/docs/providers)
- **You want built-in LSP and permission rules — OpenCode:** Diagnostics and allow, ask or deny. Language server errors go back to the agent, and permissions are set per tool in opencode.json. [29](https://opencode.ai/docs/lsp)[27](https://opencode.ai/docs/permissions)
- **You already pay for ChatGPT — Codex:** Included from Plus to Enterprise. Codex comes with paid ChatGPT plans, and OpenAI documents the usage limits for each one. OpenCode can also sign in with Plus or Pro. [6](https://learn.chatgpt.com/docs/pricing)[21](https://opencode.ai/docs/providers)
- **You want an OS-level sandbox — Codex:** Seatbelt, bubblewrap, Windows sandbox. By default Codex can only write inside the workspace, and the operating system enforces it. [9](https://learn.chatgpt.com/docs/sandboxing)
- **You want to embed an agent in your code — Codex:** TypeScript SDK and GitHub Action. Codex has an SDK, a non-interactive mode for scripts, and an official GitHub Action. [14](https://learn.chatgpt.com/docs/codex-sdk)[15](https://learn.chatgpt.com/docs/github-action)

## Features: License and models

| Feature | OpenCode | Codex |
| --- | --- | --- |
| License [18](https://github.com/anomalyco/opencode)[4](https://github.com/openai/codex) | **MIT.** MIT-licensed, from Anomaly. | **Apache-2.0.** Written in Rust, by OpenAI. |
| Model choice [21](https://opencode.ai/docs/providers)[7](https://learn.chatgpt.com/docs/config-file/config-advanced) | **75+ providers and local models.** Through the AI SDK and Models.dev. | **OpenAI first; others by config.** Add providers in `config.toml`, or run local models with `--oss`. |
| ChatGPT plan sign-in [21](https://opencode.ai/docs/providers)[6](https://learn.chatgpt.com/docs/pricing) | **Plus and Pro.** Through the ChatGPT Plus/Pro login option. | **Plus to Enterprise.** Free and Go plans get GPT-6 Luna in the desktop app only. |
| Instruction files [28](https://opencode.ai/docs/rules)[8](https://learn.chatgpt.com/docs/agent-configuration/agents-md) | **`AGENTS.md`; `CLAUDE.md` fallback.** Reads CLAUDE.md when no AGENTS.md exists. | **`AGENTS.md`.** Other file names can be added with `project_doc_fallback_filenames`. |

## Features: Agent capabilities

| Feature | OpenCode | Codex |
| --- | --- | --- |
| Subagents [24](https://opencode.ai/docs/agents)[10](https://learn.chatgpt.com/docs/agent-configuration/subagents) | **General and Explore.** Plus custom agents. | **On by default.** The agent can start, message and wait for other agents. |
| Plan mode [24](https://opencode.ai/docs/agents)[11](https://learn.chatgpt.com/docs/developer-commands) | **Plan agent.** Can’t edit files except Markdown plans. | **`/plan`.** Switches the chat to plan mode. |
| Sandbox [27](https://opencode.ai/docs/permissions)[9](https://learn.chatgpt.com/docs/sandboxing) | **No OS sandbox.** Uses permission rules instead. | **OS-enforced.** Read-only, workspace-write (default) or full access. |
| Permission prompts [27](https://opencode.ai/docs/permissions)[9](https://learn.chatgpt.com/docs/sandboxing) | **Allow, ask, deny.** Most actions allowed by default; `.env` reads and folders outside the project ask first. | **On request or never.** Asks before leaving the sandbox, or uses a reviewer agent. |
| MCP [30](https://opencode.ai/docs/mcp-servers)[12](https://learn.chatgpt.com/docs/codex/cli) | **Local and remote.** Configured in opencode.json. | **Local and remote.** Added with `codex mcp`. |
| Language servers [29](https://opencode.ai/docs/lsp)[12](https://learn.chatgpt.com/docs/codex/cli) | **Built in.** Diagnostics are fed back to the agent. | **Not built in.** The agent runs the compiler or linter through the shell. |
| Web search [25](https://opencode.ai/docs/tools)[17](https://learn.chatgpt.com/docs/web-search) | **Some providers.** Only with OpenCode’s own providers or an Exa or Parallel key. | **Cached by default.** Live results with `--search`. |
| Sessions [34](https://opencode.ai/docs/tui)[11](https://learn.chatgpt.com/docs/developer-commands) | **Resume, undo and redo.** `/undo` and `/redo` roll back messages and file changes. | **`codex resume`.** Resume any earlier session by ID. |

## Features: Interfaces

| Feature | OpenCode | Codex |
| --- | --- | --- |
| Ways to run it [20](https://opencode.ai/download)[31](https://opencode.ai/docs/acp)[32](https://opencode.ai/docs/server)[13](https://learn.chatgpt.com/docs/codex/ide)[14](https://learn.chatgpt.com/docs/codex-sdk) | **Terminal, desktop, IDE, server.** Plus a server with an OpenAPI spec. | **Terminal, ChatGPT app, IDE, SDK.** Plus `codex exec` for scripts. |
| GitHub [33](https://opencode.ai/docs/github)[15](https://learn.chatgpt.com/docs/github-action)[16](https://learn.chatgpt.com/docs/third-party/github) | **`/oc` comments.** `opencode github install` adds a workflow that answers comments. | **Action and `@codex review`.** Code review needs a ChatGPT plan. |

## Running OpenCode or Codex in the cloud

Both agents run on your own computer by default, so they stop when it sleeps or shuts down. Replicas runs each task in its own cloud VM with your repositories cloned.

- **Pick either agent:** Choose OpenCode or Codex for a chat, an automation, or a task started from the CLI or API. [35](https://docs.replicas.dev/features/coding-agents/opencode)[36](https://docs.replicas.dev/features/coding-agents/codex)
- **Use your ChatGPT plan or keys:** Codex can use your ChatGPT subscription through `replicas codex-auth`, an OpenAI API key, Microsoft Foundry or an OpenAI-compatible endpoint. [36](https://docs.replicas.dev/features/coding-agents/codex)
- **Start tasks from your tools:** Start a task from the dashboard, Slack, Linear, GitHub, the CLI, the API and more. The agent opens the pull request when it’s done.
- **Compare the results:** Send the same task to both agents and review the two pull requests side by side.

Disclosure: Replicas publishes this comparison and supports both agents. It runs OpenCode, Codex, Claude Code, Pi, Cursor and more, each task in its own Linux VM. Try both on Replicas: https://app.replicas.dev/auth?mode=signup

## FAQ

### Is OpenCode or Codex faster?
In Artificial Analysis’s tests, Codex with GPT-6 Astra took 24.8 minutes per task and OpenCode with GLM-5.3 took 56.2 minutes. The two used different models, so this compares the agent and the model together. OpenCode can also run OpenAI models.

### Is OpenCode cheaper than Codex?
Both agents are free; you pay for the model. In Artificial Analysis’s tests, OpenCode with GLM-5.3 cost $5.23 per task, Codex with GPT-6 Astra $7.04 and Codex with GPT-6.1 Sol $1.50. OpenCode’s pay-as-you-go provider charges OpenAI’s list price for GPT-6.1 Sol. With a ChatGPT plan, usage counts against the plan’s limits instead.

### Which agent scores higher on benchmarks?
On the Artificial Analysis Coding Agent Index, Codex with GPT-6 Astra scores 55 and OpenCode with GLM-5.3 scores 49. The biggest difference is on Terminal-Bench 4.0, 56% against 40%. OpenCode has no entry on the official Terminal-Bench 4.0 leaderboard.

### Can I use my ChatGPT subscription with OpenCode?
Yes. OpenCode’s OpenAI provider has a ChatGPT Plus/Pro login option. Codex works with ChatGPT Plus, Pro, Business, Edu and Enterprise. The Free and Go plans include only GPT-6 Luna in the ChatGPT desktop app.

### Can Codex use Claude or other non-OpenAI models?
Codex can use other providers that you add to `config.toml`, such as Azure, Amazon Bedrock or Mistral, and local models through Ollama or LM Studio. OpenCode supports 75+ providers out of the box, including Anthropic.

### Can I run OpenCode and Codex in the cloud?
Yes. Replicas runs both in their own cloud VM per task with your repositories cloned. Codex can use your ChatGPT subscription or an OpenAI API key. Tasks can start from the dashboard, Slack, Linear, GitHub, the CLI, the API and more.

## Sources

1. [Codex vs Opencode: coding agent comparison](https://artificialanalysis.ai/agents/coding-agents/comparisons/codex-vs-opencode) (Artificial Analysis)
2. [Terminal-Bench 4.0 leaderboard](https://www.tbench.ai/leaderboard) (Terminal-Bench)
3. [OpenAI API pricing](https://developers.openai.com/api/docs/pricing) (OpenAI)
4. [openai/codex repository and license](https://github.com/openai/codex) (GitHub)
5. [Codex authentication](https://learn.chatgpt.com/docs/auth) (OpenAI)
6. [Codex pricing and plan features](https://learn.chatgpt.com/docs/pricing) (OpenAI)
7. [Codex model providers](https://learn.chatgpt.com/docs/config-file/config-advanced) (OpenAI)
8. [Codex AGENTS.md instructions](https://learn.chatgpt.com/docs/agent-configuration/agents-md) (OpenAI)
9. [Codex sandboxing and approvals](https://learn.chatgpt.com/docs/sandboxing) (OpenAI)
10. [Codex subagents](https://learn.chatgpt.com/docs/agent-configuration/subagents) (OpenAI)
11. [Codex slash commands](https://learn.chatgpt.com/docs/developer-commands) (OpenAI)
12. [Codex CLI](https://learn.chatgpt.com/docs/codex/cli) (OpenAI)
13. [Codex IDE extension](https://learn.chatgpt.com/docs/codex/ide) (OpenAI)
14. [Codex SDK](https://learn.chatgpt.com/docs/codex-sdk) (OpenAI)
15. [Codex GitHub Action](https://learn.chatgpt.com/docs/github-action) (OpenAI)
16. [Codex code review in GitHub](https://learn.chatgpt.com/docs/third-party/github) (OpenAI)
17. [Codex web search](https://learn.chatgpt.com/docs/web-search) (OpenAI)
18. [anomalyco/opencode repository and license](https://github.com/anomalyco/opencode) (GitHub)
19. [OpenCode intro and install](https://opencode.ai/docs) (OpenCode)
20. [Download OpenCode](https://opencode.ai/download) (OpenCode)
21. [OpenCode providers](https://opencode.ai/docs/providers) (OpenCode)
22. [OpenCode Go](https://opencode.ai/docs/go) (OpenCode)
23. [OpenCode Zen](https://opencode.ai/docs/zen) (OpenCode)
24. [OpenCode agents](https://opencode.ai/docs/agents) (OpenCode)
25. [OpenCode tools](https://opencode.ai/docs/tools) (OpenCode)
26. [OpenCode CLI](https://opencode.ai/docs/cli) (OpenCode)
27. [OpenCode permissions](https://opencode.ai/docs/permissions) (OpenCode)
28. [OpenCode rules (AGENTS.md)](https://opencode.ai/docs/rules) (OpenCode)
29. [OpenCode LSP servers](https://opencode.ai/docs/lsp) (OpenCode)
30. [OpenCode MCP servers](https://opencode.ai/docs/mcp-servers) (OpenCode)
31. [OpenCode IDE and ACP support](https://opencode.ai/docs/acp) (OpenCode)
32. [OpenCode server](https://opencode.ai/docs/server) (OpenCode)
33. [OpenCode GitHub integration](https://opencode.ai/docs/github) (OpenCode)
34. [OpenCode TUI commands](https://opencode.ai/docs/tui) (OpenCode)
35. [OpenCode in Replicas](https://docs.replicas.dev/features/coding-agents/opencode) (Replicas)
36. [Codex in Replicas](https://docs.replicas.dev/features/coding-agents/codex) (Replicas)

## Related docs


