Codex Mini
Codex Mini is OpenAI's lightweight coding agent model optimized for fast, asynchronous software engineering tasks like writing features, fixing bugs, and running tests in sandboxed cloud environments.
import { streamText } from 'ai'
const result = streamText({ model: 'openai/codex-mini', prompt: 'Why is the sky blue?'})Playground
Try out Codex Mini 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.
About Codex Mini
Codex Mini was released on May 16, 2025 as part of OpenAI's Codex product line, which provides cloud-based coding agents that operate asynchronously on software engineering tasks. The model is optimized for the specific loop that coding agents execute: read context from a repository, reason about what changes to make, write code, execute tests, and iterate until the task is complete.
As the mini variant, Codex Mini is tuned for speed and cost efficiency rather than maximum reasoning depth. It handles the majority of everyday coding tasks, from bug fixes and feature implementations to answering questions about a codebase, at a fraction of the cost and latency of larger models. This makes it practical to deploy as a continuous assistant that processes tasks in parallel.
The model operates within sandboxed environments where it can safely execute code, run test suites, and verify its own output before returning results. This execution-verification loop is central to its design and distinguishes it from models that only generate code without validating it.
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 |
|---|
What To Consider When Choosing a Provider
- Configuration: Codex Mini is purpose-built for agent-style execution where it reads a codebase, writes code, runs tests, and iterates autonomously. It works best when given clear task specifications and access to a sandboxed environment.
- Configuration: As the mini variant, Codex Mini prioritizes speed over exhaustive reasoning. For complex architectural decisions or multi-file refactors that require deep deliberation, consider a larger model in the family.
- Zero Data Retention: AI Gateway does not currently support Zero Data Retention for this model. See the documentation for models that support ZDR.
- Authentication: AI Gateway authenticates requests using an API key or OIDC token. You do not need to manage provider credentials directly.
When to Use Codex Mini
Best For
- Autonomous bug fixes: Reads issue descriptions, locates relevant code, and produces patches with test coverage
- Feature scaffolding: Generates boilerplate, implements straightforward features, and wires up tests
- Codebase Q&A: Answers questions about repository structure, function behavior, and dependencies
- CI integration: Lightweight enough to run on every pull request for automated code suggestions
- Parallel task execution: Low cost enables running multiple coding agents simultaneously across different tasks
Consider Alternatives When
- Deep architectural reasoning needed: Larger codex models or GPT-5 provide more thorough analysis for complex refactors
- Non-coding tasks: General-purpose models like GPT-4o or GPT-4.1 are better suited for mixed workloads
- Long multi-step reasoning: Reasoning models like o3 or o4-mini handle complex logical chains more reliably
Conclusion
Codex Mini brings affordable, fast coding agent capability to developer workflows. For teams that want to automate routine engineering tasks like bug fixes, feature scaffolding, and code review without the cost of a full-size model, it provides a practical balance of speed and capability through AI Gateway.
Frequently Asked Questions
What types of coding tasks is Codex Mini best at?
It excels at well-scoped tasks: bug fixes with clear reproduction steps, feature implementations with defined requirements, test generation, and answering questions about codebases. It operates autonomously in a sandboxed environment.
How does Codex Mini differ from GPT-4.1 for coding?
Codex Mini is purpose-built for the agentic coding loop of read-write-execute-verify. GPT-4.1 is a general-purpose model with strong coding benchmarks but without the specialized agent execution architecture.
Can Codex Mini run tests and verify its own output?
Yes. It operates in sandboxed cloud environments where it can execute code, run test suites, and iterate on its solutions before returning results.
What is the context window for Codex Mini?
Codex Mini supports a context window of 200K tokens, sufficient for reading substantial portions of a codebase in a single pass.
How does AI Gateway handle authentication for Codex Mini?
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 Codex Mini suitable for production CI pipelines?
Yes. Its low cost and fast response times make it practical to run on every pull request or commit for automated code suggestions and review.
What are typical latency characteristics?
This page shows live throughput and time-to-first-token metrics measured across real AI Gateway traffic.