OpenClaw 中 Model / 模型,是AI助理的“智力”水平体现

模型很重要,至少要选用25年12月之后发布的。

有内置与Custom Provider两种类型,推荐使用 Custom Provider

维度内置 ProviderCustom Provider
优点API KEY是保存在sqlite里模型参数可以自己控制(全在~/.openclaw/openclaw.json里)
缺点– 很有可能选错(code plan与opne API是不一样的接入URL)
– 可用模型有限,更别数据参数是什么了,比如火山。
– API KEY也在里面,好像与在sqlite里没有区别。<br>- 参数也要手工调。

安装时选择 Skip for now by 26.3.12

使用 openclaw configure --section models 命令进入交互配置CLI,配置完成后运行 openclaw gateway restart 重启生效。

修改默认模型

  1. 运行 openclaw dashboard 会自动打开 OpenClaw 的控制台页面(通常是 http://127.0.0.1:18789 )。
  2. 配置 > RAW(或Config > RAW)。
  3. 修改 agents.defaults.model.primary 字段为目标模型。
    • 或者直接在 ~/.openclaw/openclaw.json 中修改,但需要重启。
  4. 配置完成后,单击右上角 Save 保存配置,单击 Update。

[不推荐]手工修改~/.openclaw/openclaw.jsonmodels与agents节点

不推荐原因是未来json格式变化就不适用了,下面以兼容OpenAPI为示例。

  1. 注意:使用上面两个方法,会自动生成,但手工修改配置文件,需要重启网关才生效。
  2. 修改有备注的行,其他行直接复制使用。
  "models": {
    "mode": "merge",
    "providers": {
      "custom-ark-cn-beijing-volces-com": {
       // 第一个
      },
      "custom-qwen3-5-plus-aliyuncs-com": {  // 为 兼容OpenAPI 的 Endpoint ID
        "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1", // baseUrl
        "apiKey": "sk-xxx", // apiKey
        "api": "openai-completions",
        "models": [
          {
            "id": "qwen3.5-plus", // 为 Model ID
            "name": "qwen3.5-plus (Custom Provider)",
            "reasoning": false,
            "input": [
              "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 16000,
            "maxTokens": 4096
          }
        ]
      } // 还有第三个的话,继续。
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "custom-qwen3-5-plus-aliyuncs-com/qwen3.5-plus"
      },
      "models": {
        "custom-ark-cn-beijing-volces-com/glm-4-7-251222": { // 第一个
          "alias": "volcengine_glm47"
        },
        "custom-qwen3-5-plus-aliyuncs-com/qwen3.5-plus": { // 本次新增
          "alias": "aliyuncs_qwen3-5-plus" // 为 Model alias (optional)
        } // 还有第三个的话,继续。
      }, 
      "workspace": "C:\\Users\\xxx\\.openclaw\\workspace"
    }
  },

Custom Provider by 26.7.1

  1. 先使用 openclaw config 添加,提前准备,添加过中会验证。
  2. [可选]再进入TUI 对话验证是否成功
  3. vim ~/.openclaw/openclaw.json 调整模型参数,删除内置的auth节点 ,OpenClaw–火山方舟-火山引擎
  4. 重启生效

一般 contextWindow、maxTokens、reasoning 是为空值或保守的值,需要手动调整。

# 注意:根据你的实际值调整 ark-cn.models[0] 与三个Valuew 值
$ openclaw config set models.providers.ark-cn.models[0].contextWindow 1024000
$ openclaw config set models.providers.ark-cn.models[0].maxTokens 65536
$ openclaw config set models.providers.ark-cn.models[0].reasoning true  # 开启推理支持,LLM到现在很少有不支持推理的了。

配置内容效果:

  "agents": {
    "defaults": {
      "workspace": "~/.openclaw/workspace",
      "models": {
        "ark-cn/deepseek-v4-flash": {}
      },
      "model": {
        "primary": "ark-cn/deepseek-v4-flash" // 默认Model
      }
    }
  },
  "models": {
    "mode": "merge",
    "providers": {
      "ark-cn": {
        "baseUrl": "https://ark.cn-beijing.volces.com/api/coding/v3",
        "api": "openai-completions",  // 在配置过程可选 openai-responses
        "apiKey": "APIKEY",
        "models": [
          {
            "id": "deepseek-v4-flash",
            "name": "deepseek-v4-flash",
            "contextWindow": 1024000,
            "maxTokens": 65536,
            "input": [
              "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "reasoning": true
          }
        ]
      }
    }
  }

Custom Provider 添加第2个Model

第2个 Provider 可以使用 openclaw config 添加,但第2个Model需要手工添加。

  1. agents.defaults.models 添加记录 ,"<Provider>/<Model>":{}
  2. models.providers.ark-cn.models 添加数组,如下面内容
,
          {
            "id": "glm-5.2",
            "name": "glm-5.2",
            "reasoning": true,
            "contextWindow": 1024000,
            "maxTokens": 65536,
            "input": [
              "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            }
          }
  1. 在vim保存后,运行 openclaw config validate 验证,如果失败有具体提示:
Invalid config at /home/claw/.openclaw/openclaw.json:\n- models.providers.ark-cn.models.1.cost: Invalid input
  1. 验证成功后,重启生效

使用命令添加:

# 先要看目前索引是多少
openclaw config set models.providers.ark-cn.models.2 '{"id":"minimax-m3","name":"minimax-m3","reasoning": true,"contextWindow":512000,"maxTokens":65536,"input":["text","image"], "cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}}'
openclaw config set agents.defaults.models.'ark-cn/minimax-m3' '{}'
openclaw config set agents.defaults.model.primary 'ark-cn/minimax-m3'

内置 Provider by 26.7.1

查看当前生效的凭证配置:$ openclaw models status$ openclaw models auth list

Auth overview
Auth store    : ~/.openclaw/agents/main/agent/openclaw-agent.sqlite
Shell env     : off
Providers w/ OAuth/tokens (0): -
- volcengine effective=profiles:~/.openclaw/agents/main/agent/openclaw-agent.sqlite | profiles=1 (oauth=0, token=0, api_key=1) | volcengine:default=ark-0487...ee-a8e09
  
Agent: main
Auth state store: ~/.openclaw/agents/main/agent/openclaw-agent.sqlite
Profiles: (none)

删除内置的API KEY

# --force 是先删除已有配置,再重新配置,volcengine 是 <provider-id>
# 如果你只想清除、不想重新登录,在交互步骤直接 `Ctrl+C` 退出即可
$ openclaw models auth login --provider volcengine --force

内置 Model

$ openclaw models list # 查看供应商中,可用的模型列表 

# 设置默认模型,格式为 provider/model
$ openclaw models set volcengine-plan/ark-code-latest
# 没有 volcengine-plan/deepseek-v4-flash,只有少数几个低阶模型。

# 查看当前 allowlist 配置,也就是在TUI /model 中可用的模型
$ openclaw config get agents.defaults.models

# 删除TUI /model 中的模型
$ openclaw config unset agents.defaults.models.'列表中值'

在TUI /model 里看不到 models list的值:解答,添加办法:

# 单个添加
$ openclaw config set agents.defaults.models.'volcengine-plan/glm-4.7' '{}'

# 移除 allowlist 限制
$ openclaw config unset agents.defaults.models

发表回复