Direct answer
To use a custom provider in Codex CLI, edit the user-level~/.codex/config.toml. Set model_provider = "custom", define [model_providers.custom], use https://bettertoken.ai/v1 as the Base URL, and set wire_api = "responses". Read the BetterToken API Key through env_key, and copy the Model ID from the GPT provider.
Find the correct config file
In the VS Code Codex extension, click the gear icon and choose Codex Settings → Open config.toml. The CLI and IDE extension share the same config layers.
Minimum working configuration
1
Set the API Key environment variable
macOS, Linux, or WSL:Windows PowerShell:Replace
YOUR_API_KEY with your BetterToken API Key. For persistent use, store it in a protected operating-system environment, not the project repository.2
Edit config.toml
model is an example. Copy a currently available Model ID from the GPT provider in the model plaza.3
Restart and test
Exit Codex completely, open a new terminal, and run:Send a simple prompt. A normal response confirms the provider, authentication, and Model ID are active.
Recommended full configuration
Use this version when you need a review model and longer stream timeout:[model_providers.custom] content. Do not declare the same TOML table twice.
How the fields fit together
To keep the official Codex App login, plugins, and Remote Control while using a third-party API, use the dedicated official login and unified session setup instead of this ordinary authentication example.
Common errors
Related docs
- Complete Codex setup guide
- Configure a custom Base URL in the VS Code Codex extension
- model_provider, base_url, and wire_api explained
- Codex CLI sandbox and approval mode
- What is AGENTS.md?

