Install and configure Codex CLI on your computer using environment-variable-style configuration files.Windows#
1. Install Node.js#
Go to the Node.js official website, then download and install the LTS version. If Node.js is already installed, you can skip this step.If a version number is displayed, Node.js has been installed successfully.Please note that the Node.js version must be 18 or later.If your version is lower than this, you can ask an AI assistant how to upgrade Node.js. Ask it to give you commands for collecting system information first, and then it can provide the fastest and most accurate guidance.
2. Install Codex CLI#
If you see an error saying that scripts are disabled on this system, run PowerShell as administrator, then execute:Set-ExecutionPolicy Unrestricted
3. Create Configuration Files#
Run the following in PowerShell:
$dir = Join-Path $env:USERPROFILE ".codex"
New-Item -ItemType Directory -Path $dir -Force | Out-Null
$auth = @'
{
"OPENAI_API_KEY": "replace_with_your_API_KEY_here"
}
'@
[System.IO.File]::WriteAllText(
(Join-Path $dir "auth.json"),
$auth,
(New-Object System.Text.UTF8Encoding($false))
)
$config = @'
model_provider = "moteapi"
model = "gpt-5.5"
model_reasoning_effort = "high"
disable_response_storage = true
preferred_auth_method = "apikey"
requires_openai_auth = true
enableRouteSelection = true
[model_providers.moteapi]
name = "moteapi"
base_url = "https://api.moteapi.com/chatgpt/v1"
wire_api = "responses"
'@
[System.IO.File]::WriteAllText(
(Join-Path $dir "config.toml"),
$config,
(New-Object System.Text.UTF8Encoding($false))
)
Verify that the configuration was created successfully:Get-Content "$env:USERPROFILE\.codex\auth.json"
Get-Content "$env:USERPROFILE\.codex\config.toml"
4. Verify the Installation#
Enter codex in PowerShell to start Codex:Then type the following in the dialog:Say hello to it. If Codex replies normally and you can see the request record on the platform, the installation was successful.

macOS#
1. Install Node.js#
First, make sure Homebrew is installed on your computer. If it is not installed, open the Homebrew website and copy the installation command from the page to install it with one command.Some resources required during Homebrew installation are hosted overseas, so you may need to enable a TUN proxy.
After Homebrew is installed, use it to install Node.js. If Node.js is already installed, you can skip this step.Use the following command to verify the installation:If a version number is displayed, Node.js has been installed successfully.Please note that the Node.js version must be 18 or later.If your version is lower than this, you can ask an AI assistant how to upgrade Node.js. Ask it to give you commands for collecting system information first, and then it can provide the fastest and most accurate guidance.
2. Install Codex CLI#
3. Create Configuration Files#
Run the following in Terminal:Verify that the configuration was created successfully:4. Verify the Installation#
Enter codex in Terminal to start Codex, then type the following in the dialog:If Codex replies normally and you can see the request record on the platform, the configuration was successful.Linux#
1. Install Node.js#
Use the following commands to install Node.js. If Node.js is already installed, you can skip this step.Please note that the Node.js version must be 18 or later.If your version is lower than this, you can ask an AI assistant how to upgrade Node.js. Ask it to give you commands for collecting system information first, and then it can provide the fastest and most accurate guidance.
2. Install Codex CLI#
If the output looks like the screenshot below, the installation was successful.3. Create Configuration Files#
Run the following in Terminal:Verify that the configuration was created successfully:4. Verify the Installation#
Enter codex in Terminal to start Codex, then type the following in the dialog:If Codex replies normally and you can see the request record on the platform, the configuration was successful.FAQ#
1. Since this folder is not version controlled, we recommend requiring approval of all edits and commands.#
Error Screenshot#
Solution#
This prompt asks whether you allow Codex to work in this folder without asking for confirmation every time.Repeated confirmations can be inconvenient, so you can select the first option and let it continue.