Back to docs

Codex

Codex CLI Custom API Guide

Configure Codex CLI to call models through the OurToken API and use your OurToken account balance in about 3 minutes.

3 minBeginnerLast updated: 2026-06-09

Before you start: two values you need

SettingValueWhere to get it
OPENAI_BASE_URLhttps://api.ourtoken.ai/v1Copy this value directly
OPENAI_API_KEYYour OurToken API KeyCreate it at https://ourtoken.ai/api-keys

Important

OPENAI_BASE_URL should be exactly:

text
https://api.ourtoken.ai/v1

Do not append /responses. Codex adds the request path automatically.

When writing the API Key in auth.json, do not add the Bearer prefix.


Step 1: Install Codex CLI

Mac users

Open Terminal, then paste and run:

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

After installation, add Codex to your system PATH:

bash
p="$HOME/.local/bin"; grep -qxF 'export PATH="$HOME/.local/bin:$PATH"' "$HOME/.zshrc" 2>/dev/null || echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.zshrc"; export PATH="$p:$PATH"; codex --version

Windows users

Search for PowerShell in the Start menu, open it, then paste and run:

powershell
powershell -ExecutionPolicy Bypass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

After installation, add Codex to your system PATH:

powershell
$p="$env:USERPROFILE\.local\bin"; $u=[Environment]::GetEnvironmentVariable("Path","User"); if (($u -split ";") -notcontains $p) {[Environment]::SetEnvironmentVariable("Path",$u.TrimEnd(";")+";"+$p,"User")}; $env:Path+=";$p"; codex --version

Run:

bash
codex --version

If the Codex version appears, installation is complete.

Codex CLI version screenshotCodex CLI version screenshot

Common issue

If the codex command does not run, check whether the Codex installation directory has been added to your system PATH.

⚠️ After installation, do not sign in with an OpenAI account. The next step connects Codex directly with your OurToken API Key.


Step 2: Configure OurToken credentials

After Codex is installed, configure these two files:

  1. config.toml
  2. auth.json

If the file or folder does not exist, create it manually.

Codex configuration directory screenshotCodex configuration directory screenshot

1. Configure config.toml

File path:

Mac:

text
~/.codex/config.toml

Windows:

text
C:\Users\<username>\.codex\config.toml

Replace <username> with your Windows username.

Paste the following into config.toml:

toml
model = "gpt-5.5"
model_provider = "ourtoken"
model_reasoning_effort = "high"
disable_response_storage = true
preferred_auth_method = "apikey"

[model_providers.ourtoken]
name = "OurToken"
base_url = "https://api.ourtoken.ai/v1"
wire_api = "responses"

2. Configure auth.json

File path:

Mac:

text
~/.codex/auth.json

Windows:

text
C:\Users\<username>\.codex\auth.json

Paste the following into auth.json:

json
{
  "OPENAI_API_KEY": "Your OurToken API Key"
}

Replace Your OurToken API Key with the real API Key you created in OurToken.

Example:

json
{
  "OPENAI_API_KEY": "sk-xxxxxxxxxxxxxxxx"
}

Step 3: Verify the configuration

Open Terminal or PowerShell and run this command in any directory:

bash
codex

After entering the Codex interface, send a simple message:

text
Hello

If Codex replies normally and you can see the API usage record in the OurToken Dashboard, the configuration is successful.

  • ✅ Codex replies normally
  • ✅ API usage appears in the OurToken Dashboard
  • ✅ Your account balance changes accordingly

Codex is now connected to the OurToken API and ready to use.