OpenClaw 配置

一、概述

OpenClaw(原 Clawdbot)是一个开源的AI代理框架,支持通过配置文件或GUI界面进行灵活配置。LongCat 系列模型支持在 OpenClaw 中使用,本文档介绍如何将OpenClaw与LongCat API 开放平台对接。

二、使用前准备

在使用OpenClaw前,您需要准备好以下内容:

  1. OpenClaw安装包

MacOS 环境下安装命令如下:

bash
# 使用npm安装
npm install -g openclaw@latest

# 或使用pnpm安装
pnpm add -g openclaw@latest

# 或使用curl安装
curl -fsSL https://openclaw.ai/install.sh | bash

Windows PowerShell 环境下安装命令如下:

bash
iwr -useb https://openclaw.ai/install.ps1 | iex
  1. LongCat核心配置

支持的模型:

模型名称API格式描述
LongCat-2.0OpenAI/Anthropic高性能Agentic模型

三、快速启动

向导启动命令

bash
openclaw onboard --install-daemon

向导配置选项说明

步骤建议
Risk确认选择 yes 继续
Onboarding mode推荐选择 QuickStart,快速完成基础配置
Model/auth provider选择 Skip for now
Filter models by provider选择 All providers
Default model选择 Keep current
Select channelSkip for now,后续再配置
Configure skills推荐选 Yes,启用本地实用技能
Preferred node manager for skill installs选择 npm
Install missing skill dependencies选择 Skip for now
各种API Key设置没有的话选 NoSkip
Gateway service选择 InstallReinstall 安装 Gateway 服务
How to hatch your bot推荐选 Hatch in TUI 体验交互式界面

四、启动后的配置

向导启动完成后,OpenClaw会自动启动Gateway服务并打开Web控制页面。

默认访问地址

http://127.0.0.1:18789

如果页面没有自动打开,可以手动在浏览器中访问上述地址。

配置文件位置

OpenClaw的配置文件位于:~/.openclaw/openclaw.json

五、LongCat模型配置

启动后我们可以通过修改自定义配置来接入LongCat模型。

配置方案一:修改配置文件

1. 增加自定义模型供应商

openclaw.json中添加models字段:

json
{
   "models": {
      "mode": "merge",
      "providers": {
         "longCat": {
            "baseUrl": "https://api.longcat.chat/openai",
            "apiKey": "YOUR_API_KEY",
            "api": "openai-completions",
            "authHeader": true,
            "models": [
               {
                  "id": "LongCat-2.0",
                  "name": "LongCat-2.0",
                  "reasoning": false,
                  "input": ["text"],
                  "contextWindow": 1048576,
                  "maxTokens": 131072,
                  "compat": {
                      "maxTokensField": "max_tokens"
                  }
               }
            ]
         }
      }
   }
}

2. 修改默认模型设置

修改agents字段,设置默认模型:

json
{
   "agents": {
      "defaults": {
         "model": {
            "primary": "longCat/LongCat-2.0"
         }
      }
   }
}

修改保存后立即生效。

配置方案二:GUI界面配置

  1. 在Web控制页面中,进入 Config → Models → Providers
  2. 添加如下配置:
配置项
Apiopenai-completions
Api KeyLongCat的API Key
Base Urlhttps://api.longcat.chat/openai
models - idLongCat模型名
models - nameLongCat模型名

完整配置示例

json
{
  "meta": {
    "lastTouchedVersion": "2026.1.24-3",
    "lastTouchedAt": "2026-01-29T02:21:28.058Z"
  },
  "wizard": {
    "lastRunAt": "2026-01-29T02:13:14.153Z",
    "lastRunVersion": "2026.1.24-3",
    "lastRunCommand": "onboard",
    "lastRunMode": "local"
  },
  "auth": {
    "profiles": {
      "anthropic:default": {
        "provider": "anthropic",
        "mode": "api_key"
      }
    }
  },
  "models": {
    "mode": "merge",
    "providers": {
      "longCat": {
        "baseUrl": "https://api.longcat.chat/openai",
        "apiKey": "YOUR_API Key",
        "auth": "api-key",
        "api": "openai-completions",
        "authHeader": true,
        "models": [
          {
            "id": "LongCat-2.0",
            "name": "LongCat-2.0",
            "reasoning": false,
            "input": ["text"],
            "contextWindow": 1048576,
            "maxTokens": 131072,
            "compat": {
              "maxTokensField": "max_tokens"
            }
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "longCat/LongCat-2.0"
      },
      "workspace": "/Users/xxx/.openclaw/workspace",
      "contextPruning": {
        "mode": "cache-ttl",
        "ttl": "1h"
      },
      "compaction": {
        "mode": "safeguard"
      },
      "heartbeat": {
        "every": "30m"
      },
      "maxConcurrent": 4,
      "subagents": {
        "maxConcurrent": 8
      }
    }
  },
  "messages": {
    "ackReactionScope": "group-mentions"
  },
  "commands": {
    "native": "auto",
    "nativeSkills": "auto"
  },
  "gateway": {
    "port": 18789,
    "mode": "local",
    "bind": "loopback",
    "auth": {
      "mode": "token",
      "token": ""
    },
    "tailscale": {
      "mode": "off",
      "resetOnExit": false
    }
  },
  "skills": {
    "install": {
      "nodeManager": "npm"
    }
  }
}

六、开始使用

配置生效后,即可使用 OpenClaw。

  • 打开TUI,并查看Gateway状态
bash
openclaw tui
/status
  • 打开Web UI,在Chat页面进行交互
bash
openclaw dashboard

然后输入测试消息,如:"你好,请介绍一下自己"

如果配置正确,您将收到来自LongCat模型的回复。