mirror of
https://github.com/hanzoai/bot.git
synced 2026-11-01 18:02:28 +00:00
Three coordinated things:
1. Resolve the committed upstream/main merge conflicts. 94 files were
sitting with raw <<<<<<< HEAD ... >>>>>>> upstream/main blocks. Every
conflict had HanzoBot/Bot on HEAD and OpenClaw on upstream. Resolved
by keeping HEAD everywhere — 540 conflict blocks.
2. Rewrite remaining OpenClaw text refs.
OPENCLAW → HANZO_BOT
OpenClaw → HanzoBot (PascalCase type identifiers)
openclaw → bot (codebase convention — botToken,
botUsername etc.; avoids invalid
hyphenated JS identifiers)
openclaw[_]/openclaw[A-Z] → bot[_]/bot[A-Z] (compound)
ai.openclaw.x → ai.hanzo.bot.x (JVM package path)
3. Delete or rename openclaw-named file paths (116 of them). Dead
duplicates with a Bot-named canonical from the partial migration:
deleted. Otherwise renamed.
ai/openclaw/** → deleted (ai/hanzo/bot/** canonical)
Sources/OpenClaw*/ → deleted (Sources/Bot* canonical)
Tests/OpenClawIPCTests/ → deleted (Tests/BotIPCTests canonical)
OpenClawKit/ → deleted (BotKit canonical)
openclaw-tools.*.ts → deleted (bot-tools.*.ts canonical)
openclaw-root.ts etc. → deleted (bot-root.ts canonical)
types.openclaw.ts → deleted (types.bot.ts canonical)
extensions/*/openclaw.plugin.json → renamed hanzo-bot.plugin.json
docs/start/openclaw.md → renamed hanzo-bot.md (+ zh-CN)
docs/assets/openclaw-*.png, whatsapp-openclaw*.jpg → deleted
scripts/.../openclaw-* → deleted (bot/hanzo-bot parallels)
openclaw.mjs → deleted (hanzo-bot.mjs is package.bin)
Then patched 65 broken JS/TS import strings where hanzo-bot had ended
up inside an import path ('./types.hanzo-bot.js' → './types.bot.js'
etc., since the on-disk filename uses the brand-neutral bot- prefix).
Pre-existing lint debt cleaned up to get oxlint --type-aware to 0/0:
removed the dead i18n test that referenced a path no longer existing;
defined the missing DIDConfig and WalletConfig types in types.base.ts
(they were imported but never declared); dropped unused imports;
collapsed redundant type assertion and a tautological meta.bot lookup
that the openclaw→bot rename made redundant.
The a2ui.bundle.js generated artifact is kept at its pre-rebrand
contents — it gets regenerated by 'pnpm canvas:a2ui:bundle' from
sources I cannot rebuild in this commit; the source side is clean.
Verified: 0 occurrences of openclaw (case-insensitive) in tree source
content, 0 file or directory paths with openclaw in the name; oxlint
--type-aware src test reports 0/0.
4.4 KiB
4.4 KiB
read_when, summary, title, x-i18n
| read_when | summary | title | x-i18n | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
将 Claude Max/Pro 订阅用作 OpenAI 兼容的 API 端点 | Claude Max API 代理 |
|
Claude Max API 代理
claude-max-api-proxy 是一个社区工具,将你的 Claude Max/Pro 订阅暴露为 OpenAI 兼容的 API 端点。这使你可以将订阅与任何支持 OpenAI API 格式的工具配合使用。
为什么使用它?
| 方式 | 费用 | 适用场景 |
|---|---|---|
| Anthropic API | 按 token 计费(Opus 约 $15/M 输入,$75/M 输出) | 生产应用、高流量场景 |
| Claude Max 订阅 | 每月固定 $200 | 个人使用、开发、无限用量 |
如果你有 Claude Max 订阅并希望与 OpenAI 兼容工具配合使用,这个代理可以帮你节省大量费用。
工作原理
你的应用 → claude-max-api-proxy → Claude Code CLI → Anthropic(通过订阅)
(OpenAI 格式) (转换格式) (使用你的登录凭据)
该代理:
- 在
http://localhost:3456/v1/chat/completions接受 OpenAI 格式的请求 - 将其转换为 Claude Code CLI 命令
- 以 OpenAI 格式返回响应(支持流式传输)
安装
# 需要 Node.js 20+ 和 Claude Code CLI
npm install -g claude-max-api-proxy
# 验证 Claude CLI 已认证
claude --version
使用方法
启动服务器
claude-max-api
# 服务器运行在 http://localhost:3456
测试
# 健康检查
curl http://localhost:3456/health
# 列出模型
curl http://localhost:3456/v1/models
# 聊天补全
curl http://localhost:3456/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4",
"messages": [{"role": "user", "content": "Hello!"}]
}'
与 HanzoBot 配合使用
你可以将 HanzoBot 指向该代理作为自定义 OpenAI 兼容端点:
{
env: {
OPENAI_API_KEY: "not-needed",
OPENAI_BASE_URL: "http://localhost:3456/v1",
},
agents: {
defaults: {
model: { primary: "openai/claude-opus-4" },
},
},
}
可用模型
| 模型 ID | 对应模型 |
|---|---|
claude-opus-4 |
Claude Opus 4 |
claude-sonnet-4 |
Claude Sonnet 4 |
claude-haiku-4 |
Claude Haiku 4 |
macOS 自动启动
创建 LaunchAgent 以自动运行代理:
cat > ~/Library/LaunchAgents/com.claude-max-api.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.claude-max-api</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/node</string>
<string>/usr/local/lib/node_modules/claude-max-api-proxy/dist/server/standalone.js</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/opt/homebrew/bin:~/.local/bin:/usr/bin:/bin</string>
</dict>
</dict>
</plist>
EOF
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.claude-max-api.plist
链接
- npm: https://www.npmjs.com/package/claude-max-api-proxy
- GitHub: https://github.com/atalovesyou/claude-max-api-proxy
- Issues: https://github.com/atalovesyou/claude-max-api-proxy/issues
注意事项
- 这是一个社区工具,并非由 Anthropic 或 HanzoBot 官方支持
- 需要有效的 Claude Max/Pro 订阅并已认证 Claude Code CLI
- 代理在本地运行,不会将数据发送到任何第三方服务器
- 完全支持流式响应
另请参阅
- Anthropic 提供商 - HanzoBot 与 Claude 的原生集成,使用 setup-token 或 API 密钥
- OpenAI 提供商 - 适用于 OpenAI/Codex 订阅