Home›Developer Center›Claude Code CLI Windows

Claude Code CLI Windows

API DocumentationOpenAI ChatGPT APIAnthropic (Claude) APIGoogle Gemini APIGoogle Search APIGoogle News APIOpenRouter APIAPI Pricing
CLI & Agent Guidescc-switch macOScc-switch Windowscc-switch LinuxOpenCode macOSOpenCode WindowsOpenCode LinuxOpenClaw macOSOpenClaw WindowsOpenClaw LinuxHermes Agent macOSHermes Agent WindowsHermes Agent LinuxClaude Code CLI macOSClaude Code CLI WindowsClaude Code CLI LinuxCodex CLI macOSCodex CLI WindowsCodex CLI Linux
MYAI168 API & MCPMYAI168 MCP CLIMYAI168 MCP Web & App
No matching questions on this page.Search the whole site
Installation Overview (Windows)

Claude Code CLI Installation and MYAI168 Setup Guide — Windows

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.

Endpoint and Model (the most critical part)

  • Endpoint: https://www.myai168.com/en/api/anthropic (do not append /v1 at the end)
  • Model: claude-opus-4-8

The 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.)

Important Security Notes

  • Claude Code can read, write, and execute files in the working directory. For real use, cd into a project folder before launching it; do not launch it in your home directory.
  • Treat your API key like a password and never leak it; if it leaks, revoke and replace it in the MYAI168 console.
0.5 Install Node.js (if not installed)

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:

  • Method A (recommended): go to https://nodejs.org, download the LTS Windows installer (.msi), double-click and click Next all the way through, then "close and reopen PowerShell" and check node --version again.
  • Method B (fallback): 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.

1. Install Claude Code and Clean Up Leftovers

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
2. Create the apiKeyHelper (the key-supply method this guide uses)
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"
3. Configure MYAI168 (Method A: cc-switch, recommended)
  • Open cc-switch and click the "Claude Code" tab at the top.
  • Click "+" to add, and choose Custom Configuration.
  • Basic fields:
    • Provider Name: myai168-claude
    • API Key: your key
    • API Endpoint: https://www.myai168.com/en/api/anthropic (without /v1)
  • Expand Advanced Options:
    • API Format: Anthropic Messages (Native)
    • Auth Field: ANTHROPIC_API_KEY (do not choose AUTH_TOKEN)
  • Model Mapping: set the Requested model for Sonnet / Opus / Fable / Haiku all to 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.)
  • Config JSON area: confirm it contains apiKeyHelper (pointing to the .cmd from "2. Create the apiKeyHelper"). If not, paste:
    {
      "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"
    }
  • Click Save → Enable it on the card.

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.

3-B. Configure MYAI168 (Method B: manual, fallback)
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.)

4. Launch and Verify

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.

5. Quick Troubleshooting

"Model does not exist / It may not exist or you may not have access"

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").

Not logged in / Please run /login

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.

Auth conflict warning

Both apiKeyHelper and ANTHROPIC_API_KEY are set. Remove ANTHROPIC_API_KEY from env / your shell.

401 / developer key is wrong

Wrong key. Check that the key inside the helper script is correct and has no extra spaces.

Replies fail with 404 / not found

(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.

.local\bin\claude.exe missing or broken (Windows)

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.

claude command not found (new terminal)

macOS: source ~/.zshrc or reopen the terminal. Windows: open a new PowerShell so PATH takes effect.

Switch / confirm the model

Use /model to switch during a conversation; use /status to confirm the endpoint and model.

6. Maintenance and Security

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

Change the API Key (after a leak or for regular rotation)

  1. Revoke the old key and create a new one in the MYAI168 console.
  2. Windows: edit the string after echo in %USERPROFILE%\.claude\api-key-helper.cmd.
  3. If you use cc-switch, also update the API Key on the card and Enable it again.

Config File Locations (Windows)

  • %USERPROFILE%\.claude\settings.json
  • %USERPROFILE%\.claude\api-key-helper.cmd

Official Docs

  • https://code.claude.com/docs/en/authentication
  • https://docs.claude.com/en/docs/claude-code/overview
‹ Previous page: Claude Code CLI macOSNext page: Claude Code CLI Linux ›
↑
Question link copied.

Other FAQ pages

API Documentation

  • OpenAI ChatGPT API
  • Anthropic (Claude) API
  • Google Gemini API
  • Google Search API
  • Google News API
  • OpenRouter API
  • API Pricing

CLI & Agent Guides

  • cc-switch macOS
  • cc-switch Windows
  • cc-switch Linux
  • OpenCode macOS
  • OpenCode Windows
  • OpenCode Linux
  • OpenClaw macOS
  • OpenClaw Windows
  • OpenClaw Linux
  • Hermes Agent macOS
  • Hermes Agent Windows
  • Hermes Agent Linux
  • Claude Code CLI macOS
  • Claude Code CLI Linux
  • Codex CLI macOS
  • Codex CLI Windows
  • Codex CLI Linux

MYAI168 API & MCP

  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App