跳转到内容

Claude Max API 代理

claude-max-api-proxy 是一个社区工具,可以将您的 Claude Max/Pro 订阅暴露为 OpenAI 兼容的 API 端点。这允许您在与 OpenAI API 格式兼容的任何工具中使用您的订阅。

方式费用最适合
Anthropic API按令牌付费(Opus 输入约 $15/M,输出 $75/M)生产应用,高吞吐量
Claude Max 订阅$200/月 固定费用个人使用,开发,不限量使用

如果您拥有 Claude Max 订阅并希望将其与 OpenAI 兼容的工具一起使用,此代理可能会减少某些工作流程的成本。对于生产使用,API 密钥仍然是更明确的政策路径。

Your App → claude-max-api-proxy → Claude Code CLI → Anthropic (via subscription)
(OpenAI format) (converts format) (uses your login)

该代理:

  1. http://localhost:3456/v1/chat/completions 接受 OpenAI 格式的请求
  2. 将它们转换为 Claude Code CLI 命令
  3. 以 OpenAI 格式返回响应(支持流式传输)
Terminal window
# Requires Node.js 20+ and Claude Code CLI
npm install -g claude-max-api-proxy
# Verify Claude CLI is authenticated
claude --version
Terminal window
claude-max-api
# Server runs at http://localhost:3456
Terminal window
# Health check
curl http://localhost:3456/health
# List models
curl http://localhost:3456/v1/models
# Chat completion
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
  • 代理在本地运行,不会将数据发送到任何第三方服务器
  • 完全支持流式响应