# GPT-5-Codex

A GPT-5-class coding agent model built for autonomous software engineering, combining GPT-5-class reasoning with the ability to read, write, execute, and verify code in sandboxed cloud environments.

- **Model ID:** `openai/gpt-5-codex`
- **Type:** chat
- **Providers:** azure
- **Context window:** 400,000
- **Maximum output tokens:** 128,000
- **Pricing:** $1.25/1M input tokens, $10.0/1M output tokens
- **Canonical page:** https://vercel.com/ai-gateway/models/gpt-5-codex

## Supported parameters

Detailed capability metadata has not been reported for this model.

## Example

```ts
import { streamText } from 'ai'

const result = streamText({
  model: 'openai/gpt-5-codex',
  prompt: 'Why is the sky blue?'
})
```

## About

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

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.

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.

## When to use

### 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

## 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

- **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

## Frequently asked questions

### How does GPT-5-Codex differ from codex-mini?

GPT-5-Codex brings GPT-5-class reasoning to coding tasks, making it better at complex refactors, architectural decisions, and multi-file changes. Codex-mini is optimized for speed and cost on simpler tasks.

### Can GPT-5-Codex execute and test its own code?

Yes. It operates in sandboxed environments where it can run code, execute test suites, and iterate on solutions before returning verified results.

### What context window does GPT-5-Codex support?

400K tokens, enabling it to read large portions of a codebase in a single pass for comprehensive understanding.

### How does AI Gateway handle authentication for GPT-5-Codex?

AI Gateway accepts a single API key or OIDC token for all requests. You don't embed OpenAI credentials in your application; AI Gateway routes and authenticates on your behalf.

### Is GPT-5-Codex suitable for production CI pipelines?

Yes, though its higher cost means it's best reserved for complex tasks. Use codex-mini for routine per-PR checks and GPT-5-Codex for deeper architectural reviews.

### What are typical latency characteristics?

This page shows live throughput and time-to-first-token metrics measured across real AI Gateway traffic.

## Links

- [Model page](https://vercel.com/ai-gateway/models/gpt-5-codex)
- [AI Gateway documentation](https://vercel.com/docs/ai-gateway)
- [Provider model documentation](https://learn.microsoft.com/en-us/azure/ai-foundry/foundry-models/concepts/models-sold-directly-by-azure?pivots=azure-openai&tabs=global-standard-aoai%2Cstandard-chat-completions%2Cglobal-standard#gpt-5.1)
- [Provider pricing](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service)
