Codex CLI

Prerequisites

ItemValue
Codex CLILatest version
Config file~/.codex/config.toml
Provider idjoytoken
Model nameauto
JoyToken Base URLhttps://api.joytokens.ai/openai/v1
Wire APIOpenAI Responses
API key envJOY_TOKEN_API_KEY

Step 1: Install

npm install --global @openai/codex@latest
codex --version

Step 2: Set the API key

Replace sk-xxx with your JoyToken API key:

export JOY_TOKEN_API_KEY="sk-xxx"

For persistent use, provide the variable through your shell profile or secret manager. Do not store the key in config.toml.

Step 3: Configure the provider

Add the following top-level settings and provider definition to ~/.codex/config.toml:

model = "auto"
model_provider = "joytoken"
[model_providers.joytoken]
name = "JoyToken"
base_url = "https://api.joytokens.ai/openai/v1"
env_key = "JOY_TOKEN_API_KEY"
wire_api = "responses"

Provider and authentication settings must be in the user-level config. Codex ignores model_provider and model_providers in project-level .codex/config.toml files.

Step 4: Start

cd /path/to/your/project
codex

Step 5: Verify

codex exec "Reply with exactly: pong"

A successful response includes pong.

JoyToken Check

PlaceExpected result
LogsRequest path is /openai/v1/responses
AuthBearer authentication uses JOY_TOKEN_API_KEY
ModelRequested model is auto
UsageTokens and credits are recorded

Common Errors

ErrorFix
JOY_TOKEN_API_KEY is missingExport the variable in the current shell
Codex uses another providerCheck model_provider = "joytoken" in ~/.codex/config.toml
Provider config is ignoredMove it from project .codex/config.toml to user ~/.codex/config.toml
401 UnauthorizedCheck that JOY_TOKEN_API_KEY contains a valid JoyToken API key

Resources