Codex CLI is OpenAI's command-line coding assistant. This guide shows how to install Codex, configure ApiPass as the model provider, and start an interactive coding session from your terminal.
Make sure you have:
Supported terminal choices:
If Node.js is not installed yet, install the LTS version from https://nodejs.org/ first.
Install the latest Codex CLI package globally:
1npm install -g @openai/codex@latestOn macOS or Linux, use sudo only if your npm global directory requires elevated permissions:
1sudo npm install -g @openai/codex@latestVerify the installation:
1codex --versionInstall Node.js LTS first. You can download it from https://nodejs.org/ or install it with Windows Package Manager:
1winget install OpenJS.NodeJS.LTSIf you use Chocolatey or Scoop instead, install Node.js LTS with your package manager:
1choco install nodejs-lts1scoop install nodejs-ltsOpen a new PowerShell window and verify Node.js and npm:
1node --version
2npm --versionInstall Codex globally:
1npm install -g @openai/codex@latestVerify the installation:
1codex --versionIf PowerShell reports that codex is not recognized, close and reopen PowerShell or Windows Terminal so the updated npm global binary path is loaded.
If you prefer WSL2, install Node.js and Codex inside the WSL2 Linux distribution, then use the macOS/Linux commands in this guide from the WSL shell.
Use WSL2 instead of WSL1. Codex configuration inside WSL2 is stored under the Linux home directory, for example ~/.codex, and is separate from the native Windows directory %USERPROFILE%\.codex.
Codex reads user-level settings from ~/.codex/config.toml and API-key credentials from ~/.codex/auth.json.
Create the Codex configuration directory:
1mkdir -p ~/.codexCreate ~/.codex/config.toml:
1cat > ~/.codex/config.toml << 'EOF'
2model_provider = "apipass"
3model = "gpt-5.3-codex"
4model_reasoning_effort = "high"
5disable_response_storage = true
6preferred_auth_method = "apikey"
7
8[model_providers.apipass]
9name = "apipass"
10base_url = "https://api.apipass.dev/codex/v1"
11wire_api = "responses"
12requires_openai_auth = true
13EOFCreate ~/.codex/auth.json:
1cat > ~/.codex/auth.json << 'EOF'
2{
3 "OPENAI_API_KEY": "YOUR_API_KEY"
4}
5EOFCreate the Codex configuration directory:
1New-Item -ItemType Directory -Force "$env:USERPROFILE\.codex"Create %USERPROFILE%\.codex\config.toml:
1@'
2model_provider = "apipass"
3model = "gpt-5.3-codex"
4model_reasoning_effort = "high"
5disable_response_storage = true
6preferred_auth_method = "apikey"
7
8[model_providers.apipass]
9name = "apipass"
10base_url = "https://api.apipass.dev/codex/v1"
11wire_api = "responses"
12requires_openai_auth = true
13'@ | Set-Content -Encoding UTF8 "$env:USERPROFILE\.codex\config.toml"Create %USERPROFILE%\.codex\auth.json:
1@'
2{
3 "OPENAI_API_KEY": "YOUR_API_KEY"
4}
5'@ | Set-Content -Encoding UTF8 "$env:USERPROFILE\.codex\auth.json"Replace YOUR_API_KEY with the API key copied from your ApiPass API Keys page.
When using WSL2, run the macOS/Linux configuration commands inside the WSL shell. Do not create the files in %USERPROFILE%\.codex unless you are running native Windows PowerShell.
Your WSL2 files should be:
~/.codex/config.toml~/.codex/auth.jsonUse https://api.apipass.dev/codex/v1 as the Codex base_url. Codex appends the Responses API path automatically, so requests are sent to:
https://api.apipass.dev/codex/v1/responseshttps://api.apipass.dev/codex/v1/responses/compactDo not use https://api.apipass.dev alone unless your deployment explicitly proxies /v1/responses to the Codex service.
Start an interactive session:
1codexOr send a one-off prompt:
1codex "help me review this project"ApiPass deducts credits when Codex sends requests through https://api.apipass.dev/codex/v1. The exact amount depends on the selected Codex-compatible model, token usage, and the active ApiPass pricing rule.
Use these pages to inspect cost and usage:
In the logs table, the Credits column shows the deduction for each request. Opening a row's details shows the request payload and token usage when the response includes token accounting.
If you also want to use Claude Code through ApiPass, open the related guide in the sidebar or go directly to Claude Code Tutorial.
codex: command not found or codex is not recognizedConfirm that npm installed Codex globally:
1npm list -g @openai/codexThen restart your terminal and check that the npm global binary directory is in PATH.
On Windows PowerShell, find the npm global prefix:
1npm config get prefixIf codex is still not recognized, restart Windows Terminal or add the returned npm global prefix directory to the user Path environment variable. You can also check whether the Codex command shim exists:
1where.exe codexIf global installation fails in PowerShell because of permissions, open PowerShell or Windows Terminal as Administrator and run:
1npm install -g @openai/codex@latestIf you installed Node.js through a version manager or package manager, use the same shell environment for both Node.js and Codex.
If PowerShell shows an error such as npm.ps1 cannot be loaded because running scripts is disabled, use npm.cmd:
1npm.cmd install -g @openai/codex@latestOr, if your organization policy allows it, enable local user script execution:
1Set-ExecutionPolicy -Scope CurrentUser RemoteSignedNative Windows PowerShell uses:
1%USERPROFILE%\.codex\config.toml
2%USERPROFILE%\.codex\auth.jsonWSL2 uses:
1~/.codex/config.toml
2~/.codex/auth.jsonThese are different locations. If Codex still asks for authentication, confirm that you created auth.json in the same environment where you run the codex command.
If Codex cannot read the configuration file created in PowerShell, inspect the file content:
1Get-Content "$env:USERPROFILE\.codex\config.toml"
2Get-Content "$env:USERPROFILE\.codex\auth.json"If the content looks incorrect, recreate the files with the PowerShell commands above. They use Set-Content -Encoding UTF8 to avoid encoding issues.
Check that ~/.codex/auth.json contains a valid ApiPass key:
1{
2 "OPENAI_API_KEY": "YOUR_API_KEY"
3}Also confirm that preferred_auth_method = "apikey" is present in config.toml.
If you see a 404 error, verify that base_url includes /codex/v1:
1base_url = "https://api.apipass.dev/codex/v1"Without /codex, Codex will call https://api.apipass.dev/v1/responses, which is not the ApiPass Codex endpoint.
If a model returns an availability error, switch the model value in config.toml to another Codex-compatible model enabled for your ApiPass account.