openclaw调用ollama本地模型
环境:
需要互联网,需要从互联网下载openclaw包,及模型api调用。或者先下载工具和模型,离线导入使用,后面有说明
操作系统:Kylin Linux Advanced Server
release V11 2503/(Swan25)-x86_64-Build20/20250715
Kernel: 6.6.0-32.7.v2505.ky11.x86_64
准备工作:
node版本:>=22,离线包方式提供node-v24.14.0-linux-x64.tar.xz。
安装脚本:install.sh 离线包方式提供
注:离线安装openclaw,后面有说明,离线包openclaw-2026.3.2.tgz
安装步骤:
配置
所需文件已存放到/root下
cd /root
tar xf ./node-v24.14.0-linux-x64.tar.x
echo "PATH=/root/node-v24.14.0-linux-x64/bin/:$PATH" >> /etc/profile
source /etc/profile
node -v
npm -v
npm config set registry https://registry.npmmirror.com
curl -fsSL https://clawd.org.cn/install.sh | sudo bash -s
注:或者手动安装
npm install -g openclaw@latest
openclaw-cn onboard
会自动安装openclaw,并运行openclaw-cn向导
向导开始后,参考如下配置
此处选择Qwen

浏览器访问地址,需要注册千问账号,注册后访问地址确认登录


配置技能等,默认即可

默认即可

当选择 Hatch in TUI (recommended),会在当前终端连接ai对话

显示本地访问地址,不加参数--no-open,会打开浏览器自动访问
注:需要系统有图形桌面,并有浏览器
openclaw dashboard --no-open

浏览器访问
当需要远程访问时,需要配置端口转发
1、在openclaw服务所在机器上执行命令:
编辑 /etc/ssh/sshd_config ,查找X11Forwarding yes所在行,确认配置为yes
退出保存,重启systemctl restart sshd

2、在需要远程访问的机器上执行命令:
ssh -N -L 18789:127.0.0.1:18789 root@192.168.88.55 #输入密码后终端处在连接状态,不能关闭

说明:将远程主机18789端口绑定到192.168.88.55的18789端口,
3、远程主机访问
浏览器访问127.0.0.1:18789或带令牌的链接http://127.0.0.1:18789/#token=e18f8c740d38840f068a0ee72a358cd13e1f91237ac80065
配置令牌:

对话

配置文件
~/.openclaw/openclaw.json
也可通过图形界面修改

配合ollama,连接其本地模型和云端模型
ollama网站 https://ollama.com/download/linux
linux版本离线包需要去github下载,在线下载访问
在线安装:
curl -fsSL https://ollama.com/install.sh | sh
离线安装:已导入ollama包
cd /root
mkdir ollama
tar xf ollama-linux-amd64.tar.zst -C ollama
ln -s /root/ollama/bin/ollama /usr/bin/
ollama --help
ollama serve #启动服务
ollama launch #启动向导,另起一个终端
选择 Run a model
选择 minimax-m2.5:cloud
拉取一个云端模型 #拉取云端模型需要注册登录ollama
拉取一个模型到本地,并对话模型,qwen3.5:0.8b模型大小在1G多
ollama run qwen3.5:0.8b
配置文件夹
~/.ollama/
配置文件 ~/.ollama/config.json
模型存放位置:
~/.ollama/models/ 模型目录
ollama关联openclaw
ollama launch
Launch OpenClaw > minimax-m2.5:cloud
离线包方式
npm install -g ./openclaw-2026.3.2.tgz

openclaw-cn onboard
后续同前面
获取离线包,配置仓库
npm pack openclaw@latest
会打包依赖,生成对应的离线包文件
官方文档:
https://docs.openclaw.ai/zh-CN
github
https://github.com/openclaw/openclaw
在线千问配置
[root@localhost ~]# cat ~/.openclaw/openclaw.json
查看代码
{
"wizard": {
"lastRunAt": "2026-03-09T08:00:08.454Z",
"lastRunVersion": "2026.3.8",
"lastRunCommand": "onboard",
"lastRunMode": "local"
},
"auth": {
"profiles": {
"qwen-portal:default": {
"provider": "qwen-portal",
"mode": "oauth"
}
}
},
"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
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "qwen-portal/coder-model"
},
"models": {
"qwen-portal/coder-model": {
"alias": "qwen"
},
"qwen-portal/vision-model": {}
},
"workspace": "/root/.openclaw/workspace",
"compaction": {
"mode": "safeguard"
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
}
}
},
"tools": {
"profile": "coding"
},
"messages": {
"ackReactionScope": "group-mentions"
},
"commands": {
"native": "auto",
"nativeSkills": "auto",
"restart": true,
"ownerDisplay": "raw"
},
"session": {
"dmScope": "per-channel-peer"
},
"gateway": {
"port": 18789,
"mode": "local",
"bind": "loopback",
"auth": {
"mode": "token",
"token": "e18f8c740d38840f068a0ee72a358cd13e1f91237ac80065"
},
"tailscale": {
"mode": "off",
"resetOnExit": false
},
"nodes": {
"denyCommands": [
"camera.snap",
"camera.clip",
"screen.record",
"contacts.add",
"calendar.add",
"reminders.add",
"sms.send"
]
}
},
"plugins": {
"entries": {
"qwen-portal-auth": {
"enabled": true
}
}
},
"meta": {
"lastTouchedVersion": "2026.3.8",
"lastTouchedAt": "2026-03-09T08:00:08.485Z"
}
}
相关内容:ollama及openclaw
通过网盘分享的文件:AI工具及模型
链接: https://pan.baidu.com/s/1Azn3wqZMC6FBCqcv3JYNNw?pwd=xaej 提取码: xaej
本文来自博客园,作者:赛博狗尾草,转载请注明原文链接:https://www.cnblogs.com/gpysir/p/19701006
浙公网安备 33010602011771号