Home›Developer Center›Claude Code CLI Linux

Claude Code CLI Linux

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 (Linux)

Claude Code CLI Installation and MYAI168 Setup Guide — Linux

Goal of this guide: install the Claude Code CLI on a Linux desktop, connect it to your own MYAI168 API, and use Claude Opus 4.8. (Ubuntu / Debian as the example.)

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.

The setup logic is the same as on macOS (apiKeyHelper + settings.json, base_url without /v1); use the Linux home-directory paths, and the shell config file depends on your shell.

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 and Check Your Shell

First check Node (the official Claude Code npm package requires Node.js 22 or later; upgrade if yours is older):

node --version
npm --version

If missing, install it (Ubuntu / Debian):

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

Check your shell: echo $SHELL — bash → ~/.bashrc; zsh → ~/.zshrc.

1. Install Claude Code

Do not use sudo. If you hit an npm permission error, point the npm global directory to your home directory, then install:

npm install -g @anthropic-ai/claude-code

Verify:

claude --version

(If the command is not found: make sure ~/.local/bin or ~/.npm-global/bin is in PATH; for example:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

then check again.)

2. Create the apiKeyHelper

Create the key script (paste the whole block and press Enter once; replace the key with your real MYAI168 key):

mkdir -p ~/.claude
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
3. Configure MYAI168 (Method A: cc-switch, recommended)

cc-switch is a cross-platform GUI; the Linux desktop interface is the same as on other platforms. (For installation, see the "cc-switch Linux" page in the Developer Center.)

  • 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.
  • Config JSON area: make sure it contains apiKeyHelper (pointing to the script from "2. Create the apiKeyHelper"). If not, fix it to:
    {
      "apiKeyHelper": "/home/your-account/.claude/api-key-helper.sh",
      "env": {
        "ANTHROPIC_BASE_URL": "https://www.myai168.com/en/api/anthropic",
        "ANTHROPIC_MODEL": "claude-opus-4-8"
      }
    }
  • Click Save → Enable it on the card.

Verify the config file that was written (key points: the base URL does not contain /v1, apiKeyHelper is present, and ANTHROPIC_API_KEY is used):

cat ~/.claude/settings.json
3-B. Configure MYAI168 (Method B: manual, fallback)

Write settings.json with a heredoc (paste the whole block and press Enter; replace the account in the path with yours, which you can find with whoami):

cat > ~/.claude/settings.json << 'EOF'
{
  "apiKeyHelper": "/home/your-account/.claude/api-key-helper.sh",
  "env": {
    "ANTHROPIC_BASE_URL": "https://www.myai168.com/en/api/anthropic",
    "ANTHROPIC_MODEL": "claude-opus-4-8"
  }
}
EOF

Note: once you use apiKeyHelper, do NOT also export ANTHROPIC_API_KEY, otherwise you get an Auth conflict.

(The Linux home directory is usually /home/account; if unsure, confirm with echo $HOME.)

4. Launch and Verify

Open a "brand-new" terminal (do not export any ANTHROPIC_* variables separately):

mkdir -p ~/cc-test
cd ~/cc-test
claude

After the first-run screens (theme, security, trust folder), type /status to confirm the endpoint and model, then ask a question; getting a reply means success.

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

Switch / confirm the model

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

6. Maintenance

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

Config File Locations (Linux)

  • ~/.claude/settings.json
  • ~/.claude/api-key-helper.sh

Official Docs

  • https://code.claude.com/docs/en/authentication
  • https://docs.claude.com/en/docs/claude-code/overview
‹ Previous page: Claude Code CLI WindowsNext page: Codex CLI macOS ›
↑
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 Windows
  • Codex CLI macOS
  • Codex CLI Windows
  • Codex CLI Linux

MYAI168 API & MCP

  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App