Home›Developer Center›Codex CLI macOS

Codex CLI macOS

API DocumentationOpenAI ChatGPT APIAnthropic (Claude) APIGoogle Gemini APIGoogle Search APIGoogle News APIOpenRouter APIAPI Pricing
CLI & Agent Guidescc-switch macOScc-switch Windowscc-switch LinuxOpenCode macOSOpenCode WindowsOpenCode LinuxOpenClaw macOSOpenClaw WindowsOpenClaw LinuxHermes Agent macOSHermes Agent WindowsHermes Agent LinuxClaude Code CLI macOSClaude Code CLI WindowsClaude Code CLI LinuxCodex CLI macOSCodex CLI WindowsCodex CLI Linux
MYAI168 API & MCPMYAI168 MCP CLIMYAI168 MCP Web & App
No matching questions on this page.Search the whole site
Installation Overview (macOS)

OpenAI Codex CLI Installation and MYAI168 Setup Guide — macOS

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 and Model

Endpoint   https://www.myai168.com/en/api/openai/v1
Model      gpt-5.6-sol

Important Security Notes

  • Codex can read, write, and execute files in the working directory. In real use, cd into a project folder before starting it; do not start it in your home directory.
  • Treat your API key like a password and never share it. If it leaks, revoke it in the MYAI168 dashboard and issue a new one.
  • Verify with a "math question", not with "who are you" (model self-identification is unreliable); also cross-check with the API call records in the MYAI168 dashboard.

Prerequisites

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.

1. Install

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
2. Configure MYAI168 (Method A: cc-switch, recommended)

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.)

  1. Open cc-switch and click the "Codex" tab at the top.
  2. Click "+" to add, and choose Custom Configuration.
  3. Fill in: Provider Name = MYAI168; API Key = your key; API Request URL = https://www.myai168.com/en/api/openai/v1
  4. Expand Advanced Options: keep "Needs Local Routing" OFF for now (gpt-5.6-sol is a GPT-series model and can use responses, so it is usually not needed; if the direct connection fails, turn it on to convert via a local proxy, and keep cc-switch running while you use Codex).
  5. Click Save → Enable on the card.

Confirm 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
2-B. Configure MYAI168 (Method B: manual, fallback)

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.

3. Launch and Verify (macOS)

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.)

4. Quick Troubleshooting
  • codex command not found → run 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.)
  • no_pricing_info / model does not exist → that model is not registered on this endpoint; make sure you are using gpt-5.6-sol.
  • 404 / responses not found (direct connection fails) → the MYAI168 endpoint may only support Chat Completions for this model. Go back to cc-switch, turn ON "Needs Local Routing", Save, Enable, and keep cc-switch running while you use Codex.
  • 401 / unauthorized → check 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.)
  • Status bar shows default / replies look like the official model → the config was not applied. Most common cause: env_key was filled with the key string instead of the variable name.
  • Switch models → use /model inside a conversation; or change the model line in config.toml. One-off temporary switch: codex -c model='"model-name"'
5. Maintenance

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

Rotate the API Key

Update the export MYAI168_API_KEY line in ~/.zshrc, then run source ~/.zshrc to apply.

Config File Location

~/.codex/config.toml

Official Docs

  • https://developers.openai.com/codex/cli
  • https://developers.openai.com/codex/config-reference
‹ Previous page: Claude Code CLI LinuxNext page: Codex CLI Windows ›
↑
Question link copied.

Other FAQ pages

API Documentation

  • OpenAI ChatGPT API
  • Anthropic (Claude) API
  • Google Gemini API
  • Google Search API
  • Google News API
  • OpenRouter API
  • API Pricing

CLI & Agent Guides

  • cc-switch macOS
  • cc-switch Windows
  • cc-switch Linux
  • OpenCode macOS
  • OpenCode Windows
  • OpenCode Linux
  • OpenClaw macOS
  • OpenClaw Windows
  • OpenClaw Linux
  • Hermes Agent macOS
  • Hermes Agent Windows
  • Hermes Agent Linux
  • Claude Code CLI macOS
  • Claude Code CLI Windows
  • Claude Code CLI Linux
  • Codex CLI Windows
  • Codex CLI Linux

MYAI168 API & MCP

  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App