Claude Max API 代理
claude-max-api-proxy 是一個社群工具,能將您的 Claude Max/Pro 訂閱作為 OpenAI 相容的 API 端點暴露出來。這讓您能在任何支援 OpenAI API 格式的工具中使用您的訂閱。
為什麼使用這個?
Section titled “為什麼使用這個?”| 方式 | 成本 | 最適合 |
|---|---|---|
| Anthropic API | 按 token 付費(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)該代理:
- 在
http://localhost:3456/v1/chat/completions接受 OpenAI 格式的請求 - 將其轉換為 Claude Code CLI 指令
- 以 OpenAI 格式回傳回應(支援串流)
安裝代理
需要 Node.js 20+ 和 Claude Code CLI。
Terminal window npm install -g claude-max-api-proxy# Verify Claude CLI is authenticatedclaude --version啟動伺服器
Terminal window claude-max-api# Server runs at http://localhost:3456測試代理
Terminal window # Health checkcurl http://localhost:3456/health# List modelscurl http://localhost:3456/v1/models# Chat completioncurl 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" },},},}
| 模型 ID | 對應至 |
|---|---|
claude-opus-4 | Claude Opus 4 |
claude-sonnet-4 | Claude Sonnet 4 |
claude-haiku-4 | Claude Haiku 4 |
Proxy-style OpenAI-compatible notes
此路徑使用與其他自訂
/v1 後端相同的代理式 OpenAI 相容路由:
- 原生僅限 OpenAI 的請求塑形不適用
- 無
service_tier,無 Responsesstore,無提示快取提示,且無 OpenAI 推理相容負載塑形 - 隱藏的 OpenClaw 歸屬標頭(
originator、version、User-Agent) 不會在代理 URL 上注入
Auto-start on macOS with LaunchAgent
建立一個 LaunchAgent 以自動執行代理:
cat > ~/Library/LaunchAgents/com.claude-max-api.plist << 'EOF'Label
com.claude-max-api
RunAtLoad
KeepAlive
ProgramArguments
/usr/local/bin/node
/usr/local/lib/node_modules/claude-max-api-proxy/dist/server/standalone.js
EnvironmentVariables
PATH
/usr/local/bin:/opt/homebrew/bin:~/.local/bin:/usr/bin:/bin
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
- 問題: https://github.com/atalovesyou/claude-max-api-proxy/issues
- 這是一個 社群工具,並非由 Anthropic 或 OpenClaw 官方支援
- 需要有效的 Claude Max/Pro 訂閱,並已驗證 Claude Code CLI
- 代理在本地執行,不會將資料發送到任何第三方伺服器
- 完全支援串流回應
使用 Claude CLI 或 API 金鑰的原生 OpenClaw 整合。
適用於 OpenAI/Codex 訂閱。
所有提供者、模型參照和故障轉移行為的概覽。
完整設定參考。