How you can Set up and Use OpenAI Codex CLI Regionally?

The ability of OpenAI’s newest reasoning fashions is delivered straight to your terminal with the OpenAI Codex CLI, an open-source command-line software. It serves as a transportable coding assistant that may learn, edit, and execute code regionally in your pc to hurry up characteristic growth, repair points, and enable you to perceive advanced code. Your supply code by no means leaves your setting except you select to share it, because the CLI operates regionally, based on OpenAI. On this article, I’ll present you how one can set up and use OpenAI’s Codex CLI regionally.

Why Codex CLI?

Codex CLI is designed for builders who’re snug within the terminal and need ChatGPT-level reasoning mixed with the power to run code, handle recordsdata, and iterate, all whereas retaining model management intact. Briefly, it’s chat-driven growth that understands and executes your code. A few of its key options are:

  • Zero Setup: No configuration required, simply carry your OpenAI API key, and also you’re able to go!
  • Minimal Necessities: You’ll want Node.js (v22+) and npm (v10+), however total, the setup is fast and light-weight.
  • Full Auto Mode: Operates in a listing sandbox with the community disabled, guaranteeing your information stays personal and safe.
  • Multimodal Help: Ship in screenshots or diagrams, Codex CLI can interpret and replicate the necessities proven in your photographs.
  • Open Supply: The software is totally open-source, so you’ll be able to discover the codebase and even contribute to its growth

Please observe that Codex CLI is an ongoing experimental challenge. It could have points, lack options, or expertise disruptive modifications as a result of it isn’t but secure.

Additionally Learn: How you can Entry and Use OpenAI Codex?

Approval Modes

Approval modes management the extent of entry granted to the AI system (Codex CLI). There are three approval modes obtainable, every described beneath:

Mode What the Agent Can Do When to Use
Counsel (default) Learn recordsdata. Proposes edits & shell instructions, however requires your approval earlier than making modifications or executing instructions. Protected exploration, code critiques, studying a codebase.
Auto Edit Learn and write recordsdata mechanically. Nonetheless asks earlier than working shell instructions. Refactoring or repetitive edits the place you wish to control side-effects.
Full Auto Learn, write, and execute instructions autonomously inside a sandboxed, network-disabled setting scoped to the present listing. Longer duties like fixing a damaged construct or prototyping options when you seize a espresso.

Sandboxing Particulars

macOS 12+

Codex CLI makes use of Apple Seatbelt (sandbox-exec) to sandbox instructions.

  • Many of the filesystem is positioned in a read-only jail, with just a few exceptions resembling $PWD, $TMPDIR, and ~/.codex, which stay writable.
  • By default, outbound community entry is totally blocked—even when a toddler course of tries to make use of curl, it can fail.

Linux

Sandboxing will not be enabled by default. OpenAI recommends utilizing Docker for sandboxing.
Codex CLI runs inside a light-weight container picture, along with your repository mounted in the identical location for learn/write entry. A customized iptables/ipset firewall script blocks all egress besides entry to the OpenAI API. This ensures repeatable, predictable execution with out requiring root entry on the host. To allow this, use the run_in_container.sh script to configure the sandbox setting.

New codex-mini-latest

codex-mini-latest is a fine-tuned model of o4-mini particularly to be used in Codex CLI. It has a context window of 200k, and may output a max of 100,000 tokens. codex-mini-latest’s is pricing between GPT-4.1 and o4-mini, and beneath is the picture displaying the pricing of enter, cached enter, and output per million tokens. 

How you can Entry Codex CLI?

Observe these easy steps to entry Codex CLI:

  1. Go to a challenge that you’re engaged on

    If you want to experiment with a dummy repository, suggesting you to clone this repository in order that we will begin testing out codex cli. Github Repository hyperlink

    Use the command “git clone https://github.com/Badribn0612/warren_buffet_persona” to clone this repository. You should utilize a even smaller repository as effectively. 

  2. Go to the listing the place the repository is current

    Use the command “cd <working listing>” to go to that listing.

  3. Set up Codex CLI

    Now that we’re set to begin accessing Codex CLI. Let’s set up the identical. Use the command:
    npm set up -g @openai/codex – this command will set up codex cli globally in your system. install Codex cli

  4. Get the API

    OpenAI gives 5$ price of codex-mini-latest api for Plus customers and 50$ price of credit for Professional customers. To be able to redeem that use the command. 

    codex — login 

    This may ask you to login or use an API key.Get the API

  5. Now you’ll be able to Signin with Codex CLI with ChatGPT

    signin to codex cli with chatgpt

  6. Profitable Redemption Message

    After efficiently Signing in into Codex CLI, it is best to have the ability to see a profitable redemption message in your terminal in addition to your OpenAI dashboard. successful redemption message

  7. Verify for those who can entry Codex CLI in terminal

    Begin accessing codex cli:access Codex CLI in terminal

  8. Scan your repository

    After 3 complete minutes of skimming and scanning the repository it gave me a complete response in regards to the repository. Scan your repository

  9. Make modifications within the repo

    Let’s now ask Codex CLI to make some modifications.

    Immediate:Improve the chainlit software app.py, this has the persona of warren buffet:
    1. Add search instruments
    2. Enhance the code high quality, 3. Improve the chainlit softwareMake changes in the repo

Output:

After working the codex cli for round 15+ min, and having gone by modifications 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. 

Additionally Learn: 12 AI Code Generator Instruments in 2025

Inference from Utilizing Codex CLI

Based mostly on my expertise utilizing the Codex CLI agent, I discovered that it takes a cautious and deliberate strategy when making modifications. It verifies every step, applies modifications solely the place essential, and persistently goals to search out the very best resolution. Nonetheless, the method will be noticeably slower in comparison with making comparable modifications manually utilizing instruments like Cursor or Windsurf.

After all, that is simply my private expertise, your outcomes might differ relying on the area or tech stack you’re working with. On this case, the codebase concerned not too long ago up to date libraries, which Codex struggled with. (Word: Codex has a data cutoff of June 1, 2024)

You may also take into account experimenting with Claude Code to see the way it handles your use case, and resolve which software works finest in your workflow.

Additionally Learn: Constructing a CodeBase Explorer with Google’s Gemini-2.0

Conclusion

Codex CLI is a robust command-line software that brings OpenAI’s superior reasoning capabilities on to your native growth setting. It permits builders to work together with their code, utilizing pure language, enabling duties like debugging, refactoring, and have growth, all whereas retaining delicate information native and safe.

With built-in sandboxing, multimodal assist, and minimal setup, Codex CLI is good for builders preferring working within the terminal and wish to keep full management over their codebase. Whereas it stays experimental and could also be slower than different instruments in sure eventualities, its cautious strategy to code modifications and powerful emphasis on privateness make it a compelling alternative for integrating clever code help into your workflow.

Information science Trainee at Analytics Vidhya, specializing in ML, DL and Gen AI. Devoted to sharing insights by articles on these topics. Wanting to be taught and contribute to the sector’s developments. Enthusiastic about leveraging information to resolve advanced issues and drive innovation.

Login to proceed studying and revel in expert-curated content material.