Direct answer
Put user-level settings in~/.codex/config.toml and make model_provider = "custom" point to [model_providers.custom]. For BetterToken, use https://www.bettertoken.ai/v1 as base_url, responses as wire_api, and a Model ID from the GPT Key group. Use env_key to read the API Key from a local environment variable instead of storing it in TOML or a repository.
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 Key group 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?