Set up Codex (CLI / VS Code extension)

OpenAI's coding agent. Add one custom provider to config.toml and you're set

Steps

  1. Install Codex (skip if installed)

    Install the CLI with a command below and check codex --version. In VS Code, search the Extensions view for "Codex" and install the one from OpenAI; it shares the same config as the CLI.

    macOS / Linux

    curl -fsSL https://chatgpt.com/codex/install.sh | sh

    Windows (PowerShell)

    powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

    Or install with npm

    npm install -g @openai/codex
  2. Store the key in an environment variable

    Codex reads the key from the CHERRYCHAT_API_KEY environment variable, so the config file never contains it. Reopen the terminal afterwards, and fully quit and reopen VS Code.

    • CHERRYCHAT_API_KEY (API key): sk-your-key

    macOS / Linux (append to ~/.zshrc)

    echo 'export CHERRYCHAT_API_KEY="sk-your-key"' >> ~/.zshrc
    source ~/.zshrc

    Windows (reopen PowerShell afterwards)

    setx CHERRYCHAT_API_KEY "sk-your-key"
  3. Edit config.toml

    Open ~/.codex/config.toml (%USERPROFILE%\.codex\config.toml on Windows) with the command below and paste the config. The first three lines must sit at the very top, before any [section]. If the file already has a model = or model_provider = line, delete the old one; keys cannot repeat.

    • base_url (API address): https://gpt.cherrychat.org/v1 (Stop at /v1; Codex adds /responses itself)
    • model (model name): gpt-6.1-sol

    Open the file (macOS)

    mkdir -p ~/.codex && touch ~/.codex/config.toml && open -e ~/.codex/config.toml

    Open the file (Windows)

    mkdir $HOME\.codex -Force; notepad $HOME\.codex\config.toml

    config.toml content

    model = "gpt-6.1-sol"
    model_provider = "cherrychat"
    web_search = "disabled"
    
    [model_providers.cherrychat]
    name = "CherryChat"
    base_url = "https://gpt.cherrychat.org/v1"
    env_key = "CHERRYCHAT_API_KEY"
    wire_api = "responses"
    requires_openai_auth = false
  4. Verify the connection

    Open a new terminal and run the command below; a reply means it works. codex exec normally runs only inside a Git repository, and --skip-git-repo-check lets this test run in any folder. You can also start codex and type /status to see the active model and provider (should be cherrychat).

  5. Use it in the VS Code extension

    The extension reads the same config.toml: click the gear in the Codex sidebar → "Codex Settings" → "Open config.toml" to check it. After changing the config or the variable, fully quit and reopen VS Code.

Common pitfalls

Error → cause → fix

What you seeWhyWhat to do
Missing environment variable: CHERRYCHAT_API_KEYCodex cannot see the variable (not set, or the terminal was not reopened)Follow step 2 and reopen the terminal; check with echo $CHERRYCHAT_API_KEY (Windows: echo $env:CHERRYCHAT_API_KEY)
HTTP 401 UnauthorizedThe key is wrong, has spaces, or was disabled / deletedCopy the key again from My Keys, reset CHERRYCHAT_API_KEY and reopen the terminal
HTTP 404 Not Foundbase_url is missing /v1 or already ends with /responsesChange it to https://gpt.cherrychat.org/v1
Model not found (model_not_found)The model name is wrong, or the model does not support the Responses APIPick a model tagged for Codex on the Models page, e.g. gpt-6.1-sol
HTTP 402 or "insufficient balance" (billing_error in Claude format)Your credits cannot cover this call. API calls are paid from credits only; memberships and unlimited plans do not applyTop up any amount in the CherryChat Store, then retry after a few seconds
HTTP 429 Too Many RequestsToo many requests: by default 120 per minute per key and 8 at a time per accountLower the concurrency or requests per second in the tool and wait for the Retry-After seconds; most tools retry on their own

Guide checked 2026-11-02. The tool's screens may change; the official docs win if they differ.

API · API Pricing

Operated by UK Company CHERRYCHAT LTD · Company Number 16096119 · Support WeChat: JsnonoChat · Content is AI-generated — please verify before relying on it

CherryChat

The network is slow. Still loading…