Using Codex CLI on macOS (Apple Silicon)#
Codex CLI is the terminal interface for OpenAI Codex.
Codex supports two authentication methods:
-
ChatGPT account
- Uses ChatGPT plan limits (Free, Plus, Pro)
- No API key required
-
OpenAI API key
- Uses OpenAI Platform API billing
- Requires an API key
- Usage is charged against API credits
You can switch between both methods.
1. Installation#
Install Codex CLI via Homebrew Cask:
brew install --cask codexVerify:
which codex
codex --version2. Configuration#
Codex stores configuration in:
~/.codex/Important files:
| File | Purpose |
|---|---|
config.toml |
Main configuration |
auth.json |
Authentication state |
logs_*.sqlite |
Conversation logs |
state_*.sqlite |
Internal state |
Edit configuration:
nano ~/.codex/config.toml3. MCP Server Configuration#
MCP servers are managed through the centralized Git-backed pipeline documented in:
Check MCP and system configuration:
codex doctor4. Authentication#
Option A — ChatGPT Account Login#
Uses your ChatGPT account limits.
Login:
codex loginCheck status:
codex login statusExample:
Logged in using ChatGPTCheck Codex usage:
/statusOnline usage page:
https://chatgpt.com/codex/settings/usageOption B — OpenAI API Key Login#
Uses OpenAI API billing.
Create an API key:
https://platform.openai.com/api-keysStore the key in 1Password.
Add it to your shell environment:
nano ~/.zshrcAdd to ~/.zshrc:
alias codexa='printf "%s" "$OPENAI_API_KEY SEE 1Passoed" | codex login --with-api-key'Then switch to API authentication:
codexa5. Switching Authentication Methods#
Check current login:
codex login statusSwitch to ChatGPT account:
codex loginSwitch to API key:
codexa6. Checking Usage#
Inside Codex:
/statusChatGPT usage:
https://chatgpt.com/codex/settings/usageAPI usage:
https://platform.openai.com/usage7. Diagnostics#
Run:
codex doctorCheck configuration:
cat ~/.codex/config.toml8. Quick Reference#
| Command | Description |
|---|---|
codex |
Start Codex CLI |
codex --version |
Show version |
codex login |
Login with ChatGPT account |
codex login status |
Show authentication mode |
codex-api |
Switch to API key authentication |
codex doctor |
Diagnose installation |
/status |
Show current session information |
Notes#
Codex CLI uses the same installation for both authentication methods.
| Authentication | Billing source |
|---|---|
| ChatGPT login | ChatGPT plan limits |
| API key | OpenAI Platform API credits |
Use:
- ChatGPT login when you want to use included Codex access.
- API key login when you want API billing and usage tracking.