Skip to content

Codex CLI Configuration Guide ​

What is Codex CLI ​

Codex CLI is a powerful AI programming assistant that allows you to collaborate with AI directly in your terminal. Supported on macOS, Linux, and Windows (WSL).

Installation Requirements ​

  • Node.js version ≥ 18.0
  • Supported operating systems: macOS, Linux, Windows (WSL)

Note

If you are using Windows, make sure you have WSL installed to use Codex CLI. Do not use Windows built-in cmd.

Installation Steps ​

1. Install Node.js ​

If you haven't installed Node.js 18.0 or higher, please install it first.

2. Install Codex CLI ​

Install using npm:

bash
npm install -g @openai/codex

Or using Homebrew (macOS):

bash
brew install codex

Configure AI-TokenHub API ​

Get Required Configuration ​

You need to prepare two important configuration items:

ConfigDescriptionHow to Get
OPENAI_API_KEYAPI authentication tokenGet from API Keys page after registration (starts with sk-)
OPENAI_BASE_URLAPI service addressUse https://ai-tokenhub.com/api/v1

Configure Environment Variables ​

Method 1: Temporary Configuration ​

Run in your project directory:

bash
export OPENAI_API_KEY="$YOUR_API_KEY"
export OPENAI_BASE_URL="https://ai-tokenhub.com/api/v1"

Method 2: Permanent Configuration ​

To avoid manually setting environment variables each time, add the configuration to your system config file:

bash
# Add the following to ~/.bashrc or ~/.zshrc
export OPENAI_API_KEY="$YOUR_API_KEY"
export OPENAI_BASE_URL="https://ai-tokenhub.com/api/v1"

Then run:

bash
source ~/.bashrc  # or source ~/.zshrc

Running Codex CLI ​

Determine the Model to Use ​

If you want to use the model gpt-5, the corresponding model name on the platform is gpt-5-2025-08-07, so you need to use the parameter --model gpt-5-2025-08-07 when starting.

Launch Codex CLI ​

Enter your project directory and run:

bash
codex

Select option 2 (Run Codex CLI using API).

First Run Authorization ​

On first run, select option 1 to grant permissions.

Test Verification ​

After successful startup, enter "Hello" to test.

FAQ ​

Request Failed ​

Check if the API Key is correct and if the account has sufficient balance.

Connection Timeout ​

Check network connectivity and ensure you can access https://ai-tokenhub.com.

Wrong Model Name ​

Ensure the model name is spelled correctly. Please check the platform for available models.