Goal of this guide: install the Claude Code CLI on Windows, 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.)
First check in PowerShell:
node --version
npm --version
If Node is version 22 or later (required by the official Claude Code npm package), skip to "1. Install Claude Code and Clean Up Leftovers". If it is older than 22 or you get "command not recognized", install / upgrade as follows:
node --version again.winget install OpenJS.NodeJS.LTS, then reopen PowerShell after it finishes.Note: if Node was bundled by another tool (such as Hermes), Node disappears when that tool is removed. Installing Node independently is more stable.
If PowerShell's execution policy blocks you, allow scripts first (affects the current user only):
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
Install:
npm install -g @anthropic-ai/claude-code
Remove leftovers that may interfere (recommended before a fresh install):
Remove-Item -Force "$env:USERPROFILE\.claude.json.backup" -ErrorAction SilentlyContinue
* If %USERPROFILE%\.local\bin\claude.exe also exists, check where it came from before deleting anything — that location is exactly where the official native installer puts Claude Code. If you installed with the official native installer (or are not sure), keep it and simply use it (you can skip the npm install above). Only delete it (Remove-Item -Force "$env:USERPROFILE\.local\bin\claude.exe") if you are sure you want the npm version and that file is a broken or stale native leftover. With both installed, PATH order decides which one runs — check with Get-Command claude.
Open a new PowerShell and verify:
claude --version
notepad $env:USERPROFILE\.claude\api-key-helper.cmd
(Notepad asks whether to create the file → Yes; if the folder does not exist, run mkdir $env:USERPROFILE\.claude first.)
Paste these two lines (replace with your real key) and save:
@echo off
echo your-MYAI168-key
Verify (it should print your key):
cmd /c "$env:USERPROFILE\.claude\api-key-helper.cmd"
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. (Recommended for third-party endpoints — otherwise background subtasks use the original model names and fail.){
"apiKeyHelper": "C:\\Users\\your-account\\.claude\\api-key-helper.cmd",
"env": {
"ANTHROPIC_BASE_URL": "https://www.myai168.com/en/api/anthropic",
"ANTHROPIC_MODEL": "claude-opus-4-8"
},
"theme": "dark"
}
Verify the config file that was written:
Get-Content $env:USERPROFILE\.claude\settings.json
Key points: the base URL does not contain /v1, apiKeyHelper is present, and ANTHROPIC_API_KEY is used.
notepad $env:USERPROFILE\.claude\settings.json
Paste the following (replace the account with yours; do not put ANTHROPIC_API_KEY in env — the helper provides it):
{
"apiKeyHelper": "C:\\Users\\your-account\\.claude\\api-key-helper.cmd",
"env": {
"ANTHROPIC_BASE_URL": "https://www.myai168.com/en/api/anthropic",
"ANTHROPIC_MODEL": "claude-opus-4-8"
},
"theme": "dark"
}
Save. (Reminder again: the base URL ends with .../anthropic, without /v1.)
Open a "brand-new" PowerShell (do not set any ANTHROPIC_* variables separately, to avoid conflicting with the helper):
mkdir $env:USERPROFILE\cc-test -Force
cd $env:USERPROFILE\cc-test
claude
First-run screens: a question about a detected environment key → does not matter; theme → pick one; Security notes → Enter; Trust this folder? → 1. Yes.
Ask a question on the main screen; getting a reply means success (the bottom-left corner shows Opus 4.8 · API Usage Billing). Type /status — it should show the MYAI168 base URL and claude-opus-4-8 as the Model.
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.
Check its origin before acting — that location is exactly where the official native installer puts Claude Code. If it is your active official native install, do NOT delete it; run claude update to repair it instead. Only delete the file (Remove-Item -Force "$env:USERPROFILE\.local\bin\claude.exe") if you use the npm version and have confirmed the file is a broken native leftover. Use Get-Command claude to see which copy actually runs.
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
%USERPROFILE%\.claude\api-key-helper.cmd.%USERPROFILE%\.claude\settings.json%USERPROFILE%\.claude\api-key-helper.cmd