Skip to content

Codex Setup

Codex is an AI coding assistant from OpenAI. It runs in your terminal and uses natural language prompts to read, write, and modify files on your machine. It is powered by OpenAI’s models and integrates with your local development environment.

All the steps below happen inside a terminal. If you have never used a terminal before, follow the Using the Terminal guide first, then come back here.

Codex requires Node.js 22 or later. You may already have it installed. Open your terminal and run:

node --version

If you see a version number like v22.x.x or higher, skip ahead to Step 2. If you see “command not found” or a version below 22, follow the instructions below.

Install Node.js

macOS

Visit nodejs.org and download the LTS installer for macOS. Run the .pkg file and follow the prompts.

Alternatively, if you have Homebrew installed:

brew install node
Windows

Visit nodejs.org and download the LTS installer for Windows. Run the .msi file and follow the prompts. Make sure “Add to PATH” is ticked during installation.

After installing, verify by running:

node --version

You should see a version number like v22.x.x or higher.

  1. Visit platform.openai.com and sign in or create an account.
  2. Navigate to API Keys in the dashboard.
  3. Click Create new secret key and copy the key.

Set the API key in your terminal:

Set API Key

macOS
export OPENAI_API_KEY="your-api-key-here"

To make this permanent, add the line above to your ~/.zshrc or ~/.bashrc file.

Windows
set OPENAI_API_KEY=your-api-key-here

To make this permanent, add it as a system environment variable via System Properties > Environment Variables.

Open your terminal and run:

npm install -g @openai/codex

Verify the installation:

codex --version

Navigate to your project folder and start Codex:

cd ~/my-project
codex

You are now in an interactive session. Try your first prompt:

Step 1
List all the files in this directory and describe what each one does

Codex will read your files and respond directly in the terminal.

CommandDescription
codexStart an interactive session in the current directory
codex "your prompt"Run a single prompt without entering interactive mode
codex --helpShow all available options
Ctrl+CCancel the current response
Ctrl+DExit the interactive session

Return to the Prerequisites page and continue with the guides. When you see an LLM Prompt Box, copy the prompt and paste it into your Codex session.