提供商
Claude Max API 代理
claude-max-api-proxy 是一个社区 npm 软件包(不是 OpenClaw 插件),它将 Claude Max/Pro 订阅公开为与 OpenAI 兼容的 API 端点,因此你可以让任何与 OpenAI 兼容的工具使用你的订阅,而不必使用 Anthropic API key。
为什么使用此方案
| 方式 | 计费路径 | 最适合 |
|---|---|---|
| Anthropic API key | 通过 Claude Console 按 token 付费 | 生产应用、共享自动化和大规模用量 |
| Claude 订阅代理 | Claude Code / claude -p 套餐和点数规则 |
使用兼容工具进行个人实验 |
此代理让 Claude Max 或 Pro 订阅可与 OpenAI 兼容工具配合使用。它并不是不限量的固定费率方案,而是沿用 Claude Code 的使用限额。对于生产用途,API key 仍是计费方式更清晰的路径。
工作原理
Your App -> claude-max-api-proxy -> Claude Code CLI / claude -p -> Anthropic (OpenAI format) (converts format) (uses your login)代理会针对每个请求将 Claude Code CLI 作为子进程启动,把 OpenAI 格式的聊天请求转换为 CLI 提示词,并以 OpenAI 格式流式传回(或直接返回)响应。
入门指南
Install the proxy
需要 Node.js 20+ 以及已完成身份验证的 Claude Code CLI。
npm install -g claude-max-api-proxy # Verify Claude CLI is authenticatedclaude --versionclaude auth login # if not already authenticatedStart the server
claude-max-api# Server runs at http://localhost:3456Test the proxy
curl http://localhost:3456/healthcurl 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!"}] }'Configure OpenClaw
将 OpenClaw 指向该代理,把它作为自定义的 OpenAI 兼容端点:
{ env: { OPENAI_API_KEY: "not-needed", OPENAI_BASE_URL: "http://localhost:3456/v1", }, agents: { defaults: { model: { primary: "openai/claude-opus-4" }, }, },}| 模型 ID | CLI 别名 | 当前映射 |
|---|---|---|
claude-opus-4 |
opus |
Claude Opus 4.5 |
claude-sonnet-4 |
sonnet |
Claude Sonnet 4 |
claude-haiku-4 |
haiku |
Claude Haiku 4 |
高级配置
Proxy-style OpenAI-compatible notes
此方案使用 OpenClaw 通用的自定义 /v1 OpenAI 兼容路由,与其他任何自托管 OpenAI 兼容后端使用相同路径:
- 不会应用仅限原生 OpenAI 的请求结构调整。
/fast和service_tier仅适用于直接发送到api.anthropic.com的流量;代理路由不会修改service_tier(请参阅 Anthropic 提供商快速模式)。- 不会进行 Responses
store、提示词缓存提示或 OpenAI 推理兼容载荷的结构调整。 - OpenClaw 的 OpenAI/Codex 归属标头(
originator、version、User-Agent)仅随原生api.openai.comOAuth 流量发送,不会发送到此代理这类自定义OPENAI_BASE_URL目标。
Auto-start on macOS with 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注意事项
- 沿用 Claude Code 的
claude -p计费、使用点数和速率限制行为。 - 仅绑定到
127.0.0.1;除了 CLI 自身向 Anthropic 发出的调用之外,不会将数据发送到任何第三方服务器。 - 支持流式响应。
- 启动时不会检查身份验证失败,只有在实际运行聊天请求后才会暴露此问题;如果 CLI 尚未完成身份验证,预期首次请求会失败,而不是服务器拒绝启动。
相关内容
Was this useful?