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
- You have created an API key and saved the full key.
- You picked a model ID from the model marketplace.
- 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"
| Field | Meaning |
|---|---|
model | Default model ID |
model_provider | Points at the provider defined below |
base_url | OpenAI-compatible address, including /v1 (Codex calls {base_url}/responses) |
env_key | Name of the environment variable holding the key — the key itself stays out of the file |
wire_api | Only 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
| Symptom | Cause and fix |
|---|---|
| 401 | OLETOKEN_API_KEY is not exported or holds a wrong value — env_key only names the variable, the key must exist in the environment |
| 404 | base_url is missing /v1 |
| Provider ignored | The config is in a project-level .codex/config.toml; move it to ~/.codex/config.toml |
| Model not found | The ID is not listed on this site; copy it from the model marketplace |
| Insufficient balance | Top up first |
wire_apionly supportsresponses, 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).

