opencode or Codex CLI: which terminal agent to choose
Both agents are open source, both read AGENTS.md and both work with your own API. The differences are in providers, modes and cache billing. We compare and price a session.
6 min · · агенты · сравнение
opencode or Codex CLI: the question comes up when you need a terminal agent that reads your project, edits files and runs commands without being tied to a subscription. Both tools are open source, both can work with your own API provider, but they are built differently. Below is a comparison on what actually affects the choice: interface, agents and modes, provider setup, cache and session cost.
The tools are described from their documentation as of October 18, 2026 (opencode.ai/docs, the openai/codex repository) and from the Zukko guides. Products change fast, so check flag and menu names against your version.
A short profile of each
opencode is an open source AI coding agent. According to its documentation it is available as a terminal interface, a desktop app and an IDE extension. You install it with the script curl -fsSL https://opencode.ai/install | bash or through a package manager (for example npm install -g opencode-ai). The documentation separately warns that OpenCode 1 and OpenCode 2 share the same opencode command, so check which one you installed.
Codex CLI is a coding agent from OpenAI that runs locally on your computer and installs, for example, through npm install -g @openai/codex or brew install --cask codex. Besides the terminal there is an editor extension, a desktop app and a cloud version, Codex Web, but this article is about the terminal. By default Codex suggests signing in with a ChatGPT account. Using it with an API key is also possible but needs extra setup.
We do not write about ChatGPT or other subscription terms: they change, so see the current plan on the service's site. Here we only cover paying for tokens with your own key.
opencode vs Codex: point-by-point comparison
| Item | opencode | Codex CLI |
|---|---|---|
| Interfaces | terminal, desktop app, IDE extension | terminal, editor extension, desktop app, web |
| Agent modes | two primary agents, Build and Plan, switched with Tab; built-in subagents (General, Explore and others) | approval and sandbox modes (see the Codex documentation) |
| Rules file | AGENTS.md, created with /init | AGENTS.md |
| Configuration | opencode.json in ~/.config/opencode/ or the project root | ~/.codex/config.toml and ~/.codex/auth.json |
| Custom provider | any provider by key; Zukko documents the Anthropic provider | model_providers in config.toml; Zukko documents wire_api = "responses" |
| Models at Zukko | Claude: claude-sonnet-5, claude-opus-5-5 | GPT and Claude; GLM models do not work in Codex |
| API format | Anthropic (Claude cache is visible) | Responses, /v1/responses |
The main practical takeaway: the set of available models depends not only on the agent but on the way you connect. Per the Zukko guides, opencode is set up through the Anthropic provider and works with Claude, while Codex goes through the Responses API and works with GPT and Claude. If you want other providers in opencode, see the providers section of its documentation.
Setup with Zukko
opencode. The file ~/.config/opencode/opencode.json (or opencode.json in the project root):
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"options": {
"baseURL": "https://api.zukko.pro/v1",
"apiKey": "fetch_your_key"
},
"models": {
"claude-opus-5-5": {},
"claude-sonnet-5": {}
}
}
}
}/v1 is required here: without it requests go to /messages and return 404. Then run opencode, type /models and choose Anthropic and the model you want.
Codex CLI. The file ~/.codex/config.toml:
model = "gpt-6.1-sol"
model_provider = "zukko"
[model_providers.zukko]
name = "zukko"
base_url = "https://api.zukko.pro/v1"
wire_api = "responses"
requires_openai_auth = trueAnd ~/.codex/auth.json:
{ "OPENAI_API_KEY": "fetch_your_key" }You can change the model at launch: codex -m gpt-6.1-sol. For Windows and macOS Zukko provides an installer that writes both files; details in the Codex guide. There is a separate article on connecting Codex without a ChatGPT subscription: Codex without a ChatGPT subscription.
Agents, modes and rules
opencode has a built-in split: a Build agent with full tool access and a Plan agent restricted to analysis and planning. Per the documentation, file edits and bash commands in Plan require confirmation by default. Subagents such as General and Explore are invoked with an @ mention or by the primary agent itself. That is handy if you want to discuss a plan first without fear of accidental edits.
In Codex, safety is built around approval and sandbox modes: what the agent may do without asking and what needs confirmation. Exact mode names and flags change, so see the approvals and security page in the Codex documentation.
What both share is an AGENTS.md file in the project root with build commands, tests and conventions. If you write it carefully, it works in both agents. Keep in it only what the agent cannot quickly find out on its own: check commands, prohibitions and non-obvious conventions.
What a session costs
An agent sends the accumulated history to the model at every step, so input is what you count. Take a hypothetical session: 30 requests, 50,000 input and 1,000 output tokens each. Totals: input 1.5M, output 0.03M. Zukko prices as of October 18, 2026, $ per 1M tokens.
Without cache:
- opencode with
claude-sonnet-5(0.4 / 2): 1.5 × 0.4 + 0.03 × 2 = 0.6 + 0.06 = $0.66 - Codex with
gpt-6.1-sol(0.27 / 1.32): 1.5 × 0.27 + 0.03 × 1.32 = 0.405 + 0.0396 = $0.44
With cache (assumption: 45,000 of the 50,000 tokens in each request are read from cache, and the remaining 5,000 arrive fresh and, for Claude, are written to cache):
- opencode in the Anthropic format: read 30 × 45,000 = 1.35M × 0.05 = 0.0675; write 30 × 5,000 = 0.15M × 0.5 = 0.075; output 0.06. Total about $0.20.
- Codex with GPT: read 1.35M × 0.013 = 0.0176; fresh input 0.15M × 0.27 = 0.0405; output 0.0396. Total about $0.10. For GPT only cache reads are visible, with no separate write charge.
This is an illustration, not a forecast: the cache hit share depends on the task and the tool. If you run Claude through Codex, count conservatively without a cache discount: for Claude the discount works in the Anthropic format, while Codex goes through Responses. More: the cache documentation. We do not compare model quality: rely on price, context and strength index (claude-sonnet-5 has 45, gpt-6.1-sol has 52) and test on your own tasks.
What to choose
- You want several interfaces and a Plan mode for discussing code safely: look at opencode.
- You already work in the OpenAI ecosystem or want GPT and Claude models through one config: Codex.
- Not sure: install both. They do not conflict, each has its own settings folder. Give both the same small task and compare the result and the cost from the usage in your dashboard.
FAQ
opencode vs Codex: which is cheaper?
The agents themselves are free; you pay for tokens. The model and cache decide the total: in the example above Codex with gpt-6.1-sol came out cheaper than opencode with claude-sonnet-5, but that follows from model prices, not from the agents.
Can I use GPT in opencode?
The Zukko guide describes connecting through the Anthropic provider with Claude models. For other providers see the opencode documentation, and remember the rule: OpenAI-compatible clients use a Base URL with /v1.
Does Codex work with Claude models?
According to the Zukko guide, yes: through the Responses API both GPT and Claude models work. GLM models do not work in Codex.
How do I connect both agents and pay from Russia?
Create a key in the dashboard and top up the balance: access from Russia goes through the gateway, with payment by SBP, MasterCard or crypto. One key works for both agents.
You create the key in the dashboard, and setting up both agents takes a few minutes.
zukko
Pay 25×
less
for Claude Code & ChatGPT
One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.
Related articles
- RAG or MCP: what is the difference and which to choose for giving a model dataRAG puts retrieved pieces into the prompt, MCP gives the model tools it calls itself. How they differ, what each costs and how to combine them.
- Claude Desktop or Claude Code: What Is the Difference and Which to PickThe desktop app and the console agent share one engine but sign in differently. We compare scenarios, model access and cost.
- Function calling or MCP: what is the difference and what to chooseThese are not two rival methods but two levels of the same task. Who describes a tool, who runs it, and when you need MCP.
- Claude Code locally: what actually works with a local modelClaude Code can run on a model that lives on your own computer. We cover the setup, how it differs from cloud models, and when you should count dollars instead of hardware.