Install the official Codex CLI, then import with CC Switch, or put the key in an environment variable and add a default model config.
What is CC Switch
CC Switch is a provider switcher for command-line tools such as Claude Code and Codex. It keeps endpoints, keys and models on your machine and lets you switch with one click.
Easier than editing environment variables and config files when you use several models and tools.
Click "Import to CC Switch" on the API keys page and the browser hands the configuration to it.
Not required: you can also use the manual setup below.
You can connect without CC Switch
Write the endpoint and key into the tool's own configuration. Copy the key from the API keys page and replace YOUR_API_KEY below.
Requirements
macOS 12 or later with Terminal or iTerm2
Node.js 18 or later
Install and connect
1Check your Node.js version
node -v
2Install Codex CLI
Use the official npm package.
npm install -g @openai/codex
3Import with CC Switch (recommended)
Install it first (see the CC Switch guide), then click "Import to CC Switch" on the API keys page and choose Codex.
Manual setup without CC Switch
1Save the key in a dedicated environment variable
A dedicated name keeps it out of OPENAI_API_KEY, which other tools read. Append it to your shell config; use ~/.bashrc instead of ~/.zshrc if you use bash.
Back up your existing config, then append to ~/.codex/config.toml (nothing is overwritten). Replace YOUR_MODEL with a model from the model market. Start with codex --profile latticehub; your existing defaults stay untouched.
Check: Reopen your terminal and run codex --profile latticehub. If it answers, you are connected. Codex uses the Responses API; if a model reports it is unsupported, try another model.