Skip to content

Latest commit

 

History

History
206 lines (155 loc) · 4.3 KB

File metadata and controls

206 lines (155 loc) · 4.3 KB

Claude Max Subscription via CLI Wrapper

Use your Claude Pro/Max subscription as a LibreChat endpoint — no API key billing.


Architecture

LibreChat  ->  CLIProxyAPI (:8317)  ->  claude CLI (SDK)  ->  Anthropic
               OpenAI-compatible       CLAUDE_CODE_OAUTH_TOKEN

Step 1 — Generate Long-Lived Token

Run on any machine with a browser (one-time):

claude setup-token
# -> sk-ant-oat01-...   <- shown ONCE, save it now

Store securely:

cat >> ~/.claude-auth.env << 'EOF'
CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-...
EOF
chmod 600 ~/.claude-auth.env

Token is valid for 1 year. No refresh cron needed.


Step 2 — Install CLIProxyAPI

macOS:

brew install router-for-me/tap/cliproxyapi

Linux / manual:

# Requires Node 18+
npm install -g cliproxyapi

On Uberspace (via augur):

augur proxy setup
# Installs cliproxyapi, creates config, registers service

Step 3 — Configure CLIProxyAPI

mkdir -p ~/.cli-proxy-api
cat > ~/.cli-proxy-api/config.yaml << 'EOF'
port: 8317
remote-management:
  allow-remote: false
  secret-key: ""
auth-dir: "~/.cli-proxy-api"
auth:
  providers: []    # empty = use OAuth token, not API key validation
debug: false
EOF

Step 4 — Run the Proxy

source ~/.claude-auth.env
cliproxyapi --config ~/.cli-proxy-api/config.yaml

Verify:

curl http://localhost:8317/v1/models
# -> should list claude-sonnet-*, claude-opus-*, etc.

As a systemd user service (~/.config/systemd/user/cliproxyapi.service):

[Unit]
Description=CLIProxyAPI — Claude subscription OpenAI endpoint
After=network.target

[Service]
EnvironmentFile=%h/.claude-auth.env
ExecStart=cliproxyapi --config %h/.cli-proxy-api/config.yaml
Restart=always
RestartSec=10

[Install]
WantedBy=default.target
systemctl --user enable --now cliproxyapi

On Uberspace (systemd):

augur proxy start
# Uses ~/.config/systemd/user/cliproxyapi.service

Step 5 — Wire into LibreChat

Already preconfigured in librechat.yaml (commented out by default).

Uncomment the "Claude Max" endpoint section and restart:

augur yaml    # edit librechat.yaml
augur restart

Or manually add to librechat.yaml:

endpoints:
  custom:
    - name: "Claude Max"
      apiKey: "dummy"
      baseURL: "http://localhost:8317/v1"
      models:
        default:
          - claude-sonnet-4-6
          - claude-opus-4-6
          - claude-haiku-4-5-20251001
        fetch: false
      titleConvo: true
      titleModel: "claude-sonnet-4-6"
      directEndpoint: true
      summarize: false

Ensure .env has custom in ENDPOINTS:

ENDPOINTS=openAI,anthropic,custom

Restart LibreChat — "Claude Max" appears in the model selector.


Step 6 — Token Expiry Monitoring

Use claude-auth-daemon.sh --once in cron to check token health:

# crontab -e
*/30 * * * *  ~/bin/claude-auth-daemon.sh --once >> ~/.claude-auth.log 2>&1
# Annual renewal reminder
0 9 1 */11 * curl -sd "Claude setup-token renewal due -- $(hostname)" https://ntfy.sh/your-topic

On Uberspace, the augur cron hook runs the check automatically every 30 minutes when ~/.claude-auth.env exists.


augur proxy Commands

augur proxy setup     Install CLIProxyAPI, create config, register service
augur proxy start     Start CLIProxyAPI service
augur proxy stop      Stop CLIProxyAPI service
augur proxy status    Show CLIProxyAPI service status
augur proxy test      Test proxy endpoint (curl /v1/models)
augur proxy token     Show token expiry info

Limitations

Feature Status
Chat completions + streaming Supported
Multi-turn conversation Supported
Model selection Supported
temperature / top_p / max_tokens Ignored by CLI layer
1M context window Not available (OAuth restriction)
Token cost tracking in LibreChat Not available (subscription, not per-token)
Multi-user LibreChat Shared subscription limits apply

ToS Note

Anthropic's terms are designed for individual interactive use. Using a subscription via CLI wrapper for personal single-user self-hosted LibreChat is a grey area at moderate scale. For business/production use, the commercial API (ANTHROPIC_API_KEY) is the correct path.