We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c0b7709 commit 996cc47Copy full SHA for 996cc47
1 file changed
docs/zh/s00-api-basics.md
@@ -10,7 +10,7 @@
10
11
- 熟悉 TypeScript / JavaScript
12
- 有 Node.js 开发环境
13
-- 有 Anthropic API Key([获取地址](https://console.anthropic.com/))
+- 有 Anthropic API Key([获取地址](https://console.anthropic.com/)),或智谱 GLM API Key([获取地址](https://open.bigmodel.cn/))作为替代
14
15
## 你将学到
16
@@ -71,6 +71,20 @@ npm install
71
cp .env.example .env
72
```
73
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
88
### 步骤 2: 单次调用
89
90
核心代码只有几行——创建客户端,发送消息,解析响应:
0 commit comments