Tuesday, June 10, 2025
HomeBig DataThe right way to Set up and Use OpenAI Codex CLI Regionally?

The right way to Set up and Use OpenAI Codex CLI Regionally?

The facility of OpenAI’s newest reasoning fashions is delivered straight to your terminal with the OpenAI Codex CLI, an open-source command-line instrument. It serves as a conveyable coding assistant that may learn, edit, and execute code domestically in your laptop to hurry up characteristic growth, repair points, and make it easier to perceive advanced code. Your supply code by no means leaves your atmosphere except you select to share it, because the CLI operates domestically, based on OpenAI. On this article, I’ll present you set up and use OpenAI’s Codex CLI domestically.

Why Codex CLI?

Codex CLI is designed for builders who’re comfy within the terminal and wish ChatGPT-level reasoning mixed with the power to run code, handle recordsdata, and iterate, all whereas conserving 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 general, the setup is fast and light-weight.
  • Full Auto Mode: Operates in a listing sandbox with the community disabled, making certain your information stays personal and safe.
  • Multimodal Help: Ship in screenshots or diagrams, Codex CLI can interpret and replicate the necessities proven in your pictures.
  • Open Supply: The instrument is totally open-source, so you possibly can discover the codebase and even contribute to its growth

Please notice that Codex CLI is an ongoing experimental venture. It might have points, lack options, or expertise disruptive adjustments as a result of it’s not but secure.

Additionally Learn: The right way to 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 out there, every described under:

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

Sandboxing Particulars

macOS 12+

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

  • A lot of the filesystem is positioned in a read-only jailwith a couple of exceptions equivalent to $PWD, $TMPDIRand ~/.codexwhich stay writable.
  • By default, outbound community entry is totally blocked—even when a baby course of tries to make use of curlit would fail.

Linux

Sandboxing just isn’t 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 atmosphere.

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 might output a max of 100,000 tokens. codex-mini-latest’s is pricing between GPT-4.1 and o4-mini, and under is the picture exhibiting the pricing of enter, cached enter, and output per million tokens.

The right way to Entry Codex CLI?

Observe these easy steps to entry Codex CLI:

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

    If you need to experiment with a dummy repository, suggesting you to clone this repository in order that we are able to 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 need to use a even smaller repository as effectively.

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

    Use the command “cd ” to go to that listing.

  3. Set up Codex CLI

    Now that we’re set to start out 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 offers 5$ price of codex-mini-latest api for Plus customers and 50$ price of credit for Professional customers. With the intention to redeem that use the command.

    codex — login

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

  5. Now you possibly can Signin with Codex CLI with ChatGPT

    signin to codex cli with chatgpt

  6. Profitable Redemption Message

    After efficiently Signing in into Codex CLI, you must be capable of see a profitable redemption message in your terminal in addition to your OpenAI dashboard. successful redemption message

  7. Examine in case you 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 concerning the repository. Scan your repository

  9. Make adjustments within the repo

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

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

Output:

After operating the codex cli for round 15+ min, and having gone by way of adjustments 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

Primarily based on my expertise utilizing the Codex CLI agent, I discovered that it takes a cautious and deliberate strategy when making adjustments. It verifies every step, applies modifications solely the place essential, and constantly goals to seek out the very best answer. Nevertheless, the method will be noticeably slower in comparison with making comparable adjustments 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 lately up to date libraries, which Codex struggled with. (Word: Codex has a information 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 instrument works greatest on your workflow.

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

Conclusion

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

With built-in sandboxing, multimodal help, and minimal setup, Codex CLI is right for builders preferring working within the terminal and need 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 adjustments and powerful emphasis on privateness make it a compelling alternative for integrating clever code help into your workflow.

Badrinarayan M

Knowledge science Trainee at Analytics Vidhya, specializing in ML, DL and Gen AI. Devoted to sharing insights by way of articles on these topics. Desirous to study and contribute to the sector’s developments. Captivated with leveraging information to resolve advanced issues and drive innovation.

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

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments