目录
- 一、本地部署GLM-4.5-Air量化版
- [二、Claude Code安装及配置](#二、Claude Code安装及配置)
-
- 安装Node
- [安装Claude Code](#安装Claude Code)
- [配置Claude Code及Claude Code VS Code插件](#配置Claude Code及Claude Code VS Code插件)
- [三、Claude Code Router安装及配置](#三、Claude Code Router安装及配置)
-
- [安装Claude Code Router](#安装Claude Code Router)
- [配置Claude Code Router](#配置Claude Code Router)
- [四、使用Claude Code调用本地部署模型](#四、使用Claude Code调用本地部署模型)
一、本地部署GLM-4.5-Air量化版
安装Python并创建虚拟环境
官网下载、安装Python后,环境最好用venv隔离一下,这个不赘述。
下载模型
我成功部署的是这个,大小63GB,量化完参数17B:cpatonn-mirror/GLM-4.5-Air-AWQ
激活venv虚拟环境后,安装ModelScope环境,慢的话切一下国内源:
bash
pip install modelscope
下载模型,取决于你的网速,我能把带宽跑满 (接近400Mbps):
bash
modelscope download --model cpatonn-mirror/GLM-4.5-Air-AWQ --local_dir ./你的目录
如果要下特定文件:
bash
modelscope download --model cpatonn-mirror/GLM-4.5-Air-AWQ 要单独下的文件 --local_dir ./你的目录
安装vLLM
激活venv虚拟环境后,安装vLLM环境,慢的话切一下国内源:
bash
pip install vllm
部署模型
我在A4500 20G * 8 部署成功,但是用Claude Code接入后,模型会说胡话,可能是参数配置问题;因此尝试在A6000 48G * 2重新部署,实际成功的参数如下:
bash
CUDA_VISIBLE_DEVICES=0,1 vllm serve 你的模型路径/glm-4.5-air-awq \
--pipeline-parallel-size 2 \
--host 你的模型部署主机IP \
--served-model-name glm-4.5-air-awq \
--dtype float16 \
--tool-call-parser glm45 \
--reasoning-parser glm45 \
--enable-auto-tool-choice \
--disable-custom-all-reduce \
--gpu-memory-utilization 0.95 \
--max-model-len 130000 \
--max-num-seqs 64 \
--port 8000
PS:我还clone了GLM-4.5的Repo装了依赖,实际可能不需要。
二、Claude Code安装及配置
安装Node
官网下载、安装Node v20以上,这个不赘述。
安装Claude Code
直接npm安装,慢的话切一下国内源,或者使用nrm等工具管理源:
bash
npm install -g @anthropic-ai/claude-code
这时候,你直接运行claude会要求你使用官方付费账户登录,科学上网不付费也无法直接使用,后面我们用配置和Claude Code Router解决这个问题
配置Claude Code及Claude Code VS Code插件
这部分我是参照这篇博文配置的,不赘述了。其中APIKEY应该可以不设;如果要设置,就设置成一致的。
三、Claude Code Router安装及配置
安装Claude Code Router
直接npm安装,慢的话切一下国内源,或者使用nrm等工具管理源:
bash
npm install -g @musistudio/claude-code-router
配置Claude Code Router
下载这个脚本,并放到下面json第五行的路径下:
修改配置文件C:\Users\你的用户名\.claude-code-router\config.json (Linux/Mac用户就是你的home/你的用户名目录下的相应配置文件),这个配置文件是我实际跑起来的:
json
{
"LOG": true,
"transformers": [
{
"path": "/home/你的用户名/.claude-code-router/glm-4.5-air-disable-thinking-transformer.js"
}
],
"Providers": [
{
"name": "glm-4.5-air",
"api_base_url": "http://你的模型部署主机IP:8000/v1/chat/completions",
"api_key": "none",
"models": [
"glm-4.5-air-awq"
],
"transformer": {
"use": [
[
"sampling",
{
"_comment": "Using values described at https://z.ai/blog/glm-4.5. Claude Code sets temperature 0 for requests determining the conversation topic and 1 for serious requests. I'm not going to put in the effort to differentiate between these two request types, so I am setting it to the value that I think should help more with important requests.",
"temperature": 0.6,
"top_p": 1.0
}
]
],
"glm-4.5-air-awq": {
"use": [
"reasoning"
]
}
}
}
],
"Router": {
"default": "glm-4.5-air,glm-4.5-air-awq"
}
}
四、使用Claude Code调用本地部署模型
一切就绪后重启Claude Code Router:
bash
ccr restart
在你的项目目录下启动Claude Code Router路由的Claude Code:
bash
ccr code
跑起来显示用的官方模型,实际是把请求路由到了你本地部署的模型:


Enjoy it~
Ref:
1\]: https://www.modelscope.cn/models/cpatonn-mirror/GLM-4.5-Air-AWQ \[2\]: https://docs.vllm.com.cn/projects/recipes/en/latest/GLM/GLM-4.5.html \[3\]: https://blog.csdn.net/Dvesiz/article/details/156387378 \[4\]: https://rosetears.cn/archives/63/ \[5\]: https://github.com/danielrothfus/ccr-vllm-glm-4.5-setup