跳转到内容

Claude Max API Proxy

claude-max-api-proxy 是一个社区工具,它将您的 Claude Max/Pro 订阅公开为 OpenAI 兼容的 API 端点。这允许您将订阅与任何支持 OpenAI API 格式的工具一起使用。

方法成本最适合
Anthropic API按 token 付费 (~$15/M 输入, $75/M 输出 for Opus)生产应用,高容量
Claude Max 订阅$200/月 固定费用个人使用,开发,无限使用

如果您有 Claude Max 订阅并希望将其与 OpenAI 兼容的工具一起使用,此代理可以为您节省大量资金。

您的应用 → claude-max-api-proxy → Claude Code CLI → Anthropic (通过订阅)
(OpenAI 格式) (转换格式) (使用您的登录)

代理:

  1. http://localhost:3456/v1/chat/completions 接受 OpenAI 格式的请求
  2. 将它们转换为 Claude Code CLI 命令
  3. 以 OpenAI 格式返回响应(支持流式传输)
Terminal window
# 需要 Node.js 20+ 和 Claude Code CLI
npm install -g claude-max-api-proxy
# 验证 Claude CLI 已认证
claude --version
Terminal window
claude-max-api
# 服务器运行在 http://localhost:3456
Terminal window
# 健康检查
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!"}]
}'

您可以将 OpenClaw 指向代理作为自定义 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-4Claude Opus 4
claude-sonnet-4Claude Sonnet 4
claude-haiku-4Claude Haiku 4

创建一个 LaunchAgent 以自动运行代理:

Terminal window
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
  • 这是一个 社区工具,不受 Anthropic 或 OpenClaw 官方支持
  • 需要有效的 Claude Max/Pro 订阅并已认证 Claude Code CLI
  • 代理在本地运行,不会将数据发送到任何第三方服务器
  • 完全支持流式响应