~/.codex/config.toml, and the API Key is supplied through BETTERTOKEN_API_KEY.
Key settings
Prerequisites
- Install Node.js
- Create a BetterToken API Key
- Copy a Model ID from the model plaza or the key Setup dialog
Install
Command-line setup
The BetterToken Automatic setup script writes the Codex provider configuration. It requires Node.js and prompts for the API Key or Model ID when they are not passed as arguments.- macOS / Linux
- Windows
~/.codex/config.toml (or %USERPROFILE%\.codex\config.toml on Windows), confirm that model, review_model, and the BetterToken provider were written correctly, and fully restart Codex.
Manual setup
GPT, Kimi, and GLM use the sameconfig.toml structure. Only replace YOUR_MODEL_ID with a current Model ID from the selected provider. One-click command-line setup is currently available for GPT only.
Set the API Key
- macOS / Linux
- Windows PowerShell
~/.zshrc or ~/.bashrc to persist it.Configure config.toml
Edit~/.codex/config.toml:
model_provider = "custom" must match the [model_providers.custom] table. Replace both YOUR_MODEL_ID values with a current complete Model ID.
Verify the connection
Open a new terminal and run:401, or model errors confirms the setup.
Switch models
Changemodel and, optionally, review_model. Save the file, stop the current Codex process, and start it again. Use the Model ID from the Setup dialog or model plaza.
Common errors
Advanced setup
Supported providers
Statuses apply to the BetterToken setup documented on this page.
What the setup methods mean
What the setup methods mean
- Command-line + manual setup: use a generated command or follow the complete manual steps.
- Manual setup: enter the API Key, Base URL, and Model.
- Not supported: no verified direct setup is currently available.
Codex Extension
The Codex VS Code Extension sharesconfig.toml, but preserving the official login uses a different authentication configuration. See the Codex Extension setup guide.
Related FAQ
- What is Codex CLI?
- Codex CLI vs Codex App vs Codex Web
- Codex config.toml setup guide
- What are model_provider, base_url, and wire_api?
- What do review_model and reasoning_effort mean?
- What is AGENTS.md and how should you write it?
- What are Codex CLI sandbox and approval modes?
- How to keep the official Codex login with a third-party API
- OpenAI-compatible API vs Anthropic-compatible API
- Claude Code vs Codex CLI
- Manage the Codex provider with CC Switch
Official reference
Technical details
Responses protocol
Responses protocol
Codex uses OpenAI Responses. Set
base_url to https://bettertoken.ai/v1 and keep wire_api = "responses". Codex appends /responses.
