Skip to content
08Install guides · 10 min

Install Codex CLI

Codex CLI is OpenAI's coding agent for the terminal. It reads your project, runs commands and makes changes you approve.

Roman Urdu: Codex OpenAI ka terminal agent ha. ChatGPT account se login hota ha, free plan pe bhi kuch limit ke saath chal jata ha.

Cost: Included with ChatGPT plans, Free included: Free $0, Go $8/month, Plus $20/month, Pro from $100/month, Business $20/user/month billed yearly. Usage limits differ by plan. With an API key instead, you pay standard API rates (Codex pricing page, 2026-12-05).

Windows

  1. Codex runs natively on Windows with its own Windows sandbox. In PowerShell:
    $ powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
  2. Or, if you have Node.js:
    $ npm install -g @openai/codex
  3. Prefer Linux tools? Use WSL 2 (WSL 1 is no longer supported) and follow the Linux tab inside Ubuntu.
  4. Open a new terminal in your project folder and start it. Pick Sign in with ChatGPT:
    $ codex

macOS

  1. Run the official installer:
    $ curl -fsSL https://chatgpt.com/codex/install.sh | sh
  2. Or with Homebrew:
    $ brew install --cask codex
  3. Or with npm:
    $ npm install -g @openai/codex
  4. Start it in your project folder and pick Sign in with ChatGPT:
    $ codex

Linux (Ubuntu/Debian)

  1. Run the official installer (Ubuntu, Debian, Fedora, WSL 2):
    $ curl -fsSL https://chatgpt.com/codex/install.sh | sh
  2. Or with npm:
    $ npm install -g @openai/codex
  3. Start it in your project folder and pick Sign in with ChatGPT:
    $ codex
  4. No browser on this machine (a server, or a remote login)? Turn on device code login in your ChatGPT security settings first, then:
    $ codex login --device-auth

Check it worked

$ codex --version

codex-cli 0.x.x (npm had 0.174.0 on 2026-12-05)

Common errors

codex: command not found or not recognized
Open a new terminal window so it picks up the new PATH.
npm install -g fails with EACCES
Do not use sudo. Use the official installer above, or install Node with nvm/fnm (see the Node.js guide).
Login page does not come back to the terminal (remote machine or WSL)
Use codex login --device-auth after turning on device code login in ChatGPT settings.
You hit a usage limit
Each ChatGPT plan has its own limit. Wait for it to reset, upgrade, or sign in with an API key (printenv OPENAI_API_KEY | codex login --with-api-key), billed at API rates.
Codex fails inside WSL 1
WSL 1 support ended with Codex 0.115. Upgrade the distro: wsl --set-version Ubuntu 2.

Official docs

Checked against these pages on 2026-12-05. Tools change: if a step differs, the official page wins.