Skip to content
Sign Up Free
Coding Agent setup

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

FieldValue
API Keyexperimental_bearer_token = "YOUR_API_KEY"
Base URLhttps://bettertoken.ai/v1
Modelgpt-6-astra

Prerequisites

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 = true
experimental_bearer_token = "YOUR_API_KEY"
supports_websockets = false

Configuration parameters

ParameterPurpose and locationDefaults and examples
model_providerUser config root; selects the provider ID defined below.Defaults to openai; this guide uses bettertoken.
modelRoot; the full Model ID from the model plaza.Example: gpt-6-astra; replace as needed.
nameProvider table; a display name only.BetterToken is not a Model ID.
base_urlProvider table; the model API Base URL.Use https://bettertoken.ai/v1; Codex appends /responses.
wire_apiProvider table; the request protocol.Only responses is currently supported; it is also the default.
requires_openai_authProvider 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_tokenProvider 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_websocketsProvider 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

ErrorFix
Extension asks you to sign in againRestore the official login and keep requires_openai_auth = true.
401 or 403Copy experimental_bearer_token again; do not overwrite auth.json.
Duplicate tableRemove the other [model_providers.bettertoken] table and keep one authentication mode.
Model not foundReplace gpt-6-astra with a current complete Model ID.
Configuration not appliedSave the file and run Developer: Reload Window.

Advanced setup

Official references

Technical details

Responses protocol

The Extension sends model requests to https://bettertoken.ai/v1 through OpenAI Responses.