一、注册领取免费额度
免费领取Claude Code $100 额度,可用Claude4-Opus,手慢无!
👉 链接地址:anyrouter.top/register?af...
添加API令牌(后面要用):
注册后在 API令牌 页面点击 添加令牌
获得(以 sk- 开头)
名称随意,额度建议设为无限额度,其他保持默认设置即可
二、安装 Node.js(已安装可跳过)
确保 Node.js 版本 ≥ 18.0
bash
# Windows 用户需要先安装WSL2,再安装Ubuntu。可以参考我以前的文章:Windows安装WSL2
# Ubuntu / Debian 用户
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo bash -
sudo apt-get install -y nodejs
node --version
# macOS 用户
sudo xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install node
node --version
三、安装 Claude Code
bash
# 安装 Claude Code
sudo npm install -g @anthropic-ai/claude-code
# 查看版本
claude --version
四、配置环境变量
为避免每次重复输入,将环境变量写入 bash_profile 和 bashrc 将sk-xxx替换为前面获取的API令牌:
bash
echo -e '\n export ANTHROPIC_AUTH_TOKEN=sk-xxx' >> ~/.bash_profile
echo -e '\n export ANTHROPIC_BASE_URL=https://anyrouter.top' >> ~/.bash_profile
echo -e '\n export ANTHROPIC_AUTH_TOKEN=sk-xxx' >> ~/.bashrc
echo -e '\n export ANTHROPIC_BASE_URL=https://anyrouter.top' >> ~/.bashrc
echo -e '\n export ANTHROPIC_AUTH_TOKEN=sk-xxx' >> ~/.zshrc
echo -e '\n export ANTHROPIC_BASE_URL=https://anyrouter.top' >> ~/.zshrc
五、使用 Claude Code
重启终端后,直接使用:
bash
# 默认工作目录为home,也可以切换到你的工程目录
cd your-project-folder
# 启动Claude Code
claude
首次运行: 选择你喜欢的主题 + Enter 确认安全须知 + Enter 使用默认 Terminal 配置 + Enter 信任工作目录 + Enter
开始在终端里和你的 AI 编程搭档一起写代码吧!🚀

我试着用它写了个贪吃蛇小游戏,也就用了1分钟,耗费$0.1,还行
选择模型:
bash
/model
默认的模型是Claude 4 Sonnet
💡 省钱小贴士:对于日常任务,推荐使用 Claude 4 Sonnet,费率仅为 Claude 4 Opus 的 1/5;对于有挑战性的任务,可以使用更强大的 Claude 4 Opus
👉 关注公众号"北灵聊AI",一个专注于技术的博主