OpenClaw

OpenClaw 接入第三方 API 时,需要配置供应商、接口协议、服务地址、API Key 和默认模型。

安装并进入配置向导

如果还没有安装 OpenClaw,根据系统运行官方安装命令。安装完成后会自动进入配置向导。

  • Windows PowerShell
iwr -useb https://openclaw.ai/install.ps1 | iex
  • Windows Cmd
powershell -NoProfile -ExecutionPolicy Bypass -Command "& ([scriptblock]::Create((irm https://openclaw.ai/install.ps1)))"
  • macOS / Linux
curl -fsSL https://openclaw.ai/install.sh | bash

如果已经安装 OpenClaw,运行下面的命令重新进入配置向导:

  • 终端
openclaw onboard --install-daemon

完成基础设置

进入配置向导后,按下面的方式选择:

  1. Continue? 选择 Yes。
OpenClaw 配置向导:Continue 选择 Yes
  1. Help make OpenClaw better? 选择 No thanks。
选择 No thanks
  1. Setup mode 选择 QuickStart。
Setup mode 选择 QuickStart
  1. Agent 名称保持默认的 main,直接按 Enter。
Agent 名称保持 main
  1. Model/auth provider 选择 Skip for now。
Model/auth provider 选择 Skip for now
  1. Default model 选择 Keep current。这里显示的模型名称不同也没关系,后面会重新写入 HiModels 配置。
Default model 选择 Keep current
  1. Select channel 选择 Skip for now。
Select channel 选择 Skip for now
  1. Search provider 选择 Skip for now。
Search provider 选择 Skip for now
  1. Install missing skill dependencies 选择 Skip for now。这是多选页面,需要先按 Space 选中,再按 Enter 提交。
Install missing skill dependencies 选择 Skip for now

其余设置保持默认,或选择 Skip for now。

HiModels 是自定义 Provider,因此先跳过内置模型配置,下一步再写入 HiModels 的 Key 和请求地址。

下面两种接入方式使用不同的 Provider 名称。你可以只配置一种,也可以继续配置其他模型;后续配置不会覆盖已经添加的模型。

OpenAI 接入

  • 根据你的系统选择对应命令,把其中的 sk-your-api-key 换成刚创建的 API Key,再将整段命令复制到终端运行。
  • macOS / Linux
cat <<'EOF' | openclaw config patch --stdin
{  
    "agents": {    
        "defaults": {      
            "model": {        
                "primary": "himodels-openai/gpt-6-astra"      
             }    
         }  
 },  
 "models": {    
     "mode": "merge",    
     "providers": {      
         "himodels-openai": {        
             "baseUrl": "https://api.himodels.ai/v1",        
             "apiKey": "sk-your-api-key",        
             "api": "openai-responses",        
             "models": [          
                 {            
                     "id": "gpt-6-astra",            
                     "name": "GPT-6 Astra"          
                 }        
              ]      
         }    
     }  
  }
}
EOF

Claude 接入

  • 根据你的系统选择对应命令,把其中的 sk-your-api-key 换成刚创建的 API Key,再将整段命令复制到终端运行。
  • macOS / Linux
cat <<'EOF' | openclaw config patch --stdin
{  
    "agents": {    
        "defaults": {      
            "model": {        
                "primary": "himodels-claude/claude-sonnet-5-5"      
             }    
         }  
 },  
 "models": {    
     "mode": "merge",    
     "providers": {      
         "himodels-claude": {        
             "baseUrl": "https://api.himodels.ai",        
             "apiKey": "sk-your-api-key",        
             "api": "anthropic-messages",        
             "models": [          
                 {            
                     "id": "claude-sonnet-5-5",            
                     "name": "Claude Sonnet 5.5"          
                 }        
              ]      
         }    
     }  
  }
}
EOF

检查配置

完成任意一种接入配置后,运行下面的命令检查配置:

终端:
openclaw config validate
openclaw config get agents.defaults.model.primary

看到 Config valid,并且第二条命令显示刚配置的模型,即表示配置已经写入:

  • OpenAI:himodels-openai/gpt-6-astra
  • Claude:himodels-claude/claude-sonnet-5-5
openclaw config validate 显示 Config valid

打开 Dashboard 验证是否接入成功

重新启动 Gateway,再打开 Dashboard:

终端:
openclaw gateway restart
openclaw dashboard

浏览器打开后:

  1. 新建一个会话。
  2. 点击输入框下方的模型名称,选择刚配置的模型。
  3. 发送一条消息。

最后配置的模型会成为新会话的默认模型;已有会话可能继续使用此前选中的模型,因此验证时需要新建会话或手动切换。OpenClaw 能正常回复,并且 HiModels 的用量记录中出现了对应模型的请求,即表示接入成功。

先确认 API Key 选择了对应的可外接分组,再核对上表中的请求地址、API 模式和模型名称。遇到 401、403、429 等错误时,查看 常见问题。