Clawdbot 安装与配置阿里云百炼模型指南2
本文档记录从安装 Clawdbot (OpenClaw) 到配置阿里云百炼 DashScope qwen3-max-2026-01-23 模型的完整步骤。
目录
openclaw tui --session new 这是开启新对话命令
1. 环境准备
服务器要求
- Linux 服务器(Ubuntu/Debian/CentOS 等)
- Node.js 18+
- npm 或 pnpm
检查 Node.js 版本
node -v
npm -v
2. 安装 Clawdbot
2.1 解决 GitHub SSH 权限问题(如遇到)
如果安装时报错 Permission denied (publickey),先运行:
git config --global url."https://github.com/".insteadOf ssh://git@github.com/
2.2 全局安装
npm i -g clawdbot
或使用淘宝镜像(国内服务器推荐):
npm i -g clawdbot --registry=https://registry.npmmirror.com
2.3 验证安装
clawdbot --version
3. 初始化配置
3.1 运行初始化向导
clawdbot init
或
openclaw init
3.2 初始化选项说明
初始化过程中会询问几个问题:
| 步骤 | 说明 |
|---|---|
| Start TUI | 定义 agent 的行为,可填写唤醒消息 |
| Token | Gateway 认证令牌,自动生成 |
| How to hatch your bot | 选择 Hatch in TUI 或 Do this later |
3.3 Qwen OAuth 认证
如果使用 Qwen Portal 免费模型,会要求进行 OAuth 认证:
- 打开提示的 URL:
https://chat.qwen.ai/authorize?user_code=XXX&client=qwen-code - 在浏览器中授权
- 终端显示
Qwen OAuth complete即成功
4. Web UI 远程访问与调试 (SSH 端口转发)
如果你希望在本地浏览器中使用 Clawdbot 的图形界面 (Web UI) 来调试和操作远程服务器上的 Agent,请按以下步骤操作。
4.1 建立 SSH 隧道
在本地电脑(不是远程服务器)的终端中运行以下命令:
ssh -L 18789:127.0.0.1:18789 root@你的服务器IP
参数说明:
-L 18789:127.0.0.1:18789:将远程服务器的 18789 端口映射到本地电脑的 18789 端口。- 这样你访问本地的
localhost:18789就等于访问远程服务器的127.0.0.1:18789。
4.2 获取访问链接 (Token)
在远程服务器的终端中运行:
clawdbot dashboard --no-open
# 或者
openclaw dashboard --no-open
系统会输出类似以下的链接:
Dashboard URL: http://127.0.0.1:18789/?token=1cee16b58ad695526efa5a0172e5d278da8cd6d2251b54a6
4.3 本地浏览器访问
复制上面生成的链接,将 127.0.0.1 替换为 localhost (或者直接使用),粘贴到本地浏览器地址栏:
http://localhost:18789/?token=你的token
现在你就可以在本地图形界面中调试和控制远程的 Clawdbot 了。
提示:如果链接中 token 为
undefined,请参考常见问题中的解决方法重新配置 Gateway Token。
5. 配置自定义模型 qwen3-max-2026-01-23
5.1 获取阿里云 DashScope API Key
- 访问 阿里云百炼控制台
- 创建 API Key
- 记录 API Key(格式:
sk-xxxxxxxxxxxxxxxx)
5.2 API Base URL
DashScope 提供两种 API 格式:
| 类型 | Base URL | 用途 |
|---|---|---|
| OpenAI 兼容 ✅ | https://dashscope.aliyuncs.com/compatible-mode/v1 |
Clawdbot 使用 |
| DashScope 原生 | https://dashscope.aliyuncs.com/api/v1 |
阿里云 SDK |
Clawdbot 必须使用 OpenAI 兼容格式!
5.3 编辑配置文件
配置文件位置:
~/.openclaw/openclaw.json
# 或
~/.clawdbot/clawdbot.json
5.4 完整配置文件示例
使用以下命令写入配置:
cat > ~/.openclaw/openclaw.json << 'EOF'
{
"messages": {
"ackReactionScope": "group-mentions"
},
"agents": {
"defaults": {
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
},
"compaction": {
"mode": "safeguard"
},
"workspace": "/root/.openclaw/workspace",
"models": {
"qwen-portal/coder-model": {
"alias": "qwen"
},
"qwen-portal/vision-model": {},
"dashscope/deepseek-v3.2": {}
},
"model": {
"primary": "dashscope/deepseek-v3.2"
}
}
},
"gateway": {
"mode": "local",
"auth": {
"mode": "token",
"token": "1cee16b58ad695526efa5a0172e5d278da8cd6d2251b54a6"
},
"port": 18789,
"bind": "loopback",
"tailscale": {
"mode": "off",
"resetOnExit": false
}
},
"plugins": {
"entries": {
"qwen-portal-auth": {
"enabled": true
}
}
},
"models": {
"providers": {
"qwen-portal": {
"baseUrl": "https://portal.qwen.ai/v1",
"apiKey": "qwen-oauth",
"api": "openai-completions",
"models": [
{
"id": "coder-model",
"name": "Qwen Coder",
"reasoning": false,
"input": ["text"],
"cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0},
"contextWindow": 128000,
"maxTokens": 8192
},
{
"id": "vision-model",
"name": "Qwen Vision",
"reasoning": false,
"input": ["text", "image"],
"cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0},
"contextWindow": 128000,
"maxTokens": 8192
}
]
},
"dashscope": {
"baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"apiKey": "sk-24984e6efaab4294b889b3635840703c",
"api": "openai-completions",
"models": [
{
"id": "deepseek-v3.2",
"name": "DeepSeek V3.2",
"reasoning": false,
"input": ["text"],
"contextWindow": 65536,
"maxTokens": 8192
}
]
}
}
},
"auth": {
"profiles": {
"qwen-portal:default": {
"provider": "qwen-portal",
"mode": "oauth"
}
}
},
"wizard": {
"lastRunAt": "2026-01-30T08:59:57.704Z",
"lastRunVersion": "2026.1.29",
"lastRunCommand": "onboard",
"lastRunMode": "local"
},
"meta": {
"lastTouchedVersion": "2026.1.29",
"lastTouchedAt": "2026-01-30T08:59:57.716Z"
}
}
EOF
cat > ~/.openclaw/openclaw.json << 'EOF'
{
"messages": {
"ackReactionScope": "group-mentions"
},
"agents": {
"defaults": {
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
},
"compaction": {
"mode": "safeguard"
},
"workspace": "/root/.openclaw/workspace",
"models": {
"qwen-portal/coder-model": {
"alias": "qwen"
},
"qwen-portal/vision-model": {},
"dashscope/qwen3-max-2026-01-23": {}
},
"model": {
"primary": "dashscope/qwen3-max-2026-01-23"
}
}
},
"gateway": {
"mode": "local",
"auth": {
"mode": "token",
"token": "你的gateway-token"
},
"port": 18789,
"bind": "loopback",
"tailscale": {
"mode": "off",
"resetOnExit": false
}
},
"plugins": {
"entries": {
"qwen-portal-auth": {
"enabled": true
}
}
},
"models": {
"providers": {
"qwen-portal": {
"baseUrl": "https://portal.qwen.ai/v1",
"apiKey": "qwen-oauth",
"api": "openai-completions",
"models": [
{
"id": "coder-model",
"name": "Qwen Coder",
"reasoning": false,
"input": ["text"],
"cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0},
"contextWindow": 128000,
"maxTokens": 8192
},
{
"id": "vision-model",
"name": "Qwen Vision",
"reasoning": false,
"input": ["text", "image"],
"cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0},
"contextWindow": 128000,
"maxTokens": 8192
}
]
},
"dashscope": {
"baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"apiKey": "sk-你的DashScope密钥",
"api": "openai-completions",
"models": [
{
"id": "qwen3-max-2026-01-23",
"name": "Qwen3 Max",
"reasoning": false,
"input": ["text"],
"contextWindow": 256000,
"maxTokens": 8192
}
]
}
}
},
"auth": {
"profiles": {
"qwen-portal:default": {
"provider": "qwen-portal",
"mode": "oauth"
}
}
},
"wizard": {
"lastRunAt": "2026-01-30T08:59:57.704Z",
"lastRunVersion": "2026.1.29",
"lastRunCommand": "onboard",
"lastRunMode": "local"
},
"meta": {
"lastTouchedVersion": "2026.1.29",
"lastTouchedAt": "2026-01-30T08:59:57.716Z"
}
}
EOF
清除旧会话
rm -rf ~/.openclaw/workspace/sessions/*
重启
openclaw tui
5.5 关键配置说明
| 配置项 | 说明 |
|---|---|
agents.defaults.model.primary |
默认使用的模型,设为 dashscope/qwen3-max-2026-01-23 |
models.providers.dashscope.baseUrl |
DashScope OpenAI 兼容端点 |
models.providers.dashscope.apiKey |
你的 DashScope API Key |
models.providers.dashscope.models |
模型定义列表 |
5.6 验证 JSON 格式
cat ~/.openclaw/openclaw.json | python3 -m json.tool
如果输出格式化的 JSON,说明格式正确。
6. 启动与验证
6.1 启动 TUI
openclaw tui
# 或
clawdbot tui
6.2 检查状态栏
启动后,底部状态栏应显示:
agent main | session main | dashscope/qwen3-max-2026-01-23 | tokens xxx/256k
如果显示 anthropic/qwen3-max-2026-01-23 则配置有误,需重新检查。
6.3 测试对话
在 TUI 中输入任意问题测试模型是否正常响应。
7. 常见问题
Q1: SSH 连接报错 "REMOTE HOST IDENTIFICATION HAS CHANGED"
原因:服务器 SSH 密钥变更
解决:
ssh-keygen -R 服务器IP
然后重新连接。
Q2: npm 安装报错 "Permission denied (publickey)"
原因:npm 尝试用 SSH 从 GitHub 拉取依赖
解决:
git config --global url."https://github.com/".insteadOf ssh://git@github.com/
npm i -g clawdbot
Q3: Token 显示 undefined
原因:Gateway Token 未正确配置
解决:
clawdbot configure --section gateway
Q4: 模型无响应(超时)
原因:模型配置错误,Provider 不匹配
检查:
- 确认
primary模型名与providers中定义的一致 - 确认使用 OpenAI 兼容的 Base URL
- 确认 API Key 正确
Q5: nano 粘贴内容格式乱掉
解决:不要用 nano 粘贴多行内容,改用 cat << 'EOF' 方式写入文件。
附录
可用模型参考
| Provider | 模型 | 说明 |
|---|---|---|
| qwen-portal | coder-model | Qwen 代码模型(免费) |
| qwen-portal | vision-model | Qwen 视觉模型(免费) |
| dashscope | qwen3-max-2026-01-23 | Qwen3 Max(需 API Key) |
| dashscope | qwen-plus | Qwen Plus |
| dashscope | qwen-turbo | Qwen Turbo |
相关链接
文档更新日期:2026-01-30

评论 0