@wy51ai/clawzenmux 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -60
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
**[English](README_EN.md)** | 中文
|
|
4
4
|
|
|
5
|
-
OpenClaw 智能 LLM 路由插件 —— 通过 [ZenMux](https://zenmux.ai) 统一网关调用 100+
|
|
5
|
+
OpenClaw 智能 LLM 路由插件 —— 通过 [ZenMux](https://zenmux.ai) 统一网关调用 100+ 模型,自动选择最便宜的模型处理请求,最高节省 78-98% 的 token 费用。
|
|
6
|
+
|
|
6
7
|
|
|
7
|
-
> **注意**:这是一个社区第三方插件,非 OpenClaw 或 ZenMux 官方出品。欢迎各位大佬提交PR改进。
|
|
8
|
-
>
|
|
9
|
-
> 本插件参考 [ClawRouter](https://github.com/BlockRunAI/ClawRouter) 架构开发,去掉了区块链/x402 支付部分,改用 ZenMux 统一网关 + API Key 认证。感谢 ClawRouter 作者的开源贡献!
|
|
10
8
|
|
|
11
9
|
## 工作原理
|
|
12
10
|
|
|
@@ -31,15 +29,9 @@ OpenClaw Agent
|
|
|
31
29
|
|
|
32
30
|
### 1. 获取 ZenMux API Key
|
|
33
31
|
|
|
34
|
-
前往 [zenmux.ai](https://zenmux.ai)
|
|
35
|
-
|
|
36
|
-
### 2. 安装插件
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
openclaw plugins install @wy51ai/clawzenmux
|
|
40
|
-
```
|
|
32
|
+
前往 [zenmux.ai](https://zenmux.ai/invite/U5LELA) 注册,创建密钥,建议订阅套餐使用,更节省费用。
|
|
41
33
|
|
|
42
|
-
###
|
|
34
|
+
### 2. 配置 API Key(三种方式,任选其一)
|
|
43
35
|
|
|
44
36
|
```bash
|
|
45
37
|
# 方式一:环境变量(推荐)
|
|
@@ -49,9 +41,29 @@ export ZENMUX_API_KEY=your-key-here
|
|
|
49
41
|
echo "your-key-here" > ~/.openclaw/zenmux/api.key
|
|
50
42
|
|
|
51
43
|
# 方式三:在 openclaw.json 中配置
|
|
52
|
-
#
|
|
44
|
+
# 见下方「配置」章节,如果使用方式三,需要在安装插件后配置
|
|
53
45
|
```
|
|
54
46
|
|
|
47
|
+
### 3. 安装插件
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
openclaw plugins install @wy51ai/clawzenmux
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 安装告警说明(OpenClaw 安全提示)
|
|
54
|
+
|
|
55
|
+
安装时 OpenClaw 可能提示:
|
|
56
|
+
|
|
57
|
+
`WARNING: Plugin "clawzenmux" contains dangerous code patterns: Environment variable access combined with network send — possible credential harvesting`
|
|
58
|
+
|
|
59
|
+
这是因为插件会读取 `ZENMUX_API_KEY`(环境变量)并发起网络请求,触发了通用安全规则。该行为在本插件中的用途仅为:
|
|
60
|
+
|
|
61
|
+
- 将 API Key 放入 `Authorization: Bearer ...` 请求头
|
|
62
|
+
- 请求 ZenMux 官方接口 `https://zenmux.ai/api`(如 `/v1/chat/completions`、`/v1/models`)
|
|
63
|
+
|
|
64
|
+
不会将你的 API Key 上传到任何第三方服务。若你不希望使用环境变量,也可以改用 `~/.openclaw/zenmux/api.key` 或 `openclaw.json` 配置方式(见下方)。
|
|
65
|
+
|
|
66
|
+
|
|
55
67
|
### 4. 使用智能路由
|
|
56
68
|
|
|
57
69
|
```bash
|
|
@@ -123,7 +135,6 @@ USE COMPLEX 设计一个分布式消息队列的架构
|
|
|
123
135
|
≥ 0.25 → REASONING
|
|
124
136
|
|
|
125
137
|
特殊规则:2+ 个推理关键词命中 → 直接判定 REASONING
|
|
126
|
-
架构设计信号(architecture/架构 + 分布式/消息队列/分片/容灾/QPS/多租户等)→ 直接判定 COMPLEX
|
|
127
138
|
置信度 < 0.6 → 标记为「模糊」,回退到默认层级 (MEDIUM)
|
|
128
139
|
```
|
|
129
140
|
|
|
@@ -134,14 +145,14 @@ USE COMPLEX 设计一个分布式消息队列的架构
|
|
|
134
145
|
- **模糊判定** → 默认 MEDIUM
|
|
135
146
|
|
|
136
147
|
## 配置
|
|
137
|
-
|
|
138
|
-
在 `~/.openclaw/openclaw.json` 中配置插件:
|
|
148
|
+
如果需要自定义各个分级的模型,需要在 `~/.openclaw/openclaw.json` 中配置插件,注意,如果开启这个配置,apiKey必须要在这个配置中填写:
|
|
139
149
|
|
|
140
150
|
```json
|
|
141
151
|
{
|
|
142
152
|
"plugins": {
|
|
143
153
|
"entries": {
|
|
144
154
|
"clawzenmux": {
|
|
155
|
+
"enabled": true,
|
|
145
156
|
"config": {
|
|
146
157
|
"apiKey": "your-zenmux-api-key",
|
|
147
158
|
"routing": {
|
|
@@ -171,7 +182,7 @@ USE COMPLEX 设计一个分布式消息队列的架构
|
|
|
171
182
|
|
|
172
183
|
| 参数 | 类型 | 默认值 | 说明 |
|
|
173
184
|
|------|------|--------|------|
|
|
174
|
-
| `apiKey` | string | — | ZenMux API Key
|
|
185
|
+
| `apiKey` | string | — | ZenMux API Key |
|
|
175
186
|
| `routing.tiers.{TIER}.primary` | string | 见上表 | 该层级的首选模型 |
|
|
176
187
|
|
|
177
188
|
## 动态模型同步
|
|
@@ -179,50 +190,7 @@ USE COMPLEX 设计一个分布式消息队列的架构
|
|
|
179
190
|
插件启动时会调用 ZenMux `GET /v1/models` API 获取最新的模型列表和定价信息:
|
|
180
191
|
|
|
181
192
|
- 30 分钟缓存,避免频繁请求
|
|
182
|
-
- API 不可用时自动回退到内置静态模型目录
|
|
183
|
-
- 确保定价信息始终最新
|
|
184
|
-
|
|
185
|
-
## 支持的模型
|
|
186
|
-
|
|
187
|
-
通过 ZenMux 平台访问 100+ 模型,包括:
|
|
188
|
-
|
|
189
|
-
| 提供商 | 模型 |
|
|
190
|
-
|--------|------|
|
|
191
|
-
| **OpenAI** | GPT-5.2 Pro, GPT-5.2, GPT-5.1, GPT-5, GPT-5 Mini/Nano, GPT-4.1, o3, o4-mini, Codex |
|
|
192
|
-
| **Anthropic** | Claude Opus 4.6/4.5, Claude Sonnet 4.5/4, Claude Haiku 4.5 |
|
|
193
|
-
| **Google** | Gemini 3 Pro/Flash Preview, Gemini 2.5 Pro/Flash/Flash-Lite |
|
|
194
|
-
| **DeepSeek** | V3.2, Reasoner |
|
|
195
|
-
| **xAI** | Grok 4.1 Fast, Grok 4 Fast, Grok 3 |
|
|
196
|
-
| **阿里** | Qwen3-Max, Qwen3-Coder-Plus, Qwen3-VL-Plus |
|
|
197
|
-
| **智谱** | GLM 4.7, GLM 4.6 |
|
|
198
|
-
| **月之暗面** | Kimi K2 Thinking, Kimi K2.5 |
|
|
199
|
-
| **Mistral** | Mistral Large 3 |
|
|
200
|
-
| **百度** | ERNIE-5.0 Thinking Preview |
|
|
201
|
-
| **字节** | Doubao-Seed-Code |
|
|
202
|
-
| **小米** | MiMo-V2-Flash |
|
|
203
|
-
|
|
204
|
-
## 项目结构
|
|
205
193
|
|
|
206
|
-
```
|
|
207
|
-
src/
|
|
208
|
-
├── index.ts # 插件入口,注册 provider,启动代理
|
|
209
|
-
├── provider.ts # OpenClaw provider 定义
|
|
210
|
-
├── proxy.ts # 本地 HTTP 代理服务器 (port 8513)
|
|
211
|
-
├── models.ts # 内置模型目录(100+ 模型 + 定价)
|
|
212
|
-
├── model-sync.ts # 动态模型同步(从 ZenMux API 拉取最新)
|
|
213
|
-
├── auth.ts # API Key 解析(config / 文件 / 环境变量 / 向导)
|
|
214
|
-
├── types.ts # OpenClaw 插件类型定义
|
|
215
|
-
├── dedup.ts # 请求去重(防止超时重试导致重复计费)
|
|
216
|
-
├── retry.ts # 指数退避重试(429/502/503/504)
|
|
217
|
-
├── logger.ts # 使用日志(~/.openclaw/zenmux/logs/)
|
|
218
|
-
├── errors.ts # 错误类型定义
|
|
219
|
-
└── router/
|
|
220
|
-
├── index.ts # 路由入口(纯规则评分,同步)
|
|
221
|
-
├── rules.ts # 规则引擎(14 维加权评分)
|
|
222
|
-
├── selector.ts # 层级 → 模型选择 + 费用估算
|
|
223
|
-
├── config.ts # 默认路由配置
|
|
224
|
-
└── types.ts # 路由类型定义
|
|
225
|
-
```
|
|
226
194
|
|
|
227
195
|
## 代理服务器特性
|
|
228
196
|
|
|
@@ -258,6 +226,16 @@ npm run build
|
|
|
258
226
|
curl http://localhost:8513/health
|
|
259
227
|
# {"status":"ok","provider":"zenmux","models":94}
|
|
260
228
|
```
|
|
229
|
+
> **注意**:这是一个社区第三方插件,非官方出品。欢迎各位大佬提交PR改进。
|
|
230
|
+
>
|
|
231
|
+
> 本插件参考 [ClawRouter](https://github.com/BlockRunAI/ClawRouter) 架构开发,去掉了区块链/x402 支付部分,改用 ZenMux 统一网关 + API Key 认证。感谢 ClawRouter 作者的开源贡献!
|
|
232
|
+
|
|
233
|
+
## 安全提醒
|
|
234
|
+
|
|
235
|
+
- `8513` 是本地代理端口,仅用于 `localhost` 回环访问,请勿对外网开放。
|
|
236
|
+
- 不要把 `8513` 做端口转发/内网穿透(如路由器端口映射、云安全组放行、FRP、ngrok 等)。
|
|
237
|
+
- 该端口用于接收本地 OpenClaw 请求,若暴露到外部,可能被他人滥用你的配额或触发异常请求。
|
|
238
|
+
- 建议只监听 `127.0.0.1`,并确认防火墙未放行 `8513` 的公网入站流量。
|
|
261
239
|
|
|
262
240
|
## 作者
|
|
263
241
|
|