OctoLink GEO

OpenAI Codex CLI: A Step-by-Step Installation Guide for Windows, macOS, and Linux

Author Editor
OpenAI Codex CLI: A Step-by-Step Installation Guide for Windows, macOS, and Linux

OpenAI Codex CLI is a local terminal-based AI coding assistant that streamlines code editing, patch generation, and command execution. This guide covers...

OpenAI Codex CLI AI Coding Assistant Terminal Tools Installation Guide New API Integration Windows macOS Linux

OpenAI Codex CLI is a local, terminal-based AI coding assistant developed by OpenAI to help developers edit code, generate patches, and run commands directly from the command line. As a coding proxy, it offers a suite of tools to enhance workflow efficiency while maintaining control and security.

Key features of Codex CLI include:

  • Terminal-based interactive coding assistance for code editing and patch generation.
  • Tool-driven architecture with utilities like apply_patch, shell, update_plan, and multi_tool_use for controlled repository changes.
  • Atomic patch editing via apply_patch for easy audit trails and rollbacks.
  • Sandbox policies (e.g., workspace-write, read-only) and approval modes (on-request, on-failure, never) to manage file write and network access.
  • Plan tracking with update_plan to keep progress clear with only one in-progress step.
  • Friendly, concise interactions with progress updates before critical operations.
  • Strict security constraints to avoid unintended changes, requiring user approval for sensitive actions.
  • Parallel tool execution via multi_tool_use.parallel to boost efficiency.

For Windows users:

  1. Install WSL2: Run wsl --install in PowerShell (as administrator if needed) and restart your computer.
  2. Install NVM: Use curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash to get Node Version Manager.
  3. Install Node.js: Open a new WSL window and run nvm install 22 (check OpenAI’s official site for the latest required version).
  4. Install Codex CLI: Execute npm i -g @openai/codex to install globally.
  5. Configure: Run iex (irm 'https://raw.githubusercontent.com/QuantumNous/new-api-docs/refs/heads/main/helper/codex-cli-setup.ps1') to set up the config file.
  6. Launch: Start WSL2, then run codex (or navigate to your project directory first).

For macOS users:

  1. Install Homebrew: If not present, run /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)".
  2. Install Node.js: Update Homebrew with brew update, then install Node.js using brew install node.
  3. Install Codex CLI: Run npm install -g @openai/codex (use sudo for permission issues).
  4. Configure: Execute curl -fsSL https://raw.githubusercontent.com/QuantumNous/new-api-docs/refs/heads/main/helper/codex-cli-setup.sh | bash to set up the config.
  5. Launch: Run codex directly or navigate to your project directory first.

After installation, set permissions: choose to allow direct file modifications or require manual approval. Use the /model command to select a model. Note that modifying the API endpoint routes all calls to your authorized New API access point—ensure you use a legally approved service or your own deployment.

Security reminder: Avoid untrusted API addresses or keys in production to maintain compliance and data safety.

Sources

Related reading