Codex Configuration
The Codex CLI, Codex desktop applications and VSCode Codex plugins can use OpenAI-compatible API of MoonNexAI. Use MoonNexAI Base URLs and API Keys for configuration. Do not save real keys in project files.
Recommended Configuration
| Configure Item | Value |
|---|---|
| Base URL | https://moonnexai.com/v1 |
| API Key | <MOONNEXAI_API_KEY> |
| Common Chat Model | gpt-5.6-terra, or model ID returned using GET /v1/models |
| Chat Endpoint | /chat/completions |
| Models Endpoint | /models |
Preparation for installation
Codex CLI usually requires Node.js 22+ and npm. The version can be confirmed with the following command:
node --version
npm --versionInstall Codex CLI:
npm install -g @openai/codex
codex --versionVSCode plugin users can search for Codex and install it at the extended store.
Get API Key
- Login
https://moonnexai.com. - Enter the API token page of console.
- Creates or copys an API Key that can be used in text models.
- Only the real key is saved in this machine configuration or environment variable.
Use environment variables
Suggests to place API Key in an environment variable and then have Codex read the variable.
PowerShell:
$env:MOONNEXAI_API_KEY="<MOONNEXAI_API_KEY>"Bash / zsh:
export MOONNEXAI_API_KEY="<MOONNEXAI_API_KEY>"Configure Codex
Codex's user-level configuration is usually in ~/.codex/config.toml. Windows users can enter the .codex folder in the resource manager; if this directory is not available, open the hidden items first.
If the file does not exist, config.toml can be created. The following is the minimum configuration example for MoonNexAI:
model = "gpt-5.6-terra"
model_provider = "moonnexai"
[model_providers.moonnexai]
name = "MoonNexAI"
base_url = "https://moonnexai.com/v1"
env_key = "MOONNEXAI_API_KEY"
wire_api = "responses"If your Codex version or client only supports Chat Comppletions, use the same Base URL in the client interface and select the /chat/completions entry.
After the configuration is completed, restart the terminal or Codex application and then enter the project directory to start:
cd your-project-folder
codexMacOS users can also use ~/.codex/config.toml and environment variable configuration. Save and reopen the terminal and run codex.
The VSCode plugin will be installed in the sidebar, which will normally read the same Codex configuration.
Connectivity testing
Confirm the list of API Key accessible models:
curl https://moonnexai.com/v1/models \
-H "Authorization: Bearer <MOONNEXAI_API_KEY>"Chat test:
curl https://moonnexai.com/v1/chat/completions \
-H "Authorization: Bearer <MOONNEXAI_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-terra",
"messages": [
{
"role": "user",
"content": "回复 ok。"
}
]
}'Common Settings
| Item | Recommendations |
|---|---|
| Model Name | Prefer GET /v1/models returned id. |
| API Key | Use an environment variable or a private configuration of your machine, not to be submitted to the warehouse. |
| Configure Location | User-level default uses ~/.codex/config.toml. |
| Start Failed | Rerun codex after restarting the terminal, confirming that the environment variable is in effect. |
| Return Model Error | Replace the model name available in console or model API. |
More generic settings are available at Client configuration.