Set up Claude Code
Anthropic's terminal coding agent. Set two environment variables to run it on CherryChat's Claude models
- API format: Anthropic Messages
- Base URL format: Domain only (https://gpt.cherrychat.org)
- Recommended model: claude-sonnet-5-5, claude-opus-5-5
- Background model: claude-haiku-5-5
- Platforms: macOS, Windows, Linux, VS Code, JetBrains
Steps
Install Claude Code (skip if installed)
Open Terminal on macOS or PowerShell on Windows, paste the matching command and press Enter. Run claude --version afterwards to confirm. If the script download fails, install with npm instead (requires Node.js 22 or later).
macOS / Linux
curl -fsSL https://claude.ai/install.sh | bashWindows (PowerShell)
irm https://claude.ai/install.ps1 | iexOr install with npm
npm install -g @anthropic-ai/claude-codeOption 1 (recommended): settings.json
Open ~/.claude/settings.json in your home folder (%USERPROFILE%\.claude\settings.json on Windows) with the command below and paste the block in. If the file already has content, merge only the "env" section instead of overwriting it. The file is strict JSON: no comments and no trailing commas. This applies to every terminal and to the VS Code / JetBrains extensions.
- ANTHROPIC_BASE_URL (API address): https://gpt.cherrychat.org (Domain only, without /v1)
- ANTHROPIC_AUTH_TOKEN (API key): sk-your-key
- ANTHROPIC_MODEL (main model): claude-sonnet-5-5
- ANTHROPIC_DEFAULT_HAIKU_MODEL (background model): claude-haiku-5-5 (Used for titles, summaries and other background tasks; cheap and fast)
Open the file (macOS)
mkdir -p ~/.claude && touch ~/.claude/settings.json && open -e ~/.claude/settings.jsonOpen the file (Windows)
mkdir $HOME\.claude -Force; notepad $HOME\.claude\settings.jsonsettings.json content
{ "env": { "ANTHROPIC_BASE_URL": "https://gpt.cherrychat.org", "ANTHROPIC_AUTH_TOKEN": "sk-your-key", "ANTHROPIC_MODEL": "claude-sonnet-5-5", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5" } }Option 2: environment variables
Use this if you prefer not to edit settings.json. "Permanent" appends to ~/.zshrc (use ~/.bashrc for bash) or uses setx on Windows; reopen the terminal afterwards. "This window only" is handy for a quick try and disappears when the window closes. Pick one option, not both.
Permanent (append to ~/.zshrc)
cat >> ~/.zshrc <<'EOF' export ANTHROPIC_BASE_URL="https://gpt.cherrychat.org" export ANTHROPIC_AUTH_TOKEN="sk-your-key" export ANTHROPIC_MODEL="claude-sonnet-5-5" export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-5-5" EOF source ~/.zshrcThis window only
export ANTHROPIC_BASE_URL="https://gpt.cherrychat.org" export ANTHROPIC_AUTH_TOKEN="sk-your-key" export ANTHROPIC_MODEL="claude-sonnet-5-5" export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-5-5" claudePermanent (setx, then reopen PowerShell)
setx ANTHROPIC_BASE_URL "https://gpt.cherrychat.org" setx ANTHROPIC_AUTH_TOKEN "sk-your-key" setx ANTHROPIC_MODEL "claude-sonnet-5-5" setx ANTHROPIC_DEFAULT_HAIKU_MODEL "claude-haiku-5-5"This window only
$env:ANTHROPIC_BASE_URL = "https://gpt.cherrychat.org" $env:ANTHROPIC_AUTH_TOKEN = "sk-your-key" $env:ANTHROPIC_MODEL = "claude-sonnet-5-5" $env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "claude-haiku-5-5" claudeVerify the connection
Open a new terminal, go to your project folder and run the command below; a reply means it works. Inside claude, type /status: the "Anthropic base URL" line should show https://gpt.cherrychat.org and the "Auth token" line should name ANTHROPIC_AUTH_TOKEN.
If it asks you to log in
A login screen means Claude Code did not pick up ANTHROPIC_AUTH_TOKEN. Make sure you started it from a terminal opened after the change, or use option 1 and put it in ~/.claude/settings.json. You do not need an Anthropic account. If you used to sign in with claude.ai and see a warning about two credentials, run /logout inside Claude Code.
Use it in the VS Code extension (optional)
The VS Code extension checks credentials before it starts, so add them to VS Code settings too: press Cmd/Ctrl + Shift + P, run "Preferences: Open User Settings (JSON)", add the block below inside the outer braces, save and restart VS Code.
"claudeCode.environmentVariables": [ { "name": "ANTHROPIC_BASE_URL", "value": "https://gpt.cherrychat.org" }, { "name": "ANTHROPIC_AUTH_TOKEN", "value": "sk-your-key" }, { "name": "ANTHROPIC_MODEL", "value": "claude-sonnet-5-5" }, { "name": "ANTHROPIC_DEFAULT_HAIKU_MODEL", "value": "claude-haiku-5-5" } ]
Common pitfalls
- Use the domain only (https://gpt.cherrychat.org), without /v1. Claude Code appends /v1/messages itself.
- Put the key in ANTHROPIC_AUTH_TOKEN. Do not also set ANTHROPIC_API_KEY; the two conflict.
- Never put the key in a project's .claude/settings.json; it gets committed with the code. Use ~/.claude/settings.json in your home folder.
- When both settings.json and shell variables are set, settings.json wins; update both when you change the key.
- ANTHROPIC_SMALL_FAST_MODEL is the old, deprecated name; current versions use ANTHROPIC_DEFAULT_HAIKU_MODEL (set both on very old versions). To switch Opus / Sonnet with /model, also set ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5 and ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5-5.
- Claude Code's built-in WebSearch tool is not supported yet, and the Claude desktop app ignores these settings. This guide covers the CLI and the VS Code / JetBrains extensions.
Error → cause → fix
| What you see | Why | What to do |
|---|---|---|
| HTTP 401 / Invalid bearer token | The key is mistyped, has extra spaces, or was disabled / deleted; or it went into ANTHROPIC_API_KEY by mistake | Copy the key again from My Keys on the API page into ANTHROPIC_AUTH_TOKEN, then retry in a new terminal |
| HTTP 404 Not Found | ANTHROPIC_BASE_URL was set to https://gpt.cherrychat.org/v1 or includes /messages, so the path is doubled | Change it to the domain only: https://gpt.cherrychat.org |
| "There's an issue with the selected model" or model not found | ANTHROPIC_MODEL is misspelled (case, spaces) or names a model CherryChat does not offer | Use a name from the Models page, e.g. claude-sonnet-5-5 (all lowercase) |
| 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 |
| Spins for a long time, then a connection error or timeout (ECONNREFUSED, ENOTFOUND, timeout) | The address is misspelled, is missing https://, or your network cannot reach the domain | Open https://gpt.cherrychat.org/v1/models in a browser. Any JSON reply, even an error, means the network path works; then recheck the address in the tool character by character |
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
