Skip to main content

Codex CLI

Codex CLI is an AI programming agent launched by OpenAI that runs in the terminal. It can read local codebases and complete development tasks such as code writing, file operations, and command execution through natural language interaction.

Prerequisites

  • You have activated a TCB environment and obtained the environment ID cloudBaseEnvID
  • Enable the required model in the AI console
  • Obtain the Base URL and API Key in the AI console
Base URLhttps://<ENV_ID>.api.tcloudbasegateway.com/v1/ai/cloudbase

Configuration Steps

Codex CLI supports connecting to custom models through the config.toml configuration file.

Configuration Field Mapping Table

FieldExplanation
modelThe large model ID. Copy the identifier of an enabled large model from the model list in the AI console and enter it here.
model_providerThe provider ID, which points to the custom [model_providers] configuration.
base_urlThe Base URL for the large model, which is obtained in the AI console.
env_keyThe name of the environment variable corresponding to the API Key.

CC Switch is an open-source desktop application for centrally managing provider configurations for multiple AI coding tools. For installation instructions, refer to the CC Switch configuration guide.

  1. Open CC Switch and add CloudBase as a provider
FieldDescription
API KeyObtained from the AI console
Base URLhttps://{{cloudBaseEnvID}}.api.tcloudbasegateway.com/v1/ai/cloudbase
API FormatChat Completions (requires local routing)
  1. Enable local route mapping in advanced options and enter the model ID

  2. Switch to the CloudBase provider and start Codex CLI

Common Error Troubleshooting

Error MessageSolution
404 Model Not FoundThe Base URL is entered incorrectly. Go to the AI console to copy the correct Base URL.
401 Credentials are invalidThe API Key is entered incorrectly or may have been deleted.
429 Token usage exceeded quota limitAn incorrect large model name is configured, or the large model is not enabled in the AI console.