Goal of this guide: install OpenAI Codex CLI on macOS and connect it to your own MYAI168 API, using gpt-5.6-sol.
Codex speaks the OpenAI format, so it connects to the MYAI168 "OpenAI-compatible endpoint" with gpt-5.6-sol.
Endpoint https://www.myai168.com/en/api/openai/v1
Model gpt-5.6-sol
Have your MYAI168 API key ready (Codex reads the key via the MYAI168_API_KEY environment variable; the setup steps are in "2. Configure MYAI168"). Node.js is only needed for the npm install method — the officially preferred standalone installer does not need Node.
Officially preferred: the standalone installer (no Node.js needed; official docs https://developers.openai.com/codex/cli/):
curl -fsSL https://chatgpt.com/codex/install.sh | sh
codex --version
Alternative: npm (requires Node.js):
npm install -g @openai/codex
source ~/.zshrc
codex --version
cc-switch is a cross-platform GUI; the macOS interface is the same as on Windows. (For installation, see the "cc-switch macOS" page in the Developer Center.)
MYAI168; API Key = your key; API Request URL = https://www.myai168.com/en/api/openai/v1Confirm the key is exported in ~/.zshrc (Codex reads it via env_key):
echo "[$MYAI168_API_KEY]"
It should print the key, not an empty []; if it is empty, add it first and make it effective:
echo 'export MYAI168_API_KEY="your-key"' >> ~/.zshrc
source ~/.zshrc
Confirm cc-switch wrote it into config.toml:
cat ~/.codex/config.toml
If cc-switch did not write the file successfully (config.toml does not exist), use the manual method. Copy the entire block below, paste it, and press Enter (the first line must start with cat >):
mkdir -p ~/.codex
cat > ~/.codex/config.toml << 'EOF'
model = "gpt-5.6-sol"
model_provider = "myai168"
[model_providers.myai168]
name = "MYAI168"
base_url = "https://www.myai168.com/en/api/openai/v1"
env_key = "MYAI168_API_KEY"
wire_api = "responses"
EOF
Confirm:
cat ~/.codex/config.toml
Key point: env_key takes the environment variable NAME, MYAI168_API_KEY, not the key string itself.
cd into a test folder before starting (not your home directory):
mkdir -p ~/cc-test
cd ~/cc-test
codex
On first run it asks whether to trust the folder → 1. Yes.
Verify: once inside codex, ask a question that requires actual computation:
What is 123456 times 789? Reply with the number only.
If it answers 97406784 and the status bar shows gpt-5.6-sol, the connection works.
(Do not verify with "who are you" — model self-identification is unreliable; the API call records in the MYAI168 dashboard are authoritative.)
source ~/.zshrc or reopen the terminal. (On Windows: open a new PowerShell; or the npm bin directory is not on PATH — find it with npm prefix -g and add it to PATH.)echo "[$MYAI168_API_KEY]" has a value; if needed add requires_openai_auth = false to the provider block. (On Windows: confirm [Environment]::GetEnvironmentVariable("MYAI168_API_KEY","User") has a value, and open a new window.)/model inside a conversation; or change the model line in config.toml. One-off temporary switch: codex -c model='"model-name"'Update Codex (standalone-installer installs: rerun the official install command; npm installs: use install @latest, not npm update -g):
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# npm installs: npm install -g @openai/codex@latest
Update the export MYAI168_API_KEY line in ~/.zshrc, then run source ~/.zshrc to apply.
~/.codex/config.toml