Goal of this guide: install Claude Code CLI on macOS and connect it to your own MYAI168 API, using Claude Opus 4.8.
Claude Code only speaks the Anthropic Messages protocol, so any provider with an Anthropic-compatible endpoint can be connected directly — no proxy needed. MYAI168 has a native Anthropic endpoint, which is a perfect fit.
Claude Code's interactive mode has one limitation —— without a pre-existing login record, it still forces the login screen even if you set the API key via an environment variable. This guide therefore uses the official apiKeyHelper mechanism to bypass login, which is the most stable and reliable approach.
Endpoint https://www.myai168.com/en/api/anthropic
Model claude-opus-4-8
First check whether it is already installed:
claude --version
If you see a version number, skip to the next section. 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.)
Make sure the settings folder exists:
mkdir -p ~/.claude
Copy the whole block below, 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 the script outputs the key correctly:
~/.claude/api-key-helper.sh
It should print your key string, which means success.
Again, paste the whole block and press Enter (replace annie91 in the path with your macOS username, which you can find with whoami):
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
Once you use apiKeyHelper, do NOT also export ANTHROPIC_API_KEY in ~/.zshrc or your shell, otherwise Claude Code will show an Auth conflict warning. If you previously added a function or export in .zshrc pointing to Claude Code, edit ~/.zshrc and remove them.
Open "a brand-new terminal window" (to avoid leftover old environment variables interfering) and just type:
claude
(Do not pass any environment variables; apiKeyHelper will provide the key automatically.)
On first launch, a few screens appear in sequence — handle them as follows:
On success, you go straight to the "Welcome back" main screen, without a login menu popping up.
Once on the main screen, verify:
/status
Confirm: no /login is requested, the Anthropic base URL is MYAI168, and the Model is claude-opus-4-8.
Then ask a question to test:
Hello, please tell me which model you are using
If it replies normally and reports the model as Claude Opus 4.8, the connection succeeded. The bottom-left of the main screen shows "Opus 4.8 · API Usage Billing"; "API Usage Billing" means it is using API-key billing (your MYAI168), not an official subscription.
Once set up, just type claude as usual and it goes through MYAI168 — no extra commands needed.
For actual development, enter the project folder before launching:
cd ~/your-project-folder
claude
To switch back to the official subscription: remove the apiKeyHelper line from ~/.claude/settings.json, then run /login again.
Interactive mode needs apiKeyHelper to skip login. Make sure both files in section 2 were created correctly, and that you opened a brand-new terminal window. Press Esc to temporarily skip the menu.
The key is wrong. Check whether the key inside api-key-helper.sh is the real key, with no extra spaces or placeholder text.
The key was not read. Usually the helper script lacks execute permission (rerun chmod +x), or the path is wrong, or there is a leftover environment-variable conflict (try a new window).
Both apiKeyHelper and ANTHROPIC_API_KEY are set. Remove the ANTHROPIC_API_KEY export from your shell.
An endpoint-path issue. Change ANTHROPIC_BASE_URL in settings.json to .../anthropic/v1 (add /v1) and try again.
Use /model in the conversation; or change ANTHROPIC_MODEL in settings.json.
Type /status inside Claude Code.
Update Claude Code:
npm update -g @anthropic-ai/claude-code
~/.claude/settings.json: endpoint and apiKeyHelper settings.~/.claude/api-key-helper.sh: the script that provides the key.