Set up Codex (CLI / VS Code extension)
OpenAI's coding agent. Add one custom provider to config.toml and you're set
- API format: OpenAI Responses
- Base URL format: Up to /v1 (https://gpt.cherrychat.org/v1)
- Recommended model: gpt-6.1-sol, gpt-5.5
- Platforms: macOS, Windows, Linux, VS Code
Steps
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 | shWindows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"Or install with npm
npm install -g @openai/codexStore 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 ~/.zshrcWindows (reopen PowerShell afterwards)
setx CHERRYCHAT_API_KEY "sk-your-key"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.tomlOpen the file (Windows)
mkdir $HOME\.codex -Force; notepad $HOME\.codex\config.tomlconfig.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 = falseVerify 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).
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
- Set base_url to /v1 (https://gpt.cherrychat.org/v1); Codex appends /responses. Do not use https://gpt.cherrychat.org/v1/responses or the bare domain.
- wire_api must be "responses"; the "chat" value from older guides is no longer supported.
- The model, model_provider and web_search lines must come before the first [model_providers…] section, or they are read as part of it and ignored.
- Use ~/.codex/config.toml in your home folder; a project .codex/config.toml ignores model_provider. Do not name the provider openai, ollama or lmstudio (reserved).
- Keep web_search = "disabled": Codex sends its built-in web search by default, and CherryChat API does not support built-in tools yet.
- Reopen the terminal after setting the variable. On Windows, close every PowerShell and VS Code window after setx.
Error → cause → fix
| What you see | Why | What to do |
|---|---|---|
| Missing environment variable: CHERRYCHAT_API_KEY | Codex 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 Unauthorized | The key is wrong, has spaces, or was disabled / deleted | Copy the key again from My Keys, reset CHERRYCHAT_API_KEY and reopen the terminal |
| HTTP 404 Not Found | base_url is missing /v1 or already ends with /responses | Change 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 API | Pick 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 apply | Top up any amount in the CherryChat Store, then retry after a few seconds |
| HTTP 429 Too Many Requests | Too many requests: by default 120 per minute per key and 8 at a time per account | Lower 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.
Operated by UK Company CHERRYCHAT LTD · Company Number 16096119 · Support WeChat: JsnonoChat · Content is AI-generated — please verify before relying on it
