Skip to content

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 ItemValue
Base URLhttps://moonnexai.com/v1
API Key<MOONNEXAI_API_KEY>
Common Chat Modelgpt-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:

bash
node --version
npm --version

Install Codex CLI:

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

VSCode plugin users can search for Codex and install it at the extended store.

Get API Key ​

  1. Login https://moonnexai.com.
  2. Enter the API token page of console.
  3. Creates or copys an API Key that can be used in text models.
  4. 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:

powershell
$env:MOONNEXAI_API_KEY="<MOONNEXAI_API_KEY>"

Bash / zsh:

bash
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:

toml
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:

bash
cd your-project-folder
codex

MacOS 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:

bash
curl https://moonnexai.com/v1/models \
  -H "Authorization: Bearer <MOONNEXAI_API_KEY>"

Chat test:

bash
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 ​

ItemRecommendations
Model NamePrefer GET /v1/models returned id.
API KeyUse an environment variable or a private configuration of your machine, not to be submitted to the warehouse.
Configure LocationUser-level default uses ~/.codex/config.toml.
Start FailedRerun codex after restarting the terminal, confirming that the environment variable is in effect.
Return Model ErrorReplace the model name available in console or model API.

More generic settings are available at Client configuration.