How to start with OpenAI Codex CLI: install, sign in and run your first task
Install OpenAI Codex CLI on macOS, Linux or Windows, sign in with ChatGPT or an API key, and give Codex its first task in your project.
Codex CLI is OpenAI’s coding agent that runs locally on your computer [3]. It can inspect files in your repository, make edits and run the tools already installed on your machine [1]. This guide follows the official getting-started steps: install, sign in and run a first task [1].
Step 1: Install
On macOS or Linux, use the standalone installer [1]:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
On Windows, run this from a new PowerShell window [1]:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
You can also install with npm or Homebrew [1]:
npm install -g @openai/codex
brew install --cask codex
To update later, run the same installer command again, or npm install -g @openai/codex for npm, or brew upgrade --cask codex for Homebrew [1].
Step 2: Sign in
Open a project folder and run codex [1]:
codex
The first time, choose Sign in with ChatGPT or another sign-in method [1]. Signing in with ChatGPT gives subscription access, and the sign-in opens a browser window that returns your credentials to Codex [2]. OpenAI recommends this route to use Codex as part of a Plus, Pro, Business, Edu or Enterprise plan [3]. You can also run codex login to start the same browser sign-in [2].
If you prefer usage-based billing, sign in with an API key from the OpenAI dashboard by piping it to codex login [2]:
printenv OPENAI_API_KEY | codex login --with-api-key
Step 3: Your first task
Describe what you want in plain language, for example ask Codex to explain the project [1]:
Tell me about this project
You can also ask for a focused change or for help debugging an issue [1]. OpenAI suggests making Git checkpoints before and after a task so you can revert changes [1].
Useful next commands
Sources
Written and checked by AI from the sources below
Fact-checked by gpt-6.1-sol on · Editorial policy