Skip to content

Commit 996cc47

Browse files
hashpandaclaude
andcommitted
docs: 添加智谱 GLM 替代方案说明
在 s00-api-basics 中文文档中补充智谱 GLM API Key 配置指引, 说明其兼容 Anthropic SDK 的使用方式。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c0b7709 commit 996cc47

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

docs/zh/s00-api-basics.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
- 熟悉 TypeScript / JavaScript
1212
- 有 Node.js 开发环境
13-
- 有 Anthropic API Key([获取地址](https://console.anthropic.com/)
13+
- 有 Anthropic API Key([获取地址](https://console.anthropic.com/),或智谱 GLM API Key([获取地址](https://open.bigmodel.cn/))作为替代
1414

1515
## 你将学到
1616

@@ -71,6 +71,20 @@ npm install
7171
cp .env.example .env
7272
```
7373

74+
编辑 `.env` 文件,填入你的 API Key。如果没有 Anthropic API Key,可以使用智谱 GLM 作为替代:
75+
76+
```bash
77+
# 使用 Anthropic(默认)
78+
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxx
79+
80+
# 使用智谱 GLM(替代方案)
81+
ANTHROPIC_API_KEY=your-glm-api-key
82+
ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic
83+
MODEL_NAME=glm-4.7
84+
```
85+
86+
> 智谱 GLM 提供兼容 Anthropic 的 API 接口,Anthropic SDK 的 `ANTHROPIC_BASE_URL` 环境变量会自动切换请求地址,代码无需任何修改。
87+
7488
### 步骤 2: 单次调用
7589

7690
核心代码只有几行——创建客户端,发送消息,解析响应:

0 commit comments

Comments
 (0)