Install Codex on macOS
0. Prerequisite: install Node.js
Install Node.js first (22+ recommended): Node.js on macOS
1. Install Codex
Option A: npm (recommended)
Step 1: open Terminal (press Command + Space, type Terminal, hit Enter)
Step 2: run the install command
npm install -g @openai/codexStep 3: check the install
codex --versionIf you see a version number, it's installed.
Option B: Homebrew (optional)
If you'd rather manage apps with Homebrew:
brew install --cask codex2. 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 configauth.json: your credentials
2.2 Create the config directory
mkdir -p ~/.codex2.3 Write config.toml
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" }
EOFWhat the settings do:
model_provider: the provider to use (here, flashapi)model: the default modelreview_model: code review also usesgpt-6.1-solmodel_context_window: sized for GPT-6.1 Sol's 272K tierbase_url: the Flash API endpointwire_api: the OpenAI-compatible wire formatrequires_openai_auth: must staytrue, or Codex won't read the API key fromauth.json
2.4 Write auth.json (replace the API key)
cat > ~/.codex/auth.json <<'EOF'
{
"OPENAI_API_KEY": "YOUR_FLASH_API_KEY"
}
EOFYou must replace YOUR_FLASH_API_KEY with the real key you copied from the Flash API console.
How:
- Copy the whole command above
- Replace
YOUR_FLASH_API_KEYwith your real key - Paste it into the terminal and run it
2.5 Check the files were created
ls -la ~/.codexYou should see both config.toml and auth.json.
Optional: view the config
cat ~/.codex/config.toml3. Launch and verify
Step 1: go to your project directory
cd /path/to/your/projectReplace /path/to/your/project with your actual project path.
Step 2: start Codex
codexIf 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:
- Check Node.js is installed correctly:
node -v - Restart your terminal
- Still failing? Reinstall Codex
2. Writing the config file fails
Cause: usually a permissions issue or a missing directory.
Fix:
- Create the directory by hand:
mkdir -p ~/.codex - 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:
- Check auth.json:
cat ~/.codex/auth.json - Make sure the API key is correct (watch for stray spaces)
- Log in to the Flash API console and check your balance