VOOZH about

URL: https://www.analyticsvidhya.com/blog/2025/05/codex-cli/

โ‡ฑ How to Install and Use OpenAI Codex CLI Locally?


India's Most Futuristic AI Conference Is Back โ€“ Bigger, Sharper, Bolder

  • d
  • :
  • h
  • :
  • m
  • :
  • s

Reading list

How to Install and Use OpenAIโ€™s Codex CLI Locally?

Badrinarayan M Last Updated : 29 May, 2025
6 min read

The power of OpenAIโ€™s latest reasoning models is delivered straight to your terminal with the OpenAI Codex CLI, an open-source command-line tool. It serves as a portable coding assistant that can read, edit, and execute code locally on your computer to speed up feature development, fix issues, and help you understand complex code. Your source code never leaves your environment unless you choose to share it, as the CLI operates locally, according to OpenAI. In this article, I will show you how to install and use OpenAIโ€™s Codex CLI locally.

Why Codex CLI?

Codex CLI is designed for developers who are comfortable in the terminal and want ChatGPT-level reasoning combined with the ability to run code, manage files, and iterate, all while keeping version control intact. In short, itโ€™s chat-driven development that understands and executes your code. Some of its key features are:

  • Zero Setup: No configuration required, just bring your OpenAI API key, and youโ€™re ready to go!
  • Minimal Requirements: Youโ€™ll need Node.js (v22+) and npm (v10+), but overall, the setup is quick and lightweight.
  • Full Auto Mode: Operates in a directory sandbox with the network disabled, ensuring your data remains private and secure.
  • Multimodal Support: Send in screenshots or diagrams, Codex CLI can interpret and replicate the requirements shown in your images.
  • Open Source: The tool is completely open-source, so you can explore the codebase and even contribute to its development

Please note that Codex CLI is an ongoing experimental project. It may have issues, lack features, or experience disruptive changes because it is not yet stable.

Also Read: How to Access and Use OpenAI Codex?

Approval Modes

Approval modes control the level of access granted to the AI system (Codex CLI). There are three approval modes available, each described below:

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 uses Apple Seatbelt (sandbox-exec) to sandbox commands.

  • Most of the filesystem is placed in a read-only jail, with a few exceptions such as $PWD, $TMPDIR, and ~/.codex, which remain writable.
  • By default, outbound network access is completely blockedโ€”even if a child process tries to use curl, it will fail.

Linux

Sandboxing is not enabled by default. OpenAI recommends using Docker for sandboxing.
Codex CLI runs 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 egress except access to the OpenAI API. This ensures repeatable, predictable execution without requiring root access on the host. To enable 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 has a context window of 200k, and can output a max of 100,000 tokens. codex-mini-latestโ€™s is pricing between GPT-4.1 and o4-mini, and below is the image showing the pricing of input, cached input, and output per million tokens. 

How to Access Codex CLI?

Follow these simple steps to access Codex CLI:

  1. Go to a project that you are working on

    If you would like to experiment with a dummy repository, suggesting you to clone this repository so that we can start testing out codex cli. Github Repository link

    Use the command โ€œgit clone https://github.com/Badribn0612/warren_buffet_personaโ€ to clone this repository. You can use a even smaller repository as well. 

  2. Go to the directory where the repository is present

    Use the command โ€œcd <working directory>โ€ to go to that directory.

  3. Install Codex CLI

    Now that we are set to start accessing Codex CLI. Letโ€™s install the same. Use the command:
    npm install -g @openai/codex โ€“ this command will install codex cli globally in your system. ๐Ÿ‘ install Codex cli

  4. Get the API

    OpenAI provides 5$ worth of codex-mini-latest api for Plus users and 50$ worth of credits for Pro users. In order to redeem that use the command. 

    codex โ€” login 

    This will ask you to login or use an API key.๐Ÿ‘ Get the API

  5. Now you can Signin with Codex CLI with ChatGPT

    ๐Ÿ‘ signin to codex cli with chatgpt

  6. Successful Redemption Message

    After successfully Signing in into Codex CLI, you should be able to see a successful redemption message in your terminal as well as your OpenAI dashboard. ๐Ÿ‘ successful redemption message

  7. Check if you can access Codex CLI in terminal

    Start accessing codex cli:๐Ÿ‘ access Codex CLI in terminal

  8. Scan your repository

    After 3 entire minutes of skimming and scanning the repository it gave me a comprehensive response about the repository. ๐Ÿ‘ Scan your repository

  9. Make changes in the repo

    Letโ€™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โ€๐Ÿ‘ Make changes in the repo

Output:

After running the codex cli for around 15+ min, and having gone through changes made by the agent and approving them, the execution stopped. 

๐Ÿ‘ Output 1 | Codex CLI
๐Ÿ‘ Output 2 | Codex CLI
๐Ÿ‘ Output 3 | Codex CLI

Above are some screenshots in between the Codex CLI agent execution. 

Also Read: 12 AI Code Generator Tools in 2025

Inference from Using Codex CLI

Based on my experience using the Codex CLI agent, I found that it takes a cautious and deliberate approach when making changes. It verifies each step, applies modifications only where necessary, and consistently aims to find the best possible solution. However, the process can be noticeably slower compared to making similar changes manually using tools like Cursor or Windsurf.

Of course, this is just my personal experience, your results may vary depending on the domain or tech stack youโ€™re working with. In this case, the codebase involved recently updated libraries, which Codex struggled with. (Note: Codex has a knowledge cutoff of June 1, 2024)

You might also consider experimenting with Claude Code to see how it handles your use case, and decide which tool works best for your workflow.

Also Read: Building a CodeBase Explorer with Googleโ€™s Gemini-2.0

Conclusion

Codex CLI is a powerful command-line tool that brings OpenAIโ€™s advanced reasoning capabilities directly to your local development environment. It allows developers to interact with their code, using natural language, enabling tasks like debugging, refactoring, and feature development, all while keeping sensitive data local and secure.

With built-in sandboxing, multimodal support, and minimal setup, Codex CLI is ideal for developers who prefer working in the terminal and want to maintain full control over their codebase. While it remains experimental and may be slower than other tools in certain scenarios, its careful approach to code changes and strong emphasis on privacy make it a compelling choice for integrating intelligent code assistance into your workflow.

Data science Trainee at Analytics Vidhya, specializing in ML, DL and Gen AI. Dedicated to sharing insights through articles on these subjects. Eager to learn and contribute to the field's advancements. Passionate about leveraging data to solve complex problems and drive innovation.

Login to continue reading and enjoy expert-curated content.

Free Courses

Generative AI - A Way of Life

Explore Generative AI for beginners: create text and images, use top AI tools, learn practical skills, and ethics.

Getting Started with Large Language Models

Master Large Language Models (LLMs) with this course, offering clear guidance in NLP and model training made simple.

Building LLM Applications using Prompt Engineering

This free course guides you on building LLM apps, mastering prompt engineering, and developing chatbots with enterprise data.

Improving Real World RAG Systems: Key Challenges & Practical Solutions

Explore practical solutions, advanced retrieval strategies, and agentic RAG systems to improve context, relevance, and accuracy in AI-driven applications.

Microsoft Excel: Formulas & Functions

Master MS Excel for data analysis with key formulas, functions, and LookUp tools in this comprehensive course.

Responses From Readers

Flagship Programs

GenAI Pinnacle Program| GenAI Pinnacle Plus Program| AI/ML BlackBelt Program| Agentic AI Pioneer Program

Free Courses

Generative AI| DeepSeek| OpenAI Agent SDK| LLM Applications using Prompt Engineering| DeepSeek from Scratch| Stability.AI| SSM & MAMBA| RAG Systems using LlamaIndex| Building LLMs for Code| Python| Microsoft Excel| Machine Learning| Deep Learning| Mastering Multimodal RAG| Introduction to Transformer Model| Bagging & Boosting| Loan Prediction| Time Series Forecasting| Tableau| Business Analytics| Vibe Coding in Windsurf| Model Deployment using FastAPI| Building Data Analyst AI Agent| Getting started with OpenAI o3-mini| Introduction to Transformers and Attention Mechanisms

Popular Categories

AI Agents| Generative AI| Prompt Engineering| Generative AI Application| News| Technical Guides| AI Tools| Interview Preparation| Research Papers| Success Stories| Quiz| Use Cases| Listicles

Generative AI Tools and Techniques

GANs| VAEs| Transformers| StyleGAN| Pix2Pix| Autoencoders| GPT| BERT| Word2Vec| LSTM| Attention Mechanisms| Diffusion Models| LLMs| SLMs| Encoder Decoder Models| Prompt Engineering| LangChain| LlamaIndex| RAG| Fine-tuning| LangChain AI Agent| Multimodal Models| RNNs| DCGAN| ProGAN| Text-to-Image Models| DDPM| Document Question Answering| Imagen| T5 (Text-to-Text Transfer Transformer)| Seq2seq Models| WaveNet| Attention Is All You Need (Transformer Architecture) | WindSurf| Cursor

Popular GenAI Models

Llama 4| Llama 3.1| GPT 4.5| GPT 4.1| GPT 4o| o3-mini| Sora| DeepSeek R1| DeepSeek V3| Janus Pro| Veo 2| Gemini 2.5 Pro| Gemini 2.0| Gemma 3| Claude Sonnet 3.7| Claude 3.5 Sonnet| Phi 4| Phi 3.5| Mistral Small 3.1| Mistral NeMo| Mistral-7b| Bedrock| Vertex AI| Qwen QwQ 32B| Qwen 2| Qwen 2.5 VL| Qwen Chat| Grok 3

AI Development Frameworks

n8n| LangChain| Agent SDK| A2A by Google| SmolAgents| LangGraph| CrewAI| Agno| LangFlow| AutoGen| LlamaIndex| Swarm| AutoGPT

Data Science Tools and Techniques

Python| R| SQL| Jupyter Notebooks| TensorFlow| Scikit-learn| PyTorch| Tableau| Apache Spark| Matplotlib| Seaborn| Pandas| Hadoop| Docker| Git| Keras| Apache Kafka| AWS| NLP| Random Forest| Computer Vision| Data Visualization| Data Exploration| Big Data| Common Machine Learning Algorithms| Machine Learning| Google Data Science Agent
๐Ÿ‘ Av Logo White

Continue your learning for FREE

Forgot your password?
๐Ÿ‘ Av Logo White

Enter OTP sent to

Edit

Wrong OTP.

Enter the OTP

Resend OTP

Resend OTP in 45s

๐Ÿ‘ Popup Banner
๐Ÿ‘ AI Popup Banner