额外的api配置

为降低泄露风险,将API Key配置到系统环境变量,而非直接写入文件: 1. 确认Shell类型:终端输入echo $SHELL,判断为zsh或bash;
2. zsh用户配置: - 输入命令(替换“YOURDASHSCOPEAPIKEY”为实际API Key):`echo “expor…’

配置环境变量(避免API Key泄露)

为降低泄露风险,将API Key配置到系统环境变量,而非直接写入文件:

  1. 确认Shell类型:终端输入echo $SHELL,判断为zsh或bash;
  2. zsh用户配置:
    • 输入命令(替换“YOUR_DASHSCOPE_API_KEY”为实际API Key):echo "export DASHSCOPE_API_KEY='YOUR_DASHSCOPE_API_KEY'" >> ~/.zshrc
    • 执行source ~/.zshrc使配置生效;
    • 验证:重新打开终端,输入echo $DASHSCOPE_API_KEY,输出API Key即成功;
  3. bash用户配置:
    • 输入命令(替换实际API Key):echo "export DASHSCOPE_API_KEY='YOUR_DASHSCOPE_API_KEY'" >> ~/.bash_profile
    • 执行source ~/.bash_profile生效;
    • 验证:重新打开终端,输入echo $DASHSCOPE_API_KEY,输出API Key即成功。
      如果json文件直接配置apikey好了,也不需要弄了(可以先不设置)。

编辑OpenClaw配置文件

OpenClaw模型配置需按指定格式写入~/.openclawd/openclawd.json

注意两个问题:

  1. OpenClaw 无法识别 minimaxai/minimax-m2.1 模型,核心原因是配置文件中的模型定义与实际调用不一致
    OpenClaw 2026.1.30 要求模型 ID 必须包含 完整命名空间
    错误格式:
    "id": "minimaxai/minimax-m2.1" // ❌ 缺少 provider 前缀
    正确格式应为:
    "id": "nvidia/minimaxai/minimax-m2.1"

  2. 错误信息 Invalid config at /root/.openclaw/openclaw.json: Invalid input [plugins] 插件已注册 和 models.providers.nvidia.api: Invalid input,
    核心问题: NVIDIA provider 的 api 字段值无效
    在您的配置中:
    "nvidia": { "baseUrl": "https://integrate.api.nvidia.com/v1", "apiKey": "${DASHSCOPE_API_KEY}", "api": "openai", // ❌ 这里值无效! "models": [ ... ] }
    OpenClaw 2026.1.30 版本严格要求 api 字段必须为 openai-completions(即使 NVIDIA NIM 兼容 OpenAI API)。 这是 OpenClaw 的硬性验证规则,与实际 API 兼容性无关。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
{

  "meta": {

    "lastTouchedVersion": "2026.1.30",

    "lastTouchedAt": "2026-02-06T20:07:20.472Z"

  },

  "wizard": {

    "lastRunAt": "2026-02-06T20:07:20.451Z",

    "lastRunVersion": "2026.1.30",

    "lastRunCommand": "onboard",

    "lastRunMode": "local"

  },

  "auth": {

    "profiles": {

      "qwen-portal:default": {

        "provider": "qwen-portal",

        "mode": "oauth"

      }

    }

  },

  "models": {

    "mode": "merge",

    "providers": {

      "qwen-portal": {

        "baseUrl": "https://portal.qwen.ai/v1",

        "apiKey": "qwen-oauth",

        "api": "openai-completions",

        "models": [

          {

            "id": "qwen-portal/coder-model",

            "name": "Qwen Coder",

            "reasoning": false,

            "input": [

              "text"

            ],

            "cost": {

              "input": 0,

              "output": 0,

              "cacheRead": 0,

              "cacheWrite": 0

            },

            "contextWindow": 128000,

            "maxTokens": 8192

          },

          {

            "id": "qwen-portal/vision-model",

            "name": "Qwen Vision",

            "reasoning": false,

            "input": [

              "text",

              "image"

            ],

            "cost": {

              "input": 0,

              "output": 0,

              "cacheRead": 0,

              "cacheWrite": 0

            },

            "contextWindow": 128000,

            "maxTokens": 8192

          }

        ]

      },

      "nvidia": {

        "baseUrl": "https://integrate.api.nvidia.com/v1",

        "apiKey": "nvapi-AAAA",

        "api": "openai-completions",

        "models": [

          {

            "id": "nvidia/minimaxai/minimax-m2.1",

            "name": "minimax-m2.1",

            "reasoning": false,

            "input": [

              "text"

            ],

            "cost": {

              "input": 0.0025,

              "output": 0.01,

              "cacheRead": 0,

              "cacheWrite": 0

            },

            "contextWindow": 262144,

            "maxTokens": 65536

          }

        ]

      }

    }

  },

  "agents": {

    "defaults": {

      "model": {

        "primary": "nvidia/minimaxai/minimax-m2.1"

      },

      "models": {

        "qwen-portal/coder-model": {

          "alias": "qwen"

        },

        "qwen-portal/vision-model": {},

        "nvidia/minimaxai/minimax-m2.1": {

          "alias": "minimax"

        }

      },

      "workspace": "/root/.openclaw/workspace",

      "compaction": {

        "mode": "safeguard"

      },

      "maxConcurrent": 4,

      "subagents": {

        "maxConcurrent": 8

      }

    }

  },

  "messages": {

    "ackReactionScope": "group-mentions"

  },

  "commands": {

    "native": "auto",

    "nativeSkills": "auto"

  },

  "hooks": {

    "internal": {

      "enabled": true,

      "entries": {

        "boot-md": {

          "enabled": true

        },

        "command-logger": {

          "enabled": true

        },

        "session-memory": {

          "enabled": true

        }

      }

    }

  },

  "channels": {

    "qqbot": {

      "enabled": true,

      "appId": "111",

      "clientSecret": "AAA"

    }

  },

  "gateway": {

    "port": 18789,

    "mode": "local",

    "bind": "loopback",

    "auth": {

      "mode": "token",

      "token": "AAA"

    },

    "tailscale": {

      "mode": "off",

      "resetOnExit": false

    }

  },

  "skills": {

    "install": {

      "nodeManager": "npm"

    }

  },

  "plugins": {

    "entries": {

      "qwen-portal-auth": {

        "enabled": true

      },

      "qqbot": {

        "enabled": true

      }

    }

  }

}

验证模型识别状态

输入clawdbot models list,若配置正确,终端会输出模型信息,示例如下:

1
2
3
Clawdbot 2026.1.24-3 (885167d) - No $999 stand required.
Model Input Ctx Local Auth Tags
bailian/qwen3-max-2026-01-23 text 256k no default, configured, alias:通义千问 Max Thinking 版

输出包含模型ID、输入类型、上下文窗口大小等信息,说明模型已被识别。

模型连通探测(真实请求验证)

输入openclaw models status –probe`(会产生模型调用费用),
若“Status”显示“ok”,说明模型调用正常;若失败,检查API Key有效性、环境变量配置或网络连接。

重启OpenClaw Gateway

终端输入openclaw gateway restart`,阿里云部署可通过“命令助手”远程执行,重启成功会显示“Restarted LaunchAgent”提示。

对话场景验证

openclaw agent –agent main –message “你是谁?”

补充

注册模型:

Run openclaw configure or set an API key env var.
![[Pasted image 20260207125107.png]]

切换模型

1
2
openclaw models list
openclaw models set (模型名)
作者

K.S.J

发布于

2026-02-01

更新于

2026-02-28

许可协议