Claude Max API 代理
claude-max-api-proxy 是一個社群工具,能將您的 Claude Max/Pro 訂閱作為 OpenAI 相容的 API 端點暴露出來。這讓您能在任何支援 OpenAI API 格式的工具中使用您的訂閱。
為什麼使用這個?
Section titled “為什麼使用這個?”| 方式 | 計費路徑 | 最適合 |
|---|---|---|
| Anthropic API | 透過 Claude Console 或雲端依 Token 付費 | 生產環境應用程式、共用自動化、大量使用 |
| Claude 訂閱代理 | Claude Code / claude -p 方案與額度規則 | 使用相容工具進行個人實驗 |
如果您擁有 Claude Max 或 Pro 訂閱並希望搭配 OpenAI 相容工具使用,此代理可能適合某些個人工作流程。這並非 無限量的固定費率路徑。對於生產環境使用,API 金鑰 仍是更清晰的政策與計費途徑。
Your App → claude-max-api-proxy → Claude Code CLI / claude -p → Anthropic (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
- 這是一個社群工具,並非由 Anthropic 或 OpenClaw 官方支援
- 需要有效的 Claude Max/Pro 訂閱,並已透過 Claude Code CLI 完成驗證
- 繼承 Claude Code
claude -p的計費、使用額度與速率限制行為 - 此代理在本機執行,不會將資料傳送至任何第三方伺服器
- 完全支援串流回應
與 Claude CLI 或 API 金鑰的原生 OpenClaw 整合。
用於 OpenAI/Codex 訂閱。
所有提供者、模型參照與故障轉移行為的總覽。
完整設定參考。