Codex CLI

Prerequisites

  • Node.js 22+
  • Codex CLI installed: npm install -g @openai/codex
  • A Chuizi.AI account with an API key (starts with ck-)

Configuration

Set environment variables to configure Codex CLI to use Chuizi.AI as its backend:

terminal
bash
export OPENAI_BASE_URL=https://api.chuizi.ai/v1
export OPENAI_API_KEY=ck-your-key-here

To make this permanent, add the variables to your shell configuration file (~/.zshrc or ~/.bashrc):

terminal
bash
echo 'export OPENAI_BASE_URL=https://api.chuizi.ai/v1' >> ~/.zshrc
echo 'export OPENAI_API_KEY=ck-your-key-here' >> ~/.zshrc
source ~/.zshrc

Usage

Once configured, use Codex CLI as normal:

terminal
bash
# Analyze the current codebase
codex "explain this codebase"

# Generate code
codex "add error handling to the main function"

# Specify a model
codex --model openai/gpt-4.1 "refactor this file"

Verify the Configuration

  1. Run the following in your terminal:
    terminal
    bash
    codex "say hello"
  2. If you receive a normal response, the configuration is working
  3. Check the Chuizi.AI dashboard request logs to confirm

Common Issues

Invalid API Key

Verify your environment variables are set correctly. Run echo $OPENAI_API_KEY to check that it starts with ck-. If you use multiple terminal windows, make sure each one has loaded the configuration.

Unsupported Model

Codex CLI defaults to the codex-mini model. If that model is not available, use the --model flag to specify an alternative, such as openai/gpt-4.1.

Interrupted Responses

Long-running requests may be interrupted by network timeouts. Ensure your network connection is stable, or try a faster-responding model.

Next Steps