Goal of this guide: install the Claude Code CLI on macOS, connect it to your own MYAI168 API, and use Claude Opus 4.8.
Claude Code speaks the Anthropic Messages protocol and connects to MYAI168's native Anthropic endpoint — no proxy needed. The key is supplied via an apiKeyHelper script — this is NOT a required setting (Claude Code officially supports setting the ANTHROPIC_API_KEY environment variable directly; apiKeyHelper is officially intended for dynamic / rotating credentials). This guide uses it so the key stays out of your shell environment variables and is easy to replace in one place.
https://www.myai168.com/en/api/anthropic (do not append /v1 at the end)claude-opus-4-8The base_url must end with .../anthropic — "never add /v1". Claude Code appends /v1/messages by itself; if the URL already contains /v1 the path becomes wrong, and you get a misleading "model does not exist" error. (This is the most common pitfall.)
Node.js 22 or later (required by the official npm package as of v2.1.198; on older Node the install prints an EBADENGINE warning).
First check whether it is already installed:
claude --version
If you see a version number, skip to "2. Create the apiKeyHelper". If it shows command not found, install via npm:
npm install -g @anthropic-ai/claude-code
After installing, make the command available and confirm:
source ~/.zshrc
claude --version
(If it is still command not found, it is usually because PATH has not taken effect — reopen a terminal window and try again.)
This guide supplies the key via an apiKeyHelper whether you use cc-switch or configure manually (it is not an official requirement — Claude Code also supports setting the ANTHROPIC_API_KEY environment variable directly; to follow this guide's flow, create it first):
mkdir -p ~/.claude
Create the key script (copy the whole block, paste it into the terminal, and press Enter once; replace the key with your real MYAI168 key):
cat > ~/.claude/api-key-helper.sh << 'EOF'
#!/bin/bash
echo "your-MYAI168-key"
EOF
chmod +x ~/.claude/api-key-helper.sh
Verify it outputs the key (it should print your key string):
~/.claude/api-key-helper.sh
cc-switch is a cross-platform GUI; the macOS interface is the same as on Windows. (For installation, see the "cc-switch macOS" page in the Developer Center.)
myai168-claudehttps://www.myai168.com/en/api/anthropic (without /v1)Anthropic Messages (Native)ANTHROPIC_API_KEY (do not choose AUTH_TOKEN)claude-opus-4-8; set the Default fallback model to claude-opus-4-8 as well.{
"apiKeyHelper": "/Users/your-account/.claude/api-key-helper.sh",
"env": {
"ANTHROPIC_BASE_URL": "https://www.myai168.com/en/api/anthropic",
"ANTHROPIC_MODEL": "claude-opus-4-8"
}
}
Verify the config file written by cc-switch (key points: the base URL does not contain /v1, apiKeyHelper is present, and ANTHROPIC_API_KEY is used):
cat ~/.claude/settings.json
If you do not use cc-switch, create settings.json directly from the terminal (replace annie91 in the path with your macOS username, which you can find with whoami; paste the whole block and press Enter):
cat > ~/.claude/settings.json << 'EOF'
{
"apiKeyHelper": "/Users/annie91/.claude/api-key-helper.sh",
"env": {
"ANTHROPIC_BASE_URL": "https://www.myai168.com/en/api/anthropic",
"ANTHROPIC_MODEL": "claude-opus-4-8"
}
}
EOF
Important: once you use apiKeyHelper, do NOT also export ANTHROPIC_API_KEY, otherwise Claude Code shows an Auth conflict warning. If ~/.zshrc has old Claude Code functions / exports, remove them.
(Reminder again: the base URL ends with .../anthropic, without /v1.)
Open a "brand-new" terminal window (to avoid leftover environment variables interfering) and just type:
claude
(Do not pass any environment variables; apiKeyHelper provides the key automatically.)
First-run screens: color theme → pick one; Security notes → Enter; Terminal setup → 1. Yes; Trust this folder? → 1. Yes. You should go straight to the "Welcome back" main screen, without a login menu.
Verify: type /status and confirm the base URL is MYAI168 and the Model is claude-opus-4-8. Then ask a question; getting a reply means success (the bottom-left corner shows Opus 4.8 · API Usage Billing, meaning API-key billing rather than an official subscription).
Most common cause: /v1 was appended to the base_url. Change it to .../anthropic (without /v1). Second cause (Windows): a leftover .claude.json.backup interferes → delete it (Remove-Item -Force "$env:USERPROFILE\.claude.json.backup").
The apiKeyHelper is missing, or the helper does not output the key. Confirm the script exists, is executable (chmod +x on macOS), and settings.json has the apiKeyHelper field. The login menu only accepts official accounts — do not use it; skip it via apiKeyHelper.
Both apiKeyHelper and ANTHROPIC_API_KEY are set. Remove ANTHROPIC_API_KEY from env / your shell.
Wrong key. Check that the key inside the helper script is correct and has no extra spaces.
(Only when you have confirmed /v1 was not added and you still get 404) try changing the base URL to .../anthropic/v1 and test again; normally keep it without /v1.
macOS: source ~/.zshrc or reopen the terminal. Windows: open a new PowerShell so PATH takes effect.
Use /model to switch during a conversation; use /status to confirm the endpoint and model.
Update (the official docs say to use install @latest and to avoid npm update -g — it respects the semver range from the original install and may not move you to the newest release):
npm install -g @anthropic-ai/claude-code@latest
~/.claude/api-key-helper.sh.~/.claude/settings.json: endpoint and apiKeyHelper settings.~/.claude/api-key-helper.sh: the script that provides the key.