Kimi K2 × Claude Code 接入指南

前言

朋友rockets推荐了一个链接Kimi K2 × Claude Code 接入指南,真的丝滑 ,我根据文档操作了一下,在树莓派5上部署成功了,于是便有了这篇文档。

部署步骤

  • 第一步:安装Node.js
  • 第二步:安装Claude Code
  • 第三步:接入Kimi K2
  • 第四步:充值加速

第一步:安装Node.js

  • 树莓派5 最新操作系统
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm
pi@raspberrypi:~ $
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 6.12.34+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.12.34-1+rpt1~bookworm (2025-06-26) aarch64 GNU/Linux
pi@raspberrypi:~ $

````

* 安装Node.js 

```bash
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo bash -
sudo apt -y install nodejs 
node --version 
  • 安装过程如下:

pi@raspberrypi:~ $ curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo bash -
2025-08-06 16:11:17 - Installing pre-requisites
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian-security bookworm-security InRelease
Hit:3 http://deb.debian.org/debian bookworm-updates InRelease
Hit:4 http://archive.raspberrypi.com/debian bookworm InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ca-certificates is already the newest version (20230311+deb12u1).
curl is already the newest version (7.88.1-10+deb12u12).
gnupg is already the newest version (2.2.40-1.1).
gnupg set to manually installed.
The following NEW packages will be installed:
  apt-transport-https
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 25.2 kB of archives.
After this operation, 35.8 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main arm64 apt-transport-https all 2.6.1 [25.2 kB]
Fetched 25.2 kB in 0s (155 kB/s)
Selecting previously unselected package apt-transport-https.
(Reading database ... 175579 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_2.6.1_all.deb ...
Unpacking apt-transport-https (2.6.1) ...
Setting up apt-transport-https (2.6.1) ...
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian-security bookworm-security InRelease
Hit:3 http://deb.debian.org/debian bookworm-updates InRelease
Hit:4 http://archive.raspberrypi.com/debian bookworm InRelease
Get:5 https://deb.nodesource.com/node_22.x nodistro InRelease [12.1 kB]
Get:6 https://deb.nodesource.com/node_22.x nodistro/main arm64 Packages [7,388 B]
Fetched 19.5 kB in 1s (15.9 kB/s)
Reading package lists... Done
2025-08-06 16:11:26 - Repository configured successfully.
2025-08-06 16:11:26 - To install Node.js, run: apt-get install nodejs -y
2025-08-06 16:11:26 - You can use N|solid Runtime as a node.js alternative
2025-08-06 16:11:26 - To install N|solid Runtime, run: apt-get install nsolid -y

pi@raspberrypi:~ $
pi@raspberrypi:~ $ sudo apt -y install nodejs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 35.7 MB of archives.
After this operation, 223 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_22.x nodistro/main arm64 nodejs arm64 22.18.0-1nodesource1 [35.7 MB]
Fetched 35.7 MB in 7s (5,288 kB/s)
Selecting previously unselected package nodejs.
(Reading database ... 175583 files and directories currently installed.)
Preparing to unpack .../nodejs_22.18.0-1nodesource1_arm64.deb ...
Unpacking nodejs (22.18.0-1nodesource1) ...
Setting up nodejs (22.18.0-1nodesource1) ...
Processing triggers for man-db (2.11.2-2) ...
pi@raspberrypi:~ $
  • 检查版本:
node --version 
  • 结果:
pi@raspberrypi:~ $ node --version
v22.18.0
pi@raspberrypi:~ $

第二步:安装Claude code

安装pnpm然后安装Claude code.

sudo npm install --global pnpm
  • 安装效果:
pi@raspberrypi:~ $  sudo npm install --global pnpm

added 1 package in 10s

1 package is looking for funding
  run `npm fund` for details
npm notice
npm notice New major version of npm available! 10.9.3 -> 11.5.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.5.2
npm notice To update run: npm install -g npm@11.5.2
npm notice
  • 安装Claude-code
pnpm setup
  • 结果:
pi@raspberrypi:~ $ pnpm setup
Appended new lines to /home/pi/.bashrc

Next configuration changes were made:
export PNPM_HOME="/home/pi/.local/share/pnpm"
case ":$PATH:" in
  *":$PNPM_HOME:"*) ;;
  *) export PATH="$PNPM_HOME:$PATH" ;;
esac

To start using pnpm, run:
source /home/pi/.bashrc
pi@raspberrypi:~ $
  • 初始化
source ~/.bashrc
  • 安装Claude code
pnpm install -g @anthropic-ai/claude-code
  • 安装结果:
pi@raspberrypi:~ $ pnpm install -g @anthropic-ai/claude-code
Packages: +3
+++
Downloading @img/sharp-libvips-linux-arm64@1.0.4: 7.10 MB/7.10 MB, done
Downloading @anthropic-ai/claude-code@1.0.69: 56.46 MB/56.46 MB, done
Progress: resolved 12, reused 0, downloaded 3, added 3, done

/home/pi/.local/share/pnpm/global/5:
+ @anthropic-ai/claude-code 1.0.69

Done in 13.2s using pnpm v10.14.0
  • 版本检查
pi@raspberrypi:~ $
pi@raspberrypi:~ $ claude --version
1.0.69 (Claude Code)
pi@raspberrypi:~ $
  • Claude 初始化 由于这玩意儿涉及科学上网,没有过墙梯会遇到这个问题:

00

挂好梯子后,直接再执行:claude

01

不要犹豫,直接选择2,第一个是要claude账号,妈蛋国内还注册不了。注册要钱不说还可能被封。

02

然后提示要sign in,复制链接到能翻墙的浏览器上去授权一下。

03

第一次可能会让你初始化一下,我这里已经配置过了,就是那个javis‘s 的组织,你自己顶一个personal的就行。

04

然后就会看到一个Claude code 的验证码,把它贴回终端中去。

05

如图:

06

成功就会看到login successful.

07

警告直接忽略回车即可。

08

询问是否信任目录的文件,我这里先退出了,选择一个合适测试的目录操作它。

09

  • 我创建一个测试目录:
mkdir claude_test 
cd claude_test
claude 
  • 视频如下:

第三步:接入Kimi K2

首先需要到Kimi官网申请一个API: kimi官方

这个API key管理->新建API Key 生成新的key.

10

创建完API Key 切记及时复制保存到其他地方,否则就得重建了。 11

然后把这个key 添加到树莓派的~/.bashrc 文件里面。

vim ~/.bashrc 

添加:

export ANTHROPIC_BASE_URL="https://api.moonshot.cn/anthropic/"
export ANTHROPIC_API_KEY="你的API KEY"

保存退出后执行:

source ~/.bashrc 

12

再执行claude

13

接下来就可以让他干活了,不过最好去充个值。不然每分钟3次请求很快就卡死了

14

15

这个就是用量限制,记得使用钞能力哦! 16

结束语

就特喵坑爹,没有梯子的小伙伴可能会遇到很多问题。