Home›Developer Center›Codex CLI Linux

Codex CLI Linux

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 (Linux)

OpenAI Codex CLI Installation and MYAI168 Setup Guide — Linux

Goal of this guide: install OpenAI Codex CLI on a Linux desktop (Ubuntu / Debian as the example) 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.
0.5 Install Node.js (if not already installed)

First check whether node --version and npm --version print version numbers. If not, install (Ubuntu / Debian):

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

Or use nvm:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install --lts
0.6 Check Your Shell First (decides which config file to use)
echo $SHELL
  • Ends with /bash → use ~/.bashrc
  • Ends with /zsh → use ~/.zshrc

Wherever this guide says "shell config file" below, substitute yours.

1. Install Codex

Officially preferred: the standalone installer (no Node.js needed — you can skip the Node install in "0.5"; official docs https://developers.openai.com/codex/cli/):

curl -fsSL https://chatgpt.com/codex/install.sh | sh

Alternative: npm (requires Node.js). Do not use sudo (it causes permission problems); if you hit an npm permission error, point the npm global directory to your own home directory before installing:

npm install -g @openai/codex

Check:

codex --version
2. Configure MYAI168 (Method A: cc-switch, recommended)

cc-switch is a cross-platform GUI; the Linux desktop interface is the same as on other platforms. (Prerequisite: cc-switch is installed — for installation, see the "cc-switch Linux" page in the Developer Center.)

  1. Open cc-switch and click the "Codex" tab.
  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. Advanced Options: keep "Needs Local Routing" OFF for now (turn it on only if the direct connection fails).
  5. Save → Enable on the card.

Set the environment variable (Codex reads it via env_key; write it into your shell config file — use ~/.zshrc for zsh):

echo 'export MYAI168_API_KEY="your-key"' >> ~/.bashrc
source ~/.bashrc

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), write it manually with a heredoc (paste the whole block and press Enter):

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

Also confirm the key environment variable is set (the same export line as in Method A).

3. Launch and Verify (Linux)

cd into a test folder before starting (not your home directory):

mkdir -p ~/cc-test
cd ~/cc-test
codex

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 ~/.bashrc (or source ~/.zshrc) or reopen the terminal; or the npm bin directory is not on PATH — find it with npm prefix -g and add it to PATH. (On Windows: open a new PowerShell.)
  • 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

Config File Location

~/.codex/config.toml

Official Docs

  • https://developers.openai.com/codex/cli
  • https://developers.openai.com/codex/config-reference
‹ Previous page: Codex CLI WindowsNext page: MYAI168 MCP CLI ›
↑
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 macOS
  • Codex CLI Windows

MYAI168 API & MCP

  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App