Home›Developer Center›Codex CLI Windows

Codex CLI Windows

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

OpenAI Codex CLI Installation and MYAI168 Setup Guide — Windows

Goal of this guide: install OpenAI Codex CLI on Windows 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: run node --version and npm --version in PowerShell. If they print version numbers, skip to "1. Install Codex"; if you get "command not recognized", install Node as follows:

  • Method A (recommended): download the LTS Windows installer (.msi) from https://nodejs.org, double-click and click Next all the way through, then close and reopen PowerShell and check node --version again.
  • Method B (fallback): winget install OpenJS.NodeJS.LTS, then reopen PowerShell.

Note: if Node was originally bundled by another tool (such as Hermes), it disappears together with that tool when it is removed. Installing Node independently is more stable.

1. Install Codex

If the execution policy blocks scripts, allow them first:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

This page teaches the npm install; the official docs also offer other install methods — see https://developers.openai.com/codex/cli/ for the latest guidance.

Install (the package name must include the @openai/ prefix):

npm install -g @openai/codex

Open a new PowerShell and check:

codex --version

If you see Missing optional dependency @openai/codex-win32-x64:

$v = npm view @openai/codex version
npm install -g "@openai/codex@$v" "@openai/codex-win32-x64@npm:@openai/codex@$v-win32-x64"
2. Configure MYAI168 (Method A: cc-switch, recommended)

cc-switch has good support for Codex. (For installation, see the "cc-switch Windows" 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.

Set the environment variable (Codex reads it via env_key):

[Environment]::SetEnvironmentVariable("MYAI168_API_KEY", "your-key", "User")

No output means success; verify with:

[Environment]::GetEnvironmentVariable("MYAI168_API_KEY", "User")

Confirm cc-switch wrote it into config.toml:

Get-Content $env:USERPROFILE\.codex\config.toml
2-B. Configure MYAI168 (Method B: manual, fallback)

Create the config folder and open the config file with Notepad:

mkdir $env:USERPROFILE\.codex -Force
notepad $env:USERPROFILE\.codex\config.toml

Paste in (env_key takes the environment variable NAME, not the key itself):

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"

Save. Then set the environment variable (same SetEnvironmentVariable as Method A).

3. Launch and Verify (Windows)

Open a new PowerShell (so the environment variable takes effect):

mkdir $env:USERPROFILE\cc-test -Force
cd $env:USERPROFILE\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 → open a new PowerShell window; or the npm bin directory is not on PATH — find it with npm prefix -g and add it to PATH. (On macOS: source ~/.zshrc / reopen the terminal.)
  • 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 → confirm [Environment]::GetEnvironmentVariable("MYAI168_API_KEY","User") has a value, and open a new window. (On macOS: check echo "[$MYAI168_API_KEY]" has a value; if needed add requires_openai_auth = false to the provider block.)
  • 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.
  • Multi-line paste gets reordered in PowerShell → edit with Notepad instead, or write the command on a single line.
  • Scripts blocked by the execution policy → Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
5. Maintenance

Update Codex (use install @latest, not npm update -g — it respects the semver range from the original install and may not move you to the newest release):

npm install -g @openai/codex@latest

Rotate the API Key

Run the command below and open a new PowerShell; or update the cc-switch card and Enable it again:

[Environment]::SetEnvironmentVariable("MYAI168_API_KEY", "new-key", "User")

Config File Location

%USERPROFILE%\.codex\config.toml

Official Docs

  • https://developers.openai.com/codex/cli
  • https://developers.openai.com/codex/config-reference
‹ Previous page: Codex CLI macOSNext page: Codex CLI Linux ›
↑
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 Linux

MYAI168 API & MCP

  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App