Skip to content

在 OpenClaw 中使用🦞

1. Windows/Linux/MacOS安装

安装Node.js

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

sudo apt-get install -y nodejs

验证安装:

node --version
npm --version

安装openclaw:

npm i -g openclaw

验证安装:

openclaw --version

初始化运行:

openclaw onboard

2. 设置openclaw

  • Model/auth provider选择Custom Provider

  • API Base URL填写(以Codex中的模型为例):https://onlycode.shop/v1

  • 接着填写你的API Key🔗

  • Endpoint compatibility项如果是gpt系列模型请选择:OpenAI-compatible

  • Model ID可以填写:gpt-5.3-codex

  • 其余项默认或者随意。

  • 设置完成✅开始你的OpenClaw🦞之旅吧。

3. 错误

  • 403错误:如果您搭建的OpenClaw服务提示该报错,可能是由于您的网络问题导致触发了cloudflare的风险控制。请您尝试更换网络或者稍后再试。

  • 该网页无法正常运作(502):需要开启对应的服务器/设备端口。

4.直接修改文件进行配置

  • 可以参考该链接🔗

编辑json文件:

vi ~/.openclaw/openclaw.json

下面是一个简单的例子:

{
  "models": {
    "mode": "merge",
    "providers": {
      "onlycode": {
        "baseUrl": "https://onlycode.shop/v1",
        "apiKey": "你的密钥",
        "api": "openai-completions",
        "models": [
          {
            "id": "gpt-5.3-codex",
            "name": "gpt-5.3-codex"
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "onlycode/gpt-5.3-codex"
      }
    }
  }
}

以下为我测试时产生的openclaw.json文件,修改了contextWindow/maxTokens的值以及xhigh思考:

{
  "wizard": {
    "lastRunAt": "2026-02-22T13:41:48.373Z",
    "lastRunVersion": "2026.2.21-2",
    "lastRunCommand": "onboard",
    "lastRunMode": "local"
  },
  "models": {
    "mode": "merge",
    "providers": {
      "custom-onlycode-shop": {
        "baseUrl": "https://onlycode.shop/v1",
        "apiKey": "你的密钥",
        "api": "openai-completions",
        "models": [
          {
            "id": "gpt-5.3-codex",
            "name": "gpt-5.3-codex (Custom Provider)",
            "reasoning": false,
            "input": [
              "text"
            ],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 1000000,
            "maxTokens": 1000000
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "custom-onlycode-shop/gpt-5.3-codex"
      },
      "models": {
        "custom-onlycode-shop/gpt-5.3-codex": {}
      },
      "workspace": "/root/.openclaw/workspace",
      "compaction": {
        "mode": "safeguard"
      },
      "thinkingDefault": "xhigh",
      "maxConcurrent": 4,
      "subagents": {
        "maxConcurrent": 8
      }
    }
  },
  "messages": {
    "ackReactionScope": "group-mentions"
  },
  "commands": {
    "native": "auto",
    "nativeSkills": "auto",
    "restart": true,
    "ownerDisplay": "raw"
  },
  "gateway": {
    "port": 18789,
    "mode": "local",
    "bind": "loopback",
    "auth": {
      "mode": "token",
      "token": "你的token"
    },
    "tailscale": {
      "mode": "off",
      "resetOnExit": false
    },
    "nodes": {
      "denyCommands": [
        "camera.snap",
        "camera.clip",
        "screen.record",
        "calendar.add",
        "contacts.add",
        "reminders.add"
      ]
    }
  },
  "meta": {
    "lastTouchedVersion": "2026.2.21-2",
    "lastTouchedAt": "2026-02-22T13:41:48.380Z"
  }
}

Made with ❤️ by OnlyCode Team