Skip to content

OpenClaw 配置指南

OpenClaw Version

OpenClaw 是一个自托管的消息网关,可以将 WhatsApp、Telegram、Discord、iMessage 等聊天平台与 AI Agent 连接起来。

以下配置以默认端点 iina.ai 为例,如需使用国内加速端点,请将 iina.ai 替换为 acc.iina.ai

安装 OpenClaw

shell
# 安装(需要 Node 22+)
curl -fsSL https://openclaw.ai/install.sh | bash

配置 API 密钥

  1. 获取 API 密钥:登录控制台新建令牌,建议留空 模型限制列表 以支持所有模型。

  2. 将密钥写入 ~/.openclaw/.env 文件:

    ~/.openclaw/.env
    shell
    IINA_API_KEY=sk-xxx
  3. 编辑 ~/.openclaw/openclaw.json 配置文件:

    ~/.openclaw/openclaw.json
    json
    {
      "auth": {
        "profiles": {
          "anthropic:default": {
            "provider": "anthropic",
            "mode": "api_key"
          }
        }
      },
      "models": {
        "mode": "merge",
        "providers": {
          "anthropic": {
            "baseUrl": "https://iina.ai/",
            "apiKey": { "source": "env", "provider": "default", "id": "IINA_API_KEY" },
            "auth": "api-key",
            "api": "anthropic-messages",
            "authHeader": true,
            "models": [
              {
                "id": "claude-opus-4-7",
                "name": "claude-opus-4-7",
                "api": "anthropic-messages",
                "reasoning": true,
                "input": ["text", "image"],
                "cost": {
                  "input": 5,
                  "output": 25,
                  "cacheRead": 0.5,
                  "cacheWrite": 6.25
                },
                "contextWindow": 1000000,
                "maxTokens": 128000,
                "compat": {
                  "supportsStore": true,
                  "supportsDeveloperRole": true,
                  "supportsReasoningEffort": true
                }
              },
              {
                "id": "claude-sonnet-4-6",
                "name": "claude-sonnet-4-6",
                "api": "anthropic-messages",
                "reasoning": true,
                "input": ["text", "image"],
                "cost": {
                  "input": 3,
                  "output": 15,
                  "cacheRead": 0.3,
                  "cacheWrite": 3.75
                },
                "contextWindow": 1000000,
                "maxTokens": 64000,
                "compat": {
                  "supportsStore": true,
                  "supportsDeveloperRole": true,
                  "supportsReasoningEffort": true
                }
              }
            ]
          }
        }
      },
      "agents": {
        "defaults": {
          "model": {
            "primary": "anthropic/claude-opus-4-7"
          },
          "memorySearch": {
            "enabled": true,
            "provider": "openai",
            "remote": {
              "baseUrl": "https://iina.ai/v1",
              "apiKey": { "source": "env", "provider": "default", "id": "IINA_API_KEY" }
            },
            "model": "text-embedding-3-large"
          },
          "thinkingDefault": "off"
        },
        "list": [
          {
            "id": "main",
            "thinkingDefault": "adaptive"
          }
        ]
      }
    }
  4. 检查配置并重启:

    shell
    openclaw doctor
    openclaw gateway restart

关键配置说明

  • provider id 必须是 anthropic:不能改成 iina 等自定义名称。OpenClaw 内置的 Anthropic plugin 是按 provider id 来识别的,用自定义名称会导致 Opus 4.7 的 xhigh / max / adaptive thinking 无法启用。
  • contextWindow: 1000000 必须显式配置:否则会被覆盖为默认的 200K。

思考模式配置

以上配置的逻辑是:

  • 全局 thinkingDefault: "off":其他 agent 默认不开启 thinking;
  • main agent 单独设为 adaptive:主对话让模型自己判断思考深度(仅限 Opus 4.7);
  • 需要推理时手动输入 /think xhigh/think max 等指令来覆盖默认的思考模式。

使用 OpenClaw

其他配置请参考 OpenClaw 官方文档