YouTip LogoYouTip

Codex Install

Codex Installation and Usage |

\n\n

Codex can be used in multiple ways. Depending on developers’ preferences, there are roughly five installation methods:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Installation MethodUsage ScenarioRecommendation
Codex AppDownload and use the Codex app directly⭐⭐⭐⭐
Codex CLIUse in terminal⭐⭐⭐⭐⭐
IDE PluginUse in VS Code / Cursor⭐⭐⭐⭐
Homebrew InstallationMac users⭐⭐⭐⭐
GitHub Release BinaryManual installation⭐⭐⭐
\n\n

Image 1

\n\n

The following sections introduce each method in detail.

\n\n
\n\n

1. Codex App

\n\n

The simplest way is to directly use the Codex app, which requires a good network connection.

\n\n

Visit: https://chatgpt.com/codex

\n\n

Download the app:

\n\n

Image 2

\n\n

Log in with your ChatGPT account to start using it.

\n\n

Interface overview:

\n\n

Image 3

\n\n

Then, enter your request in the input box:

\n\n

Image 4

\n\n
\n

If you encounter issues accessing or using Codex, similar products in China include Alibaba’s Qwen Quest and ByteDance’s Trae Solo.

\n


AI Development Environment

\n
\n\n
\n\n

2. Codex CLI

\n\n

The most common method for developers is to use Codex CLI.

\n\n

CLI is an AI programming agent that runs in the terminal and can:

\n\n
    \n
  • Read code
  • \n
  • Modify code
  • \n
  • Execute shell commands
  • \n
  • Automatically fix bugs
  • \n
\n\n

Codex CLI runs locally, so your code is not uploaded to the cloud; only the prompt and necessary context are sent to the model.

\n\n
\n\n

Installing Codex CLI

\n\n

Install using npm:

\n\n
sudo npm install -g @openai/codex\n# Install faster using a domestic mirror\nsudo npm install -g @openai/codex --registry=https://registry.npmmirror.com
\n\n

After installation, run:

\n\n
codex
\n\n

to start Codex.

\n\n

Logging into Codex

\n\n

The first run requires login.

\n\n

There are two methods:

\n\n

Method 1: ChatGPT Login (Recommended)

\n\n
codex
\n\n

Select:

\n\n
Sign in with ChatGPT
\n\n

Then the browser will open the login page. After logging in, you can start using it.

\n\n

Method 2: API Key Login

\n\n

For developers using the developer mode, you can use an API key:

\n\n
# macOS / Linux - Temporary setting (valid only for current terminal session)\nexport OPENAI_API_KEY="sk-Your API key"\n# Permanent configuration (add to ~/.bashrc or ~/.zshrc)\necho 'export OPENAI_API_KEY="sk-Your API key"' >> ~/.zshrc\nsource ~/.zshrc\n\n# Windows PowerShell\n$env:OPENAI_API_KEY="sk-Your API key"\n\n# After configuration, start Codex (specify model)\ncodex --model gpt-5-codex
\n\n

Then run:

\n\n
codex
\n\n

Method 3: auth.json Configuration

\n\n

Manually edit the authentication file. Create the directory:

\n\n
mkdir -p ~/.codex
\n\n

Write the API key:

\n\n
cat > ~/.codex/auth.json << 'EOF'\n{\n  "OPENAI_API_KEY": "sk-Your API key"\n}\nEOF
\n\n

First-time Run of Codex

\n\n

Enter your project directory:

\n\n
cd my-project
\n\n

Start Codex:

\n\n
codex
\n\n

Then input:

\n\n
Analyze the current project structure
\n\n

Codex will automatically:

\n\n
    \n
  1. Scan the codebase
  2. \n
  3. Analyze the project structure
  4. \n
  5. Output system architecture description
  6. \n
\n\n

For example, create a directory:

\n\n
mkdir codex-tutorial-test
\n\n

Enter the directory:

\n\n
cd codex-tutorial-test
\n\n

Create a new test.py file with the following code:

\n\n
print("Hello Tutorial!")
\n\n

Start Codex:

\n\n
codex
\n\n

Select the first option Yes, continue and press Enter. Now you can start using Codex CLI to write code:

\n\n

Image 5

\n\n

Three Running Modes of Codex

\n\n

Codex CLI provides three security modes:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
ModeFunctionality
SuggestSuggests modifications only
Auto EditAutomatically modifies files
Full AutoAutomatically executes all operations
\n\n

The default mode is:

\n\n
Suggest
\n\n

To switch modes:

\n\n
codex --auto-edit
\n\n

or:

\n\n
codex --full-auto
\n\n

The Full Auto mode can automatically execute code fixes and tasks.

\n\n

Updating and Uninstalling

\n\n
# Update to the latest version\nnpm update -g @openai/codex\n\n# Or force reinstall the latest version\nnpm install -g @openai/codex@latest\n\n# Uninstall\nnpm uninstall -g @openai/codex\n\n# Homebrew uninstall\nbrew uninstall --cask codex
\n\n
\n\n

3. Homebrew Installation (Recommended for Mac)

\n\n

Mac users can install using Homebrew:

\n\n
brew install --cask codex
\n\n

After installation, run:

\n\n
codex
\n\n

to start Codex.

\n\n

This method is suitable for:

\n\n
    \n
  • Mac developers
  • \n
  • Users who do not want to install Node.js
  • \n
\n\n
\n\n

GitHub Release Installation (Binary)

\n\n

If you prefer not to use npm, you can download the binary version directly.

\n\n

Download link: https://github.com/openai/codex/releases

\n\n

Common versions:

\n\n
    \n
  • Mac Apple Silicon: codex-aarch64-apple-darwin.tar.gz
  • \n
  • Mac Intel: codex-x86_64-apple-darwin.tar.gz
  • \n
  • Linux: codex-x86_64-unknown-linux-musl.tar.gz
  • \n
\n\n

After downloading, extract the archive:

\n\n
tar -xzf codex-xxx.tar.gz
\n\n

Rename the binary:

\n\n
mv codex-x86_64-unknown-linux-musl codex
\n\n

Add to PATH:

\n\n
sudo mv codex /usr/local/bin
\n\n

Then run:

\n\n
codex
\n\n

to start using it.

\n\n
\n\n

5. IDE Plugin Installation

\n\n

Codex can also be used within IDEs, such as:

\n\n
    \n
  • VS Code
  • \n
  • Cursor
  • \n
  • Windsurf
  • \n
  • VS Code forks
  • \n
\n\n

Installation steps:

\n\n
    \n
  1. Open the IDE plugin marketplace
  2. \n
  3. Search for Codex
  4. \n
  5. Install the plugin
  6. \n
  7. Log in with your ChatGPT account
  8. \n
\n\n

Image 6

\n\n

Now you can use Codex directly inside your IDE, for example:

\n\n
    \n
  • Automatically fix code
  • \n
  • Automatically generate functions
  • \n
  • Automatically refactor code
  • \n
\n\n
\n\n

6. Updating Codex

\n\n

Updating Codex CLI is very simple:

\n\n
codex --upgrade
\n\n

or:

\n\n
npm update -g @openai/codex\ncodex --version
\n\n

Codex CLI currently supports:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
SystemSupport Status
macOSFully supported
LinuxFully supported
WindowsExperimental support (WSL recommended)
← Codex Config FileCodex Tutorial β†’