OpenClaw 中转站配置详细教程

  发布时间:2026-03-02 11:50:29   作者:秒懂AI+   我要评论
本文介绍了如何在Windows、macOS和Linux系统上配置OpenClaw使用自定义API中转站,通过安装OpenClaw、初始化配置文件、编辑主配置文件和鉴权文件,以及启动Gateway和TUI,本文提供常见问题的解决方法和配置要点总结,帮助用户顺利完成配置,感兴趣的朋友跟随小编一起看看吧

OpenClaw 中转站配置教程

前言

本教程教你如何配置 OpenClaw 使用自定义 API 中转站。

适用系统: Windows / macOS / Linux
预计时间: 10 分钟

第一步:安装与初始化

1. 安装 OpenClaw

npm install -g openclaw

注意:Windows 用户如果提示 openclaw 不是命令,可以使用 clawdbot 代替。

2. 执行初始化

openclaw onboard

按提示完成基础设置。

第二步:修改主配置文件

⚠️ 重要提示

OpenClaw 不支持通过环境变量 ANTHROPIC_BASE_URL 来设置自定义 API 端点。必须通过配置文件的 models.providers 来配置。

配置文件位置

系统配置文件路径
WindowsC:\Users\你的用户名\.clawdbot\clawdbot.json
macOS~/.clawdbot/clawdbot.json~/openclaw/clawdbot.json
Linux~/.clawdbot/clawdbot.json~/openclaw/clawdbot.json

注意: 配置文件可能在 .clawdbotopenclaw 目录,取决于你的安装方式。

步骤 1:备份配置文件(可选)

macOS/Linux:

# 如果在 .clawdbot 目录
cp ~/.clawdbot/clawdbot.json ~/.clawdbot/clawdbot.json.bak
# 或者在 openclaw 目录
cp ~/openclaw/clawdbot.json ~/openclaw/clawdbot.json.bak

Windows:

copy %USERPROFILE%\.clawdbot\clawdbot.json %USERPROFILE%\.clawdbot\clawdbot.json.bak

步骤 2:编辑配置文件

macOS/Linux:

# 如果在 .clawdbot 目录
nano ~/.clawdbot/clawdbot.json
# 或者在 openclaw 目录
nano ~/openclaw/clawdbot.json

Windows:

notepad %USERPROFILE%\.clawdbot\clawdbot.json

步骤 3:复制以下配置内容

{
  "models": {
    "mode": "merge",
    "providers": {
      "api-proxy-gpt": {
        "baseUrl": "https://apipro.maynor1024.live/v1",
        "api": "openai-completions",
        "apiKey": "sk-你的API密钥",
        "models": [
          {
            "id": "gpt-4o",
            "name": "GPT-4o",
            "reasoning": false,
            "input": ["text"],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 128000,
            "maxTokens": 8192
          }
        ]
      },
      "api-proxy-claude": {
        "baseUrl": "https://apipro.maynor1024.live",
        "api": "anthropic-messages",
        "apiKey": "sk-你的API密钥",
        "models": [
          {
            "id": "claude-sonnet-4-5-20250929",
            "name": "Claude Sonnet 4.5",
            "reasoning": false,
            "input": ["text"],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 200000,
            "maxTokens": 8192
          }
        ]
      },
      "api-proxy-google": {
        "baseUrl": "https://apipro.maynor1024.live/v1beta",
        "api": "google-generative-ai",
        "apiKey": "sk-你的API密钥",
        "models": [
          {
            "id": "gemini-3-pro-preview",
            "name": "Gemini 3 Pro",
            "reasoning": false,
            "input": ["text"],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 2000000,
            "maxTokens": 8192
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "api-proxy-claude/claude-sonnet-4-5-20250929"
      },
      "models": {
        "api-proxy-gpt/gpt-4o": {
          "alias": "GPT-4o"
        },
        "api-proxy-claude/claude-sonnet-4-5-20250929": {
          "alias": "Claude Sonnet 4.5"
        },
        "api-proxy-google/gemini-3-pro-preview": {
          "alias": "Gemini 3 Pro"
        }
      }
    }
  },
  "auth": {
    "profiles": {
      "api-proxy-gpt:default": {
        "provider": "api-proxy-gpt",
        "mode": "api_key"
      },
      "api-proxy-claude:default": {
        "provider": "api-proxy-claude",
        "mode": "api_key"
      },
      "api-proxy-google:default": {
        "provider": "api-proxy-google",
        "mode": "api_key"
      }
    }
  }
}

关键配置说明

字段说明必需
baseUrl自定义 API 端点地址
apiKey你的 API 密钥(直接写在这里)
apiAPI 类型
models模型列表配置

🔑 重要:将所有 sk-你的API密钥 替换为你的真实 API Key!

第三步:配置鉴权文件

配置文件位置

系统鉴权文件路径
WindowsC:\Users\你的用户名\.clawdbot\agents\main\agent\auth-profiles.json
macOS~/.clawdbot/agents/main/agent/auth-profiles.json
~/openclaw/agents/main/agent/auth-profiles.json
Linux~/.clawdbot/agents/main/agent/auth-profiles.json
~/openclaw/agents/main/agent/auth-profiles.json

编辑鉴权文件

macOS/Linux:

# 如果在 .clawdbot 目录
nano ~/.clawdbot/agents/main/agent/auth-profiles.json
# 或者在 openclaw 目录
nano ~/openclaw/agents/main/agent/auth-profiles.json

Windows:

notepad %USERPROFILE%\.clawdbot\agents\main\agent\auth-profiles.json

复制以下内容

{
  "version": 1,
  "profiles": {
    "api-proxy-gpt:default": {
      "type": "api_key",
      "provider": "api-proxy-gpt",
      "key": "sk-你的API密钥"
    },
    "api-proxy-claude:default": {
      "type": "api_key",
      "provider": "api-proxy-claude",
      "key": "sk-你的API密钥"
    },
    "api-proxy-google:default": {
      "type": "api_key",
      "provider": "api-proxy-google",
      "key": "sk-你的API密钥"
    }
  },
  "lastGood": {
    "api-proxy-gpt": "api-proxy-gpt:default",
    "api-proxy-claude": "api-proxy-claude:default",
    "api-proxy-google": "api-proxy-google:default"
  }
}

🔑 重要:将所有 sk-你的API密钥 替换为你的真实 API Key!

第四步:检查并启动

1. 运行健康检查(可选)

openclaw doctor

2. 启动 Gateway 服务

openclaw gateway

预期输出:

🚀 OpenClaw Gateway starting...
📡 WebSocket server listening on ws://127.0.0.1:18789
🌐 Web interface available at http://127.0.0.1:18789
✨ Gateway ready!

保持这个窗口打开!

3. 启动 TUI(新窗口)

打开新的终端窗口,运行:

openclaw tui

4. 测试对话

在 TUI 中输入:

你好

如果 AI 正常回复,配置成功!🎉

5. 访问 Web 控制台(可选)

打开浏览器访问:http://127.0.0.1:18789/

使用 openclaw onboard 结尾输出的 Token 登录。

常用命令

命令说明
/models查看所有可用模型
/model api-proxy-gpt/gpt-4o切换到 GPT-4o
/model api-proxy-claude/claude-sonnet-4-5-20250929切换到 Claude Sonnet 4.5
/model api-proxy-google/gemini-3-pro-preview切换到 Gemini 3 Pro
/model status查看当前模型状态
/clear清空对话历史
/save保存当前会话
/quit退出 TUI

常见问题

问题 1: (no output) - 没有响应

原因: API Key 未配置或配置错误

解决步骤:

  1. 检查 clawdbot.json 中的 apiKey 字段
  2. 检查 auth-profiles.json 中的 key 字段
  3. 确认两个文件中的 API Key 一致
  4. 确认没有拼写错误和多余空格
  5. 重启 Gateway 和 TUI

问题 2: fetch failed - 请求失败

原因: 网络连接问题或 API 地址错误

解决步骤:

  1. 检查 baseUrl 是否正确:

    • GPT: https://apipro.maynor1024.live/v1
    • Claude: https://apipro.maynor1024.live
    • Gemini: https://apipro.maynor1024.live/v1beta
  2. 测试网络连接:

curl -I https://apipro.maynor1024.live
  1. 查看 Gateway 日志查找错误

问题 3: 端口被占用

错误信息: Port 18789 already in use

Windows 解决:

netstat -ano | findstr :18789
taskkill /PID <PID> /F

macOS/Linux 解决:

lsof -i :18789
kill -9 <PID>

问题 4: 找不到配置文件

解决: 确保已经运行过 openclaw onboard 初始化

如果配置目录不存在,手动创建:

Windows:

mkdir %USERPROFILE%\.clawdbot\agents\main\agent

macOS/Linux:

mkdir -p ~/.clawdbot/agents/main/agent
# 或者
mkdir -p ~/openclaw/agents/main/agent

配置文件完整路径速查

Windows

主配置文件:
C:\Users\你的用户名\.clawdbot\clawdbot.json
鉴权文件:
C:\Users\你的用户名\.clawdbot\agents\main\agent\auth-profiles.json

macOS/Linux

主配置文件:
~/.clawdbot/clawdbot.json
或
~/openclaw/clawdbot.json
鉴权文件:
~/.clawdbot/agents/main/agent/auth-profiles.json
或
~/openclaw/agents/main/agent/auth-profiles.json

提示: 使用以下命令查找配置文件位置:

macOS/Linux:

find ~ -name "clawdbot.json" 2>/dev/null

Windows (PowerShell):

Get-ChildItem -Path $env:USERPROFILE -Filter "clawdbot.json" -Recurse -ErrorAction SilentlyContinue

配置要点总结

  • API Key 需要配置在两个地方:
    • config.jsonmodels.providers[].apiKey
    • auth-profiles.jsonprofiles[].key
  • 两个文件中的 API Key 必须一致
  • baseUrl 必须正确:
    • GPT 需要 /v1 后缀
    • Claude 不需要后缀
    • Gemini 需要 /v1beta 后缀
  • 不支持环境变量配置
  • 配置完成后需要重启 Gateway

总结

配置步骤:

  1. ✅ 安装 OpenClaw
  2. ✅ 修改 config.json(包含 apiKey)
  3. ✅ 修改 auth-profiles.json(包含 key)
  4. ✅ 启动 Gateway 和 TUI
  5. ✅ 开始使用

到此这篇关于OpenClaw 中转站配置完全指南的文章就介绍到这了,更多相关OpenClaw 中转站配置内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!

相关文章

  • OpenClaw 中转站配置详细教程

    本文介绍了如何在Windows、macOS和Linux系统上配置OpenClaw使用自定义API中转站,通过安装OpenClaw、初始化配置文件、编辑主配置文件和鉴权文件,以及启动Gateway和TUI,本文
    2026-03-02
  • 超轻量级OpenClaw本地部署与一键安装、配置指南

    OpenClaw超轻量版本地部署指南介绍了一个功能完整且轻量级的AI助手,适用于学习和使用,该指南详细介绍了环境准备、快速安装、基础配置、核心功能体验等步骤,安装配置过程比
    2026-03-02
  • OpenClaw千帆模型切换:精准配置步骤与关键命令详解

    本文围绕OpenClaw千帆模型切换展开,系统梳理从环境准备到配置落地的全流程,精准拆解关键配置步骤与核心命令,涵盖模型选择、授权登录、配置生效等环节,为开发者提供实操
    2026-03-02
  • OpenClaw配置部署完整实战指南(附踩坑记录)

    OpenClaw是一个开源的AI智能体,文章详细介绍了部署OpenClaw的流程,包括部署和配置,在过程中可以少踩很多坑,感兴趣的可以了解一下
    2026-03-02
  • OpenClaw 集成自定义 Grok API 完整攻略(最新整理)

    本文记录了将 OpenClaw 飞书机器人从默认 AI 模型切换到自定义 Grok API 的完整过程,包括遇到的问题和解决方案,非常适合需要为 OpenClaw 配置自定义 AI 提供商的开发者参
    2026-03-02
  • Windows 系统下的 WSL2 中安装 OpenClaw 的完整详细教程

    在 Windows 系统下的 WSL2 中安装 OpenClaw 的完整详细教程,你可以让它运行在自己的电脑上,通过 WhatsApp、Telegram、Discord、Slack 等你已经在用的聊天软件与它对话
    2026-03-01
  • OpenClaw入门教程之介绍与安装、配置分享 (原Clawdbot)

    OpenClaw 是一个可执行任务的智能体,我们给指令,它不仅回答,还能主动操作系统、访问网页、处理邮件、整理文件、发起提醒甚至自动编写代码
    2026-03-01
  • OpenClaw 从新手到中级完整教程

    上一篇文章为大家分享了max mini系统下OpenClaw的安装与基本配置,这里接着为大家分享一下OpenClaw的进阶知识,方便大家更好的掌握openclaw的核心功能,多多研究skill,找
    2026-03-01
  • 苹果Macmini下OpenClaw保姆级配置教程(全网最简单)

    如果你也想把 Macmini 变成 24h 在线的 私人秘书,这篇就是保姆级喂饭教程,为什么选择mac mini来配置OpenClaw,因为OpenClaw是在unix开发的,而openclaw也是unix系统,所
    2026-03-01
  • OpenClaw 常用命令小结

    OpenClaw 的命令行工具非常强大,覆盖了从安装配置到日常使用的方方面面,为了让你能快速上手,我将最常用的命令整理为以下分类速查表,你可以将它看作一份随时查阅的急救手
    2026-03-01

最新评论