如何使用 LMStudio 设置 Openclaw
Source: Dev.to
请提供您希望翻译的具体文本内容,我将为您翻译成简体中文。
引言
OpenClaw 引起了广泛关注,经历了 Clawdbot → Moltbot → OpenClaw 的演变。大多数教程依赖外部 API(OpenAI、Anthropic、Google 等),这可能会变得昂贵。本指南展示了如何在基于 Linux 的 Lenovo ThinkPad 上使用 LMStudio 本地运行 OpenClaw。
安装 LMStudio
- 在你的 Linux 系统上安装 LMStudio。
如果你需要帮助,YouTube 教程可以指导你完成安装过程。
Selecting a Model
Because of limited hardware resources, a quantized version of GLM‑4.7 Flash was chosen. After downloading the model, LMStudio’s chat interface responded to a simple “hello” in about 50 seconds, which is slow but acceptable for initial testing.
安装 OpenClaw
curl -fsSL https://openclaw.bot/install.sh | bash
在安装过程中,使用了 手动配置 向导。由于缺少一些必填字段(技能、模型提供商、令牌等),需要手动编辑配置文件。
编辑 openclaw.json
打开 ~/.openclaw/openclaw.json(或安装程序显示的路径),并添加以下章节。根据你的环境需要调整路径和数值。
{
"meta": {
"lastTouchedVersion": "2026.1.29",
"lastTouchedAt": "2026-01-31T02:01:52.403Z"
},
"wizard": {
"lastRunAt": "2026-01-31T02:01:52.399Z",
"lastRunVersion": "2026.1.29",
"lastRunCommand": "onboard",
"lastRunMode": "local"
},
"models": {
"providers": {
"lmstudio": {
"baseUrl": "http://127.0.0.1:1234/v1",
"apiKey": "lm-studio",
"api": "openai-responses",
"models": [
{
"id": "glm-4.7-flash",
"name": "GLM-4.7 Flash",
"reasoning": true,
"input": ["text"],
"cost": {
"input": 0,
"output": 0
},
"contextWindow": 20000,
"maxTokens": 8192
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "lmstudio/glm-4.7-flash"
},
"workspace": "/home/Ubuntu/.openclaw/workspace",
"compaction": {
"mode": "safeguard"
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
}
}
},
"messages": {
"ackReactionScope": "group-mentions"
},
"commands": {
"native": "auto",
"nativeSkills": "auto"
},
"hooks": {
"internal": {
"enabled": true,
"entries": {
"session-memory": {
"enabled": true
}
}
}
},
"gateway": {
"port": 18789,
"bind": "loopback",
"mode": "local",
"auth": {
"mode": "token",
"token": "generate-your-token"
},
"tailscale": {
"mode": "off",
"resetOnExit": false
}
},
"skills": {
"install": {
"nodeManager": "npm"
}
}
}
生成令牌
为网关身份验证创建令牌:
openssl rand -hex 20
将 gateway.auth.token 字段中的 "generate-your-token" 替换为生成的值。
验证安装
运行设置验证命令:
openclaw setup
预期输出:
Config OK: ~/.openclaw/openclaw.json
Workspace OK: ~/.openclaw/workspace
Sessions: OK: ~/.openclaw/agents/main/sessions
启动网关
检查网关状态:
openclaw gateway status
您应该会看到类似以下的行:
Listening: 127.0.0.1:18789
这表明 OpenClaw 正在本地监听端口 18789。
下一步
此时 OpenClaw 已安装并可通过本地网关访问。后续工作包括:
- 通过 OpenClaw CLI 或兼容客户端与机器人交互。
- 添加自定义技能或代理。
- 监控性能并根据需要调整模型参数。
压力测试 AI 代理(可选)
如果您为内部或商业用途开发 AI 代理,可以使用 Zeroshot 工具进行快速压力测试:
zeroshot scan --target-url https://your-target-url --max-attacks 20
该工具可以使用包含 1,000 多个攻击向量的库,对各种 AI 系统类别执行多达 50 次(或更多)攻击。访问 Zeroshot 网站获取免费试用。