The advanced reasoning capabilities of OpenAI's latest models are now accessible directly from your terminal via the OpenAI Codex Command-Line Interface (CLI), an open-source tool. This portable coding assistant can read, modify, and run code locally on your machine, accelerating feature development, resolving issues, and aiding in understanding complex code. Unless you opt to share it, your source code never leaves your environment, as the CLI functions locally, as stated by OpenAI. In this article, I will guide you through the installation and usage of OpenAI's Codex CLI locally.
Table of Contents
- Why Codex CLI?
- Approval Modes
- Sandboxing Details
- New codex-mini-latest
- How to Access Codex CLI?
- Inference from Using Codex CLI
- Conclusion
Why Codex CLI?
Codex CLI is tailored for developers familiar with the terminal who desire ChatGPT-level reasoning coupled with the ability to run code, manage files, and iterate, while maintaining version control. Essentially, it’s chat-driven development that comprehends and executes your code. Some of its standout features include:
- No Setup Required: Just bring your OpenAI API key, and you're good to go!
- Lightweight Requirements: Node.js (v22 ) and npm (v10 ) are needed, but the setup is quick and simple.
- Full Auto Mode: Functions within a directory sandbox with network access disabled, ensuring data privacy and security.
- Multimodal Support: Input screenshots or diagrams, and Codex CLI can interpret and replicate the requirements shown in your images.
- Open Source: The tool is entirely open-source, allowing you to examine the codebase and even contribute to its development.
Please note that Codex CLI is still an ongoing experimental project. It may encounter issues, lack features, or undergo significant changes since it is not yet stable.
Also Read: How to Access and Use OpenAI Codex?
Approval Modes
Approval modes dictate the extent of access granted to the AI system (Codex CLI). Three approval modes are available, outlined below:
.responsive-table { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; } .responsive-table table { width: 100%; border-collapse: collapse; border: 1px solid #000; } .responsive-table th, .responsive-table td { border: 1px solid #000; padding: 8px; text-align: left; vertical-align: top; } .responsive-table th { background-color: #f4f4f4; } @media (max-width: 768px) { .responsive-table th, .responsive-table td { padding: 12px; } }
Mode | What the Agent Can Do | When to Use |
---|---|---|
Suggest (default) | Read files. Proposes edits & shell commands, but requires your approval before making changes or executing commands. | Safe exploration, code reviews, learning a codebase. |
Auto Edit | Read and write files automatically. Still asks before running shell commands. | Refactoring or repetitive edits where you want to keep an eye on side-effects. |
Full Auto | Read, write, and execute commands autonomously inside a sandboxed, network-disabled environment scoped to the current directory. | Longer tasks like fixing a broken build or prototyping features while you grab a coffee. |
Sandboxing Details
macOS 12
Codex CLI employs Apple Seatbelt (sandbox-exec) for command sandboxing.
- The majority of the filesystem is kept in a read-only jail, with a few exceptions like $PWD, $TMPDIR, and ~/.codex, which remain writable.
- By default, outbound network access is entirely blocked—even if a child process attempts to use curl, it will fail.
Linux
Sandboxing isn't enabled by default. OpenAI suggests using Docker for sandboxing.
Codex CLI operates inside a lightweight container image, with your repository mounted in the same location for read/write access. A custom iptables/ipset firewall script blocks all outgoing traffic except access to the OpenAI API. This ensures repeatable, predictable execution without requiring root access on the host. To activate this, use the run_in_container.sh script to configure the sandbox environment.
New codex-mini-latest
codex-mini-latest is a fine-tuned version of o4-mini specifically for use in Codex CLI. It boasts a context window of 200k and can produce up to 100,000 tokens. codex-mini-latest’s pricing falls between GPT-4.1 and o4-mini, and the following image shows the pricing of input, cached input, and output per million tokens.
How to Access Codex CLI?
Follow these straightforward steps to access Codex CLI:
-
Navigate to a project you’re working on. If you wish to test it with a dummy repository, consider cloning this repository to begin experimenting with Codex CLI. GitHub Repository link
Use the command “git clone http://m.miracleart.cn/link/851612d3c194dc64724360831ff04bf8” to clone this repository. Alternatively, you can use a smaller repository.
Change to the directory containing the repository. Use the command “cd
” to navigate to that directory. -
Install Codex CLI Now that we’re prepared to start accessing Codex CLI. Let’s install it. Use the command:
npm install -g @openai/codex – this command will install Codex CLI globally on your system. -
Obtain the API OpenAI offers $5 worth of codex-mini-latest API for Plus users and $50 worth of credits for Pro users. Redeem this by using the command:
codex — login
This will prompt you to log in or enter an API key.
Sign in with Codex CLI using ChatGPT
-
Successful Redemption MessageAfter successfully signing in to Codex CLI, you should see a successful redemption message in your terminal as well as your OpenAI dashboard.
-
Verify Codex CLI Access in TerminalStart accessing Codex CLI:
-
Scan your repositoryAfter 3 entire minutes of scanning the repository, it provided a comprehensive response about the repository.
-
Make changes in the repoLet’s now ask Codex CLI to make some changes.
Prompt: “Enhance the chainlit application app.py, this has the persona of warren buffet:
1. Add search tools
2. Improve the code quality, 3. Enhance the chainlit application”
Output:
After running the Codex CLI for approximately 15 minutes, and after reviewing and approving the changes made by the agent, the execution concluded.
These are some screenshots during the Codex CLI agent execution.
Also Read:
The above is the detailed content of How to Install and Use OpenAI Codex CLI Locally?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Google’s NotebookLM is a smart AI note-taking tool powered by Gemini 2.5, which excels at summarizing documents. However, it still has limitations in tool use, like source caps, cloud dependence, and the recent “Discover” feature

Here are ten compelling trends reshaping the enterprise AI landscape.Rising Financial Commitment to LLMsOrganizations are significantly increasing their investments in LLMs, with 72% expecting their spending to rise this year. Currently, nearly 40% a

Investing is booming, but capital alone isn’t enough. With valuations rising and distinctiveness fading, investors in AI-focused venture funds must make a key decision: Buy, build, or partner to gain an edge? Here’s how to evaluate each option—and pr

Disclosure: My company, Tirias Research, has consulted for IBM, Nvidia, and other companies mentioned in this article.Growth driversThe surge in generative AI adoption was more dramatic than even the most optimistic projections could predict. Then, a

Those days are numbered, thanks to AI. Search traffic for businesses like travel site Kayak and edtech company Chegg is declining, partly because 60% of searches on sites like Google aren’t resulting in users clicking any links, according to one stud

The gap between widespread adoption and emotional preparedness reveals something essential about how humans are engaging with their growing array of digital companions. We are entering a phase of coexistence where algorithms weave into our daily live

Let’s talk about it. This analysis of an innovative AI breakthrough is part of my ongoing Forbes column coverage on the latest in AI, including identifying and explaining various impactful AI complexities (see the link here). Heading Toward AGI And

Let’s take a closer look at what I found most significant — and how Cisco might build upon its current efforts to further realize its ambitions.(Note: Cisco is an advisory client of my firm, Moor Insights & Strategy.)Focusing On Agentic AI And Cu
