中文版本请阅读 GLM-4.5 Claude Code 集成指南
GLM-4.5 series models now support integration with Claude Code, allowing you to use Zhipu AI's latest model capabilities in the familiar Claude Code environment.
- Claude Code installed and configured
- Related API Purchase Link
- Download the setup script:
curl -o glm_claude_setup.sh "http://bigmodel-us3-prod-marketplace.cn-wlcb.ufileos.com/1753683727739-0b3a4f6e84284f1b9afa951ab7873c29.sh?ufileattname=claude_code_prod.sh"
chmod +x glm_claude_setup.sh- Run the script:
./glm_claude_setup.sh- Enter your API Key when prompted
- Set environment variables:
export ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic
export ANTHROPIC_API_KEY=YOUR_API_KEY- Or add the configuration to your shell configuration file (such as
~/.bashrcor~/.zshrc):
echo 'export ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic' >> ~/.bashrc
echo 'export ANTHROPIC_API_KEY=YOUR_API_KEY' >> ~/.bashrc
source ~/.bashrcIf you don't want to overwrite your existing Claude configuration, you can create an alias:
vim ~/.zshrc # or ~/.bashrc
alias glm="ANTHROPIC_AUTH_TOKEN="your zhipuai api keys" ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic claude"
source ~/.zshrc- After configuring the environment variables, start Claude Code. On first use, Claude Code will ask if you trust accessing the current folder, select "Yes"
claude- If you followed the instructions for Existing Claude Users, enter in the command line:
glmSeeing the following page indicates normal operation:
╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
│ cwd: /Users/zr/Code/glm-cookbook │
│ │
│ ─────────────────────────────────────────────── │
│ │
│ Overrides (via env): │
│ │
│ • API Base URL: │
│ https://open.bigmodel.cn/api/anthropic │ <- Check if API address is correct
╰───────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────╮
│ > Try "how does glm_multi_role_division.ipynb work?" │
╰───────────────────────────────────────────────────────────────────────────────╯
? for shortcuts ◯
- Claude Code uses the
GLM-4.5model by default - For lightweight tasks, the system automatically routes to
GLM-4.5-Air - You can specify a specific model through settings
GLM Coding Lite and GLM Coding Pro can be used approximately 120 times and 600 times respectively within every 5 hours. Only the number of prompts from developers asking questions on the command line is counted, model interactions during Claude Code execution are not counted.
Claude Code automatically schedules for different task types. Main scenarios such as conversation/planning/coding/complex reasoning use the GLM-4.5 model by default, while auxiliary scenarios such as file search/syntax checking use GLM-4.5-Air.
- Claude Opus 4.1 / Claude Sonnet 4 -> GLM-4.5
- Claude Haiku 3.5 -> GLM-4.5-Air
Since Claude Opus 4.1 / Claude Sonnet 4 are both mapped to the same model, the rule in the Claude Code rules under the "What happens when you hit usage limits" section about Opus switching to Sonnet does not apply to GLM-4.5.
GLM-4.5 系列模型现已支持集成到 Claude Code 中,让你可以在熟悉的 Claude Code 环境中使用智谱 AI 的最新模型能力。
- 下载配置脚本:
curl -o glm_claude_setup.sh "http://bigmodel-us3-prod-marketplace.cn-wlcb.ufileos.com/1753683727739-0b3a4f6e84284f1b9afa951ab7873c29.sh?ufileattname=claude_code_prod.sh"
chmod +x glm_claude_setup.sh- 运行脚本:
./glm_claude_setup.sh- 按提示输入你的 API Key
- 设置环境变量:
export ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic
export ANTHROPIC_API_KEY=YOUR_API_KEY- 或者将配置添加到 shell 配置文件(如
~/.bashrc或~/.zshrc):
echo 'export ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic' >> ~/.bashrc
echo 'export ANTHROPIC_API_KEY=YOUR_API_KEY' >> ~/.bashrc
source ~/.bashrc如果你不想覆盖原有的Claude配置,可以创建一个别名:
vim ~/.zshrc # or ~/.bashrc
alias glm="ANTHROPIC_AUTH_TOKEN="your zhipuai api keys" ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic claude"
source ~/.zshrc- 在配置好环境变量后,启动 Claude Code, 首次使用时,Claude Code 会询问是否信任访问当前文件夹,选择"是"
claude- 如果你是按照 对于已经有Claude的用户 章节配置, 在命令行输入:
glm看到如下页面即正常
╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
│ cwd: /Users/zr/Code/glm-cookbook │
│ │
│ ─────────────────────────────────────────────── │
│ │
│ Overrides (via env): │
│ │
│ • API Base URL: │
│ https://open.bigmodel.cn/api/anthropic │ <- 检查API地址是否正确
╰───────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────╮
│ > Try "how does glm_multi_role_division.ipynb work?" │
╰───────────────────────────────────────────────────────────────────────────────╯
? for shortcuts ◯
- Claude Code 默认使用
GLM-4.5模型 - 对于轻量级任务,系统会自动路由到
GLM-4.5-Air - 可以通过设置指定特定模型
GLM Coding Lite 和 GLM Coding Pro 每 5 小时内,分别最多使用约 120 次和 600 次 prompts。仅计算开发者与命令行提问的次数, Claude Code 执行中模型的交互均不计入。
Claude Code 会针对不同任务类型自动调度,对话/规划/代码编写/复杂推理等主场景默认使用模型 GLM-4.5,文件搜索/语法检查等辅助场景使用 GLM-4.5-Air。
- Claude Opus 4.1 / Claude Sonnet 4 -> GLM-4.5
- Claude Haiku 3.5 -> GLM-4.5-Air
由于 Claude Opus 4.1 / Claude Sonnet 4
均映射到相同模型,因此,Claude Code 规则
中的 What happens when you hit usage limits 章节中的 Opus 切换到 Sonnet 的规则不适用于 GLM-4.5。