Back to Models

GPT-5.1 Codex is a variant of GPT-5.1 purpose-built for agentic coding in Codex β€” OpenAI's agentic coding environment spanning CLI, IDE extension, cloud sandbox, and GitHub integration. Announced alongside GPT-5.1 on November 12, 2025, it is the direct successor to GPT-5 Codex and was itself superseded by GPT-5.1-Codex-Max (November 18, 2025) as the default coding model in Codex surfaces. GPT-5.1 Codex was trained on real-world software engineering tasks: building full projects from scratch, adding features and tests, debugging, large-scale refactors, and code reviews.

From a TheRouter operator's perspective, GPT-5.1 Codex is accessible through the standard /v1/chat/completions endpoint with full OpenAI-compatible parameters (temperature, top_p, max_tokens, tools, tool_choice, response_format, reasoning_effort, stop). It shares GPT-5.1's 400K context window, 128K max output, and $1.25/M input / $10/M output pricing. The model is listed as listed:true and active:true in TheRouter's catalog. For agentic coding workflows specifically, GPT-5.1 Codex benefits from dedicated Codex toolchain support (apply_patch, shell) first introduced with GPT-5.1.

Position within the family: GPT-5.1 Codex sits between the general-purpose GPT-5.1 (best for general reasoning/coding) and GPT-5.1-Codex-Max (best for long-running tasks with compaction). The Codex family also includes GPT-5.1-Codex-Mini (faster, cheaper) and GPT-5.1-Codex-Max (the most capable, with cross-window compaction). As of May 2026, GPT-5.1 Codex has been superseded by GPT-5.1-Codex-Max as the default Codex model, but remains available via API for agents that need the original agentic coding profile without the compaction overhead of Codex-Max.

Best for
  • β€’ Agentic coding workflows in Codex β€” CLI, IDE extension, cloud, and GitHub code reviews β€” where apply_patch and shell tools are the primary interaction mode
  • β€’ Automated code review β€” GPT-5.1 Codex was specifically trained to catch critical flaws before they ship, outputting fewer incorrect or unimportant comments than GPT-5
  • β€’ Long-running autonomous coding sessions β€” tested to work independently for over 7 hours on complex tasks, iterating on implementations and fixing test failures without human intervention
  • β€’ Multi-file refactors and frontend coding β€” GPT-5.1 Codex shows significant improvements in human preference evaluations for creating mobile websites and desktop applications from screenshots or wireframes
Reach for something else if
  • β€’ General reasoning and non-coding chat β€” GPT-5.1 (the general-purpose variant) is better suited and available at the same price via TheRouter; route to openai/gpt-5.1 for those workloads
  • β€’ Long-running tasks requiring multi-window context compaction β€” GPT-5.1-Codex-Max (openai/gpt-5.1-codex-max) handles compaction natively and can work for 24+ hours with automatic context pruning
  • β€’ Maximum SWE-bench or coding benchmark scores β€” GPT-5.1-Codex-Max achieves 77.9% on SWE-bench Verified vs GPT-5.1 Codex's 73.7%; Claude Opus 4.7 and GPT-5.2 also score higher
  • β€’ Sub-second latency coding β€” for fast interactive use-cases route to GPT-5.1-Codex-Mini (openai/gpt-5.1-codex-mini) at $0.25/M in, $2/M out, or GPT-5 Mini
Context Length
400K
Max Output
128K
Input Priceper 1M tokens
$1.35/ 1M tokens
Output Priceper 1M tokens
$10.80/ 1M tokens

Modalities

textimage→text

Capabilities

Vision

Pricing Breakdown

TypeRate
Input$1.35 / 1M tokens
Output$10.80 / 1M tokens

Supported Parameters

temperaturemax_tokenstop_ptoolstool_choiceresponse_formatreasoningstop

Specifications

Release date2025-11-12openai.com β†—verified
OpenAI API model idgpt-5.1-codexopenai.com β†—verified
Model typeAgentic coding variant of GPT-5.1 β€” optimized for Codex and Codex-like harnesses with apply_patch and shell tool supportopenai.com β†—verified
Reasoning typeAdaptive β€” dynamically adjusts thinking depth; reasoning_effort supports 'none', 'low', 'medium', 'high'openai.com β†—verified
Dedicated toolingapply_patch (freeform diff-based file editing), shell (command execution in sandboxed environment)openai.com β†—verified
Successor model (as of May 2026)GPT-5.1-Codex-Max (released 2025-11-18; SWE-bench 77.9%, compaction, 24h+ runs)openai.com β†—verified
LicenseProprietary (OpenAI API terms of service)verified

Benchmarks

BenchmarkDistributionScoreSource
SWE-bench Verified
GPT-5.1 Codex at 'high' reasoning effort. Source: OpenAI GPT-5.1-Codex-Max appendix (comparison table). By comparison, GPT-5.1 general-purpose variant scores 76.3% on the same benchmark.
73.7%%openai.com β†—
SWE-Lancer IC SWE
IC (individual contributor) category. Source: OpenAI GPT-5.1-Codex-Max appendix. GPT-5.1-Codex-Max scores 79.9% on the same eval.
66.3%%openai.com β†—
Terminal-Bench 2.0
Source: OpenAI GPT-5.1-Codex-Max appendix. Measures ability to complete software engineering tasks through terminal interactions.
52.8%%openai.com β†—
Token efficiency β€” fast 10%
On the fastest 10% of Codex tasks (by model-generated tokens), GPT-5.1 Codex uses 93.7% fewer tokens than GPT-5. On the slowest 10%, it spends 2Γ— more tokens reasoning and editing. Source: OpenAI Codex upgrades announcement.
93.7% fewer tokens than GPT-5openai.com β†—

API Usage Examples

Use the global api.therouter.ai endpoint shown below for new integrations; the legacy China accelerated endpoint is retired.

cURL
curl https://api.therouter.ai/v1/chat/completions   -H "Content-Type: application/json"   -H "Authorization: Bearer $THE_ROUTER_API_KEY"   -d '{
    "model": "openai/gpt-5.1-codex",
    "messages": [
      {"role": "user", "content": "Summarize the key points from this input."}
    ]
  }'

API guide

Chat completion

GPT-5.1 Codex via TheRouter uses the same OpenAI-compatible endpoint. Just switch the base URL and model name.

cURL
curl https://api.therouter.ai/v1/chat/completions \
  -H "Authorization: Bearer $THEROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.1-codex",
    "messages": [
      {"role": "user", "content": "Refactor the authentication module to use async/await instead of callbacks"}
    ],
    "tools": [
      {"type": "function", "function": {"name": "apply_patch", "parameters": {"type": "object", "properties": {"file_path": {"type": "string"}, "diff": {"type": "string"}}}},
      {"type": "function", "function": {"name": "shell", "parameters": {"type": "object", "properties": {"command": {"type": "string"}}}}
    ],
    "reasoning_effort": "medium"
  }'

More from openai

Similar models

Cross-provider sibling models

News & changes

2025-11-18

GPT-5.1-Codex-Max released β€” supersedes GPT-5.1 Codex as default in Codex

OpenAI released GPT-5.1-Codex-Max, a new frontier agentic coding model with native compaction for multi-window context across millions of tokens. Achieves 77.9% on SWE-bench Verified and 79.9% on SWE-Lancer IC SWE. Replaces GPT-5.1 Codex as the default in all Codex surfaces. Available in CLI, IDE extension, cloud, and code review.

re-authored by TheRouteropenai.com β†—
2025-11-12

GPT-5.1 and GPT-5.1 Codex announced for developers

OpenAI released GPT-5.1 with adaptive reasoning (dynamically adjusts thinking depth) and introduced GPT-5.1 Codex optimized for agentic coding. New tools: apply_patch (freeform diff-based editing) and shell. Extended prompt caching to 24 hours. Pricing unchanged from GPT-5.

re-authored by TheRouteropenai.com β†—

Frequently asked

What is the difference between GPT-5.1 and GPT-5.1 Codex?

GPT-5.1 is the general-purpose reasoning model for all text-based and coding tasks. GPT-5.1 Codex is a specialized variant trained specifically for agentic coding in Codex β€” it excels at multi-file refactors, code review, automated patch generation, and long-running agent loops. For general code-chat or one-shot code generation, GPT-5.1 works just as well at the same price. For agentic coding with apply_patch/shell tools, use GPT-5.1 Codex.

Is GPT-5.1 Codex deprecated?

No β€” GPT-5.1 Codex remains available via the OpenAI API and through TheRouter. It has been superseded by GPT-5.1-Codex-Max as the default model in Codex surfaces (CLI, IDE, cloud), but the original GPT-5.1 Codex is still an active, listed model in TheRouter's catalog. Route to GPT-5.1-Codex-Max if you need compaction for very long contexts. Route to GPT-5.1 Codex if you want the original agentic coding profile without compaction overhead.

Can I use GPT-5.1 Codex outside of Codex?

Yes β€” GPT-5.1 Codex is accessible through the standard OpenAI /v1/chat/completions endpoint via TheRouter. It supports all standard OpenAI parameters. However, the dedicated apply_patch and shell tools are designed for the Responses API and Codex-like harnesses. For simple code generation or chat, the general GPT-5.1 model is recommended instead.

What reasoning_effort should I use with GPT-5.1 Codex?

OpenAI recommends 'none' for latency-sensitive workloads (fastest responses), 'low' or 'medium' for standard coding tasks, and 'high' when reliability and correctness matter most. The model defaults to 'none'. GPT-5.1 Codex with 'medium' effort achieves strong coding performance efficiently, and even at 'high' effort it dynamically reduces thinking on simpler tasks.

re-authored by TheRouteropenai.com β†—
Fact ledger β€” every claim on this page traces here
sourceURLretrieved
Release dateopenai.com β†—2026-05-28verified
OpenAI API model idopenai.com β†—2026-05-28verified
Model typeopenai.com β†—2026-05-28verified
Reasoning typeopenai.com β†—2026-05-28verified
Dedicated toolingopenai.com β†—2026-05-28verified
Successor model (as of May 2026)openai.com β†—2026-05-28verified
Licenseβ€”β€”verified
SWE-bench Verifiedopenai.com β†—2026-05-28verified
SWE-Lancer IC SWEopenai.com β†—2026-05-28verified
Terminal-Bench 2.0openai.com β†—2026-05-28verified
Token efficiency β€” fast 10%openai.com β†—2026-05-28verified
GPT-5.1-Codex-Max released β€” supersedes GPT-5.1 Codex as default in Codexopenai.com β†—2026-05-28verified
GPT-5.1 and GPT-5.1 Codex announced for developersopenai.com β†—2026-05-28verified
What is the difference between GPT-5.1 and GPT-5.1 Codex?openai.com β†—2026-05-28to verify
Is GPT-5.1 Codex deprecated?openai.com β†—2026-05-28to verify
Can I use GPT-5.1 Codex outside of Codex?openai.com β†—2026-05-28to verify
What reasoning_effort should I use with GPT-5.1 Codex?openai.com β†—2026-05-28to verify
Help & contact