Codex CLI and desktop

Configure Responses address for codex that supports custom providers.

Codex uses the Responses protocol to connect to this site. This article first configures the CLI, and then explains the environmental differences between the desktop and the editor. Please select a model that is callable by the current key and supports calls from Responses and coding tools.

Preparation before starting

  1. Create a separate key for Codex in API Key.
  2. Query Available Models and copy the exact model ID that supports Responses.
  3. Prepare a project directory for testing; perform a read-only task for the first verification.

The API of this site is billed according to the rules of this site and is calculated separately from the ChatGPT/Codex subscription. The success of ordinary text requests does not prove that remote compression, network search, and other extended capabilities are available.

Step 1: Install and check the CLI

If you already have Node.js and npm, follow the official CLI installation method:

npm install -g @openai/codex
codex --version

The system installation method and supported platform are subject to Codex CLI official instructions. If it has already been installed, record the version first and then configure it. There is no need to install it again.

Step 2: Provide the key for the startup process

Bash or zsh:

printf 'API Key: '
read -rs DUNDUN_API_KEY
printf '\n'
export DUNDUN_API_KEY

PowerShell:

$credential = Get-Credential -UserName "api" -Message "在密码栏填写本站 API Key"
$env:DUNDUN_API_KEY = $credential.GetNetworkCredential().Password
Remove-Variable credential

The key is saved in the current process environment and should not be directly written into the project configuration file or submitted to the warehouse.

Step 3: Configure custom suppliers

After backing up the existing configuration, open .codex/config.toml in the user directory: usually ~/.codex/config.toml for macOS/Linux, and %USERPROFILE%\.codex\config.toml for Windows. When CODEX_HOME is set, the actual configuration directory should be checked.

Place the top-level model_provider and model before the first TOML header before merging the supplier tables. If a key or table with the same name already exists, modify the original item. Do not append repeatedly:

model_provider = "dundun"
model = "MODEL_ID"

[model_providers.dundun]
name = "DunDun"
base_url = "https://dunduntoken.com/v1"
env_key = "DUNDUN_API_KEY"
wire_api = "responses"
Field Function
model_provider Select dundun supplier below
model Replace with the actual model ID available on this site
base_url Fill in /v1, and the client will add /responses
env_key Points to the name of the environment variable that saves the site’s key
wire_api Using responses protocol

Keep other projects, permissions, and security settings. This example uses environment variable authentication; if the same supplier table already has other authentication fields, back it up first and clear conflicting items according to the official configuration instructions to avoid configuring auth, plaintext tokens or official login authentication at the same time.

Step 4: Start a new session and verify

Enter the test project in the terminal where you just set the key:

codex
  1. Create a new session and send “Reply OK only” to confirm that the basic request is successful.
  2. Ask “List the files in the current directory and explain the purpose of README. Do not modify the files” and observe whether the tool call can be completed.
  3. Open the Call Record of this site and check the request time, actual model and status.
  4. After the basic conversation and file reading are successful, verify the multiple rounds of tasks and the write operations you need.

Approve the operation according to the client’s normal permission process. Connection errors should be checked from the address, credentials, and protocol. There is no need to turn off permission protection.

Desktop and editor extensions

Configure other entries after the CLI is successful. Clients that support reading this custom supplier configuration need to use the configuration directory of the same user, and exit and restart completely after modification.

Processes launched from desktop icons may not inherit DUNDUN_API_KEY in the terminal; editor extensions may also run on remote hosts, WSL, or containers. If it is prompted that variables are missing, you should provide credentials in the actual operating environment and then restart the client. Don’t equate “the variables can be viewed in the terminal” with the fact that the variables have been received on the desktop.

If the client version limits the scope of custom vendor support, please refer to Official Document. This article does not provide one-click access or model directory generation functions that are not implemented on this site.

FAQ

Phenomenon Troubleshooting steps
DUNDUN_API_KEY not found Check startup process environment, remote running location and configuration for env_key
401 Verify that the key is valid and that the actual request read the old credential
404 Verify that the address is not duplicated /v1, the model supports Responses
400 or tool call failure Check model tools, inference parameters, and context capabilities; retain request ID from error
Still connected to the old platform Check whether project-level configuration, configuration files, and command-line parameters override user-level settings
Short conversations succeed, long tasks fail Verify tool invocation, context and compression capabilities respectively. Compatibility cannot be judged only by the model name

Continue reading

Responses Access · CC-Switch · Error Troubleshooting

Field basis: Codex official configuration reference.