opencode or Claude Code: two terminal agents and how they differ
Both read your project, edit files and run commands in the terminal. We compare how they connect to models, where settings live, how agents and MCP work, and what it costs.
5 min · · агенты · сравнение
If you are choosing between opencode and Claude Code, at first glance both do the same thing: read the project, edit files, run commands, all in the terminal. The differences start in the details: which models you can plug in, where settings live, how agents and MCP are set up, and how many tokens get spent. Below is the opencode vs Claude Code comparison on those points, with configurations for working through the Zukko gateway. Information about the tools comes from their official documentation; it changes, so check the current version before setting up.
A short note on each
Claude Code is a terminal agent from Anthropic. It is built for Claude models and speaks the Anthropic format. Anthropic's documentation states that pointing Claude Code at models from other families through gateways is not supported, so use Claude models inside it.
opencode is an open-source terminal agent built on the AI SDK: according to its documentation it supports more than 75 providers, including any OpenAI-compatible API. You can change the model and provider within one program.
Table of differences
| Claude Code | opencode | |
|---|---|---|
| Models | Claude | Any via providers, including OpenAI-compatible ones |
| Connecting to a gateway | environment variables | the opencode.json file and the /connect command |
| Project instructions file | CLAUDE.md | AGENTS.md (also reads CLAUDE.md if there is no AGENTS.md) |
| Creating the instructions file | by hand or with the /init command | the /init command |
| Agents | subagents in .claude/agents/ | primary agents Build and Plan (switch with Tab) plus subagents |
| MCP | claude mcp add or .mcp.json | mcp section in opencode.json, local and remote servers |
| Hooks | yes (PreToolUse and other events) | a different mechanism: plugins |
Connecting to the gateway
Claude Code
Claude Code reads the address and key from environment variables:
export ANTHROPIC_BASE_URL=https://api.zukko.pro
export ANTHROPIC_AUTH_TOKEN=fetch_your_key
export ANTHROPIC_MODEL=claude-sonnet-5-5
claudeThe address here is without /v1: Claude Code adds the path itself. The variable is specifically ANTHROPIC_AUTH_TOKEN. Full instructions are in the Claude Code documentation.
opencode
In opencode, setup goes through opencode.json in the project root (or the global ~/.config/opencode/opencode.json). For Claude models you can override the address of the built-in anthropic provider and take the key from an environment variable:
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-5-5",
"provider": {
"anthropic": {
"options": {
"baseURL": "https://api.zukko.pro/v1",
"apiKey": "{env:ZUKKO_API_KEY}"
},
"models": {
"claude-sonnet-5-5": {}
}
}
}
}Here the address is with /v1: opencode's anthropic provider works through the AI SDK, and without /v1 requests go to the wrong path and return 404. For GPT, DeepSeek or GLM you add a separate provider on @ai-sdk/openai-compatible with baseURL https://api.zukko.pro/v1 and a list of models; the format example is in the opencode docs, Custom provider section. More in the opencode guide and in the article on connecting opencode.
Project instructions and agents
Both have a rules file for the project that enters the context: CLAUDE.md in Claude Code, AGENTS.md in opencode. If a project has only CLAUDE.md, opencode will read it too according to its documentation, so moving between tools does not require rewriting rules. Keep it short: build and test commands, structure, team conventions.
Agents are organized differently. opencode has two built-in primary agents: Build with the full toolset and Plan, where file edits and shell commands require confirmation by default; you switch between them with Tab. Subagents are defined separately and can be invoked with @, and you can define your own agents in opencode.json or markdown files. In Claude Code, subagents are described by files in .claude/agents/ and are invoked by the model itself based on the description. A practical takeaway: if you want different models for different roles (a cheap one for survey, a strong one for edits), in opencode this is set in the agent config through the model field.
MCP
Both connect MCP servers, but differently. In Claude Code it is a command like claude mcp add --transport http <name> <url> for a remote server or an entry in .mcp.json. In opencode a server is described in the mcp section with "type": "local" and a launch command, or "type": "remote" and an address. Keep in mind that every connected server adds tool descriptions to the context, so enable only the ones you need.
What it costs through the gateway
Per-token billing does not depend on the tool, but it does depend on cache. For Claude, the cache discount comes from the Anthropic format (/v1/messages): the gateway sees how much input came from cache. In Claude Code this works by default. In opencode with the anthropic provider, requests also go in the Anthropic format; if you call Claude through an OpenAI-compatible provider, all input is billed at the input price. After the first session check under "Usage" in the dashboard whether tokens landed in cache reads.
An illustration with hypothetical numbers (not a measurement): a session on claude-sonnet-5-5 with 0.5M fresh input, 5M cache reads, 0.4M cache writes and 0.2M output. claude-sonnet-5-5 prices as of October 18, 2026, $ per 1M tokens: input 0.4, cache read 0.05, cache write 0.5, output 2.
- With cache: 0.5 x 0.4 + 5 x 0.05 + 0.4 x 0.5 + 0.2 x 2 = 0.20 + 0.25 + 0.20 + 0.40 = $1.05
- If all input is billed at the input price: (0.5 + 5 + 0.4) x 0.4 + 0.2 x 2 = 2.36 + 0.40 = $2.76
Real numbers depend on project size and step count. For estimating a session step by step see the agent session cost calculation.
What to choose
- Claude only and minimal setup: Claude Code. Three environment variables and it works.
- Different models for different roles, including GPT, DeepSeek, GLM: opencode.
- Your team already writes
CLAUDE.md: either fits, since opencode reads it when there is noAGENTS.md. - You need hooks on tool events: look at Claude Code, but check opencode's plugins.
The best way to decide is a day of work with each on a real task. You can create a key in the dashboard: one key works in both tools.
FAQ
Can I use one Zukko key in both tools?
Yes. Only the setup method changes: environment variables for Claude Code and opencode.json for opencode. The balance is shared.
Does opencode read Claude Code files?
According to opencode's documentation, if a project has no AGENTS.md it uses CLAUDE.md, and it also supports the .claude directory for skills. It can be turned off with an environment variable; check the details in opencode's docs.
Which one is cheaper?
The tool itself costs you nothing; you spend tokens. Spend depends on the model, context size and whether input hits the cache. Compare in the "Usage" section on the same task.
Why does opencode give a 404?
Most often because of the address. For opencode's anthropic provider you need https://api.zukko.pro/v1, while for Claude Code it is https://api.zukko.pro without /v1.
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.
- opencode or Codex CLI: which terminal agent to chooseBoth 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.
- 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.