Skip to content

Install Codex on macOS ​

0. Prerequisite: install Node.js ​

Install Node.js first (22+ recommended): Node.js on macOS

1. Install Codex ​

Step 1: open Terminal (press Command + Space, type Terminal, hit Enter)

Step 2: run the install command

bash
npm install -g @openai/codex

Step 3: check the install

bash
codex --version

If you see a version number, it's installed.

Option B: Homebrew (optional) ​

If you'd rather manage apps with Homebrew:

bash
brew install --cask codex

2. Configure Codex for Flash API ​

2.1 Where the config lives ​

Codex config directory: ~/.codex/

What that means:

  • ~ is your home directory
  • The full path is /Users/<your-username>/.codex/

You'll create two files:

  • config.toml: the main config
  • auth.json: your credentials

2.2 Create the config directory ​

bash
mkdir -p ~/.codex

2.3 Write config.toml ​

bash
cat > ~/.codex/config.toml <<'EOF'
# Base config
model_provider = "flashapi"
model = "gpt-6.1-sol"
review_model = "gpt-6.1-sol"
model_reasoning_effort = "high"
disable_response_storage = true
network_access = "enabled"
windows_wsl_setup_acknowledged = true
model_context_window = 272000
model_auto_compact_token_limit = 272000
effective_context_window_percent = 95

[model_providers.flashapi]
name = "flashapi"
base_url = "https://ai.flashapi.top/v1"
wire_api = "responses"
requires_openai_auth = true
http_headers = { "x-openai-actor-authorization" = "flashapi.top" }
EOF

What the settings do:

  • model_provider: the provider to use (here, flashapi)
  • model: the default model
  • review_model: code review also uses gpt-6.1-sol
  • model_context_window: sized for GPT-6.1 Sol's 272K tier
  • base_url: the Flash API endpoint
  • wire_api: the OpenAI-compatible wire format
  • requires_openai_auth: must stay true, or Codex won't read the API key from auth.json

2.4 Write auth.json (replace the API key) ​

bash
cat > ~/.codex/auth.json <<'EOF'
{
  "OPENAI_API_KEY": "YOUR_FLASH_API_KEY"
}
EOF

You must replace YOUR_FLASH_API_KEY with the real key you copied from the Flash API console.

How:

  1. Copy the whole command above
  2. Replace YOUR_FLASH_API_KEY with your real key
  3. Paste it into the terminal and run it

2.5 Check the files were created ​

bash
ls -la ~/.codex

You should see both config.toml and auth.json.

Optional: view the config

bash
cat ~/.codex/config.toml

3. Launch and verify ​

Step 1: go to your project directory

bash
cd /path/to/your/project

Replace /path/to/your/project with your actual project path.

Step 2: start Codex

bash
codex

If everything is configured correctly, Codex starts up connected to Flash API.

Troubleshooting ​

1. codex command not found ​

Cause: the global npm package path isn't on your PATH.

Fix:

  1. Check Node.js is installed correctly: node -v
  2. Restart your terminal
  3. Still failing? Reinstall Codex

2. Writing the config file fails ​

Cause: usually a permissions issue or a missing directory.

Fix:

  1. Create the directory by hand: mkdir -p ~/.codex
  2. Run the config-writing command again

3. API calls fail ​

Cause: the API key is wrong, or your Flash API balance has run out.

Fix:

  1. Check auth.json: cat ~/.codex/auth.json
  2. Make sure the API key is correct (watch for stray spaces)
  3. Log in to the Flash API console and check your balance

One base URL for GPT, Claude and Gemini