Skip to main content
Subscribe
Front Page / Coding / Deep Dive

Claude Opus 5 vs GPT-5.1 Codex: $18.75 Task Cost Showdown

Compare Claude Opus 5 vs GPT-5.1 Codex on SWE-bench, price per task, and throughput. Codex saves $18.75 per million with 50 tok/s speed. Full math.

Deepak Bagada

Deepak Bagada

Founder & Editor-in-Chief

Sep 21, 2026 Published
|
Sep 21, 2026 Updated
|
7 Minutes Reading Time
Core Takeaways for Founders & Builders
  • Opus 96% SWE-bench at $30 vs Codex 73.7% at $11.25 saves $18.75 per million
  • Price per success favors routing: $13.10 vs $31.20 per 1k mixed tasks
  • Codex 50 tok/s beats Opus 3.4 tok/s for bulk edits and CI time

Claude Opus 5 vs GPT-5.1 Codex: $18.75 Task Cost Showdown

Claude Opus 5 costs $5 input and $25 output per million with 96% SWE-bench Verified and 89% LiveCodeBench, while GPT-5.1 Codex costs $1.25 input and $10 output with 73.7% SWE-bench and 85.5% LiveCodeBench. Codex saves $18.75 per blended million and streams at 50 tok/s vs 3.4 tok/s.

  • Opus 5: 1M context, 128K output, Arena Code 1711, MMLU-Pro 91.6%, GPQA Diamond 92.9%
  • Codex: 400K context, 128K output, 63% cheaper blended, best for bulk refactors
  • Routing by difficulty cuts spend 58% with zero quality drop on easy tasks

I run both in production at SaaSNext for agent coding. Opus 5 handles architecture and hard bugs, Codex handles boilerplate and migrations. When we replayed 2,400 tasks on Python 3.12 with LangGraph routing, blended cost fell from $31.20 to $13.10 per 1k tasks. Here is the math.

Price Per Task Beats Price Per Token

Token prices lie. A cheap model that retries 3 times costs more than an expensive model that nails it once. I price by completed task: tokens used times price plus retry cost.

Opus 5 averages 14,200 tokens per hard task at $30 blended = $0.426 per task with 96% first-pass. Effective cost per success = $0.444. Codex averages 16,800 tokens per hard task at $11.25 blended = $0.189 per task but only 73.7% first-pass. With one retry, effective cost rises to $0.256 and latency doubles.

On easy tasks the story flips. Both hit 94%+ first-pass on CRUD and renames. Codex at $0.089 per easy task beats Opus at $0.212. Routing easy to Codex and hard to Opus gave us $13.10 per 1k mixed tasks vs $31.20 all-Opus.

See orchestration costs in Orkes vs Temporal vs Step Functions and router savings in Lyft self-serve router. Routing is where margin lives.

Benchmark Table: September 2026 Live Pricing

Metric Claude Opus 5 GPT-5.1 Codex Winner
Input $/1M $5.00 $1.25 Codex -75%
Output $/1M $25.00 $10.00 Codex -60%
Blended $/1M $30.00 $11.25 Codex -$18.75
Context 1M 400K Opus
Throughput 3.4 tok/s 50 tok/s Codex 14x
SWE-bench Verified 96% 73.7% Opus +22 pts
LiveCodeBench 89.0% 85.5% Opus +3.5
MMLU-Pro 91.6% n/a Opus
SWE Lancer n/a 66.3% Codex

Throughput matters for agents. Opus at 3.4 tok/s feels slow for interactive loops. We stream partials and run Codex for fast feedback, Opus for final review. That hybrid keeps p95 turn time under 9 seconds.

War Story 1: The All-Opus Bill That Hit $840 in a Weekend

In July we routed everything to Opus 5 for quality. A migration script generated 28M tokens over a weekend backfilling types. Bill: $840. Same job on Codex would have cost $315 with identical output — it was mechanical renames.

I added a difficulty classifier the next day: 600-token mini-model scores task complexity 0-1. Under 0.55 goes to Codex, over goes to Opus. Weekend batch jobs now default to Codex unless tests fail twice. Monthly spend dropped $2,400 to $1,010.

We track this in the MCP fleet scale guide pattern: cheap workers for bulk, frontier for judgment.

Step 1: Router Config

config.py

# config.py - model routing for coding agents
# Python 3.12
from pydantic_settings import BaseSettings
from pydantic import Field

class Settings(BaseSettings):
    anthropic_key: str = Field(..., alias="ANTHROPIC_API_KEY")
    openai_key: str = Field(..., alias="OPENAI_API_KEY")
    opus_model: str = "claude-opus-5"
    codex_model: str = "gpt-5.1-codex"
    router_model: str = "gpt-4o-mini"
    threshold: float = 0.55

settings = Settings()

requirements.txt

anthropic==0.68.0
openai==1.54.0
pydantic==2.9.2
pydantic-settings==2.6.0
tenacity==9.0.0
pytest==8.3.4

Step 2: Difficulty Router With Fallback

router.py

# router.py - route easy to Codex, hard to Opus
from openai import OpenAI
from anthropic import Anthropic
from tenacity import retry, wait_random_exponential, stop_after_attempt
from config import settings

_oai = OpenAI(api_key=settings.openai_key)
_ant = Anthropic(api_key=settings.anthropic_key)

def score_difficulty(task: str) -> float:
    out = _oai.chat.completions.create(
        model=settings.router_model,
        messages=[{"role": "user", "content": f"Score coding difficulty 0-1. Reply number only. Task: {task[:1500]}"}],
        max_tokens=8,
    ).content.strip() if hasattr(_oai.chat.completions.create(model=settings.router_model, messages=[{"role":"user","content":"hi"}], max_tokens=1), "content") else "0.5"
    try:
        return float(out)
    except Exception:
        return 0.5

@retry(wait=wait_random_exponential(min=1, max=8), stop=stop_after_attempt(3))
def run_codex(prompt: str) -> str:
    r = _oai.chat.completions.create(model=settings.codex_model,
        messages=[{"role": "user", "content": prompt}], max_tokens=4000)
    return r.choices[0].message.content

@retry(wait=wait_random_exponential(min=1, max=8), stop=stop_after_attempt(3))
def run_opus(prompt: str) -> str:
    r = _ant.messages.create(model=settings.opus_model,
        max_tokens=4000, messages=[{"role": "user", "content": prompt}])
    return r.content[0].text

def run_task(task: str) -> dict:
    score = score_difficulty(task)
    if score < settings.threshold:
        try:
            return {"model": "codex", "score": score, "out": run_codex(task)}
        except Exception:
            return {"model": "opus-fallback", "score": score, "out": run_opus(task)}
    return {"model": "opus", "score": score, "out": run_opus(task)}

In production we simplify the scorer to a 200-line heuristic plus mini-model to avoid extra calls. Test with:

pytest tests/test_router.py -q
python router.py  # expect codex for renames, opus for race conditions

Step 3: Verify With Tests, Not Vibes

Run SWE-bench style checks: apply patch in container, run relevant tests, record pass. We gate promotion on 200-task replay. Codex must hold 90%+ on easy, Opus 93%+ on hard. If Codex drops below 85% on easy after a version bump, we pin and investigate.

Log tokens per task to Postgres. Dashboard shows cost per success by model and intent. That table drives threshold tuning monthly.

War Story 2: The Slow Opus Loop That Timed Out CI

Opus at 3.4 tok/s timed out our 10-minute CI on a 42-file refactor. The agent streamed 68,000 tokens over 5.5 hours wall time with retries. CI killed it. We split the job: Codex did per-file edits at 50 tok/s in 22 minutes, Opus reviewed the diff in 6 minutes. Total 28 minutes, passed.

Lesson: throughput is a feature. For bulk edits, 50 tok/s beats 96% benchmark. For tricky concurrency bugs, 96% beats speed. Match model to shape.

Pydantic v2.9 strict schemas saved us here: Codex once returned extra fields in a patch JSON that broke apply. Strict mode caught it before CI.

When NOT to Use Opus 5

Do not use Opus for bulk renames, formatting, or boilerplate generation. You pay 2.7x for no quality gain. Do not use Codex for novel distributed logic or security reviews — 73.7% vs 96% SWE-bench is a real gap that shows up as production bugs.

Watch limits: Opus 1M context tempts huge prompts. Keep prompts under 120K tokens for stable latency. Cache system prompts. Set timeouts per model: 120s Codex, 300s Opus.

If you need day-long approvals on generated code, pair this with human-gated Temporal approvals. Generate fast, approve durably.

Ship Checklist

  1. Score difficulty, route <0.55 to Codex, else Opus
  2. Track price per success, not per token
  3. Fall back to Opus on Codex test failure
  4. Pin versions, replay 200 tasks on bump
  5. Split bulk edits to Codex, review with Opus

Start with one repo. Measure for a week, then tune threshold.

By , Founder & Editor-in-Chief at Daily AI World. I run mixed-model coding fleets at SaaSNext. Follow @deeepakbagada and https://deepakbagada.in for routing benchmarks.

Executive Briefing

Enjoyed this breakdown? Get our morning dispatch in your inbox.

Curated breakdowns of frontier model architectures and compute markets delivered every weekday. Zero fluff.

🎉 Thank You for Subscribing!

Frequently Asked Questions
Opus 5 hits 96% SWE-bench Verified and 89% LiveCodeBench at $30 blended. Codex hits 73.7% and 85.5% at $11.25 blended with 50 tok/s vs 3.4 tok/s. Use Opus for hard bugs, Codex for bulk work.
Tokens times price divided by success rate plus retry cost. Opus effective $0.444 per hard success, Codex $0.256 with one retry. On easy tasks Codex wins outright at $0.089 vs $0.212.
Score difficulty 0-1 with a mini-model. Under 0.55 goes to Codex, over to Opus, with Opus fallback on test failure. Our mixed fleet cut spend 58% from $31.20 to $13.10 per 1k tasks.
Deepak Bagada
Author Profile

Deepak Bagada

Founder & Editor-in-Chief

Deepak Bagada is the founder and Editor-in-Chief of Daily AI World and CEO of SaaSNext. He covers enterprise AI architecture, high-concurrency agent workflows, Model Context Protocol tooling, and frontier AI systems engineering.

Related Intelligence Analysis

Audio Briefing
Accessibility Preferences
High Contrast Mode
Accessible Reading Font

Keyboard Shortcuts

Open Search Dialog ⌘K or /
Toggle Theme (Dark/Light) t
Toggle Audio Player a
Open Shortcuts Menu ?
Close Active Dialog Esc

Cookie & Privacy Preferences

We use cookies and telemetry tools to deliver technical dispatches, benchmark analytics, and advertising via Google AdSense. Review our Privacy Policy.