Skip to content

Codex CLI

Codex CLI lets you add custom model providers in its config file. OpenPalmLab provides an OpenAI Responses-compatible endpoint (/v1/responses), so the setup below is all you need.

  • Codex CLI is installed.
  • Your token’s group includes models that support the Responses endpoint type (see the pricing page).

macOS / Linux (add it to ~/.bashrc or ~/.zshrc so it persists):

终端窗口
export OPENPALMLAB_API_KEY=sk-xxxx

Windows PowerShell (persists for the current user):

终端窗口
[Environment]::SetEnvironmentVariable("OPENPALMLAB_API_KEY", "sk-xxxx", "User")

Open a new terminal afterwards so the variable is picked up.

Edit ~/.codex/config.toml (on Windows, %USERPROFILE%\.codex\config.toml):

model_provider = "openpalmlab"
model = "YOUR_MODEL"
[model_providers.openpalmlab]
name = "OpenPalmLab"
base_url = "https://api.openpalmlab.com/v1"
env_key = "OPENPALMLAB_API_KEY"
wire_api = "responses"
  • base_url must include /v1.
  • env_key is the name of the environment variable, not the token itself, so the token never appears in the config file.
  • model is a model name from the pricing page.
终端窗口
codex "list the files in this directory"

If you get a normal reply and see the request on the console’s Logs page, you are set up.

Symptom Fix
Codex still asks you to log in Make sure model_provider is at the top level of the file (not under a [...] table) and matches the name in [model_providers.xxx].
401 The environment variable is not set. Run echo $OPENPALMLAB_API_KEY in the same terminal to check.
404 base_url is missing /v1.
Model not available Use a model the pricing page lists as supporting the Responses endpoint.

You can also manage Codex provider settings in a GUI with CC Switch.