我用 Kimi K2 替换了 Claude Code 默认模型,效果还不错,梳理了一下教程
完整内容移步至我的个人博客:我用 Kimi K2 替换了 Claude Code 默认模型 | jonssonyan's Website
以 MacOS M4 系统为例
1. 先去月之暗面的开发者后台申请 API Key,注册默认送 ¥15
2. 安装 Node.js
版本 >= 18
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"
# Download and install Node.js:
nvm install 18
# Verify the Node.js version:
node -v # Should print "v18.20.8".
nvm current # Should print "v18.20.8".
# Verify npm version:
npm -v # Should print "10.8.2".
3. 安装 Claude Code
npm install -g @anthropic-ai/claude-code
4. 添加环境变量
cat << 'EOF' >> ~/.zshrc
# claude code
export ANTHROPIC_BASE_URL=https://api.moonshot.cn/anthropic/
export ANTHROPIC_API_KEY=$YOUR_API_KEY
EOF
$YOUR_API_KEY 就是我们第 1 步在月之暗面后台申请的 API Key
这样我们就把 Claude Code 默认的模型替换为 Kimi K2
5. 绕过 Claude Code 认证
打开项目文件夹,终端启动 Claude Code
cd your_project
claude
这时候就会弹出登录认证网页。
我们只需要编辑 $HOME/.claude.json 添加新字段"hasCompletedOnboarding": true即可
最后我们在终端启动 claude 就可以开始对话了。
5. V50 看看实力
月之暗面 Free 账户默认“并发 1”,至少累计冲 50 解锁“并发 50” 才能完全发挥 Claude Code 的实力。
这类 编程类的 AI Agent,背后有很多流程,我们只是把“决策大脑”从 Claude AI 替换成了 Kimi K2,其他的都还是用 Clade Code 自己的。如果想要了解 AI Agent 背后原理,可以看我写的 一文读懂 AI 应用核心:Agent、LLM、RAG、MCP、Function Call




