Support QQ group1098515135

Install and configure Claude Code

Install the official Claude Code, then import with CC Switch or set the environment variables shown below.

What is CC Switch

CC Switch is a provider switcher for command-line tools such as Claude Code and Codex. It keeps endpoints, keys and models on your machine and lets you switch with one click.

  • Easier than editing environment variables and config files when you use several models and tools.
  • Click "Import to CC Switch" on the API keys page and the browser hands the configuration to it.
  • Not required: you can also use the manual setup below.

Pick a model that provides the Anthropic API

Claude Code uses the Anthropic Messages API, so only models that provide it will work. The import dialog lists only such models; for manual setup choose one of them as ANTHROPIC_MODEL.

You can connect without CC Switch

Write the endpoint and key into the tool's own configuration. Copy the key from the API keys page and replace YOUR_API_KEY below.

Requirements

  • macOS 12 or later with Terminal or iTerm2
  • Node.js 18 or later

Install and connect

  1. 1Check your Node.js version

    node -v
  2. 2Install Claude Code

    Use the official npm package.

    npm install -g @anthropic-ai/claude-code
  3. 3Import with CC Switch (recommended)

    Install it first (see the CC Switch guide), then click "Import to CC Switch" on the API keys page and choose Claude Code.

Manual setup without CC Switch

  1. 1Set the environment variables

    The endpoint has no /v1; Claude Code adds it. Replace YOUR_MODEL with a model from the market that provides the Anthropic API. All three tiers (Haiku, Sonnet, Opus) point to it, otherwise background tasks request models that do not exist here. Use ~/.bashrc instead of ~/.zshrc if you use bash.

    printf '\nexport ANTHROPIC_BASE_URL="https://api.latticehub.cc"\n' >> ~/.zshrc
    printf 'export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY"\n' >> ~/.zshrc
    printf 'export ANTHROPIC_MODEL="YOUR_MODEL"\n' >> ~/.zshrc
    printf 'export ANTHROPIC_DEFAULT_HAIKU_MODEL="YOUR_MODEL"\n' >> ~/.zshrc
    printf 'export ANTHROPIC_DEFAULT_SONNET_MODEL="YOUR_MODEL"\n' >> ~/.zshrc
    printf 'export ANTHROPIC_DEFAULT_OPUS_MODEL="YOUR_MODEL"\n' >> ~/.zshrc
    source ~/.zshrc

Check: Reopen your terminal and run claude. If it answers, you are connected.