[{"data":1,"prerenderedAt":20},["ShallowReactive",2],{"$fwt_BKYAuXe0TntBk6MXbBLMQ6SB75M6P4TLMlNxUAVc":3},{"id":4,"documentId":5,"title":6,"summary":7,"content":8,"author":9,"category":10,"tags":11,"icon":12,"views":13,"isTop":14,"isNew":14,"publishDate":15,"createdAt":16,"updatedAt":17,"publishedAt":18,"slug":19},188,"kqldhujry8waa9p7ay3ak5yx","Claude Code 接入国内大模型（智谱 GLM-4.7）图文教程","本文讲解如何用3步把 Claude Code 的模型接口切换到智谱 GLM-4.7，降低 API 使用成本。","\u003Cp>\u003Chtml>\u003Chead>\u003C/head>\u003Cbody>\u003Ch1 style=\"font-size: 28px; line-height: 1.4; font-weight: 700; margin: 20px 0 12px;\">Claude Code 接入国内大模型（智谱 GLM-4.7）图文教程\u003C/h1>\u003C/p>\u003Cp>\u003Cblockquote style=\"margin: 12px 0; padding: 10px 12px; background: #f7f7f7; border-left: 4px solid #ff6b35; color: #444;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">Claude Code 虽然强，但 API 费用确实有点肉疼？\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">今天教你如何接入国产大模型！\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">智谱最新编程模型 GLM-4.7，代码能力不输，价格直接打骨折。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">整个配置只需要 \u003Cstrong>3步\u003C/strong>，不到5分钟搞定。\u003C/p>\u003C/p>\u003Cp>\u003C/blockquote>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/01_2026_01_10_11_06_25_db13c1d3c9.png\" alt=\"2026-01-10-11-06-25\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003Cp>\u003Cimg src=\"https://aigongsheng.com/uploads/02_2026_01_10_11_07_16_46995a71b2.png\" alt=\"2026-01-10-11-07-16\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Ch2 style=\"font-size: 22px; line-height: 1.5; font-weight: 700; margin: 18px 0 10px;\">原理说明\u003C/h2>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">这些国产大模型都兼容 OpenAI 的 API 格式，且 Claude Code 支持自定义 API 端点，所以能完美适配。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/03_2026_01_09_23_45_58_d1ec8a75e2.png\" alt=\"2026-01-09-23-45-58\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">今天我们讲解如何在 Claude Code 中接入 GLM-4.7。而且，智谱清言目前有上市活动，接入 Claude Code 之后，输入指令，可以获取“智谱上市纪念礼物”。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Ca href=\"https://www.bigmodel.cn/glm-coding?ic=IHFIOFDXSG\" style=\"color: #1e80ff; text-decoration: none;\">点击前往活动链接\u003C/a>\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/04_2026_01_08_21_06_54_5eb24c4395.png\" alt=\"2026-01-08-21-06-54\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003Cp>\u003Cimg src=\"https://aigongsheng.com/uploads/05_2026_01_08_21_13_41_a7ae305fe6.png\" alt=\"2026-01-08-21-13-41\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cstrong>让我们开始吧！\u003C/strong>\u003C/p>\u003C/p>\u003Cp>\u003Ch2 style=\"font-size: 22px; line-height: 1.5; font-weight: 700; margin: 18px 0 10px;\">准备工作\u003C/h2>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">首先打开你的电脑，输入 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">cmd\u003C/code>, 进入终端。\u003C/p>\u003Cp>输入以下命令确认 Claude 安装正常：\u003C/p>\u003C/p>\u003Cp>\u003Cpre style=\"background: #f6f8fa; color: #1f2328; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.7; margin: 12px 0; white-space: pre-wrap; word-break: break-word; border: 1px solid #d0d7de;\">\u003Ccode class=\"language-bash\">claude --version\u003C/p>\u003Cp>\u003C/code>\u003C/pre>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/06_2026_01_08_20_34_29_62bd6b32c1.png\" alt=\"2026-01-08-20-34-29\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003Cp>\u003Cimg src=\"https://aigongsheng.com/uploads/07_2026_01_08_21_18_43_80273c6729.png\" alt=\"2026-01-08-21-18-43\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Cblockquote style=\"margin: 12px 0; padding: 10px 12px; background: #f7f7f7; border-left: 4px solid #ff6b35; color: #444;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">如果有异常场景，可以按照文末的 \u003Cstrong>“异常场景排查”\u003C/strong> 章节去排查问题。\u003C/p>\u003C/p>\u003Cp>\u003C/blockquote>\u003C/p>\u003Cp>\u003Ch2 style=\"font-size: 22px; line-height: 1.5; font-weight: 700; margin: 18px 0 10px;\">第一步：获取 API Key\u003C/h2>\u003C/p>\u003Cp>\u003Col style=\"padding-left: 20px; margin: 10px 0;\">\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">进入官网，登录后，点击左上角的 “API-Key”。\u003Cbr>\u003C/p>\u003Cp>\u003Ca href=\"https://www.bigmodel.cn/glm-coding?ic=IHFIOFDXSG\" style=\"color: #1e80ff; text-decoration: none;\">点击前往官网\u003C/a>\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/08_2026_01_08_21_23_59_24a1e1a898.png\" alt=\"2026-01-08-21-23-59\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">点击左上角的添加按钮，在弹窗内写一个名称，点击确认。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/09_2026_01_08_21_29_48_b03ccda766.png\" alt=\"2026-01-08-21-29-48\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">复制自己的 API-Key。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/10_2026_01_08_21_31_19_daab6d41db.png\" alt=\"2026-01-08-21-31-19\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003C/ol>\u003C/p>\u003Cp>\u003Ch2 style=\"font-size: 22px; line-height: 1.5; font-weight: 700; margin: 18px 0 10px;\">第二步：配置环境变量与模型\u003C/h2>\u003C/p>\u003Cp>\u003Ch3 style=\"font-size: 18px; line-height: 1.6; font-weight: 700; margin: 16px 0 8px;\">1. 设置环境变量\u003C/h3>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">打开 CMD 终端，依次输入以下命令（注意替换 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">your_zhipu_api_key\u003C/code> 为你刚才获取的 API Key）：\u003C/p>\u003C/p>\u003Cp>\u003Cpre style=\"background: #f6f8fa; color: #1f2328; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.7; margin: 12px 0; white-space: pre-wrap; word-break: break-word; border: 1px solid #d0d7de;\">\u003Ccode class=\"language-cmd\">setx ANTHROPIC_AUTH_TOKEN your_zhipu_api_key\u003C/p>\u003Cp>setx ANTHROPIC_BASE_URL https://open.bigmodel.cn/api/anthropic\u003C/p>\u003Cp>setx CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC 1\u003C/p>\u003Cp>\u003C/code>\u003C/pre>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cstrong>这三行指令的作用：\u003C/strong>\u003C/p>\u003C/p>\u003Cp>\u003Col style=\"padding-left: 20px; margin: 10px 0;\">\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">设置 Claude Code 访问 GLM 的 API Key。\u003C/li>\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">配置 Claude Code 连接 GLM 兼容接口的 API 地址。\u003C/li>\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">关闭 Claude Code 部分非必要的流量请求，更好适配国内环境。\u003C/li>\u003C/p>\u003Cp>\u003C/ol>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/11_2026_01_08_21_35_08_5b001d8383.png\" alt=\"2026-01-08-21-35-08\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Ch3 style=\"font-size: 18px; line-height: 1.6; font-weight: 700; margin: 16px 0 8px;\">2. 配置模型映射 (settings.json)\u003C/h3>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">为了更好地切换模型，我们需要配置 Claude Code 内部模型环境变量与 GLM 模型的对应关系。\u003C/p>\u003C/p>\u003Cp>\u003Col style=\"padding-left: 20px; margin: 10px 0;\">\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">在你的电脑里，进入 C 盘，找到 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">.claude\u003C/code> 文件夹（通常在 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">C:\\Users\\你的用户名\\.claude\u003C/code>）。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/12_2026_01_09_21_59_10_e08f3875d9.png\" alt=\"2026-01-09-21-59-10\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003Cp>\u003Cimg src=\"https://aigongsheng.com/uploads/13_2026_01_09_21_59_44_d434f96fe6.png\" alt=\"2026-01-09-21-59-44\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">新建一个文件，命名为 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">settings.json\u003C/code>。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/14_2026_01_09_22_00_41_03ff3c8768.png\" alt=\"2026-01-09-22-00-41\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">双击打开文件，贴入以下代码：\u003C/p>\u003C/p>\u003Cp>\u003Cpre style=\"background: #f6f8fa; color: #1f2328; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.7; margin: 12px 0; white-space: pre-wrap; word-break: break-word; border: 1px solid #d0d7de;\">\u003Ccode class=\"language-json\">{\u003C/p>\u003Cp>  \"env\": {\u003C/p>\u003Cp>    \"ANTHROPIC_DEFAULT_HAIKU_MODEL\": \"glm-4.5-air\",\u003C/p>\u003Cp>    \"ANTHROPIC_DEFAULT_SONNET_MODEL\": \"glm-4.7\",\u003C/p>\u003Cp>    \"ANTHROPIC_DEFAULT_OPUS_MODEL\": \"glm-4.7\"\u003C/p>\u003Cp>  }\u003C/p>\u003Cp>}\u003C/p>\u003Cp>\u003C/code>\u003C/pre>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">默认配置参考如下：\u003C/p>\u003Cp>\u003Cimg src=\"https://aigongsheng.com/uploads/15_2026_01_09_22_02_02_a57dd450bf.png\" alt=\"2026-01-09-22-02-02\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003C/ol>\u003C/p>\u003Cp>\u003Ch2 style=\"font-size: 22px; line-height: 1.5; font-weight: 700; margin: 18px 0 10px;\">第三步：启动 Claude Code 并验证\u003C/h2>\u003C/p>\u003Cp>\u003Col style=\"padding-left: 20px; margin: 10px 0;\">\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">进入你的项目文件夹内，在顶部状态栏输入 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">cmd\u003C/code> 进入终端界面。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/16_2026_01_09_22_10_54_9c588689f4.png\" alt=\"2026-01-09-22-10-54\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">输入 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">claude\u003C/code> 启动。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/17_2026_01_09_22_12_11_e50f0259e6.png\" alt=\"2026-01-09-22-12-11\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">输入指令 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">/model\u003C/code>，验证是否都变成了 GLM 的模型。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/18_2026_01_10_01_51_41_94ce3aa0b6.png\" alt=\"2026-01-10-01-51-41\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003C/ol>\u003C/p>\u003Cp>\u003Ch3 style=\"font-size: 18px; line-height: 1.6; font-weight: 700; margin: 16px 0 8px;\">领取智谱上市礼物\u003C/h3>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">开头说的“智谱上市赠礼活动”，在你接入 GLM 之后，输入指令：\u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">智谱旺旺\u003C/code>，就可以看到兑换码以及填写地址的链接。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/19_2026_01_10_01_56_56_630c5d12be.png\" alt=\"2026-01-10-01-56-56\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003Cp>\u003Cimg src=\"https://aigongsheng.com/uploads/20_2026_01_10_11_02_17_11073b987d.png\" alt=\"2026-01-10-11-02-17\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Ch2 style=\"font-size: 22px; line-height: 1.5; font-weight: 700; margin: 18px 0 10px;\">实测：GLM-4.7 贪吃蛇小游戏\u003C/h2>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">我们来做一个小游戏和上一期 Claude Code 进行对比。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cstrong>输入指令：\u003C/strong>\u003C/p>\u003C/p>\u003Cp>\u003Cblockquote style=\"margin: 12px 0; padding: 10px 12px; background: #f7f7f7; border-left: 4px solid #ff6b35; color: #444;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">“帮我做一个只有一个文件的网页，内容是一个经典的贪吃蛇游戏，要有计分功能，蛇撞墙会游戏结束。”\u003C/p>\u003C/p>\u003Cp>\u003C/blockquote>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/21_2026_01_10_11_01_17_5423f642c2.png\" alt=\"2026-01-10-11-01-17\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003Cp>\u003Cimg src=\"https://aigongsheng.com/uploads/22_2026_01_10_11_02_47_ba0ac94f6a.png\" alt=\"2026-01-10-11-02-47\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">代码生成之后，直接用浏览器打开。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/23_2026_01_10_11_03_15_0485e81e91.png\" alt=\"2026-01-10-11-03-15\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">点击开始游戏之后，使用键盘上下左右移动。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/24_2026_01_10_11_03_49_b4a2c1e11c.png\" alt=\"2026-01-10-11-03-49\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">我们可以看到 GLM-4.7 把整个游戏功能做得也很完善。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/25_2026_01_10_11_04_23_cbed208929.png\" alt=\"2026-01-10-11-04-23\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Ch2 style=\"font-size: 22px; line-height: 1.5; font-weight: 700; margin: 18px 0 10px;\">异常场景排查\u003C/h2>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">如果在安装或运行过程中遇到问题，请按以下步骤操作。\u003C/p>\u003C/p>\u003Cp>\u003Col style=\"padding-left: 20px; margin: 10px 0;\">\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cstrong>以管理员模式打开 CMD。\u003C/strong>\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/06_2026_01_08_20_34_29_62bd6b32c1.png\" alt=\"2026-01-08-20-34-29\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cstrong>检查 Node.js 版本\u003C/strong>\u003C/p>\u003Cp>输入：\u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">node -v\u003C/code>\u003C/p>\u003Cp>如果没有出现版本号，需要去官网下载 Node.js（上一期已经讲过如何安装）。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/26_2026_01_08_20_35_51_75f5824e96.png\" alt=\"2026-01-08-20-35-51\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cstrong>重装 Claude Code\u003C/strong>\u003C/p>\u003Cp>输入 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">claude -v\u003C/code>，如果出现版本号但运行异常，为了后续好接入国产大模型，建议先卸载再重新安装。\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/27_2026_01_08_20_37_46_a7b4bcae42.png\" alt=\"2026-01-08-20-37-46\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003C/li>\u003C/p>\u003Cp>\u003C/ol>\u003C/p>\u003Cp>\u003Ch3 style=\"font-size: 18px; line-height: 1.6; font-weight: 700; margin: 16px 0 8px;\">彻底卸载与重装步骤\u003C/h3>\u003C/p>\u003Cp>\u003Ch4>1. 卸载 Claude Code\u003C/h4>\u003C/p>\u003Cp>\u003Cpre style=\"background: #f6f8fa; color: #1f2328; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.7; margin: 12px 0; white-space: pre-wrap; word-break: break-word; border: 1px solid #d0d7de;\">\u003Ccode class=\"language-bash\">npm uninstall -g @anthropic-ai/claude-code\u003C/p>\u003Cp>\u003C/code>\u003C/pre>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/28_2026_01_08_20_53_07_c121f6fd8f.png\" alt=\"2026-01-08-20-53-07\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Ch4>2. 清理残留文件\u003C/h4>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">首先，查找 npm 全局安装路径：\u003C/p>\u003C/p>\u003Cp>\u003Cpre style=\"background: #f6f8fa; color: #1f2328; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.7; margin: 12px 0; white-space: pre-wrap; word-break: break-word; border: 1px solid #d0d7de;\">\u003Ccode class=\"language-bash\"># 查看 npm 全局包目录\u003C/p>\u003Cp>npm root -g\u003C/p>\u003Cp>\u003C/code>\u003C/pre>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/29_2026_01_08_21_00_50_d122e67744.png\" alt=\"2026-01-08-21-00-50\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">根据上面的路径打开文件夹：\u003C/p>\u003C/p>\u003Cp>\u003Cul style=\"padding-left: 20px; margin: 10px 0;\">\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">删除 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">node_modules\\@anthropic-ai\u003C/code> 文件夹（如果存在）。\u003C/p>\u003Cp>\u003Cimg src=\"https://aigongsheng.com/uploads/30_2026_01_08_20_59_40_e30114adb5.png\" alt=\"2026-01-08-20-59-40\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/li>\u003C/p>\u003Cp>\u003C/ul>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">在 C 盘中找到 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">C:\\Users\\你的用户名\u003C/code>：\u003C/p>\u003C/p>\u003Cp>\u003Cul style=\"padding-left: 20px; margin: 10px 0;\">\u003C/p>\u003Cp>\u003Cli style=\"margin: 6px 0; line-height: 1.9;\">清空 \u003Ccode style=\"background: #f2f4f5; padding: 2px 6px; border-radius: 4px; font-size: 0.95em;\">.claude\u003C/code> 文件夹。\u003C/p>\u003Cp>\u003Cimg src=\"https://aigongsheng.com/uploads/31_2026_01_09_22_28_08_dcff777eea.png\" alt=\"2026-01-09-22-28-08\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003Cp>\u003Cimg src=\"https://aigongsheng.com/uploads/32_2026_01_09_22_30_30_cfdd6f0c39.png\" alt=\"2026-01-09-22-30-30\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/li>\u003C/p>\u003Cp>\u003C/ul>\u003C/p>\u003Cp>\u003Ch4>3. 清理 npm 缓存\u003C/h4>\u003C/p>\u003Cp>\u003Cpre style=\"background: #f6f8fa; color: #1f2328; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.7; margin: 12px 0; white-space: pre-wrap; word-break: break-word; border: 1px solid #d0d7de;\">\u003Ccode class=\"language-bash\">npm cache clean --force\u003C/p>\u003Cp>\u003C/code>\u003C/pre>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/33_2026_01_08_21_02_19_a8be5b10f2.png\" alt=\"2026-01-08-21-02-19\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Ch4>4. 重新安装最新版本\u003C/h4>\u003C/p>\u003Cp>\u003Cpre style=\"background: #f6f8fa; color: #1f2328; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.7; margin: 12px 0; white-space: pre-wrap; word-break: break-word; border: 1px solid #d0d7de;\">\u003Ccode class=\"language-bash\">npm install -g @anthropic-ai/claude-code@latest\u003C/p>\u003Cp>\u003C/code>\u003C/pre>\u003C/p>\u003Cp>\u003Ch4>5. 验证安装\u003C/h4>\u003C/p>\u003Cp>\u003Cpre style=\"background: #f6f8fa; color: #1f2328; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.7; margin: 12px 0; white-space: pre-wrap; word-break: break-word; border: 1px solid #d0d7de;\">\u003Ccode class=\"language-bash\"># 检查版本\u003C/p>\u003Cp>claude --version\u003C/p>\u003Cp>\u003C/code>\u003C/pre>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">\u003Cimg src=\"https://aigongsheng.com/uploads/34_2026_01_08_21_03_52_29c9088a0e.png\" alt=\"2026-01-08-21-03-52\" style=\"max-width: 100%; height: auto; display: block; margin: 12px auto; border-radius: 8px;\">\u003C/p>\u003C/p>\u003Cp>\u003Cp style=\"font-size: 16px; line-height: 1.9; margin: 10px 0;\">这里是 \u003Cstrong>AI共生阁\u003C/strong>，我们下期见！\u003C/p>\u003C/p>\u003Cp>\u003C/body>\u003C/html>\u003C/p>\u003Cp>\u003Ch2>常见问题\u003C/h2>\u003Ch3>Q: 接入 GLM-4.7 需要改代码吗？\u003C/h3>\u003Cp>A: 不需要，只需设置三个环境变量（ANTHROPIC_AUTH_TOKEN、ANTHROPIC_BASE_URL、CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC）并新建一个 settings.json 做模型映射，整个过程不到 5 分钟。\u003C/p>\u003Ch3>Q: 换了国产模型后 Claude Code 还能正常用吗？\u003C/h3>\u003Cp>A: 可以，文中用一个贪吃蛇小游戏的例子做了实测，GLM-4.7 接入后代码生成功能完整可用，输入 /model 指令可以验证当前模型是否已切换成功。\u003C/p>\u003C/p>","Up Spark","AI编程",[],"📝",0,false,"2026-01-10","2026-01-10T06:25:18.520Z","2026-07-04T08:06:32.967Z","2026-07-04T08:06:32.988Z","claude-code-glm-setup",1783157886258]