Skip to content

Codex

Prerequisites

Codex CLI is installed through npm, so prepare these first:

  • Node.js
  • npm (normally included with Node.js)

Use the official Node.js download page: https://nodejs.org/en/download

  • macOS / Windows: download and install the LTS release 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:

bash
brew install node

This installs both Node.js and npm.

After installation, npm is usually available automatically. Then verify:

bash
node -v
npm -v

Once npm is available, install Codex.

Install

bash
npm i -g @openai/codex

Configure

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:

bash
codex

If 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:

bash
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:

SettingAPI key modeChatGPT account mode
auth.jsonauth_mode"apikey""chatgpt"
auth.jsonOPENAI_API_KEYyour keynull
config.tomlexperimental_bearer_tokennot presentyour key

Steps

  1. Start codex and complete the ChatGPT account login when prompted (auth_mode is chatgpt at this point).
  2. Set OPENAI_API_KEY to null in ~/.codex/auth.json (keep auth_mode: "chatgpt").
  3. Add experimental_bearer_token = "codex_your_api_key" to the [model_providers.custom] block in ~/.codex/config.toml.
  4. Restart codex and verify the session works and the model resolves to gpt-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:

  1. Install the official Codex extension from the VS Code marketplace.
  2. Open VS Code settings and search for Codex to find extension-specific UI settings.
  3. 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.

OpenAI-compatible gateway integration docs