Skip to main content

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.
Provider and authentication settings belong in user-level ~/.codex/config.toml. Project .codex/config.toml files can hold project overrides, but Codex ignores model_provider and model_providers there. Put project instructions in AGENTS.md.

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.
Use this version when you need a review model and longer stream timeout:
Merge existing top-level fields and [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

References