Skip to content

Install Claude Code on macOS ​

0. Prerequisite: install Node.js ​

Install Node.js first (22+ recommended): Node.js on macOS

Verify: run each of these

bash
node -v
bash
npm -v

If you see version numbers, Node.js is installed.

1. Install Claude Code ​

Step 1: open Terminal (press Command + Space, type Terminal, hit Enter)

Step 2: run the install command

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

Step 3: check the install

bash
claude --version

If you see a version number, it's installed.

2. Connect to Flash API ​

All Claude Code config lives in ~/.claude/settings.json. No environment variables to set.

2.1 Create the config directory ​

bash
mkdir -p ~/.claude

2.2 Write the config file (replace the API key) ​

bash
cat > ~/.claude/settings.json << 'EOF'
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://ai.flashapi.top",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_FLASH_API_KEY",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
EOF

You must replace YOUR_FLASH_API_KEY with the real key you copied from the Flash API console.

How:

  1. Copy the whole command above
  2. Replace YOUR_FLASH_API_KEY with your real key
  3. Paste it into the terminal and run it

What the settings do:

  • ANTHROPIC_BASE_URL: the Flash API endpoint, without /v1
  • ANTHROPIC_AUTH_TOKEN: your API key
  • CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: turns off nonessential traffic to cut unneeded network requests

2.3 Check the file was created ​

bash
cat ~/.claude/settings.json

You should see what you just wrote.

3. Launch and verify ​

Step 1: go to your project directory

bash
cd /path/to/your/project

Replace /path/to/your/project with your actual project path.

Step 2: start Claude Code

bash
claude

Optional: run a health check first

bash
claude doctor

Troubleshooting ​

1. Permission error on npm install -g ​

Cause: you don't have permission to install global packages.

Fix:

  • Don't force it with sudo npm install -g
  • Reinstall Node.js with Homebrew instead; see Node.js on macOS
  • Node.js installed via Homebrew doesn't need sudo

2. claude command not found ​

Cause: the global npm package path isn't on your PATH.

Fix:

  1. Check Node.js is installed correctly: node -v
  2. Restart your terminal
  3. Still failing? Reinstall Claude Code

One base URL for GPT, Claude and Gemini