Codex CLI setup
Prepare the client and protocol
Section titled “Prepare the client and protocol”Install using the official Codex quickstart. Prepare a WuDi key and a suitable model. Codex uses Responses; a successful Chat Completions request alone does not verify compatibility. Confirm a compatible route before using this configuration.
1. Set the key variable
Section titled “1. Set the key variable”macOS or Linux:
export WUDI_API_KEY='YOUR_WUDI_API_KEY'Windows PowerShell:
$env:WUDI_API_KEY = 'YOUR_WUDI_API_KEY'2. Add a custom provider
Section titled “2. Add a custom provider”Back up ~/.codex/config.toml. On Windows, the user configuration normally lives at %USERPROFILE%\\.codex\\config.toml. Merge the following without declaring the same TOML table twice:
model = "gpt-5.6-sol"model_provider = "wudi"
[model_providers.wudi]name = "WuDi API"base_url = "https://wudiapi.com/v1"env_key = "WUDI_API_KEY"wire_api = "responses"requires_openai_auth = falseenv_key is the environment variable’s name, not the actual secret. The model ID must match your key’s access. Do not add unverified reasoning settings, WebSockets or experimental options.
3. Start and verify
Section titled “3. Start and verify”Run codex from the terminal containing the environment variable. Send a short request in a new session and check the model and group in the usage log. A desktop-launched application may not inherit a terminal’s temporary variables; see desktop setup.
Configuration conflicts
Section titled “Configuration conflicts”Project-level configuration, command-line flags or a selected profile may override user settings. If an old model appears, check effective configuration rather than repeatedly creating keys. Duplicate tables, typographic quotes or misplaced top-level fields can cause parse errors.
For Responses errors, test the minimal request. A 404 can indicate an incorrect path or an unavailable protocol. Read the response details for a 400. Hosted features need separate support; replacing the Responses path with a chat path does not provide it.
Restore
Section titled “Restore”Exit Codex and restore the backup, or remove the added provider and restore the previous model_provider. You do not need to delete the entire user configuration directory.
Reference: official configuration reference.
