Use your key in Codex CLI

Configure a custom model provider in ~/.codex/config.toml with wire_api = responses, and pick a model.

Codex is OpenAI's coding agent (CLI and desktop). It supports custom model providers — point a provider at OLETOKEN and it uses your OLETOKEN key and model quota.

Before you start

  1. You have created an API key and saved the full key.
  2. You picked a model ID from the model marketplace.
  3. Node.js and npm are installed.

Configure

A custom provider must go in the user-level ~/.codex/config.toml. model_provider and model_providers in a project-level .codex/config.toml are ignored.

model = "gpt-5.6-terra"
model_provider = "oletoken"

[model_providers.oletoken]
name = "OleToken"
base_url = "https://<your-base-url>/v1"
env_key = "OLETOKEN_API_KEY"
wire_api = "responses"
FieldMeaning
modelDefault model ID
model_providerPoints at the provider defined below
base_urlOpenAI-compatible address, including /v1 (Codex calls {base_url}/responses)
env_keyName of the environment variable holding the key — the key itself stays out of the file
wire_apiOnly responses is supported today

Export the key and launch:

export OLETOKEN_API_KEY="YOUR_API_KEY"   # add to ~/.zshrc or ~/.bashrc to keep it
npm i -g @openai/codex
codex

The Quick start dialog on the API keys page offers a download of the same script with your key, model and Base URL filled in: it appends what is missing and, if config.toml already has model / model_provider, only prints the block for you to merge instead of rewriting your file.

Troubleshooting

SymptomCause and fix
401OLETOKEN_API_KEY is not exported or holds a wrong value — env_key only names the variable, the key must exist in the environment
404base_url is missing /v1
Provider ignoredThe config is in a project-level .codex/config.toml; move it to ~/.codex/config.toml
Model not foundThe ID is not listed on this site; copy it from the model marketplace
Insufficient balanceTop up first

wire_api only supports responses, so Codex sends requests to {base_url}/responses — make sure your Base URL exposes that endpoint (a 401 without a key means the route exists).