Support QQ group1098515135

Install and configure Codex CLI

Install the official Codex CLI, then import with CC Switch, or put the key in an environment variable and add a default model config.

What is CC Switch

CC Switch is a provider switcher for command-line tools such as Claude Code and Codex. It keeps endpoints, keys and models on your machine and lets you switch with one click.

  • Easier than editing environment variables and config files when you use several models and tools.
  • Click "Import to CC Switch" on the API keys page and the browser hands the configuration to it.
  • Not required: you can also use the manual setup below.

You can connect without CC Switch

Write the endpoint and key into the tool's own configuration. Copy the key from the API keys page and replace YOUR_API_KEY below.

Requirements

  • macOS 12 or later with Terminal or iTerm2
  • Node.js 18 or later

Install and connect

  1. 1Check your Node.js version

    node -v
  2. 2Install Codex CLI

    Use the official npm package.

    npm install -g @openai/codex
  3. 3Import with CC Switch (recommended)

    Install it first (see the CC Switch guide), then click "Import to CC Switch" on the API keys page and choose Codex.

Manual setup without CC Switch

  1. 1Save the key in a dedicated environment variable

    A dedicated name keeps it out of OPENAI_API_KEY, which other tools read. Append it to your shell config; use ~/.bashrc instead of ~/.zshrc if you use bash.

    printf '\nexport LATTICEHUB_API_KEY="YOUR_API_KEY"\n' >> ~/.zshrc
    source ~/.zshrc
  2. 2Append the provider and profile

    Back up your existing config, then append to ~/.codex/config.toml (nothing is overwritten). Replace YOUR_MODEL with a model from the model market. Start with codex --profile latticehub; your existing defaults stay untouched.

    mkdir -p ~/.codex
    cp -n ~/.codex/config.toml ~/.codex/config.toml.bak 2>/dev/null || true
    cat >> ~/.codex/config.toml <<'EOF'
    
    # LatticeHub
    [profiles.latticehub]
    model = "YOUR_MODEL"
    model_provider = "latticehub"
    
    [model_providers.latticehub]
    name = "LatticeHub"
    base_url = "https://api.latticehub.cc/v1"
    env_key = "LATTICEHUB_API_KEY"
    wire_api = "responses"
    EOF

Check: Reopen your terminal and run codex --profile latticehub. If it answers, you are connected. Codex uses the Responses API; if a model reports it is unsupported, try another model.