- Codex quickstart
- Codex config basics
- Codex custom model providers
- Codex Authentication
- Codex on Windows
Prerequisites
| Requirement | Details |
|---|---|
| OS | macOS, Linux, Windows native PowerShell, or Windows with WSL |
| Git | 2.23+ recommended |
| Codex | Install the Codex app or Codex CLI from the Codex quickstart |
| CometAPI API key | Get one from the CometAPI dashboard |
| Model ID | Use a model ID from the Models page |
Choose a setup path
We provide two options to help you configure Codex quickly.Option 1: Configure Codex manually (recommended)
Edit the user-level
~/.codex/config.toml file directly. This is the most reliable path, especially for Windows and WSL users.Option 2: Configure via script
Run the setup script as a shortcut. It writes the same provider configuration and stores the CometAPI API key for Codex.
Configure Codex manually
Codex reads personal provider defaults from the user-level~/.codex/config.toml file. Configure the CometAPI provider there, not in a project .codex/config.toml file. Codex ignores provider and provider-auth settings in project config files.
The recommended setup uses a named cometapi provider and command-backed authentication. This keeps CometAPI separate from the built-in OpenAI provider, does not require shell environment inheritance, and does not replace ~/.codex/auth.json.
- macOS / Linux / WSL
- Windows PowerShell
Store your CometAPI API key in a local key file:Add this configuration to
~/.codex/config.toml:Windows native Codex uses
$HOME\.codex, usually C:\Users\<user>\.codex. WSL uses the Linux distribution’s ~/.codex. Edit the directory that matches the environment where the Codex agent runs.Use environment variable authentication
If you prefer to keep the CometAPI API key in an environment variable, useenv_key instead of the [model_providers.cometapi.auth] block.
Use this provider configuration only when COMETAPI_KEY is available in the environment that launches Codex:
Run the setup script
The setup script is optional. It writes the samecometapi provider configuration to ~/.codex/config.toml, stores your CometAPI API key in ~/.codex/cometapi_key, creates backups before file changes, and verifies the configuration with codex exec when the Codex CLI is available.
For macOS, Linux, or WSL, run the interactive installer:
Choose or change a model ID
Use a model ID from the Models page. In manual configuration, change themodel value in ~/.codex/config.toml.
For macOS, Linux, or WSL, pass --model when you run the setup script:
-Model when you run the setup script:
The script uses
CODEX_HOME when it is set. Otherwise it writes to the current environment’s ~/.codex.Verify the setup
To verify the setup with the Codex CLI, run this read-only command from any local project:PATH, open the Codex app and send a short prompt from a local project.
Troubleshooting
Codex still uses the default OpenAI provider
Codex still uses the default OpenAI provider
Confirm that
model_provider = "cometapi" is in the user-level ~/.codex/config.toml file.The API key changed
The API key changed
Update
~/.codex/cometapi_key, or rerun the setup script with the updated $COMETAPI_KEY value.The PowerShell script fails during pre-flight checks
The PowerShell script fails during pre-flight checks
Use the manual Windows native PowerShell steps, then run the verification command.
The piped shell setup asks for no API key
The piped shell setup asks for no API key
Use
--key "$COMETAPI_KEY", set COMETAPI_KEY, or run the interactive sh -c "$(curl ...)" command.The connection times out or uses the wrong base URL
The connection times out or uses the wrong base URL
Confirm that
base_url is https://api.cometapi.com/v1 in ~/.codex/config.toml.The model is not found
The model is not found
Check the Models page for available model IDs.
Windows setup affects the wrong environment
Windows setup affects the wrong environment
Edit
$HOME\.codex for Windows native mode, or edit ~/.codex inside WSL for WSL agent mode.The ChatGPT login changed
The ChatGPT login changed
Do not use
--force-auth-json or -ForceAuthJson unless you want API-key login mode.