GPT-5-Codex
GPT-5-Codex is a GPT-5 family model specialized for autonomous software engineering, designed to operate as a coding agent that reads repositories, writes code, executes tests, and iterates on solutions in sandboxed environments.
import { streamText } from 'ai'
const result = streamText({ model: 'openai/gpt-5-codex', prompt: 'Why is the sky blue?'})Playground
Try out GPT-5-Codex by OpenAI. Usage is billed to your team at API rates. Free users (those who haven't made a payment) get $5 of credits every 30 days.
GPT-5-Codex
Providers
Route requests across multiple providers. Copy a provider slug to set your preference. Visit the docs for more info. Using a provider means you agree to their terms, listed under Legal.
| Provider |
|---|
P50 throughput on live AI Gateway traffic, in tokens per second (TPS). Visit the docs for more info.
P50 time to first token (TTFT) on live AI Gateway traffic, in milliseconds. View the docs for more info.
Direct request success rate on AI Gateway and per-provider. Visit the docs for more info.
More models by OpenAI
| Model |
|---|
About GPT-5-Codex
GPT-5-Codex launched on September 15, 2025 as the GPT-5-class entry in OpenAI's Codex product line, designed specifically for autonomous software engineering. The model combines GPT-5's advanced reasoning capabilities with specialized training for the coding agent workflow: reading repository context, planning changes, writing code, executing tests in sandboxed environments, and iterating until tasks are verified complete.
Unlike general-purpose models that also happen to be good at code, GPT-5-Codex is architecturally optimized for the agentic coding loop. It understands repository structures, respects existing coding conventions, and produces changes that integrate cleanly with the surrounding codebase. The sandboxed execution environment means it can validate its own work by running tests before returning results.
The model supports a context window of 400K tokens, enabling it to read substantial portions of a codebase in a single pass. This broad context awareness is critical for refactoring tasks and architectural changes that span multiple files and modules.
What To Consider When Choosing a Provider
- Configuration: GPT-5-Codex is built for the full coding agent loop rather than one-shot code generation. It reads repository context, plans changes, writes code, runs tests, and iterates until the task is complete.
- Configuration: It brings GPT-5-level reasoning to coding tasks, making it capable of handling complex refactors, architectural decisions, and multi-file changes that require understanding the broader codebase.
- Zero Data Retention: AI Gateway supports Zero Data Retention for this model via direct gateway requests (BYOK is not included). To configure this, check the documentation.
- Authentication: AI Gateway authenticates requests using an API key or OIDC token. You do not need to manage provider credentials directly.
When to Use GPT-5-Codex
Best for
- Autonomous code generation: Writing features from specifications with test verification
- Complex refactoring: Multi-file changes that require understanding architectural patterns
- Bug diagnosis and repair: Tracing issues through codebases and producing verified fixes
- Code review automation: Deep analysis of pull requests with actionable suggestions
- Test generation: Creating comprehensive test suites that cover edge cases
Consider alternatives when
- Simpler coding tasks: Codex mini handles routine bug fixes and feature scaffolding at lower cost
- General-purpose work: Base GPT-5 is better when coding is only part of a broader workflow
- Non-coding reasoning: The o-series reasoning models for pure mathematical or scientific reasoning
- Chat-based code help: GPT-5 chat for conversational coding assistance rather than autonomous execution
Conclusion
GPT-5-Codex combines GPT-5-level reasoning with purpose-built autonomous coding capabilities. For teams building AI-powered development tools on AI Gateway within the GPT-5 generation, it is the coding-specialized option.