Codex
Prerequisites
Codex CLI is installed through npm, so prepare these first:
Node.jsnpm(normally included with Node.js)
Use the official Node.js download page: https://nodejs.org/en/download
- macOS / Windows: download and install the
LTSrelease from that page - Linux: use the distro-specific method or binary package linked from the same page
On macOS, if you already use Homebrew, you can also run:
brew install nodeThis installs both Node.js and npm.
After installation, npm is usually available automatically. Then verify:
node -v
npm -vOnce npm is available, install Codex.
Install
npm i -g @openai/codexConfigure
Connecting to this service requires two files: ~/.codex/auth.json (credentials) and ~/.codex/config.toml (connection parameters).
1. Configure auth.json
~/.codex/auth.json stores the API key. Set it to API key mode:
{
"auth_mode": "apikey",
"OPENAI_API_KEY": "codex_your_api_key"
}Set OPENAI_API_KEY to your codex_... or sk-... key.
2. Configure config.toml
~/.codex/config.toml specifies the endpoint and model parameters:
model_provider = "custom"
model = "gpt-5.4"
disable_response_storage = true
model_reasoning_effort = "high"
[model_providers]
[model_providers.custom]
name = "custom"
base_url = "https://okapi.pockgo.com/v1"
requires_openai_auth = true
wire_api = "responses"
[notice.model_migrations]
"gpt-5.2-codex" = "gpt-5.4"Use the service root URL https://okapi.pockgo.com/v1 in base_url — not the full /v1/responses path.
Verify
Once both files are configured, start Codex:
codexIf Codex starts normally and resolves the model to gpt-5.4, the setup is working.
Optional: environment variable
For a temporary shell-only test, you can pass the API key via an environment variable without modifying auth.json:
export OPENAI_API_KEY="codex_your_api_key"ChatGPT account login + third-party provider (with remote control)
If you want to keep a ChatGPT account session inside the Codex App while routing API calls to a third-party provider, use this configuration instead.
The key advantage: the Codex App keeps the ChatGPT session active, enabling official remote-control features (such as running Codex CLI tasks from the ChatGPT mobile app), while model calls go to your configured third-party endpoint.
auth.json
Switch ~/.codex/auth.json to ChatGPT auth mode and set OPENAI_API_KEY to null:
{
"auth_mode": "chatgpt",
"OPENAI_API_KEY": null
}config.toml
In ~/.codex/config.toml, add experimental_bearer_token with your third-party API key directly, instead of relying on the key in auth.json:
model_provider = "custom"
model = "gpt-5.4"
disable_response_storage = true
model_reasoning_effort = "high"
[model_providers]
[model_providers.custom]
name = "custom"
base_url = "https://okapi.pockgo.com/v1"
experimental_bearer_token = "codex_your_api_key"
requires_openai_auth = true
wire_api = "responses"
[notice.model_migrations]
"gpt-5.2-codex" = "gpt-5.4"Use the service root URL https://okapi.pockgo.com/v1 in base_url. The model_provider name (custom) stays the same as in the standard config.
Key differences from API key mode:
| Setting | API key mode | ChatGPT account mode |
|---|---|---|
auth.json → auth_mode | "apikey" | "chatgpt" |
auth.json → OPENAI_API_KEY | your key | null |
config.toml → experimental_bearer_token | not present | your key |
Steps
- Start
codexand complete the ChatGPT account login when prompted (auth_modeischatgptat this point). - Set
OPENAI_API_KEYtonullin~/.codex/auth.json(keepauth_mode: "chatgpt"). - Add
experimental_bearer_token = "codex_your_api_key"to the[model_providers.custom]block in~/.codex/config.toml. - Restart
codexand verify the session works and the model resolves togpt-5.4.
VS Code Extension
As of March 31, 2026, OpenAI officially provides a Codex IDE extension for VS Code and states that it is compatible with most VS Code forks.
If you want to use Codex inside VS Code:
- Install the official
Codexextension from the VS Code marketplace. - Open VS Code settings and search for
Codexto find extension-specific UI settings. - The settings that actually control model choice, approvals, and sandbox behavior still live in the shared
~/.codex/config.toml.
For this gateway, the VS Code extension does not need a separate custom config path. Reuse the same ~/.codex/config.toml and auth.json setup shown above. Opening the extension sidebar and starting a session successfully confirms that the shared config is active.
