@blockrun/clawrouter 0.12.62 → 0.12.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,81 @@
1
+ # Routing Profiles & Pricing
2
+
3
+ ClawRouter offers four routing profiles to balance cost vs quality. Prices are in **$/M tokens** (input/output).
4
+
5
+ ## ECO (Absolute Cheapest)
6
+
7
+ Use `blockrun/eco` for maximum cost savings.
8
+
9
+ | Tier | Primary Model | Input | Output |
10
+ | --------- | ---------------------------- | ----- | ------ |
11
+ | SIMPLE | nvidia/gpt-oss-120b | $0.00 | $0.00 |
12
+ | MEDIUM | google/gemini-2.5-flash-lite | $0.10 | $0.40 |
13
+ | COMPLEX | google/gemini-2.5-flash-lite | $0.10 | $0.40 |
14
+ | REASONING | xai/grok-4-1-fast-reasoning | $0.20 | $0.50 |
15
+
16
+ ---
17
+
18
+ ## AUTO (Balanced - Default)
19
+
20
+ Use `blockrun/auto` for the best quality/price balance.
21
+
22
+ | Tier | Primary Model | Input | Output |
23
+ | --------- | ----------------------------- | ----- | ------ |
24
+ | SIMPLE | moonshot/kimi-k2.5 | $0.60 | $3.00 |
25
+ | MEDIUM | xai/grok-code-fast-1 | $0.20 | $1.50 |
26
+ | COMPLEX | google/gemini-3.1-pro | $2.00 | $12.00 |
27
+ | REASONING | xai/grok-4-1-fast-reasoning | $0.20 | $0.50 |
28
+
29
+ ---
30
+
31
+ ## PREMIUM (Best Quality)
32
+
33
+ Use `blockrun/premium` for maximum quality.
34
+
35
+ | Tier | Primary Model | Input | Output |
36
+ | --------- | -------------------- | ----- | ------ |
37
+ | SIMPLE | moonshot/kimi-k2.5 | $0.60 | $3.00 |
38
+ | MEDIUM | openai/gpt-5.2-codex | $1.75 | $14.00 |
39
+ | COMPLEX | claude-opus-4.6 | $5.00 | $25.00 |
40
+ | REASONING | claude-sonnet-4.6 | $3.00 | $15.00 |
41
+
42
+ ---
43
+
44
+ ## AGENTIC (Multi-Step Tasks)
45
+
46
+ Use `blockrun/agentic` for autonomous multi-step tasks, or let ClawRouter auto-detect agentic patterns.
47
+
48
+ | Tier | Primary Model | Input | Output |
49
+ | --------- | -------------------- | ----- | ------ |
50
+ | SIMPLE | moonshot/kimi-k2.5 | $0.60 | $3.00 |
51
+ | MEDIUM | xai/grok-code-fast-1 | $0.20 | $1.50 |
52
+ | COMPLEX | claude-sonnet-4.6 | $3.00 | $15.00 |
53
+ | REASONING | claude-sonnet-4.6 | $3.00 | $15.00 |
54
+
55
+ ---
56
+
57
+ ## ECO vs AUTO Savings
58
+
59
+ | Tier | ECO | AUTO | Savings |
60
+ | --------- | ----- | ------ | -------- |
61
+ | SIMPLE | FREE | $3.60 | **100%** |
62
+ | MEDIUM | $0.50 | $1.70 | **71%** |
63
+ | COMPLEX | $0.50 | $14.00 | **96%** |
64
+ | REASONING | $0.70 | $0.70 | 0% |
65
+
66
+ ---
67
+
68
+ ## How Tiers Work
69
+
70
+ ClawRouter automatically classifies your query into one of four tiers:
71
+
72
+ - **SIMPLE**: Basic questions, short responses, simple lookups
73
+ - **MEDIUM**: Code generation, moderate complexity tasks
74
+ - **COMPLEX**: Large context, multi-step reasoning, complex code
75
+ - **REASONING**: Logic puzzles, math, chain-of-thought tasks
76
+
77
+ The router picks the cheapest model capable of handling your query's tier.
78
+
79
+ ---
80
+
81
+ _Last updated: v0.12.24_
@@ -0,0 +1,320 @@
1
+ # Using Subscriptions with ClawRouter Failover
2
+
3
+ This guide explains how to use your existing LLM subscriptions (Claude Pro/Max, ChatGPT Plus, etc.) as primary providers, with ClawRouter x402 micropayments as automatic failover.
4
+
5
+ ## Why Not Built Into ClawRouter?
6
+
7
+ After careful consideration, we decided **not** to integrate subscription support directly into ClawRouter for several important reasons:
8
+
9
+ ### 1. Terms of Service Compliance
10
+
11
+ - Most subscription ToS (Claude Code, ChatGPT Plus) are designed for personal use
12
+ - Using them through a proxy/API service may violate provider agreements
13
+ - We want to keep ClawRouter compliant and low-risk for all users
14
+
15
+ ### 2. Security & Privacy
16
+
17
+ - Integrating subscriptions would require ClawRouter to access your credentials/sessions
18
+ - Spawning external processes (like Claude CLI) introduces security concerns
19
+ - Better to keep authentication at the OpenClaw layer where you control it
20
+
21
+ ### 3. Maintenance & Flexibility
22
+
23
+ - Each subscription provider has different APIs, CLIs, and authentication methods
24
+ - OpenClaw already has a robust provider system that handles this
25
+ - Duplicating this in ClawRouter would increase complexity without added value
26
+
27
+ ### 4. Better Architecture
28
+
29
+ - OpenClaw's native failover mechanism is more flexible and powerful
30
+ - Works with **any** provider (not just Claude)
31
+ - Zero code changes needed in ClawRouter
32
+ - You maintain full control over your credentials
33
+
34
+ ## How It Works
35
+
36
+ OpenClaw has a built-in **model fallback chain** that automatically tries alternative providers when the primary fails:
37
+
38
+ ```
39
+ User Request
40
+
41
+ Primary Provider (e.g., Claude subscription via OpenClaw)
42
+ ↓ (rate limited / quota exceeded / auth failed)
43
+ OpenClaw detects failure
44
+
45
+ Fallback Chain (try each in order)
46
+
47
+ ClawRouter (blockrun/auto)
48
+
49
+ Smart routing picks cheapest model
50
+
51
+ x402 micropayment to BlockRun API
52
+
53
+ Response returned to user
54
+ ```
55
+
56
+ **Key benefits:**
57
+
58
+ - ✅ Automatic failover (no manual intervention)
59
+ - ✅ Works with any subscription provider OpenClaw supports
60
+ - ✅ Respects provider ToS (you configure authentication directly)
61
+ - ✅ ClawRouter stays focused on cost optimization
62
+
63
+ ## Setup Guide
64
+
65
+ ### Prerequisites
66
+
67
+ 1. **OpenClaw Gateway installed** with ClawRouter plugin
68
+
69
+ ```bash
70
+ npm install -g openclaw
71
+ openclaw plugins install @blockrun/clawrouter
72
+ ```
73
+
74
+ 2. **Subscription configured in OpenClaw**
75
+ - For Claude: Use `claude setup-token` or API key
76
+ - For OpenAI: Set `OPENAI_API_KEY` environment variable
77
+ - For others: See [OpenClaw provider docs](https://docs.openclaw.ai)
78
+
79
+ 3. **ClawRouter wallet funded** (for failover)
80
+ ```bash
81
+ openclaw gateway logs | grep "Wallet:"
82
+ # Send USDC to the displayed address on Base network
83
+ ```
84
+
85
+ ### Configuration Steps
86
+
87
+ #### Step 1: Set Primary Model (Your Subscription)
88
+
89
+ ```bash
90
+ # Option A: Using Claude subscription
91
+ openclaw models set anthropic/claude-sonnet-4.6
92
+
93
+ # Option B: Using ChatGPT Plus (via OpenAI provider)
94
+ openclaw models set openai/gpt-4o
95
+
96
+ # Option C: Using any other provider
97
+ openclaw models set <provider>/<model>
98
+ ```
99
+
100
+ #### Step 2: Add ClawRouter as Fallback
101
+
102
+ ```bash
103
+ # Add blockrun/auto for smart routing (recommended)
104
+ openclaw models fallbacks add blockrun/auto
105
+
106
+ # Or specify a specific model
107
+ openclaw models fallbacks add blockrun/google/gemini-2.5-pro
108
+ ```
109
+
110
+ #### Step 3: Verify Configuration
111
+
112
+ ```bash
113
+ openclaw models show
114
+ ```
115
+
116
+ Expected output:
117
+
118
+ ```
119
+ Primary: anthropic/claude-sonnet-4.6
120
+ Fallbacks:
121
+ 1. blockrun/auto
122
+ ```
123
+
124
+ #### Step 4: Test Failover (Optional)
125
+
126
+ To verify failover works:
127
+
128
+ 1. **Temporarily exhaust your subscription quota** (or wait for rate limit)
129
+ 2. **Make a request** - OpenClaw should automatically failover to ClawRouter
130
+ 3. **Check logs:**
131
+ ```bash
132
+ openclaw gateway logs | grep -i "fallback\|blockrun"
133
+ ```
134
+
135
+ ### Advanced Configuration
136
+
137
+ #### Configure Multiple Fallbacks
138
+
139
+ ```bash
140
+ openclaw models fallbacks add blockrun/google/gemini-2.5-flash # Fast & cheap
141
+ openclaw models fallbacks add blockrun/deepseek/deepseek-chat # Even cheaper
142
+ openclaw models fallbacks add blockrun/nvidia/gpt-oss-120b # Free tier
143
+ ```
144
+
145
+ #### Per-Agent Configuration
146
+
147
+ Edit `~/.openclaw/openclaw.json`:
148
+
149
+ ```json
150
+ {
151
+ "agents": {
152
+ "main": {
153
+ "model": {
154
+ "primary": "anthropic/claude-opus-4.6",
155
+ "fallbacks": ["blockrun/auto"]
156
+ }
157
+ },
158
+ "coding": {
159
+ "model": {
160
+ "primary": "anthropic/claude-sonnet-4.6",
161
+ "fallbacks": ["blockrun/google/gemini-2.5-pro", "blockrun/deepseek/deepseek-chat"]
162
+ }
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ #### Tier-Based Configuration (ClawRouter Smart Routing)
169
+
170
+ When using `blockrun/auto`, ClawRouter automatically classifies your request and picks the cheapest capable model:
171
+
172
+ - **SIMPLE** queries → Gemini 2.5 Flash, DeepSeek Chat (~$0.0001/req)
173
+ - **MEDIUM** queries → GPT-4o-mini, Gemini Flash (~$0.001/req)
174
+ - **COMPLEX** queries → Claude Sonnet, Gemini Pro (~$0.01/req)
175
+ - **REASONING** queries → DeepSeek R1, o3-mini (~$0.05/req)
176
+
177
+ Learn more: [ClawRouter Smart Routing](./smart-routing.md)
178
+
179
+ ## Monitoring & Troubleshooting
180
+
181
+ ### Check If Failover Is Working
182
+
183
+ ```bash
184
+ # Watch real-time logs
185
+ openclaw gateway logs --follow | grep -i "fallback\|blockrun\|rate.limit\|quota"
186
+
187
+ # Check ClawRouter proxy logs
188
+ openclaw gateway logs | grep "ClawRouter"
189
+ ```
190
+
191
+ **Success indicators:**
192
+
193
+ - ✅ "Rate limit reached" or "Quota exceeded" → primary failed
194
+ - ✅ "Trying fallback: blockrun/auto" → failover triggered
195
+ - ✅ "ClawRouter: Success with model" → failover succeeded
196
+
197
+ ### Common Issues
198
+
199
+ #### Issue: Failover never triggers
200
+
201
+ **Symptoms:** Always uses primary, never switches to ClawRouter
202
+
203
+ **Solutions:**
204
+
205
+ 1. Check fallbacks are configured:
206
+ ```bash
207
+ openclaw models show
208
+ ```
209
+ 2. Verify primary is actually failing (check provider dashboard for quota/rate limits)
210
+ 3. Check OpenClaw logs for authentication errors
211
+
212
+ #### Issue: "Wallet empty" errors during failover
213
+
214
+ **Symptoms:** Failover triggers but ClawRouter returns balance errors
215
+
216
+ **Solutions:**
217
+
218
+ 1. Check ClawRouter wallet balance:
219
+ ```bash
220
+ openclaw gateway logs | grep "Balance:"
221
+ ```
222
+ 2. Fund wallet on Base network (USDC)
223
+ 3. Verify wallet key is configured correctly
224
+
225
+ #### Issue: Slow failover (high latency)
226
+
227
+ **Symptoms:** 5-10 second delay when switching to ClawRouter
228
+
229
+ **Cause:** OpenClaw tries multiple auth profiles before failover
230
+
231
+ **Solutions:**
232
+
233
+ 1. Reduce auth profile retry attempts (see OpenClaw config)
234
+ 2. Use `blockrun/auto` as primary for faster responses
235
+ 3. Accept the latency as a tradeoff for cheaper requests
236
+
237
+ ## Cost Analysis
238
+
239
+ ### Example Scenario
240
+
241
+ **Usage pattern:**
242
+
243
+ - 100 requests/day
244
+ - 50% hit Claude subscription quota (rate limited)
245
+ - 50% use ClawRouter failover
246
+
247
+ **Without failover:**
248
+
249
+ - Pay Anthropic API: $50/month (100% API usage)
250
+
251
+ **With failover:**
252
+
253
+ - Claude subscription: $20/month (covers 50%)
254
+ - ClawRouter x402: ~$5/month (50 requests via smart routing)
255
+ - **Total: $25/month (50% savings)**
256
+
257
+ ### When Does This Make Sense?
258
+
259
+ ✅ **Good fit:**
260
+
261
+ - You already have a subscription for personal use
262
+ - You occasionally exceed quota/rate limits
263
+ - You want cost optimization without managing API keys
264
+
265
+ ❌ **Not ideal:**
266
+
267
+ - You need 100% reliability (subscriptions have rate limits)
268
+ - You prefer a single provider (no failover complexity)
269
+ - Your usage is low (< 10 requests/day)
270
+
271
+ ## FAQ
272
+
273
+ ### Q: Will this violate my subscription ToS?
274
+
275
+ **A:** You configure the subscription directly in OpenClaw using your own credentials. ClawRouter only receives requests after your subscription fails. This is similar to using multiple API keys yourself.
276
+
277
+ However, each provider has different ToS. Check yours before proceeding:
278
+
279
+ - [Claude Code Terms](https://claude.ai/terms)
280
+ - [ChatGPT Terms](https://openai.com/policies/terms-of-use)
281
+
282
+ ### Q: Can I use multiple subscriptions?
283
+
284
+ **A:** Yes! Configure multiple providers with failback chains:
285
+
286
+ ```bash
287
+ openclaw models set anthropic/claude-opus-4.6
288
+ openclaw models fallbacks add openai/gpt-4o # ChatGPT Plus
289
+ openclaw models fallbacks add blockrun/auto # x402 as final fallback
290
+ ```
291
+
292
+ ### Q: Does this work with Claude Max API Proxy?
293
+
294
+ **A:** Yes! Configure the proxy as a custom provider in OpenClaw, then add `blockrun/auto` as fallback.
295
+
296
+ See: [Claude Max API Proxy Guide](https://github.com/anthropics/claude-code/blob/main/docs/providers/claude-max-api-proxy.md)
297
+
298
+ ### Q: How is this different from PR #15?
299
+
300
+ **A:** PR #15 integrated Claude CLI directly into ClawRouter. Our approach:
301
+
302
+ - ✅ Works with any provider (not just Claude)
303
+ - ✅ Respects provider ToS (no proxy/wrapper)
304
+ - ✅ Uses OpenClaw's native failover (more reliable)
305
+ - ✅ Zero maintenance burden on ClawRouter
306
+
307
+ ## Feedback & Support
308
+
309
+ We'd love to hear your experience with subscription failover:
310
+
311
+ - **GitHub Discussion:** [Share your setup](https://github.com/BlockRunAI/ClawRouter/discussions)
312
+ - **Issues:** [Report problems](https://github.com/BlockRunAI/ClawRouter/issues)
313
+ - **Telegram:** [Join community](https://t.me/blockrunAI)
314
+
315
+ ## Related Documentation
316
+
317
+ - [OpenClaw Model Failover](https://docs.openclaw.ai/concepts/model-failover)
318
+ - [OpenClaw Provider Configuration](https://docs.openclaw.ai/gateway/configuration)
319
+ - [ClawRouter Smart Routing](./smart-routing.md)
320
+ - [ClawRouter x402 Micropayments](./x402-payments.md)