Claude Max API Proxy

claude-max-api-proxy 是一个社区工具,能把你的 Claude Max/Pro 订阅暴露成 OpenAI 兼容的 API 端点。这样任何支持 OpenAI API 格式的工具都能用上你的订阅。

警告: 这只是技术层面的兼容方案。Anthropic 过去曾限制过在 Claude Code 之外使用订阅额度 的行为。是否使用请自行判断,使用前务必确认 Anthropic 当前的服务条款。

为什么用它?

方案费用适合场景
Anthropic API按 token 计费(Opus 约 $15/M 输入,$75/M 输出)生产环境、高流量
Claude Max 订阅$200/月 固定费用个人使用、开发、不限量

如果你有 Claude Max 订阅,又想在 OpenAI 兼容工具中使用,这个代理可能帮你降低某些工作流的成本。但对于生产环境来说,API 密钥仍然是合规路径更清晰的选择。

工作原理

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

代理的工作流程:

  1. http://localhost:3456/v1/chat/completions 接收 OpenAI 格式请求
  2. 转换为 Claude Code CLI 命令
  3. 以 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!"}]
  }'

在 OpenClaw 中使用

把 OpenClaw 指向代理的 OpenAI 兼容端点:

{
  env: {
    OPENAI_API_KEY: "not-needed",
    OPENAI_BASE_URL: "http://localhost:3456/v1",
  },
  agents: {
    defaults: {
      model: { primary: "openai/claude-opus-4" },
    },
  },
}

可用模型

Model ID对应模型
claude-opus-4Claude Opus 4
claude-sonnet-4Claude Sonnet 4
claude-haiku-4Claude 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

链接

注意事项

  • 这是社区工具,Anthropic 和 OpenClaw 官方均不提供支持
  • 需要有效的 Claude Max/Pro 订阅,且 Claude Code CLI 已完成认证
  • 代理在本地运行,不会将数据发送到任何第三方服务器
  • 完整支持流式响应

参见