DEV Community

Cover image for Claude Code, Codex and OpenCode on One Model: Pass Rate, Cost and Setup
AIHubMix
AIHubMix

Posted on Edited on

Claude Code, Codex and OpenCode on One Model: Pass Rate, Cost and Setup

If you keep the model fixed and swap the agent around it, does the result change? In a small, informal AIHubMix test on December 2, 2026, Claude Sonnet 5.5 passed the same coding task in Claude Code, Codex and OpenCode, three runs out of three in each. Cost and time per run did change: $0.051 per run in Claude Code, $0.058 in OpenCode and $0.100 in Codex. Larger published studies report the same pattern, with success rates a few points apart across harnesses and one model's cost up to about 5x apart.

Before any task runs, the three agents already differ in which models they accept, which API protocol they speak and how they bill.

The three agents at a glance

Claude Code Codex OpenCode
Maker Anthropic OpenAI Anomaly
License Closed source CLI: Apache-2.0 MIT
Models Claude only OpenAI by default Any provider
Custom endpoint Anthropic Messages Responses API only Chat Completions, Responses, Messages
Paid plan Claude Pro from $20 a month CLI from ChatGPT Plus, $20 a month Free; optional Go plan, $10 a month

Prices are from each vendor's pricing page on December 2, 2026.

  • Claude Code includes subagents, skills, hooks, plugins, MCP and a headless mode; the Agent SDK is a separate package. Anthropic's docs say it doesn't support routing to non-Claude models.
  • Codex ships three sandbox modes (read-only, workspace-write and danger-full-access), and its default model is GPT-6.2 Sol. ChatGPT Free and Go include Codex only in the desktop app, with GPT-6 Luna; the CLI and IDE extension start at Plus.
  • OpenCode comes from Anomaly, the team formerly behind SST, and is at version 2.4.3 (npm package @opencode/cli; opencode-ai is the 1.x package). Besides API keys, it accepts a ChatGPT Plus or Pro sign-in.

How the AIHubMix test was set up

The test was small and informal. Each agent had to implement two functions in a small Python repository: parsing and formatting duration strings such as "1h30m". A run passed if the agent left the test files untouched and both the 6 visible tests and 12 hidden tests passed. The hidden tests were added only after the agent finished.

  • Models: Claude Sonnet 5.5 (claude-sonnet-5-5) ran in Claude Code, Codex and OpenCode. GPT-6.2 Sol (gpt-6.2-sol) ran in Codex and OpenCode only, since Anthropic doesn't support Claude Code with non-Claude models.
  • Runs: three per combination, each time in a new copy of the repository, on December 2, 2026.
  • Settings: reasoning effort set to high in each agent, models served by AIHubMix.
  • Versions: Claude Code 2.1.333, Codex 0.172.0, OpenCode 2.4.3.
  • Cost: estimated from the token counts each agent reported, at the official list prices on the Anthropic and OpenAI pricing pages, which AIHubMix matches. For both models that is $2 input, $10 output, $0.10 cache read and $2.50 cache write per million tokens. The figures are estimates, not a bill.

The task and scripts are not published. Every run passed, so cost per run is also cost per completed task.

Results: all 15 runs passed, cost and time differed

Model Agent Passed Mean cost per run Median time per run
Claude Sonnet 5.5 Claude Code 3 of 3 $0.051 17.5 s
Claude Sonnet 5.5 OpenCode 3 of 3 $0.058 26.5 s
Claude Sonnet 5.5 Codex 3 of 3 $0.100 31.8 s
GPT-6.2 Sol OpenCode 3 of 3 $0.084 88.1 s
GPT-6.2 Sol Codex 3 of 3 $0.101 112.1 s

In this set of runs:

  • Accuracy didn't separate the agents on this task, since every run passed.
  • Sonnet 5.5 cost about twice as much per run in Codex as in Claude Code. Codex runs averaged about 22,000 cached input tokens per run against about 44,000 in Claude Code, which suggests more input was billed at the full rate. Sonnet reached Codex through the Responses API, so the route may account for part of the gap.
  • The Codex runs with Sonnet reported no reasoning tokens, so the high effort setting may not have reached the model on that route.
  • With GPT-6.2 Sol, OpenCode finished faster than Codex in all three runs (median 88.1 against 112.1 seconds). Its mean cost was also lower ($0.084 against $0.101), though one $0.123 Codex run accounts for most of that gap.
  • In Claude Code, the first run also paid to write the cache: $0.069, against about $0.04 for the next two.

One small task with three runs per combination can't show an accuracy gap of a few points. Codex and all GPT-6.2 Sol runs reported zero cache-write tokens, so those costs may be understated. No open model was tested.

What larger studies report

HarnessTax, a September 2026 study by UC Berkeley and Arena, ran 7 models in Claude Code, Codex CLI and Pi on 30 SWE-bench Lite tasks and 30 Terminal-Bench 2.0 tasks, three runs per task. The harness moved success rates by about 2 points on average on SWE-bench Lite and about 5 points on Terminal-Bench. On SWE-bench Lite, Claude Code cost about twice as much as Pi; on Terminal-Bench, about 1.5 times. One model's cost varied by up to about 5x across harnesses. In 12 comparisons the model maker's own harness placed first 3 times; with three harnesses, chance alone would give about 4 (computed here, not stated by the study).

A June 2026 survey of the Terminal-Bench 2.0 leaderboard found a median gap of 13.6 points between a model's best and worst harness, across 20 models with at least three results. Those rows come from different teams with different settings. The benchmark's maintainers found in Benchmarks as Software that longer time limits closed most of a gap of about 20 points between Codex and Terminus 2 on GPT-5.4. Anthropic measured a 6-point swing from container resources alone in its write-up on infrastructure noise, which adds that "leaderboard differences below 3 percentage points deserve skepticism until the eval configuration is documented and matched."

After Terminal-Bench 2.1 fixed 28 broken tasks, Claude Code with Opus 4.6 rose from 58.0% to 70.1% in Snorkel's reruns.

On the Terminal-Bench 2.1 leaderboard, five models have results both in their vendor's agent and in Terminus 2, the benchmark team's neutral agent:

Model Vendor agent Vendor agent pass rate (%) Terminus 2 pass rate (%) Difference (points)
Claude Fable 5 Claude Code 83.8 80.5 +3.3
GPT-5.5 Codex CLI 83.2 78.0 +5.2
Claude Opus 4.7 Claude Code 68.9 66.1 +2.8
Gemini 3.1 Pro Gemini CLI 65.8 65.6 +0.2
Gemini 3 Pro Gemini CLI 65.8 73.9 -8.1

Each pair comes from separate submissions, and the Claude Fable 5 pair ran at different effort levels. Values are from the archived Terminal-Bench 2.1 board via Snorkel, read December 2, 2026.

In Snorkel's own reruns of agent and model pairs, the gaps were wider, up to 29.2 points for GPT-5.4 mini in Codex over Terminus 2; the maintainers traced most of the Codex gaps to time limits. For OpenCode, the published data is thin: on the Terminal-Bench 2.0 leaderboard, Claude Opus 4.5 scored 52.1% in Claude Code and 51.7% in OpenCode (November 2025).

What changes when a model runs in another vendor's agent

  • Edit format. Cursor's engineering blog notes that OpenAI's models are trained to edit files with a patch format and Anthropic's with string replacement. Codex is built around the patch format.
  • Reasoning settings. LangChain kept gpt-5.2-codex fixed on Terminal-Bench 2.0 and scored 53.9% at xhigh effort throughout, mostly lost to timeouts, against 63.6% at high. In the AIHubMix test, the Codex runs with Sonnet reported no reasoning tokens.
  • Cost. In the AIHubMix test, Sonnet 5.5 reached Codex through the Responses API and cost $0.100 per run there, against $0.051 in Claude Code.

What carries over when you switch

Item Claude Code Codex OpenCode
Instructions CLAUDE.md, AGENTS.md AGENTS.md AGENTS.md
MCP servers .mcp.json config.toml opencode.json
Hooks settings.json config.toml Via plugins
Protocol Anthropic Responses All three
Plan sign-in Claude ChatGPT ChatGPT

"All three" means Anthropic Messages, the Responses API and Chat Completions. Claude Code reads AGENTS.md from version 2.1.277; when a directory has both files, it reads only CLAUDE.md. OpenCode reads CLAUDE.md in directories without an AGENTS.md. OpenCode's ChatGPT sign-in takes Plus or Pro, and it can use a Claude plan only through its Claude Agent provider, which runs Claude Code on the machine.

In practice:

  • Instructions written in AGENTS.md are read by all three, subject to the Claude Code rules above.
  • MCP servers and hooks have to be configured again in each tool's format.
  • With a gateway key, Claude Code bills per token instead of drawing on a Claude plan.

Connecting each agent to one AIHubMix key

AIHubMix serves Anthropic Messages, the Responses API and Chat Completions on one key. The snippets below read the key from AIHUBMIX_API_KEY. During the test, the prompt in each verification command returned OK in all five combinations.

Claude Code

Following the AIHubMix Claude Code guide:

export ANTHROPIC_BASE_URL="https://aihubmix.com"
export ANTHROPIC_AUTH_TOKEN="$AIHUBMIX_API_KEY"
claude -p "Reply with exactly the two letters OK and nothing else. Do not use any tools." --model claude-sonnet-5-5
Enter fullscreen mode Exit fullscreen mode

Expected output: OK

Common failures:

  • A base URL ending in /v1. The Anthropic protocol has no /v1; Claude Code adds the path itself.
  • An env block in ~/.claude/settings.json, which overrides shell variables.

Codex

In ~/.codex/config.toml, following the AIHubMix Codex guide:

model = "gpt-6.2-sol"
model_provider = "aihubmix"
model_reasoning_effort = "high"

[model_providers.aihubmix]
name = "AIHubMix"
base_url = "https://aihubmix.com/v1"
wire_api = "responses"
env_key = "AIHUBMIX_API_KEY"
Enter fullscreen mode Exit fullscreen mode

Verify:

codex exec "Reply with exactly the two letters OK and nothing else. Do not use any tools."
Enter fullscreen mode Exit fullscreen mode

Expected output: OK

Common failures:

  • wire_api = "chat", which Codex no longer supports.
  • Profile settings from older Codex versions, which can stop it from starting from version 0.134.0. The AIHubMix guide shows the current format.

OpenCode 2.x

In ~/.config/opencode/opencode.json, following OpenCode's provider docs:

{
  "$schema": "https://opencode.ai/config.json",
  "providers": {
    "aihubmix-claude": {
      "env": ["AIHUBMIX_API_KEY"],
      "canonical": "anthropic",
      "package": "@opencode/ai/providers/anthropic-compatible",
      "settings": { "baseURL": "https://aihubmix.com/v1" },
      "models": { "claude-sonnet-5-5": {} }
    },
    "aihubmix-openai": {
      "env": ["AIHUBMIX_API_KEY"],
      "canonical": "openai",
      "package": "@opencode/ai/providers/openai-compatible/responses",
      "settings": { "baseURL": "https://aihubmix.com/v1" },
      "models": { "gpt-6.2-sol": {} }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Verify:

opencode run -m aihubmix-claude/claude-sonnet-5-5#high "Reply with exactly the two letters OK and nothing else. Do not use any tools."
Enter fullscreen mode Exit fullscreen mode

Expected output: OK

#high sets the reasoning effort. canonical lets the custom provider inherit the model's settings from OpenCode's built-in catalog.

Common failure: following AIHubMix's OpenCode 1.x guide, which says its examples don't apply to version 2. Version 2 uses providers, package and settings.baseURL.

Limits of this comparison

  • The AIHubMix test is informal: one small task, three runs per combination. Its results hold for this task only, and its costs are estimates from reported tokens, not a bill.
  • Codex and all GPT-6.2 Sol runs reported zero cache-write tokens, so those costs may be understated. The Codex runs with Sonnet reported no reasoning tokens.
  • Leaderboard rows are submissions from different teams, not controlled experiments, and HarnessTax used 30 tasks per benchmark.
  • Published data on OpenCode is thin.
  • Anthropic's docs say Claude Code doesn't support non-Claude models. AIHubMix's Anthropic endpoint can serve other models, but that use is unsupported by Anthropic.
  • Prices and versions are as of December 2, 2026.

Keep reading: the coding agents series

Sources

Top comments (0)