tencent cloud

Codex

Download
Focus Mode
Font Size
Last updated: 2026-11-17 14:27:53
AI-Translated & Reviewed
Codex is an AI coding tool launched by OpenAI that can understand codebases, edit files, and complete programming tasks through natural language. This document describes how to configure and use Tencent Cloud CMR in Codex.

Installing Codex

Install Codex according to your local environment. For detailed operations, see Codex Quick Start. If Codex is already installed, you can skip this step.
After installation, run the following command to check the version. If the terminal displays a version number, the installation is successful.
codex --version
Attention:
The new version of Codex calls models through the OpenAI Responses API. Before configuration, confirm that the CMR instance and target model support the Responses API.

Obtaining an API Key

Log in to the CMR console and create a CMR API Key. For detailed instructions, see CMR Access Key.
Attention:
After creation, make sure to copy and securely store the API Key. Once you close the success dialog, you will not be able to view the complete API Key again.

Configuring Codex

Configuring the Model

1. Open Codex and click Settings in the lower-left corner.
2. On the Settings page, select Configuration, click Open config.toml, and open the configuration file with the system default editor.
Note:
You can also directly open the user-level configuration file: on macOS/Linux, it is ~/.codex/config.toml, and on Windows, it is $HOME\\.codex\\config.toml. If the file does not exist, create the .codex directory and the config.toml file first.
3. Write the following content at the top of the config.toml file. If other configurations already exist in the file, add the following configuration to the beginning of the file.
model_provider = "tencent-cloud-cmr"
model = "ModelRouter/auto"
disable_response_storage = true

[model_providers.tencent-cloud-cmr]
name = "Tencent Cloud CMR"
base_url = "https://<user domain>/v1"
env_key = "CMR_API_KEY"
wire_api = "responses"
The configuration items are described as follows.
Configuration Item
Description
model_provider
Specifies the custom model provider used by Codex. The value must be consistent with the name in [model_providers.tencent-cloud-cmr].
model
Specifies the model called by Codex. ModelRouter/auto indicates that an available model is selected based on the L1 CMR policy. You can also enter a model name or intent route name associated with the instance.
disable_response_storage
Prohibits upstream services from storing response data.
name
Specifies the model name displayed externally in the client.
base_url
Enter the CMR instance domain name and append /v1 at the end. Codex automatically requests /v1/responses.
env_key
Specifies the name of the environment variable that stores the CMR API Key.
wire_api
The API protocol used by Codex. Enter responses as the fixed value.
4. Save and close config.toml.

Configuring the API Key

Configure the CMR_API_KEY environment variable according to your operating system.
macOS
Windows
Run the following command in the terminal:
launchctl setenv CMR_API_KEY "<USER_API_KEY>"
CMD
PowerShell
1. Run the following command in CMD to set the environment variable.
setx CMR_API_KEY "<USER_API_KEY>"
2. Open a new CMD window and run the following command to check whether the environment variable takes effect.
echo %CMR_API_KEY%
1. Run the following command in PowerShell to set the environment variable.
[Environment]::SetEnvironmentVariable("CMR_API_KEY", "USER_API_KEY", [EnvironmentVariableTarget]::User)
2. Open a new PowerShell window and run the following command to check whether the environment variable takes effect.
echo $env:CMR_API_KEY
Warning:
Do not disclose your API Key, or commit commands, Shell configurations, or logs that contain the actual API Key to code repositories.

Verifying the Configuration

1. Exit Codex completely. Simply closing the window does not terminate the Codex process.
2. Restart Codex for the config.toml file and environment variables to take effect. Tencent Cloud CMR is displayed in the lower-right corner of the client, matching the configured model name.
3. Enter a test message in the Codex input box, such as "Describe the model currently in use in one sentence," and then send it.
4. Codex returns a normal response, indicating that the CMR configuration has taken effect.
5. If the call fails, check the following items in order:
Is base_url the CMR instance domain and does it end with /v1?
Has CMR_API_KEY taken effect in the Codex process environment?
Is model a model name or intent route name available for the current instance?
Does the target model support the Responses API?

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback