# GPT-5.1-Codex

The standard tier in OpenAI's GPT-5.1 codex family. GPT-5.1-Codex slots between codex mini and codex max, inheriting GPT-5.1 generation reasoning for autonomous coding workflows.

- **Model ID:** `openai/gpt-5.1-codex`
- **Type:** chat
- **Providers:** azure
- **Context window:** 400,000
- **Maximum output tokens:** 128,000
- **Pricing:** $1.25/1M input tokens, $10/1M output tokens
- **Canonical page:** https://vercel.com/ai-gateway/models/gpt-5.1-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.1-codex',
  prompt: 'Why is the sky blue?'
})
```

## About

GPT-5.1-Codex was released on November 12, 2025 as the standard tier in OpenAI's GPT-5.1 codex family on AI Gateway. It sits between the more affordable codex mini and the maximum-compute codex max, giving teams a middle-ground option that balances capability with cost.

The GPT-5.1 generation brought deeper reasoning and more reliable instruction following to the codex architecture. For GPT-5.1-Codex, that translates to better understanding of complex codebases, stronger adherence to existing coding conventions, and more accurate multi-step problem solving. The model operates in the agentic coding loop: reading repository context, planning changes, writing code, executing tests in sandboxed environments, and iterating.

With a context window of 400K tokens, GPT-5.1-Codex can process substantial repository contexts in a single pass, enabling it to understand broader architectural implications rather than operating on isolated files.

## What to consider

GPT-5.1-Codex builds on the GPT-5 codex foundation with the GPT-5.1 generation's improvements in reasoning and instruction following, translating to better code quality and more reliable autonomous task completion.

For maximum compute on the hardest coding problems, consider GPT-5.1 codex max. For routine tasks, codex mini provides faster, cheaper results.

## When to use

### Best For

- **Autonomous feature development:** Writing complete features from specifications with test verification
- **Complex debugging:** Tracing issues through large codebases and producing verified patches
- **Multi-file refactoring:** Changes that span modules and require understanding architectural patterns
- **Code migration:** Converting codebases between frameworks, languages, or API versions
- **Comprehensive test generation:** Creating thorough test suites that cover edge cases and failure modes

### Consider Alternatives When

- **Hardest coding challenges:** GPT-5.1 codex max applies maximum compute for the most demanding tasks
- **Routine coding tasks:** Codex mini handles simpler bug fixes and scaffolding more efficiently
- **General-purpose work:** GPT-5.1 instant or thinking for non-coding tasks
- **Budget constraints:** Earlier codex models at lower price points for cost-sensitive pipelines

## Best for

- **Autonomous feature development:** Writing complete features from specifications with test verification
- **Complex debugging:** Tracing issues through large codebases and producing verified patches
- **Multi-file refactoring:** Changes that span modules and require understanding architectural patterns
- **Code migration:** Converting codebases between frameworks, languages, or API versions
- **Comprehensive test generation:** Creating thorough test suites that cover edge cases and failure modes

## Consider alternatives

- **Hardest coding challenges:** GPT-5.1 codex max applies maximum compute for the most demanding tasks
- **Routine coding tasks:** Codex mini handles simpler bug fixes and scaffolding more efficiently
- **General-purpose work:** GPT-5.1 instant or thinking for non-coding tasks
- **Budget constraints:** Earlier codex models at lower price points for cost-sensitive pipelines

## Frequently asked questions

### How does GPT-5.1-Codex improve over GPT-5 codex?

It benefits from the GPT-5.1 generation's advances in reasoning and instruction following, producing better code quality and more reliable autonomous task completion.

### When should I use codex max instead?

When tackling the most complex coding challenges where maximum compute and reasoning depth are worth the additional cost, such as large-scale architectural changes or critical security audits.

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

400K tokens, enabling comprehensive codebase understanding in a single pass.

### Can GPT-5.1-Codex run tests?

Yes. It operates in sandboxed environments where it can execute code and run test suites to verify its output.

### How does AI Gateway handle authentication for GPT-5.1-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.

### 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.1-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)
