Editor & Tool Configuration

Codex Installation and Configuration Guide

Install and configure the Codex CLI on Windows, macOS and Linux: create a codex-group API key, set up config.toml and auth.json for AnyRouter.

Windows Guide

System requirements

  • Windows 10 or Windows 11
  • Node.js 22+
  • npm 10+
  • Internet connection

Installation steps

Prerequisite!!! Install Git Bash: visit Git - Downloads, download the version for your system, then just keep clicking "Next" to finish the installation.

1. Install Node.js Visit the Node.js website to download and install the latest LTS version.

2. Install codex Open Command Prompt (CMD) or PowerShell and run:

npm install -g @openai/codex

3. Verify the installation Open Command Prompt (CMD) or PowerShell and run:

codex --version

Configure the API

1. Get an Auth Token Visit the anyrouter.win site and do the following:

  • Go to the Console → API Keys page
  • Click Add API Key
  • For the key group, select codex专属 (Codex-only) — be sure to select this group, otherwise it will not work
  • The key name can be anything
  • Credits: we recommend setting unlimited credits
  • Leave the other options at their defaults
image.png

2. Configuration files

Important: replace sk-xxx below with the actual API key you generated on anyrouter.win! Important: replace sk-xxx below with the actual API key you generated on anyrouter.win! Important: replace sk-xxx below with the actual API key you generated on anyrouter.win!

  1. Go to the .codex folder in your user directory, e.g. C:\Users\testuser\.codex. (Note: if you cannot see this directory, "Show hidden items" is not enabled in Windows — turn it on in File Explorer first.)
image.png
  1. If the .codex folder does not exist, create it manually, then create two files inside it: config.toml and auth.json.

image.png 3. Fill in the configuration (replace sk-xxx with the real key you created).

a. Configuration in auth.json:

{"OPENAI_API_KEY": "sk-xxx"}

b. Configuration in config.toml (just paste the content below): model_reasoning_effort accepts high, medium, or low, indicating how much effort the model puts into reasoning.

model_provider = "api111"
model = "gpt-5-codex"
model_reasoning_effort = "high"
disable_response_storage = true
preferred_auth_method = "apikey"

[model_providers.api111]
name = "api111"
base_url = "https://anyrouter.win/v1"
wire_api = "responses"

Launch codex

Restart your terminal! Restart your terminal! Restart your terminal! Then go to your project directory:

cd your-project-folder

Run the following command to start:

codex
image.png

The codex VS Code extension

Once the configuration above is done, search for and install codex in the VS Code extension marketplace.

image.png

After installation, it appears in the sidebar.

image.png

macOS Guide

System requirements

  • macOS 12 or later
  • Node.js 22+
  • npm 10+
  • Internet connection

Installation steps

1. Install Node.js

  • Option 1: visit the Node.js website to download and install the latest LTS version.

  • Option 2: use Homebrew (recommended)

    # If Homebrew is not installed yet, run this command first
    /bin/bash -c "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh](https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh))"
    
    # Install Node.js
    brew install node

2. Install codex Open Terminal and run (you may need sudo):

npm install -g @openai/codex

3. Verify the installation Open Terminal and run:

codex --version

Configure the API

1. Get an Auth Token Visit the anyrouter.win site and do the following:

  • Go to the Console → API Keys page
  • Click Add API Key
  • For the key group, select codex特供 (Codex special) — be sure to select this group, otherwise it will not work
  • The key name can be anything
  • Credits: we recommend setting unlimited credits
  • Leave the other options at their defaults image.png

2. Configuration files

Important: replace sk-xxx below with the actual API key you generated on anyrouter.win! Important: replace sk-xxx below with the actual API key you generated on anyrouter.win! Important: replace sk-xxx below with the actual API key you generated on anyrouter.win!

  1. Create the directory and files:

    mkdir -p ~/.codex
    touch ~/.codex/auth.json
    touch ~/.codex/config.toml
  2. Edit the auth.json file:

    vi ~/.codex/auth.json

    Press i to enter insert mode, paste the following content (replace sk-xxx with your key), then press ESC, type :wq, and press Enter to save and exit.

    { "OPENAI_API_KEY": "sk-xxx" }
  3. Edit the config.toml file:

    vi ~/.codex/config.toml

    Press i to enter insert mode, paste the following content, then press ESC, type :wq, and press Enter to save and exit.

    model_provider = "api111"
    model = "gpt-5-codex"
    model_reasoning_effort = "high"
    disable_response_storage = true
    preferred_auth_method = "apikey"
    
    [model_providers.api111]
    name = "api111"
    base_url = "https://anyrouter.win/v1"
    wire_api = "responses"

Launch codex

Restart your terminal! Restart your terminal! Restart your terminal! Then go to your project directory:

cd your-project-folder

Run the following command to start:

codex

[image]

The codex VS Code extension

Once the configuration above is done, search for and install codex in the VS Code extension marketplace. [image]

After installation, it appears in the sidebar. [image]

Linux Guide

System requirements

  • A mainstream Linux distribution (Ubuntu 20.04+, Debian 10+, CentOS 7+, etc.)
  • Node.js 22+
  • npm 10+
  • Internet connection

Installation steps

1. Install Node.js

  • Ubuntu/Debian
    sudo apt update
    curl -fsSL [https://deb.nodesource.com/setup_lts.x](https://deb.nodesource.com/setup_lts.x) | sudo -E bash -
    sudo apt-get install -y nodejs
  • CentOS/RHEL/Fedora
    # Use dnf (Fedora) or yum (CentOS/RHEL)
    sudo dnf install nodejs npm
    # or
    sudo yum install nodejs npm
  • Arch Linux
    sudo pacman -S nodejs npm

2. Install codex Open Terminal and run:

sudo npm install -g @openai/codex

3. Verify the installation Open Terminal and run:

codex --version

Configure the API

1. Get an Auth Token Visit the anyrouter.win site and do the following:

  • Go to the Console → API Keys page
  • Click Add API Key
  • For the key group, select codex渠道-gpt (Codex channel - GPT) — be sure to select this group, otherwise it will not work
  • The key name can be anything
  • Credits: we recommend setting unlimited credits
  • Leave the other options at their defaults [image]

2. Configuration files

Important: replace sk-xxx below with the actual API key you generated on anyrouter.win! Important: replace sk-xxx below with the actual API key you generated on anyrouter.win! Important: replace sk-xxx below with the actual API key you generated on anyrouter.win!

  1. Create the directory and files:

    mkdir -p ~/.codex
    touch ~/.codex/auth.json
    touch ~/.codex/config.toml
  2. Edit the auth.json file:

    vi ~/.codex/auth.json

    Press i to enter insert mode, paste the following content (replace sk-xxx with your key), then press ESC, type :wq, and press Enter to save and exit.

    { "OPENAI_API_KEY": "sk-xxx" }
  3. Edit the config.toml file:

    vi ~/.codex/config.toml

    Press i to enter insert mode, paste the following content, then press ESC, type :wq, and press Enter to save and exit.

    model_provider = "api111"
    model = "gpt-5-codex"
    model_reasoning_effort = "high"
    disable_response_storage = true
    preferred_auth_method = "apikey"
    
    [model_providers.api111]
    name = "api111"
    base_url = "https://anyrouter.win/v1"
    wire_api = "responses"

Launch codex

Restart your terminal! Restart your terminal! Restart your terminal! Then go to your project directory:

cd your-project-folder

Run the following command to start:

codex
image.png

The codex VS Code extension

Once the configuration above is done, search for and install codex in the VS Code extension marketplace.

image.png

After installation, it appears in the sidebar.

image.png

FAQ

If you hit an error, troubleshoot as follows:

  1. Confirm the API key was created correctly: credits set to unlimited credits, no model restrictions, and group set to codex渠道-gpt.

For more codex configuration and usage details, see the official codex documentation.

On this page