mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
Feat : Gitbook
This commit is contained in:
@@ -0,0 +1,537 @@
|
||||
# Combos - Custom Fallback Chains
|
||||
|
||||
Create custom model combinations with automatic fallback. Combos let you define your own routing strategy based on cost, quality, and availability.
|
||||
|
||||
---
|
||||
|
||||
## What Are Combos?
|
||||
|
||||
Combos are **custom fallback chains** that you create in the dashboard. Instead of using a single model, you define a sequence of models that 9Router tries in order.
|
||||
|
||||
**Example:**
|
||||
```
|
||||
Combo name: premium-coding
|
||||
Models:
|
||||
1. cc/claude-opus-4-5-20251101 (try first)
|
||||
2. glm/glm-4.7 (if #1 quota exhausted)
|
||||
3. minimax/MiniMax-M2.1 (if #2 quota exhausted)
|
||||
```
|
||||
|
||||
**Usage in CLI:**
|
||||
```
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
9Router automatically tries each model in sequence until one succeeds.
|
||||
|
||||
---
|
||||
|
||||
## Why Use Combos?
|
||||
|
||||
### 1. Maximize Subscription Value
|
||||
```
|
||||
cc/claude-opus → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
→ Use subscription first, cheap backup, free emergency
|
||||
→ Get full value from subscriptions you already pay for
|
||||
```
|
||||
|
||||
### 2. Minimize Costs
|
||||
```
|
||||
glm/glm-4.7 → minimax/MiniMax-M2.1 → if/kimi-k2-thinking
|
||||
|
||||
→ Start with cheapest paid option ($0.60/1M)
|
||||
→ Fallback to even cheaper ($0.20/1M)
|
||||
→ Emergency free tier
|
||||
→ Total cost: ~$5-10/month vs $2000 on ChatGPT API
|
||||
```
|
||||
|
||||
### 3. Ensure 24/7 Availability
|
||||
```
|
||||
cc/claude-opus → cx/gpt-5.2-codex → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
→ Always include free tier at the end
|
||||
→ Never run out of quota
|
||||
→ Code anytime, anywhere
|
||||
```
|
||||
|
||||
### 4. Optimize for Quality
|
||||
```
|
||||
cc/claude-opus-4-5 → cx/gpt-5.2-codex → gc/gemini-3-pro
|
||||
|
||||
→ Best models first
|
||||
→ Fallback to other premium models
|
||||
→ Maintain high quality across fallback chain
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Create Combos
|
||||
|
||||
### Step 1: Open Dashboard
|
||||
|
||||
```
|
||||
http://localhost:20128
|
||||
→ Login with your password
|
||||
```
|
||||
|
||||
### Step 2: Navigate to Combos
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New Combo
|
||||
```
|
||||
|
||||
### Step 3: Configure Combo
|
||||
|
||||
**Combo Name:**
|
||||
```
|
||||
premium-coding
|
||||
```
|
||||
|
||||
**Description (optional):**
|
||||
```
|
||||
Subscription first, cheap backup, free emergency
|
||||
```
|
||||
|
||||
**Select Models:**
|
||||
```
|
||||
1. cc/claude-opus-4-5-20251101
|
||||
2. glm/glm-4.7
|
||||
3. minimax/MiniMax-M2.1
|
||||
```
|
||||
|
||||
**Drag to reorder** - Priority from top to bottom.
|
||||
|
||||
### Step 4: Save
|
||||
|
||||
```
|
||||
Click "Save Combo"
|
||||
→ Combo appears in model list
|
||||
```
|
||||
|
||||
### Step 5: Use in CLI
|
||||
|
||||
```
|
||||
Cursor/Cline/Any tool:
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Example Combos
|
||||
|
||||
### Example 1: Premium Coding (Subscription → Cheap → Free)
|
||||
|
||||
**Goal**: Maximize subscription value, minimize extra costs.
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: premium-coding
|
||||
Models:
|
||||
1. cc/claude-opus-4-5-20251101
|
||||
2. glm/glm-4.7
|
||||
3. minimax/MiniMax-M2.1
|
||||
```
|
||||
|
||||
**Usage:**
|
||||
```
|
||||
Cursor IDE:
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
```
|
||||
Morning (fresh quota):
|
||||
Request → cc/claude-opus-4-5 ✅
|
||||
|
||||
Afternoon (Claude quota out):
|
||||
Request → glm/glm-4.7 ✅ (auto switched)
|
||||
|
||||
Evening (GLM quota out):
|
||||
Request → minimax/MiniMax-M2.1 ✅ (auto switched)
|
||||
```
|
||||
|
||||
**Monthly cost (100M tokens):**
|
||||
```
|
||||
80M via Claude Code: $0 (subscription)
|
||||
15M via GLM: $9
|
||||
5M via MiniMax: $1
|
||||
Total: $10 + your subscription
|
||||
```
|
||||
|
||||
**Savings**: ~99% vs ChatGPT API ($2000).
|
||||
|
||||
---
|
||||
|
||||
### Example 2: Budget Combo (Cheap → Free)
|
||||
|
||||
**Goal**: Minimize costs, use free tier as backup.
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: budget-combo
|
||||
Models:
|
||||
1. glm/glm-4.7
|
||||
2. minimax/MiniMax-M2.1
|
||||
3. if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
**Usage:**
|
||||
```
|
||||
Cline:
|
||||
Provider: OpenAI Compatible
|
||||
Base URL: http://localhost:20128/v1
|
||||
Model: budget-combo
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
```
|
||||
Request → glm/glm-4.7
|
||||
✅ Daily quota available → Use GLM ($0.60/1M)
|
||||
❌ Quota exhausted → Try MiniMax ($0.20/1M)
|
||||
❌ MiniMax quota out → Use iFlow (FREE)
|
||||
```
|
||||
|
||||
**Monthly cost (100M tokens):**
|
||||
```
|
||||
70M via GLM: $42
|
||||
20M via MiniMax: $4
|
||||
10M via iFlow: $0
|
||||
Total: $46 vs $2000 on ChatGPT API
|
||||
```
|
||||
|
||||
**Savings**: 97%.
|
||||
|
||||
---
|
||||
|
||||
### Example 3: Free Combo (Zero Cost)
|
||||
|
||||
**Goal**: 100% free, no costs ever.
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: free-combo
|
||||
Models:
|
||||
1. if/kimi-k2-thinking
|
||||
2. qw/qwen3-coder-plus
|
||||
3. kr/claude-sonnet-4.5
|
||||
```
|
||||
|
||||
**Usage:**
|
||||
```
|
||||
Claude Desktop:
|
||||
Model: free-combo
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
```
|
||||
Request → if/kimi-k2-thinking
|
||||
✅ Available → Use iFlow
|
||||
❌ Error → Try Qwen
|
||||
❌ Error → Try Kiro
|
||||
```
|
||||
|
||||
**Monthly cost:**
|
||||
```
|
||||
100M tokens via free providers: $0
|
||||
Total: $0 forever
|
||||
```
|
||||
|
||||
**Use case**: Personal projects, learning, experimentation.
|
||||
|
||||
---
|
||||
|
||||
### Example 4: Quality First (Premium Models Only)
|
||||
|
||||
**Goal**: Best quality, no cheap fallback.
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: quality-first
|
||||
Models:
|
||||
1. cc/claude-opus-4-5-20251101
|
||||
2. cx/gpt-5.2-codex
|
||||
3. gc/gemini-3-pro-preview
|
||||
```
|
||||
|
||||
**Usage:**
|
||||
```
|
||||
Codex CLI:
|
||||
export OPENAI_BASE_URL="http://localhost:20128"
|
||||
Model: quality-first
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
```
|
||||
Request → cc/claude-opus-4-5
|
||||
❌ Quota out → cx/gpt-5.2-codex
|
||||
❌ Quota out → gc/gemini-3-pro-preview
|
||||
❌ All out → Return error (no cheap fallback)
|
||||
```
|
||||
|
||||
**Use case**: Critical production code, complex refactoring.
|
||||
|
||||
---
|
||||
|
||||
### Example 5: Multi-Subscription (Maximize All)
|
||||
|
||||
**Goal**: Use all subscriptions before paying extra.
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: multi-sub
|
||||
Models:
|
||||
1. gc/gemini-3-flash-preview (FREE 180K/month)
|
||||
2. cc/claude-opus-4-5-20251101 (Pro subscription)
|
||||
3. cx/gpt-5.2-codex (Plus subscription)
|
||||
4. gh/gpt-5 (Copilot subscription)
|
||||
5. glm/glm-4.7 (Cheap backup)
|
||||
6. if/kimi-k2-thinking (Free emergency)
|
||||
```
|
||||
|
||||
**Monthly cost (200M tokens):**
|
||||
```
|
||||
50M via Gemini CLI: $0 (free tier)
|
||||
80M via Claude Code: $0 (subscription)
|
||||
40M via Codex: $0 (subscription)
|
||||
20M via Copilot: $0 (subscription)
|
||||
8M via GLM: $4.80
|
||||
2M via iFlow: $0
|
||||
Total: $4.80 + existing subscriptions
|
||||
```
|
||||
|
||||
**Result**: Use 190M tokens from subscriptions, only $4.80 extra.
|
||||
|
||||
---
|
||||
|
||||
### Example 6: Quota Reset Optimization
|
||||
|
||||
**Goal**: Distribute usage based on reset times.
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: reset-optimized
|
||||
Models:
|
||||
1. cc/claude-opus-4-5 (5h reset, use morning)
|
||||
2. gc/gemini-3-flash (1K/day, use afternoon)
|
||||
3. glm/glm-4.7 (daily 10AM reset, use evening)
|
||||
4. minimax/MiniMax-M2.1 (5h rolling, use night)
|
||||
5. if/kimi-k2-thinking (unlimited, emergency)
|
||||
```
|
||||
|
||||
**Daily routine:**
|
||||
```
|
||||
08:00 - 13:00: Claude Code (fresh 5h quota)
|
||||
13:00 - 18:00: Gemini CLI (1K/day quota)
|
||||
18:00 - 22:00: GLM (resets 10AM next day)
|
||||
22:00 - 08:00: MiniMax (5h rolling) or iFlow
|
||||
```
|
||||
|
||||
**Result**: Code 24/7 with minimal costs.
|
||||
|
||||
---
|
||||
|
||||
## Use Combos in CLI Tools
|
||||
|
||||
### Cursor IDE
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [from dashboard]
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
### Claude Desktop
|
||||
|
||||
Edit `~/.claude/config.json`:
|
||||
```json
|
||||
{
|
||||
"anthropic_api_base": "http://localhost:20128/v1",
|
||||
"anthropic_api_key": "your-9router-api-key",
|
||||
"model": "budget-combo"
|
||||
}
|
||||
```
|
||||
|
||||
### Codex CLI
|
||||
|
||||
```bash
|
||||
export OPENAI_BASE_URL="http://localhost:20128"
|
||||
export OPENAI_API_KEY="your-9router-api-key"
|
||||
|
||||
codex --model quality-first "your prompt"
|
||||
```
|
||||
|
||||
### Cline / Continue / RooCode
|
||||
|
||||
```
|
||||
Provider: OpenAI Compatible
|
||||
Base URL: http://localhost:20128/v1
|
||||
API Key: [from dashboard]
|
||||
Model: free-combo
|
||||
```
|
||||
|
||||
### API Request
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/v1/chat/completions \
|
||||
-H "Authorization: Bearer your-api-key" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"model": "premium-coding",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Write a function to..."}
|
||||
],
|
||||
"stream": true
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Always Include Free Tier
|
||||
|
||||
```
|
||||
✅ Good:
|
||||
cc/claude-opus → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
❌ Bad:
|
||||
cc/claude-opus → glm/glm-4.7
|
||||
(no free fallback, can run out of quota)
|
||||
```
|
||||
|
||||
**Why**: Ensures 24/7 availability, never blocked by quota.
|
||||
|
||||
### 2. Order by Cost (Cheap to Expensive)
|
||||
|
||||
```
|
||||
✅ Good:
|
||||
glm/glm-4.7 → minimax/MiniMax-M2.1 → cc/claude-opus
|
||||
|
||||
❌ Bad:
|
||||
cc/claude-opus → glm/glm-4.7
|
||||
(wastes subscription quota on simple tasks)
|
||||
```
|
||||
|
||||
**Exception**: If you want to maximize subscription value, put subscription first.
|
||||
|
||||
### 3. Match Quality Requirements
|
||||
|
||||
```
|
||||
For production code:
|
||||
cc/claude-opus → cx/gpt-5.2-codex → glm/glm-4.7
|
||||
|
||||
For quick tasks:
|
||||
glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
For experimentation:
|
||||
if/kimi-k2-thinking → qw/qwen3-coder-plus
|
||||
```
|
||||
|
||||
### 4. Consider Quota Reset Times
|
||||
|
||||
```
|
||||
Morning combo (fresh quotas):
|
||||
cc/claude-opus → cx/gpt-5.2-codex
|
||||
|
||||
Evening combo (quotas likely exhausted):
|
||||
glm/glm-4.7 → minimax/MiniMax-M2.1 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### 5. Create Multiple Combos for Different Use Cases
|
||||
|
||||
```
|
||||
premium-coding: For complex tasks
|
||||
budget-combo: For simple tasks
|
||||
free-combo: For experimentation
|
||||
quality-first: For production code
|
||||
```
|
||||
|
||||
**Switch between combos** based on task requirements.
|
||||
|
||||
### 6. Monitor Combo Performance
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Combo Usage:
|
||||
premium-coding:
|
||||
80% via cc/claude-opus (good, using subscription)
|
||||
15% via glm/glm-4.7 (acceptable backup)
|
||||
5% via minimax (rare fallback)
|
||||
```
|
||||
|
||||
**Optimize**: If too much fallback usage, increase primary quota or reorder models.
|
||||
|
||||
---
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
### Set Budget Limits per Combo
|
||||
|
||||
```
|
||||
Dashboard → Combos → Edit → Budget:
|
||||
Daily limit: $5
|
||||
Monthly limit: $50
|
||||
```
|
||||
|
||||
When limit reached, 9Router skips paid models and uses free tier only.
|
||||
|
||||
### Enable/Disable Models in Combo
|
||||
|
||||
```
|
||||
Dashboard → Combos → Edit → Models:
|
||||
✅ cc/claude-opus-4-5 (enabled)
|
||||
❌ glm/glm-4.7 (temporarily disabled)
|
||||
✅ if/kimi-k2-thinking (enabled)
|
||||
```
|
||||
|
||||
**Use case**: Temporarily disable expensive models without deleting combo.
|
||||
|
||||
### Clone Existing Combo
|
||||
|
||||
```
|
||||
Dashboard → Combos → Clone "premium-coding"
|
||||
→ Creates copy with "-copy" suffix
|
||||
→ Modify and save as new combo
|
||||
```
|
||||
|
||||
**Use case**: Create variations for different scenarios.
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Issue: Combo not appearing in model list**
|
||||
|
||||
**Solution:**
|
||||
1. Refresh dashboard
|
||||
2. Check combo is saved (green checkmark)
|
||||
3. Restart CLI tool to refresh model list
|
||||
|
||||
**Issue: Combo always uses last model (free tier)**
|
||||
|
||||
**Solution:**
|
||||
1. Check quota for primary models (Dashboard → Quota)
|
||||
2. Verify API keys are valid (Dashboard → Providers)
|
||||
3. Check budget limits not exceeded
|
||||
|
||||
**Issue: Combo costs more than expected**
|
||||
|
||||
**Solution:**
|
||||
1. Dashboard → Analytics → Review combo usage
|
||||
2. Check if primary models are quota-exhausted
|
||||
3. Reorder models (put cheaper first)
|
||||
4. Set budget limits
|
||||
|
||||
---
|
||||
|
||||
## Related
|
||||
|
||||
- [Smart Routing](./smart-routing.md) - How auto fallback works
|
||||
- [Quota Tracking](./quota-tracking.md) - Monitor usage and costs
|
||||
@@ -0,0 +1,687 @@
|
||||
# Quota Tracking & Usage Monitoring
|
||||
|
||||
Track real-time token consumption, monitor quota limits, estimate costs, and get alerts before running out. Never waste subscription quota or exceed budget limits.
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
9Router provides comprehensive quota tracking for all providers:
|
||||
|
||||
- **Real-time token consumption** - See tokens used per request
|
||||
- **Quota limits & remaining** - Track usage vs limits
|
||||
- **Reset countdown** - Know when quota refreshes
|
||||
- **Cost estimation** - Calculate spending for paid tiers
|
||||
- **Monthly reports** - Analyze usage patterns
|
||||
- **Alerts & notifications** - Get warned before limits
|
||||
|
||||
---
|
||||
|
||||
## Dashboard Overview
|
||||
|
||||
### Quota Summary
|
||||
|
||||
```
|
||||
Dashboard → Home → Quota Overview
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ Claude Code (cc/) │
|
||||
│ ████████████░░░░░░░░ 2.5h / 5h (50%) │
|
||||
│ Resets in: 2h 30m │
|
||||
│ Cost: $0 (subscription) │
|
||||
└─────────────────────────────────────────────┘
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ Gemini CLI (gc/) │
|
||||
│ ████████░░░░░░░░░░░░ 450 / 1000 (45%) │
|
||||
│ Daily reset in: 18h 30m │
|
||||
│ Monthly: 45K / 180K (25%) │
|
||||
│ Cost: $0 (free tier) │
|
||||
└─────────────────────────────────────────────┘
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ GLM-4.7 (glm/) │
|
||||
│ ██████████████░░░░░░ 7M / 10M tokens (70%) │
|
||||
│ Resets: Daily 10:00 AM (in 5h 35m) │
|
||||
│ Cost today: $4.20 │
|
||||
└─────────────────────────────────────────────┘
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ MiniMax M2.1 (minimax/) │
|
||||
│ ████████████████░░░░ 4M / 5M tokens (80%) │
|
||||
│ Rolling 5h window │
|
||||
│ Cost (5h): $0.80 │
|
||||
└─────────────────────────────────────────────┘
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ iFlow (if/) │
|
||||
│ ████████████████████ Unlimited │
|
||||
│ Cost: $0 (free forever) │
|
||||
└─────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Real-Time Token Consumption
|
||||
|
||||
### Per-Request Tracking
|
||||
|
||||
Every request shows detailed token usage:
|
||||
|
||||
```
|
||||
Dashboard → Activity → Recent Requests
|
||||
|
||||
Request #1234
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
Timestamp: 2026-02-04 04:15:32
|
||||
|
||||
Tokens:
|
||||
Input: 1,250 tokens
|
||||
Output: 850 tokens
|
||||
Total: 2,100 tokens
|
||||
|
||||
Cost: $0 (subscription quota)
|
||||
Duration: 3.2s
|
||||
Status: ✅ Success
|
||||
```
|
||||
|
||||
### Live Usage Monitor
|
||||
|
||||
```
|
||||
Dashboard → Live Monitor
|
||||
|
||||
Current request:
|
||||
Model: glm/glm-4.7
|
||||
Tokens streamed: 450 / ~800 estimated
|
||||
Cost so far: $0.0009
|
||||
Duration: 1.8s
|
||||
```
|
||||
|
||||
### Token Breakdown by Model
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Token Usage
|
||||
|
||||
Today (Feb 4, 2026):
|
||||
cc/claude-opus-4-5: 15M tokens ($0, subscription)
|
||||
glm/glm-4.7: 8M tokens ($4.80)
|
||||
if/kimi-k2-thinking: 3M tokens ($0, free)
|
||||
|
||||
Total: 26M tokens
|
||||
Cost: $4.80
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Quota Limits & Reset Times
|
||||
|
||||
### Subscription Providers
|
||||
|
||||
**Claude Code (Pro/Max)**
|
||||
```
|
||||
Quota type: Time-based (5-hour rolling)
|
||||
Limit: 5 hours of usage
|
||||
Reset: Rolling 5-hour window + Weekly refresh
|
||||
Tracking: Usage time per model
|
||||
|
||||
Dashboard shows:
|
||||
Opus: 2.5h / 5h used
|
||||
Sonnet: 1.2h / 5h used
|
||||
Haiku: 0.8h / 5h used
|
||||
|
||||
Weekly reset: Every Monday 00:00 UTC
|
||||
```
|
||||
|
||||
**OpenAI Codex (Plus/Pro)**
|
||||
```
|
||||
Quota type: Time-based (5-hour rolling)
|
||||
Limit: 5 hours (Plus) / 10 hours (Pro)
|
||||
Reset: Rolling 5-hour window + Weekly refresh
|
||||
|
||||
Dashboard shows:
|
||||
GPT-5.2 Codex: 3.5h / 5h used
|
||||
Resets in: 1h 30m
|
||||
```
|
||||
|
||||
**Gemini CLI (FREE)**
|
||||
```
|
||||
Quota type: Request count + Monthly tokens
|
||||
Daily limit: 1,000 requests
|
||||
Monthly limit: 180,000 completions
|
||||
Reset: Daily 00:00 UTC + Monthly 1st
|
||||
|
||||
Dashboard shows:
|
||||
Today: 450 / 1,000 requests (45%)
|
||||
This month: 45K / 180K completions (25%)
|
||||
Daily reset in: 18h 30m
|
||||
Monthly reset in: 26 days
|
||||
```
|
||||
|
||||
**GitHub Copilot**
|
||||
```
|
||||
Quota type: Monthly usage
|
||||
Limit: Varies by plan
|
||||
Reset: 1st of each month
|
||||
|
||||
Dashboard shows:
|
||||
Usage: 60% of monthly quota
|
||||
Resets: March 1, 2026 (in 25 days)
|
||||
```
|
||||
|
||||
### Cheap Providers
|
||||
|
||||
**GLM-4.7**
|
||||
```
|
||||
Quota type: Daily token limit
|
||||
Limit: 10M tokens/day (Coding Plan)
|
||||
Reset: Daily 10:00 AM Beijing Time (UTC+8)
|
||||
|
||||
Dashboard shows:
|
||||
Used: 7M / 10M tokens (70%)
|
||||
Remaining: 3M tokens
|
||||
Resets in: 5h 35m
|
||||
Cost today: $4.20
|
||||
```
|
||||
|
||||
**MiniMax M2.1**
|
||||
```
|
||||
Quota type: Rolling 5-hour window
|
||||
Limit: 5M tokens per 5 hours
|
||||
Reset: Continuous rolling window
|
||||
|
||||
Dashboard shows:
|
||||
Used (5h): 4M / 5M tokens (80%)
|
||||
Oldest usage expires in: 45m
|
||||
Cost (5h): $0.80
|
||||
```
|
||||
|
||||
**Kimi K2**
|
||||
```
|
||||
Quota type: Monthly subscription
|
||||
Limit: 10M tokens/month ($9 flat)
|
||||
Reset: Monthly on subscription date
|
||||
|
||||
Dashboard shows:
|
||||
Used: 6M / 10M tokens (60%)
|
||||
Resets: Feb 15, 2026 (in 11 days)
|
||||
Cost: $9/month (prepaid)
|
||||
```
|
||||
|
||||
### Free Providers
|
||||
|
||||
**iFlow / Qwen / Kiro**
|
||||
```
|
||||
Quota type: Unlimited (rate-limited)
|
||||
Limit: No hard limit
|
||||
Reset: N/A
|
||||
|
||||
Dashboard shows:
|
||||
Used today: 5M tokens
|
||||
Cost: $0 (free forever)
|
||||
Status: ✅ Available
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cost Estimation
|
||||
|
||||
### Real-Time Cost Tracking
|
||||
|
||||
```
|
||||
Dashboard → Costs → Today
|
||||
|
||||
Subscription providers: $0
|
||||
Claude Code: 15M tokens ($0, included)
|
||||
Gemini CLI: 3M tokens ($0, free tier)
|
||||
|
||||
Paid providers: $4.80
|
||||
GLM-4.7: 8M tokens ($4.80)
|
||||
Input: 6M × $0.60/1M = $3.60
|
||||
Output: 2M × $2.20/1M = $4.40
|
||||
Total: $4.80
|
||||
|
||||
Free providers: $0
|
||||
iFlow: 3M tokens ($0)
|
||||
|
||||
Total today: $4.80
|
||||
```
|
||||
|
||||
### Monthly Spending Report
|
||||
|
||||
```
|
||||
Dashboard → Costs → This Month (February 2026)
|
||||
|
||||
Week 1 (Feb 1-7):
|
||||
Subscription: $0 (80M tokens)
|
||||
Paid: $15.20 (25M tokens)
|
||||
Free: $0 (10M tokens)
|
||||
Total: $15.20
|
||||
|
||||
Week 2 (Feb 8-14):
|
||||
Subscription: $0 (75M tokens)
|
||||
Paid: $12.80 (20M tokens)
|
||||
Free: $0 (8M tokens)
|
||||
Total: $12.80
|
||||
|
||||
Month to date: $28.00
|
||||
Projected (30 days): ~$120
|
||||
|
||||
Breakdown by provider:
|
||||
GLM-4.7: $22.00 (78%)
|
||||
MiniMax M2.1: $6.00 (22%)
|
||||
|
||||
Average cost per 1M tokens: $0.62
|
||||
Savings vs ChatGPT API: 97% ($4,000 → $120)
|
||||
```
|
||||
|
||||
### Cost Projection
|
||||
|
||||
```
|
||||
Dashboard → Costs → Projections
|
||||
|
||||
Based on last 7 days usage:
|
||||
Daily average: 50M tokens
|
||||
Daily cost: $4.50
|
||||
|
||||
Monthly projection:
|
||||
Tokens: 1,500M (1.5B)
|
||||
Cost: $135
|
||||
|
||||
Breakdown:
|
||||
Subscription: 900M tokens ($0)
|
||||
GLM-4.7: 450M tokens ($90)
|
||||
MiniMax: 120M tokens ($24)
|
||||
Free: 30M tokens ($0)
|
||||
|
||||
Budget status:
|
||||
Daily limit: $5 → 90% used today
|
||||
Monthly limit: $150 → 90% projected
|
||||
⚠️ Warning: May exceed monthly budget
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage Dashboard
|
||||
|
||||
### Overview Stats
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Overview
|
||||
|
||||
Today (Feb 4, 2026):
|
||||
Requests: 1,234
|
||||
Tokens: 26M
|
||||
Cost: $4.80
|
||||
Avg response time: 2.1s
|
||||
|
||||
This week:
|
||||
Requests: 8,456
|
||||
Tokens: 180M
|
||||
Cost: $28.00
|
||||
Success rate: 99.2%
|
||||
|
||||
This month:
|
||||
Requests: 15,234
|
||||
Tokens: 320M
|
||||
Cost: $52.00
|
||||
Top model: cc/claude-opus-4-5 (45%)
|
||||
```
|
||||
|
||||
### Usage by Model
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Models
|
||||
|
||||
Top models (this month):
|
||||
1. cc/claude-opus-4-5: 145M tokens (45%)
|
||||
2. glm/glm-4.7: 95M tokens (30%)
|
||||
3. if/kimi-k2-thinking: 50M tokens (16%)
|
||||
4. minimax/MiniMax-M2.1: 20M tokens (6%)
|
||||
5. gc/gemini-3-flash: 10M tokens (3%)
|
||||
|
||||
Cost breakdown:
|
||||
cc/claude-opus: $0 (subscription)
|
||||
glm/glm-4.7: $45.00
|
||||
if/kimi-k2-thinking: $0 (free)
|
||||
minimax/MiniMax-M2.1: $7.00
|
||||
gc/gemini-3-flash: $0 (free)
|
||||
```
|
||||
|
||||
### Usage by Time
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Timeline
|
||||
|
||||
Hourly usage (today):
|
||||
00:00 - 01:00: 0.5M tokens
|
||||
01:00 - 02:00: 0.2M tokens
|
||||
...
|
||||
08:00 - 09:00: 3.2M tokens (peak)
|
||||
09:00 - 10:00: 2.8M tokens
|
||||
...
|
||||
23:00 - 00:00: 0.8M tokens
|
||||
|
||||
Peak hours: 08:00 - 12:00 (morning coding)
|
||||
Low hours: 00:00 - 06:00 (night)
|
||||
```
|
||||
|
||||
### Usage by Combo
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Combos
|
||||
|
||||
premium-coding:
|
||||
Requests: 456
|
||||
Tokens: 12M
|
||||
Cost: $2.40
|
||||
|
||||
Breakdown:
|
||||
cc/claude-opus: 8M tokens (67%, $0)
|
||||
glm/glm-4.7: 3M tokens (25%, $1.80)
|
||||
minimax/MiniMax-M2.1: 1M tokens (8%, $0.20)
|
||||
|
||||
budget-combo:
|
||||
Requests: 234
|
||||
Tokens: 6M
|
||||
Cost: $1.20
|
||||
|
||||
Breakdown:
|
||||
glm/glm-4.7: 4M tokens (67%, $2.40)
|
||||
if/kimi-k2-thinking: 2M tokens (33%, $0)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Alerts & Notifications
|
||||
|
||||
### Quota Alerts
|
||||
|
||||
```
|
||||
Dashboard → Settings → Alerts
|
||||
|
||||
Quota warnings:
|
||||
✅ Alert at 80% quota used
|
||||
✅ Alert at 90% quota used
|
||||
✅ Alert when quota exhausted
|
||||
✅ Notify when quota resets
|
||||
|
||||
Delivery:
|
||||
✅ Dashboard notification
|
||||
✅ Email (optional)
|
||||
✅ Webhook (optional)
|
||||
```
|
||||
|
||||
**Example notifications:**
|
||||
```
|
||||
⚠️ Claude Code quota 80% used
|
||||
2.5h remaining (resets in 1h 30m)
|
||||
|
||||
⚠️ GLM-4.7 quota 90% used
|
||||
1M tokens remaining (resets in 5h)
|
||||
|
||||
✅ Gemini CLI quota reset
|
||||
1,000 requests available (daily limit)
|
||||
```
|
||||
|
||||
### Budget Alerts
|
||||
|
||||
```
|
||||
Dashboard → Settings → Budget Alerts
|
||||
|
||||
Daily budget: $5
|
||||
✅ Alert at 80% ($4)
|
||||
✅ Alert at 100% ($5)
|
||||
✅ Auto-switch to free tier when exceeded
|
||||
|
||||
Monthly budget: $150
|
||||
✅ Alert at 50% ($75)
|
||||
✅ Alert at 80% ($120)
|
||||
✅ Alert at 100% ($150)
|
||||
```
|
||||
|
||||
**Example notifications:**
|
||||
```
|
||||
⚠️ Daily budget 80% used
|
||||
$4.00 / $5.00 spent today
|
||||
|
||||
⚠️ Monthly budget 50% reached
|
||||
$75 / $150 spent this month
|
||||
Projected: $135 (within budget)
|
||||
|
||||
🚨 Daily budget exceeded
|
||||
$5.20 / $5.00 spent today
|
||||
Auto-switched to free tier
|
||||
```
|
||||
|
||||
### Cost Anomaly Detection
|
||||
|
||||
```
|
||||
Dashboard → Settings → Anomaly Detection
|
||||
|
||||
✅ Detect unusual spending patterns
|
||||
✅ Alert on cost spikes (>2× daily average)
|
||||
✅ Warn on quota exhaustion patterns
|
||||
|
||||
Example alert:
|
||||
⚠️ Cost spike detected
|
||||
Today: $12.50 (2.5× daily average)
|
||||
Reason: High GLM-4.7 usage (20M tokens)
|
||||
Suggestion: Check if primary models quota-exhausted
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Monitor Quota Daily
|
||||
|
||||
```
|
||||
Daily routine:
|
||||
1. Check dashboard quota overview (30 seconds)
|
||||
2. Review reset times
|
||||
3. Plan usage around quota availability
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```
|
||||
Morning check:
|
||||
✅ Claude Code: 5h available (fresh reset)
|
||||
✅ Gemini CLI: 1K requests available
|
||||
⚠️ GLM-4.7: 2M tokens left (resets 10AM)
|
||||
|
||||
Action: Use Claude Code for morning work
|
||||
```
|
||||
|
||||
### 2. Set Budget Limits
|
||||
|
||||
```
|
||||
Dashboard → Settings → Budget:
|
||||
Daily: $5 (prevents overspending)
|
||||
Monthly: $150 (aligns with budget)
|
||||
```
|
||||
|
||||
**Result**: Auto-switch to free tier when limit reached.
|
||||
|
||||
### 3. Optimize Combo Usage
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Combos:
|
||||
Review which models are used most
|
||||
Adjust combo order to minimize costs
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```
|
||||
Current: cc/claude-opus → glm/glm-4.7
|
||||
80% via Claude (good)
|
||||
20% via GLM ($12/month)
|
||||
|
||||
Optimized: gc/gemini-3-flash → cc/claude-opus → glm/glm-4.7
|
||||
50% via Gemini (free)
|
||||
40% via Claude (subscription)
|
||||
10% via GLM ($6/month)
|
||||
|
||||
Savings: $6/month
|
||||
```
|
||||
|
||||
### 4. Track Reset Times
|
||||
|
||||
```
|
||||
Dashboard → Quota → Reset Schedule:
|
||||
Claude Code: 5h rolling + Weekly Monday
|
||||
Gemini CLI: Daily 00:00 UTC + Monthly 1st
|
||||
GLM-4.7: Daily 10:00 AM Beijing Time
|
||||
MiniMax: Rolling 5h window
|
||||
```
|
||||
|
||||
**Strategy**: Use providers when quota is fresh.
|
||||
|
||||
### 5. Review Monthly Reports
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Monthly Report:
|
||||
Total tokens: 1.5B
|
||||
Total cost: $120
|
||||
Savings: 97% vs ChatGPT API
|
||||
|
||||
Insights:
|
||||
- 60% usage via subscriptions ($0)
|
||||
- 30% via GLM ($90)
|
||||
- 10% via free tier ($0)
|
||||
|
||||
Optimization:
|
||||
- Increase Gemini CLI usage (free)
|
||||
- Reduce GLM usage (expensive)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API Access
|
||||
|
||||
### Get Quota Status
|
||||
|
||||
```bash
|
||||
GET http://localhost:20128/api/quota
|
||||
Authorization: Bearer your-api-key
|
||||
|
||||
Response:
|
||||
{
|
||||
"providers": [
|
||||
{
|
||||
"id": "cc",
|
||||
"name": "Claude Code",
|
||||
"quota": {
|
||||
"used": 2.5,
|
||||
"limit": 5,
|
||||
"unit": "hours",
|
||||
"percentage": 50
|
||||
},
|
||||
"reset": {
|
||||
"type": "rolling",
|
||||
"window": "5h",
|
||||
"nextReset": "2026-02-04T06:45:00Z"
|
||||
},
|
||||
"cost": {
|
||||
"today": 0,
|
||||
"month": 0,
|
||||
"currency": "USD"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "glm",
|
||||
"name": "GLM-4.7",
|
||||
"quota": {
|
||||
"used": 7000000,
|
||||
"limit": 10000000,
|
||||
"unit": "tokens",
|
||||
"percentage": 70
|
||||
},
|
||||
"reset": {
|
||||
"type": "daily",
|
||||
"time": "10:00 AM UTC+8",
|
||||
"nextReset": "2026-02-04T10:00:00+08:00"
|
||||
},
|
||||
"cost": {
|
||||
"today": 4.20,
|
||||
"month": 52.00,
|
||||
"currency": "USD"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Get Usage Stats
|
||||
|
||||
```bash
|
||||
GET http://localhost:20128/api/usage?period=today
|
||||
Authorization: Bearer your-api-key
|
||||
|
||||
Response:
|
||||
{
|
||||
"period": "today",
|
||||
"date": "2026-02-04",
|
||||
"summary": {
|
||||
"requests": 1234,
|
||||
"tokens": 26000000,
|
||||
"cost": 4.80
|
||||
},
|
||||
"byModel": [
|
||||
{
|
||||
"model": "cc/claude-opus-4-5",
|
||||
"requests": 456,
|
||||
"tokens": 15000000,
|
||||
"cost": 0
|
||||
},
|
||||
{
|
||||
"model": "glm/glm-4.7",
|
||||
"requests": 234,
|
||||
"tokens": 8000000,
|
||||
"cost": 4.80
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Issue: Quota shows 0% but requests failing**
|
||||
|
||||
**Solution:**
|
||||
1. Check provider connection (Dashboard → Providers)
|
||||
2. Verify API keys are valid
|
||||
3. Check if provider is down (status page)
|
||||
4. Try reconnecting OAuth providers
|
||||
|
||||
**Issue: Cost estimation incorrect**
|
||||
|
||||
**Solution:**
|
||||
1. Dashboard → Settings → Pricing
|
||||
2. Verify pricing per provider matches current rates
|
||||
3. Update pricing if provider changed rates
|
||||
4. Contact support if discrepancy persists
|
||||
|
||||
**Issue: Reset time not updating**
|
||||
|
||||
**Solution:**
|
||||
1. Refresh dashboard (F5)
|
||||
2. Check system time is correct
|
||||
3. Verify timezone settings
|
||||
4. Restart 9Router if issue persists
|
||||
|
||||
**Issue: Alerts not received**
|
||||
|
||||
**Solution:**
|
||||
1. Dashboard → Settings → Alerts
|
||||
2. Verify email address is correct
|
||||
3. Check spam folder
|
||||
4. Test notification (Send Test button)
|
||||
|
||||
---
|
||||
|
||||
## Related
|
||||
|
||||
- [Smart Routing](./smart-routing.md) - Auto fallback based on quota
|
||||
- [Combos](./combos.md) - Create custom fallback chains
|
||||
@@ -0,0 +1,407 @@
|
||||
# Smart Routing & Auto Fallback
|
||||
|
||||
9Router automatically routes your requests through the best available provider using a 3-tier fallback system. Never stop coding due to quota limits or rate limiting.
|
||||
|
||||
---
|
||||
|
||||
## How It Works
|
||||
|
||||
9Router uses intelligent routing to maximize your existing subscriptions, minimize costs, and ensure 24/7 availability:
|
||||
|
||||
```
|
||||
Request → 9Router → Check Tier 1 (Subscription)
|
||||
↓ quota exhausted
|
||||
Check Tier 2 (Cheap)
|
||||
↓ budget limit
|
||||
Check Tier 3 (Free)
|
||||
↓
|
||||
Response
|
||||
```
|
||||
|
||||
### 3-Tier Fallback System
|
||||
|
||||
**Tier 1: SUBSCRIPTION (Primary)**
|
||||
- Claude Code (Pro/Max)
|
||||
- OpenAI Codex (Plus/Pro)
|
||||
- Gemini CLI (FREE 180K/month)
|
||||
- GitHub Copilot
|
||||
- Antigravity (Google)
|
||||
|
||||
**Goal**: Maximize value from subscriptions you already pay for.
|
||||
|
||||
**Tier 2: CHEAP (Backup)**
|
||||
- GLM-4.7 ($0.60/1M input)
|
||||
- MiniMax M2.1 ($0.20/1M input)
|
||||
- Kimi K2 ($9/month flat)
|
||||
|
||||
**Goal**: Ultra-cheap backup when subscription quota runs out (~90% cheaper than ChatGPT API).
|
||||
|
||||
**Tier 3: FREE (Emergency)**
|
||||
- iFlow (8 models)
|
||||
- Qwen (3 models)
|
||||
- Kiro (Claude FREE)
|
||||
|
||||
**Goal**: Zero-cost fallback for unlimited coding.
|
||||
|
||||
---
|
||||
|
||||
## Automatic Switching
|
||||
|
||||
9Router monitors quota in real-time and switches providers automatically:
|
||||
|
||||
### Scenario 1: Subscription Quota Exhausted
|
||||
|
||||
```
|
||||
User request → cc/claude-opus-4-5
|
||||
↓ quota exhausted (5-hour limit reached)
|
||||
Auto switch → glm/glm-4.7
|
||||
↓ daily quota exhausted
|
||||
Auto switch → minimax/MiniMax-M2.1
|
||||
↓ 5-hour quota exhausted
|
||||
Auto switch → if/kimi-k2-thinking (FREE)
|
||||
↓
|
||||
Response delivered ✅
|
||||
```
|
||||
|
||||
**Result**: Zero downtime, seamless experience.
|
||||
|
||||
### Scenario 2: Rate Limiting
|
||||
|
||||
```
|
||||
User request → cx/gpt-5.2-codex
|
||||
↓ rate limited (too many requests)
|
||||
Auto switch → glm/glm-4.7
|
||||
↓
|
||||
Response delivered ✅
|
||||
```
|
||||
|
||||
### Scenario 3: Provider Unavailable
|
||||
|
||||
```
|
||||
User request → cc/claude-opus-4-5
|
||||
↓ provider error (503)
|
||||
Auto switch → next available model
|
||||
↓
|
||||
Response delivered ✅
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Model Selection Logic
|
||||
|
||||
9Router selects the best model based on:
|
||||
|
||||
1. **Quota availability** - Check if provider has remaining quota
|
||||
2. **Cost tier** - Prefer subscription → cheap → free
|
||||
3. **Reset timing** - Consider when quota resets
|
||||
4. **Provider health** - Skip providers with errors
|
||||
|
||||
### Priority Order Example
|
||||
|
||||
For a request to `cc/claude-opus-4-5`:
|
||||
|
||||
```
|
||||
1. Check Claude Code quota
|
||||
✅ Available → Use cc/claude-opus-4-5
|
||||
❌ Exhausted → Continue to step 2
|
||||
|
||||
2. Check fallback tier (if configured)
|
||||
✅ GLM quota available → Use glm/glm-4.7
|
||||
❌ Exhausted → Continue to step 3
|
||||
|
||||
3. Check free tier
|
||||
✅ iFlow available → Use if/kimi-k2-thinking
|
||||
❌ All exhausted → Return quota error
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configuration Options
|
||||
|
||||
### Dashboard Settings
|
||||
|
||||
**1. Enable/Disable Auto Fallback**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Smart Routing
|
||||
→ Toggle "Auto Fallback" ON/OFF
|
||||
```
|
||||
|
||||
- **ON** (default): Automatic tier switching
|
||||
- **OFF**: Strict mode, return error if primary model unavailable
|
||||
|
||||
**2. Set Budget Limits**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Budget Control
|
||||
→ Daily limit: $5
|
||||
→ Monthly limit: $50
|
||||
```
|
||||
|
||||
When budget reached, 9Router automatically switches to free tier.
|
||||
|
||||
**3. Configure Fallback Order**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Fallback Priority
|
||||
→ Drag to reorder providers within each tier
|
||||
```
|
||||
|
||||
Example custom order:
|
||||
```
|
||||
Tier 1: Gemini CLI → Claude Code → Codex
|
||||
Tier 2: MiniMax → GLM → Kimi
|
||||
Tier 3: iFlow → Kiro → Qwen
|
||||
```
|
||||
|
||||
**4. Quota Reset Notifications**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Notifications
|
||||
→ Email when quota resets
|
||||
→ Alert when 80% quota used
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Basic Auto Fallback
|
||||
|
||||
**Setup:**
|
||||
```
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
Fallback: Auto (default 3-tier)
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
```
|
||||
Morning (fresh quota):
|
||||
Request → cc/claude-opus-4-5 ✅
|
||||
|
||||
Afternoon (quota exhausted):
|
||||
Request → glm/glm-4.7 ✅ (auto switched)
|
||||
|
||||
Evening (GLM quota out):
|
||||
Request → minimax/MiniMax-M2.1 ✅ (auto switched)
|
||||
|
||||
Late night (all paid quota out):
|
||||
Request → if/kimi-k2-thinking ✅ (free tier)
|
||||
```
|
||||
|
||||
**Cost**: ~$5-10/month extra (mostly covered by subscription).
|
||||
|
||||
### Example 2: Budget-Conscious Routing
|
||||
|
||||
**Setup:**
|
||||
```
|
||||
Dashboard → Settings:
|
||||
Daily budget: $2
|
||||
Monthly budget: $20
|
||||
Fallback: Enabled
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
```
|
||||
Day 1-15 (within budget):
|
||||
Requests → glm/glm-4.7 (cheap tier)
|
||||
Cost: $1.50/day
|
||||
|
||||
Day 16 (budget reached):
|
||||
Requests → if/kimi-k2-thinking (free tier)
|
||||
Cost: $0
|
||||
|
||||
Next month (budget resets):
|
||||
Requests → glm/glm-4.7 again
|
||||
```
|
||||
|
||||
**Result**: Never exceed $20/month, always available.
|
||||
|
||||
### Example 3: Subscription-Only Mode
|
||||
|
||||
**Setup:**
|
||||
```
|
||||
Dashboard → Settings:
|
||||
Auto Fallback: OFF
|
||||
Strict mode: ON
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
```
|
||||
Request → cc/claude-opus-4-5
|
||||
✅ Quota available → Success
|
||||
❌ Quota exhausted → Return error (no fallback)
|
||||
```
|
||||
|
||||
**Use case**: When you only want to use paid subscriptions, no extra costs.
|
||||
|
||||
### Example 4: Free-Only Mode
|
||||
|
||||
**Setup:**
|
||||
```
|
||||
Model: if/kimi-k2-thinking
|
||||
Fallback: qw/qwen3-coder-plus → kr/claude-sonnet-4.5
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
```
|
||||
All requests → Free tier only
|
||||
Cost: $0 forever
|
||||
```
|
||||
|
||||
**Use case**: Personal projects, learning, experimentation.
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Maximize Subscription Value
|
||||
|
||||
```
|
||||
Strategy:
|
||||
- Set subscription models as Tier 1
|
||||
- Monitor quota usage in dashboard
|
||||
- Use cheap tier only when subscription exhausted
|
||||
```
|
||||
|
||||
**Example combo:**
|
||||
```
|
||||
cc/claude-opus-4-5 → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### 2. Optimize for Cost
|
||||
|
||||
```
|
||||
Strategy:
|
||||
- Use Gemini CLI free tier first (180K/month)
|
||||
- Fallback to GLM/MiniMax (ultra-cheap)
|
||||
- Emergency: iFlow (free)
|
||||
```
|
||||
|
||||
**Example combo:**
|
||||
```
|
||||
gc/gemini-3-flash-preview → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### 3. Optimize for Quality
|
||||
|
||||
```
|
||||
Strategy:
|
||||
- Use best models (Claude Opus, GPT-5.2)
|
||||
- Fallback to good cheap models (GLM-4.7)
|
||||
- Last resort: Free tier
|
||||
```
|
||||
|
||||
**Example combo:**
|
||||
```
|
||||
cc/claude-opus-4-5 → cx/gpt-5.2-codex → glm/glm-4.7
|
||||
```
|
||||
|
||||
### 4. 24/7 Availability
|
||||
|
||||
```
|
||||
Strategy:
|
||||
- Always include free tier in fallback
|
||||
- Monitor quota reset times
|
||||
- Distribute usage across providers
|
||||
```
|
||||
|
||||
**Example combo:**
|
||||
```
|
||||
cc/claude-opus-4-5 → glm/glm-4.7 → minimax/MiniMax-M2.1 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
**Result**: Never run out of quota, code anytime.
|
||||
|
||||
---
|
||||
|
||||
## Quota Reset Strategy
|
||||
|
||||
Plan your usage around quota reset times:
|
||||
|
||||
| Provider | Quota Reset | Strategy |
|
||||
|----------|-------------|----------|
|
||||
| **Claude Code** | 5-hour + weekly | Use in morning, fresh quota |
|
||||
| **Codex** | 5-hour + weekly | Use after Claude quota out |
|
||||
| **Gemini CLI** | Daily (1K) + Monthly (180K) | Use throughout day |
|
||||
| **GLM-4.7** | Daily 10:00 AM | Use evening, resets next morning |
|
||||
| **MiniMax M2.1** | 5-hour rolling | Use anytime, tracks rolling window |
|
||||
| **iFlow/Qwen/Kiro** | No limit | Emergency backup |
|
||||
|
||||
**Daily routine example:**
|
||||
```
|
||||
08:00 - 13:00: Claude Code (fresh 5h quota)
|
||||
13:00 - 18:00: Gemini CLI (1K/day quota)
|
||||
18:00 - 22:00: GLM-4.7 (cheap, resets 10AM)
|
||||
22:00 - 08:00: MiniMax or iFlow (5h rolling or free)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Monitoring & Alerts
|
||||
|
||||
### Dashboard Quota Tracker
|
||||
|
||||
```
|
||||
Dashboard → Quota Overview:
|
||||
Claude Code: 2.5h / 5h remaining (50%)
|
||||
Gemini CLI: 450 / 1000 requests today
|
||||
GLM-4.7: 5M / 10M tokens (resets in 8h)
|
||||
MiniMax: 3M / 5M tokens (rolling 5h)
|
||||
```
|
||||
|
||||
### Real-Time Notifications
|
||||
|
||||
```
|
||||
Dashboard → Notifications:
|
||||
⚠️ Claude Code quota 80% used (1h remaining)
|
||||
✅ GLM-4.7 quota reset (10M tokens available)
|
||||
💰 Daily budget 50% used ($2.50 / $5)
|
||||
```
|
||||
|
||||
### Usage Analytics
|
||||
|
||||
```
|
||||
Dashboard → Analytics:
|
||||
Today: 50M tokens
|
||||
- 30M via Claude Code (subscription)
|
||||
- 15M via GLM-4.7 ($9)
|
||||
- 5M via iFlow (free)
|
||||
|
||||
Cost: $9 (vs $1000 on ChatGPT API)
|
||||
Savings: 99%
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Issue: "All providers quota exhausted"**
|
||||
|
||||
**Solution:**
|
||||
1. Check dashboard quota tracker
|
||||
2. Wait for quota reset (see countdown)
|
||||
3. Add free tier to fallback chain
|
||||
4. Or increase budget limit
|
||||
|
||||
**Issue: "Too many fallback switches"**
|
||||
|
||||
**Solution:**
|
||||
1. Check if primary provider is down
|
||||
2. Increase quota limits (upgrade subscription)
|
||||
3. Use cheaper primary model (GLM instead of Claude)
|
||||
|
||||
**Issue: "Unexpected costs"**
|
||||
|
||||
**Solution:**
|
||||
1. Dashboard → Analytics → Review usage
|
||||
2. Set daily/monthly budget limits
|
||||
3. Switch to free tier for non-critical tasks
|
||||
4. Use combos with free fallback
|
||||
|
||||
---
|
||||
|
||||
## Related
|
||||
|
||||
- [Combos](./combos.md) - Create custom fallback chains
|
||||
- [Quota Tracking](./quota-tracking.md) - Monitor usage and costs
|
||||
Reference in New Issue
Block a user