-
前提条件
确保已安装并运行 Ollama 服务,且模型
qwen3-vl:2b已下载。 -
配置步骤
修改 OpenClaw 配置文件,指定 Ollama 作为模型提供商并设置默认模型。
-
验证配置
通过 TUI 界面进行对话测试,确认模型正常工作。
-
高级配置
可根据需要添加更多模型或调整参数如
contextWindow和maxTokens。 -
注意事项
- 确保 Ollama 服务地址与配置中的
baseUrl一致。 - 模型 ID 必须与 Ollama 中的模型名称匹配。
- 若模型支持多模态,可在
input字段中添加"image"等类型。
- 确保 Ollama 服务地址与配置中的
编辑 ~/.openclaw/openclaw.json 文件,添加或修改以下配置内容:
json
{
"agents": {
"defaults": {
"models": {"ollama":{}},
"model": {"primary": "ollama/qwen3-vl:2b"}
}
},
"models": {
"providers": {
"ollama":{
"baseUrl": "http://127.0.0.1:11434/v1",
"apiKey": "ollama-local",
"api": "openai-completions",
"models": [
{
"id": "qwen3-vl:2b",
"name": "Qwen3 VL 2B",
"reasoning": false,
"input": ["text"],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 128000,
"maxTokens": 8192
}
]
}
}
}
}
重启 OpenClaw 网关服务
配置完成后需要重启网关服务使更改生效:
bash
openclaw gateway restart
测试对话功能
使用 OpenClaw 的 TUI 界面测试对话功能:
bash
openclaw tui