Codex VS Code Extension: custom API and official login
Configure the shared config.toml for the Codex VS Code Extension, use BetterToken Responses, and preserve official login, plugins, and Remote Control.
The Codex VS Code Extension shares ~/.codex/config.toml with Codex CLI/App. Use this page when you need to keep the official login, plugins, or Remote Control.
Key settings
| Field | Value |
|---|---|
| API Key | experimental_bearer_token = "YOUR_API_KEY" |
| Base URL | https://bettertoken.ai/v1 |
| Model | gpt-6-astra |
Prerequisites
- Install the latest Codex VS Code Extension
- Complete the official login in the Extension or Codex App
- Create a BetterToken API Key
- Copy a Model ID from the model plaza or key Setup dialog
Install
Install the extension from the VS Code Marketplace, then restart VS Code.
Manual setup
If you use a custom CODEX_HOME, edit config.toml in that directory. Otherwise use ~/.codex/config.toml on macOS / Linux or %USERPROFILE%\.codex\config.toml on Windows.
Fully quit Codex, then back up the existing config.toml and auth.json. Update the existing provider settings instead of adding a duplicate provider table.
Configure the Extension
Edit ~/.codex/config.toml:
model_provider = "bettertoken"model = "gpt-6-astra"
[model_providers.bettertoken]name = "BetterToken"base_url = "https://bettertoken.ai/v1"wire_api = "responses"requires_openai_auth = trueexperimental_bearer_token = "YOUR_API_KEY"supports_websockets = falseConfiguration parameters
| Parameter | Purpose and location | Defaults and examples |
|---|---|---|
model_provider | User config root; selects the provider ID defined below. | Defaults to openai; this guide uses bettertoken. |
model | Root; the full Model ID from the model plaza. | Example: gpt-6-astra; replace as needed. |
name | Provider table; a display name only. | BetterToken is not a Model ID. |
base_url | Provider table; the model API Base URL. | Use https://bettertoken.ai/v1; Codex appends /responses. |
wire_api | Provider table; the request protocol. | Only responses is currently supported; it is also the default. |
requires_openai_auth | Provider table; uses OpenAI authentication and its credential store. | Defaults to false; this guide uses true. It is not a switch that preserves login files. |
experimental_bearer_token | Provider table; the Bearer Key for third-party requests. | Use your BetterToken API Key; it does not rewrite the official login cache. Stored as plaintext; OpenAI discourages this field. |
supports_websockets | Provider table; Responses WebSocket support. | Defaults to false; this guide keeps HTTP/SSE transport. |
Keep the credentials created by official sign-in; do not replace them with API Key JSON. requires_openai_auth = true uses the official authentication flow; the current provider’s experimental_bearer_token supplies the third-party Key for model requests. With the former enabled, Codex ignores env_key, so do not directly substitute it for the Bearer Key. Do not share config files containing keys.
For an alternative credential setup, see OpenAI’s environment-variable and command-backed authentication guidance. These are separate authentication modes: do not add a provider auth table alongside env_key, experimental_bearer_token, or requires_openai_auth, and do not substitute env_key into this login-preserving example.
Configuration layers and legacy keys
Do not put model or reasoning settings inside [projects."<path>"]. Project-specific models can use root keys in a trusted project’s .codex/config.toml; provider and authentication settings remain in user config. Current named profiles use NAME.config.toml under CODEX_HOME, selected with codex --profile NAME, not legacy [profiles.NAME] tables or the root profile selector.
Save the file, run Developer: Reload Window in VS Code, and reopen the Codex panel.
Verify the connection
Create a new Extension session and send a short task. A response from gpt-6-astra while plugins and Remote Control remain available confirms the setup.
Switch models
Change model and, optionally, review_model, then run Developer: Reload Window. Use a Model ID from the Setup dialog or model plaza.
Common errors
| Error | Fix |
|---|---|
| Extension asks you to sign in again | Restore the official login and keep requires_openai_auth = true. |
401 or 403 | Copy experimental_bearer_token again; do not overwrite auth.json. |
| Duplicate table | Remove the other [model_providers.bettertoken] table and keep one authentication mode. |
| Model not found | Replace gpt-6-astra with a current complete Model ID. |
| Configuration not applied | Save the file and run Developer: Reload Window. |
Advanced setup
Related guides
Official references
Technical details
Responses protocol
The Extension sends model requests to https://bettertoken.ai/v1 through OpenAI Responses.

