Skip to content

Claude Max API 代理

claude-max-api-proxy 是一個社群工具,能將您的 Claude Max/Pro 訂閱作為 OpenAI 相容的 API 端點暴露出來。這讓您能在任何支援 OpenAI API 格式的工具中使用您的訂閱。

方式成本最適合
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)

該代理:

  1. http://localhost:3456/v1/chat/completions 接受 OpenAI 格式的請求
  2. 將其轉換為 Claude Code CLI 指令
  3. 以 OpenAI 格式回傳回應(支援串流)
  1. 安裝代理

    需要 Node.js 20+ 和 Claude Code CLI。

    Terminal window
    npm install -g claude-max-api-proxy
    # Verify Claude CLI is authenticated
    claude --version
  2. 啟動伺服器

    Terminal window
    claude-max-api
    # Server runs at http://localhost:3456
  3. 測試代理

    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!"}]
    }'
  4. 設定 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-4Claude Opus 4
claude-sonnet-4Claude Sonnet 4
claude-haiku-4Claude Haiku 4
Proxy-style OpenAI-compatible notes

此路徑使用與其他自訂 /v1 後端相同的代理式 OpenAI 相容路由:

  • 原生僅限 OpenAI 的請求塑形不適用
  • service_tier,無 Responses store,無提示快取提示,且無 OpenAI 推理相容負載塑形
  • 隱藏的 OpenClaw 歸屬標頭(originatorversionUser-Agent) 不會在代理 URL 上注入
Auto-start on macOS with LaunchAgent

建立一個 LaunchAgent 以自動執行代理:

Terminal window
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
  • 代理在本地執行,不會將資料發送到任何第三方伺服器
  • 完全支援串流回應

Anthropic provider

使用 Claude CLI 或 API 金鑰的原生 OpenClaw 整合。

OpenAI provider

適用於 OpenAI/Codex 訂閱。

Model selection

所有提供者、模型參照和故障轉移行為的概覽。

Configuration

完整設定參考。