Feat : Gitbook
This commit is contained in:
1 parent
7ad538bcf2
commit
fd92af77a0
124 files changed
+34154
-4
No files matched your search
@@ -0,0 +1,473 @@
|
||||
# ☁️ Cloud Deployment
|
||||
|
||||
Deploy 9Router on VPS or Docker for remote access and production use.
|
||||
|
||||
---
|
||||
|
||||
## 🖥️ VPS Deployment
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Ubuntu 20.04+ or similar Linux distribution
|
||||
- Node.js 20+
|
||||
- Git
|
||||
- Root or sudo access
|
||||
|
||||
### Step 1: Clone Repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
```
|
||||
|
||||
### Step 2: Install Dependencies
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
### Step 3: Build Application
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Step 4: Configure Environment Variables
|
||||
|
||||
Create a `.env` file or export variables:
|
||||
|
||||
```bash
|
||||
export JWT_SECRET="your-secure-secret-change-this-to-random-string"
|
||||
export INITIAL_PASSWORD="your-secure-password"
|
||||
export DATA_DIR="/var/lib/9router"
|
||||
export NODE_ENV="production"
|
||||
```
|
||||
|
||||
**Environment Variables:**
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `JWT_SECRET` | Auto-generated | **MUST change in production!** Used for JWT token signing |
|
||||
| `INITIAL_PASSWORD` | `123456` | Dashboard login password |
|
||||
| `DATA_DIR` | `~/.9router` | Database and data storage path |
|
||||
| `NODE_ENV` | `development` | Set to `production` for deployment |
|
||||
| `ENABLE_REQUEST_LOGS` | `false` | Enable debug request/response logs |
|
||||
|
||||
### Step 5: Create Data Directory
|
||||
|
||||
```bash
|
||||
sudo mkdir -p /var/lib/9router
|
||||
sudo chown $USER:$USER /var/lib/9router
|
||||
```
|
||||
|
||||
### Step 6: Start Application
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
### Step 7: Setup PM2 for Production
|
||||
|
||||
PM2 keeps your application running and restarts it on crashes:
|
||||
|
||||
```bash
|
||||
# Install PM2 globally
|
||||
npm install -g pm2
|
||||
|
||||
# Start 9Router with PM2
|
||||
pm2 start npm --name 9router -- start
|
||||
|
||||
# Save PM2 configuration
|
||||
pm2 save
|
||||
|
||||
# Setup PM2 to start on system boot
|
||||
pm2 startup
|
||||
# Follow the instructions printed by the command above
|
||||
```
|
||||
|
||||
**PM2 Management Commands:**
|
||||
|
||||
```bash
|
||||
# View logs
|
||||
pm2 logs 9router
|
||||
|
||||
# Restart application
|
||||
pm2 restart 9router
|
||||
|
||||
# Stop application
|
||||
pm2 stop 9router
|
||||
|
||||
# View status
|
||||
pm2 status
|
||||
|
||||
# Monitor resources
|
||||
pm2 monit
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🐳 Docker Deployment
|
||||
|
||||
### Option 1: Using Dockerfile
|
||||
|
||||
Create a `Dockerfile` in the `app` directory:
|
||||
|
||||
```dockerfile
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy application files
|
||||
COPY . .
|
||||
|
||||
# Build application
|
||||
RUN npm run build
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 3000 20128
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV DATA_DIR=/app/data
|
||||
|
||||
# Create data directory
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
# Start application
|
||||
CMD ["npm", "run", "start"]
|
||||
```
|
||||
|
||||
**Build and Run:**
|
||||
|
||||
```bash
|
||||
# Build image
|
||||
docker build -t 9router .
|
||||
|
||||
# Run container
|
||||
docker run -d \
|
||||
--name 9router \
|
||||
-p 3000:3000 \
|
||||
-p 20128:20128 \
|
||||
-e JWT_SECRET="your-secure-secret-change-this" \
|
||||
-e INITIAL_PASSWORD="your-secure-password" \
|
||||
-v 9router-data:/app/data \
|
||||
9router
|
||||
```
|
||||
|
||||
### Option 2: Docker Compose
|
||||
|
||||
Create `docker-compose.yml`:
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
9router:
|
||||
build: .
|
||||
container_name: 9router
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "20128:20128"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- JWT_SECRET=your-secure-secret-change-this
|
||||
- INITIAL_PASSWORD=your-secure-password
|
||||
- DATA_DIR=/app/data
|
||||
volumes:
|
||||
- 9router-data:/app/data
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
9router-data:
|
||||
```
|
||||
|
||||
**Run with Docker Compose:**
|
||||
|
||||
```bash
|
||||
# Start services
|
||||
docker-compose up -d
|
||||
|
||||
# View logs
|
||||
docker-compose logs -f
|
||||
|
||||
# Stop services
|
||||
docker-compose down
|
||||
|
||||
# Rebuild and restart
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Reverse Proxy with Nginx
|
||||
|
||||
### Why Use Nginx?
|
||||
|
||||
- SSL/TLS termination
|
||||
- Domain name mapping
|
||||
- Load balancing
|
||||
- Better security
|
||||
|
||||
### Step 1: Install Nginx
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install nginx
|
||||
```
|
||||
|
||||
### Step 2: Configure Nginx
|
||||
|
||||
Create `/etc/nginx/sites-available/9router`:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name your-domain.com;
|
||||
|
||||
# Redirect HTTP to HTTPS
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name your-domain.com;
|
||||
|
||||
# SSL certificates (use certbot to generate)
|
||||
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
|
||||
|
||||
# SSL configuration
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Proxy to 9Router
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
|
||||
# SSE support - CRITICAL for streaming
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
# API endpoint
|
||||
location /v1 {
|
||||
proxy_pass http://localhost:20128;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# SSE support - CRITICAL for streaming
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Step 3: Enable Site
|
||||
|
||||
```bash
|
||||
# Create symbolic link
|
||||
sudo ln -s /etc/nginx/sites-available/9router /etc/nginx/sites-enabled/
|
||||
|
||||
# Test configuration
|
||||
sudo nginx -t
|
||||
|
||||
# Reload Nginx
|
||||
sudo systemctl reload nginx
|
||||
```
|
||||
|
||||
### Step 4: Setup SSL with Let's Encrypt
|
||||
|
||||
```bash
|
||||
# Install certbot
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
|
||||
# Obtain SSL certificate
|
||||
sudo certbot --nginx -d your-domain.com
|
||||
|
||||
# Auto-renewal is configured automatically
|
||||
# Test renewal
|
||||
sudo certbot renew --dry-run
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔒 Security Considerations
|
||||
|
||||
### 1. Change Default Credentials
|
||||
|
||||
**CRITICAL:** Change `JWT_SECRET` and `INITIAL_PASSWORD` before deployment:
|
||||
|
||||
```bash
|
||||
# Generate secure JWT secret
|
||||
openssl rand -base64 32
|
||||
|
||||
# Use this value for JWT_SECRET
|
||||
export JWT_SECRET="generated-secret-here"
|
||||
```
|
||||
|
||||
### 2. Firewall Configuration
|
||||
|
||||
```bash
|
||||
# Allow SSH
|
||||
sudo ufw allow 22/tcp
|
||||
|
||||
# Allow HTTP/HTTPS (if using Nginx)
|
||||
sudo ufw allow 80/tcp
|
||||
sudo ufw allow 443/tcp
|
||||
|
||||
# If NOT using reverse proxy, allow 9Router ports
|
||||
sudo ufw allow 3000/tcp
|
||||
sudo ufw allow 20128/tcp
|
||||
|
||||
# Enable firewall
|
||||
sudo ufw enable
|
||||
```
|
||||
|
||||
### 3. Restrict Dashboard Access
|
||||
|
||||
If you only need API access, restrict dashboard port:
|
||||
|
||||
```bash
|
||||
# Only allow localhost access to dashboard
|
||||
sudo ufw deny 3000/tcp
|
||||
```
|
||||
|
||||
Access dashboard via SSH tunnel:
|
||||
|
||||
```bash
|
||||
ssh -L 3000:localhost:3000 user@your-server.com
|
||||
# Then open http://localhost:3000 in your browser
|
||||
```
|
||||
|
||||
### 4. Regular Updates
|
||||
|
||||
```bash
|
||||
# Update system packages
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
|
||||
# Update 9Router
|
||||
cd /path/to/9router/app
|
||||
git pull
|
||||
npm install
|
||||
npm run build
|
||||
pm2 restart 9router
|
||||
```
|
||||
|
||||
### 5. Backup Strategy
|
||||
|
||||
```bash
|
||||
# Backup data directory
|
||||
tar -czf 9router-backup-$(date +%Y%m%d).tar.gz /var/lib/9router
|
||||
|
||||
# Automated daily backup (add to crontab)
|
||||
0 2 * * * tar -czf /backups/9router-$(date +\%Y\%m\%d).tar.gz /var/lib/9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Monitoring
|
||||
|
||||
### Check Application Status
|
||||
|
||||
```bash
|
||||
# PM2 status
|
||||
pm2 status
|
||||
|
||||
# View logs
|
||||
pm2 logs 9router --lines 100
|
||||
|
||||
# Monitor resources
|
||||
pm2 monit
|
||||
```
|
||||
|
||||
### Nginx Logs
|
||||
|
||||
```bash
|
||||
# Access logs
|
||||
sudo tail -f /var/log/nginx/access.log
|
||||
|
||||
# Error logs
|
||||
sudo tail -f /var/log/nginx/error.log
|
||||
```
|
||||
|
||||
### System Resources
|
||||
|
||||
```bash
|
||||
# CPU and memory usage
|
||||
htop
|
||||
|
||||
# Disk usage
|
||||
df -h
|
||||
|
||||
# Network connections
|
||||
netstat -tulpn | grep -E '3000|20128'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Troubleshooting
|
||||
|
||||
### Application Won't Start
|
||||
|
||||
```bash
|
||||
# Check logs
|
||||
pm2 logs 9router
|
||||
|
||||
# Check if ports are in use
|
||||
sudo lsof -i :3000
|
||||
sudo lsof -i :20128
|
||||
|
||||
# Check environment variables
|
||||
pm2 env 9router
|
||||
```
|
||||
|
||||
### Nginx 502 Bad Gateway
|
||||
|
||||
```bash
|
||||
# Check if 9Router is running
|
||||
pm2 status
|
||||
|
||||
# Check Nginx error logs
|
||||
sudo tail -f /var/log/nginx/error.log
|
||||
|
||||
# Test Nginx configuration
|
||||
sudo nginx -t
|
||||
```
|
||||
|
||||
### SSE Streaming Not Working
|
||||
|
||||
Ensure `proxy_buffering off` is set in Nginx configuration for SSE support.
|
||||
|
||||
### Permission Denied Errors
|
||||
|
||||
```bash
|
||||
# Fix data directory permissions
|
||||
sudo chown -R $USER:$USER /var/lib/9router
|
||||
chmod 755 /var/lib/9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔗 Next Steps
|
||||
|
||||
- [Connect Providers](/providers/subscription.md)
|
||||
- [Setup Combos](/features/combos.md)
|
||||
- [Integrate with Tools](/integration/cursor.md)
|
||||
@@ -0,0 +1,164 @@
|
||||
# 🏠 Localhost Deployment
|
||||
|
||||
Run 9Router on your local machine for development and personal use.
|
||||
|
||||
---
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
Install 9Router globally via npm:
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
**Requirements:**
|
||||
- Node.js 20 or higher
|
||||
- npm 9 or higher
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Starting the Server
|
||||
|
||||
Start 9Router with a single command:
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
The dashboard will automatically open in your browser at `http://localhost:3000`
|
||||
|
||||
**Default Configuration:**
|
||||
- **Dashboard**: `http://localhost:3000`
|
||||
- **API Endpoint**: `http://localhost:20128/v1`
|
||||
- **Data Directory**: `~/.9router`
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Custom Data Directory
|
||||
|
||||
Set a custom data directory using environment variable:
|
||||
|
||||
```bash
|
||||
DATA_DIR=/path/to/data 9router
|
||||
```
|
||||
|
||||
### Custom Port
|
||||
|
||||
The API port (20128) and dashboard port (3000) are configured in the application. To change them, you'll need to modify the source code or use environment variables if supported.
|
||||
|
||||
---
|
||||
|
||||
## 🛑 Stopping the Server
|
||||
|
||||
Press `Ctrl+C` in the terminal where 9Router is running.
|
||||
|
||||
```bash
|
||||
# In the terminal running 9router
|
||||
^C # Press Ctrl+C
|
||||
```
|
||||
|
||||
The server will gracefully shut down and save all data.
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Restarting the Server
|
||||
|
||||
Simply run the start command again:
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
All your configurations, API keys, and combos are preserved in the data directory.
|
||||
|
||||
---
|
||||
|
||||
## 📊 Updating 9Router
|
||||
|
||||
Update to the latest version:
|
||||
|
||||
```bash
|
||||
npm update -g 9router
|
||||
```
|
||||
|
||||
Check your current version:
|
||||
|
||||
```bash
|
||||
npm list -g 9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Troubleshooting
|
||||
|
||||
### Port Already in Use
|
||||
|
||||
If port 20128 or 3000 is already in use:
|
||||
|
||||
```bash
|
||||
# Find process using the port (macOS/Linux)
|
||||
lsof -i :20128
|
||||
lsof -i :3000
|
||||
|
||||
# Kill the process
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
### Permission Errors
|
||||
|
||||
If you encounter permission errors during installation:
|
||||
|
||||
```bash
|
||||
# Use sudo (not recommended)
|
||||
sudo npm install -g 9router
|
||||
|
||||
# Or fix npm permissions (recommended)
|
||||
mkdir ~/.npm-global
|
||||
npm config set prefix '~/.npm-global'
|
||||
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
### Data Directory Issues
|
||||
|
||||
If the data directory is not accessible:
|
||||
|
||||
```bash
|
||||
# Check permissions
|
||||
ls -la ~/.9router
|
||||
|
||||
# Fix permissions
|
||||
chmod 755 ~/.9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📁 Data Directory Structure
|
||||
|
||||
```
|
||||
~/.9router/
|
||||
├── db.json # Main database (providers, combos, settings)
|
||||
├── logs/ # Application logs
|
||||
└── cache/ # Temporary cache files
|
||||
```
|
||||
|
||||
**Backup Your Data:**
|
||||
|
||||
```bash
|
||||
# Backup
|
||||
cp -r ~/.9router ~/.9router.backup
|
||||
|
||||
# Restore
|
||||
cp -r ~/.9router.backup ~/.9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔗 Next Steps
|
||||
|
||||
- [Connect Providers](/providers/subscription.md)
|
||||
- [Create Combos](/features/combos.md)
|
||||
- [Integrate with CLI Tools](/integration/cursor.md)
|
||||
@@ -0,0 +1,387 @@
|
||||
# Frequently Asked Questions
|
||||
|
||||
Common questions about 9Router.
|
||||
|
||||
---
|
||||
|
||||
## What is 9Router?
|
||||
|
||||
**9Router is an AI model router that maximizes your subscription value and minimizes costs.**
|
||||
|
||||
It intelligently routes requests across multiple AI providers using a 3-tier fallback system:
|
||||
1. **Subscription tier** - Maximize Claude Code, Codex, Gemini quotas you already pay for
|
||||
2. **Cheap tier** - Ultra-cheap alternatives ($0.20-$0.60 per 1M tokens)
|
||||
3. **Free tier** - Emergency backup with unlimited free models
|
||||
|
||||
**Key benefits:**
|
||||
- Never waste subscription quota
|
||||
- Automatic fallback when quota exhausted
|
||||
- Real-time quota tracking
|
||||
- 90% cost savings vs direct API usage
|
||||
|
||||
---
|
||||
|
||||
## How does pricing work?
|
||||
|
||||
**9Router uses a 3-tier pricing strategy:**
|
||||
|
||||
### Tier 1: Subscription (Maximize First)
|
||||
- **Claude Code** (Pro/Max): $20-100/month - 5-hour + weekly quota
|
||||
- **OpenAI Codex** (Plus/Pro): $20-200/month - 5-hour + weekly quota
|
||||
- **Gemini CLI**: FREE - 180K completions/month + 1K/day
|
||||
- **GitHub Copilot**: $10-19/month - Monthly reset
|
||||
- **Antigravity**: FREE - Similar to Gemini
|
||||
|
||||
**Goal:** Use every bit of quota before it resets!
|
||||
|
||||
### Tier 2: Cheap (Backup)
|
||||
- **GLM-4.7**: $0.60/$2.20 per 1M tokens - Daily reset 10AM
|
||||
- **MiniMax M2.1**: $0.20/$1.00 per 1M tokens - 5-hour rolling
|
||||
- **Kimi K2**: $9/month flat (10M tokens)
|
||||
|
||||
**Goal:** 90% cheaper than ChatGPT API ($20/1M)!
|
||||
|
||||
### Tier 3: Free (Emergency)
|
||||
- **iFlow**: 8 models FREE (Kimi K2, Qwen3, GLM, MiniMax...)
|
||||
- **Qwen**: 3 models FREE (Qwen3 Coder Plus/Flash, Vision)
|
||||
- **Kiro**: 2 models FREE (Claude Sonnet 4.5, Haiku 4.5)
|
||||
|
||||
**Goal:** Zero cost fallback when everything else is quota-limited!
|
||||
|
||||
---
|
||||
|
||||
## Is 9Router free?
|
||||
|
||||
**Yes, 9Router itself is 100% free and open source.**
|
||||
|
||||
**Free tier providers available:**
|
||||
- **Gemini CLI** - 180K completions/month (FREE Google account)
|
||||
- **iFlow** - 8 models unlimited (FREE OAuth)
|
||||
- **Qwen** - 3 models unlimited (FREE OAuth)
|
||||
- **Kiro** - Claude Sonnet/Haiku (FREE AWS Builder ID)
|
||||
|
||||
**You can code for FREE forever using only free tier providers!**
|
||||
|
||||
**Optional paid providers:**
|
||||
- Subscription services you may already have (Claude Code, Codex, Copilot)
|
||||
- Ultra-cheap alternatives ($0.20-$0.60 per 1M tokens)
|
||||
|
||||
---
|
||||
|
||||
## Which providers are supported?
|
||||
|
||||
### Subscription Providers
|
||||
- **Claude Code** (Pro/Max) - Claude 4.5 Opus/Sonnet/Haiku
|
||||
- **OpenAI Codex** (Plus/Pro) - GPT 5.2 Codex, GPT 5.1 Codex Max
|
||||
- **Gemini CLI** (FREE) - Gemini 3 Flash/Pro, 2.5 Pro/Flash
|
||||
- **GitHub Copilot** - GPT-5, Claude 4.5, Gemini 3
|
||||
- **Antigravity** (Google) - Gemini 3 Pro, Claude Sonnet 4.5
|
||||
|
||||
### Cheap Providers
|
||||
- **GLM** (Zhipu AI) - GLM 4.7, GLM 4.6V Vision
|
||||
- **MiniMax** - MiniMax M2.1
|
||||
- **Kimi** (Moonshot AI) - Kimi Latest
|
||||
- **OpenRouter** - Passthrough to any OpenRouter model
|
||||
|
||||
### Free Providers
|
||||
- **iFlow** - 8 models (Kimi K2, Qwen3, GLM, MiniMax, DeepSeek...)
|
||||
- **Qwen** - 3 models (Qwen3 Coder Plus/Flash, Vision)
|
||||
- **Kiro** - 2 models (Claude Sonnet 4.5, Haiku 4.5)
|
||||
|
||||
**Total: 15+ providers, 50+ models**
|
||||
|
||||
See [providers documentation](providers/subscription.md) for details.
|
||||
|
||||
---
|
||||
|
||||
## Can I use multiple providers?
|
||||
|
||||
**Yes! This is 9Router's core feature.**
|
||||
|
||||
**Combos allow you to chain multiple providers with automatic fallback:**
|
||||
|
||||
```
|
||||
Example combo: "premium-coding"
|
||||
1. cc/claude-opus-4-5 (Subscription primary)
|
||||
2. glm/glm-4.7 (Cheap backup)
|
||||
3. if/kimi-k2 (Free emergency)
|
||||
|
||||
→ Auto-switches when quota exhausted
|
||||
→ Never stops coding
|
||||
→ Minimal extra cost
|
||||
```
|
||||
|
||||
**How to create combos:**
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
→ Add models in priority order
|
||||
→ Use combo name in CLI: "premium-coding"
|
||||
```
|
||||
|
||||
**Benefits:**
|
||||
- Zero downtime when quota runs out
|
||||
- Automatic cost optimization
|
||||
- Single model name for all tools
|
||||
|
||||
See [combos documentation](features/combos.md) for examples.
|
||||
|
||||
---
|
||||
|
||||
## How does quota tracking work?
|
||||
|
||||
**9Router tracks quota in real-time for all providers:**
|
||||
|
||||
**Features:**
|
||||
- **Token consumption** - Input/output tokens per request
|
||||
- **Reset countdown** - Time until quota refreshes
|
||||
- **Usage stats** - Daily/weekly/monthly reports
|
||||
- **Cost estimation** - Projected spending (paid tiers)
|
||||
- **Quota alerts** - Notifications when quota low
|
||||
|
||||
**Quota types:**
|
||||
- **5-hour rolling** - Claude Code, Codex, MiniMax
|
||||
- **Daily reset** - Gemini CLI (1K/day), GLM (10AM)
|
||||
- **Weekly reset** - Claude Code, Codex (additional quota)
|
||||
- **Monthly reset** - Gemini CLI (180K), GitHub Copilot (1st)
|
||||
|
||||
**View quota:**
|
||||
```
|
||||
Dashboard → Providers → Quota Tracking
|
||||
→ Real-time usage + reset countdown
|
||||
```
|
||||
|
||||
See [quota tracking documentation](features/quota-tracking.md) for details.
|
||||
|
||||
---
|
||||
|
||||
## Does 9Router work with Cursor?
|
||||
|
||||
**Yes, but Cursor requires a cloud endpoint.**
|
||||
|
||||
**Problem:** Cursor IDE doesn't support localhost endpoints.
|
||||
|
||||
**Solution:** Use 9Router cloud deployment:
|
||||
|
||||
```
|
||||
Cursor Settings → Models → Advanced:
|
||||
OpenAI API Base URL: https://9router.com/v1
|
||||
OpenAI API Key: [from dashboard]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
**Alternative:** Self-host on VPS with public domain:
|
||||
```bash
|
||||
# Deploy to VPS
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
npm install && npm run build
|
||||
npm start
|
||||
|
||||
# Configure Nginx reverse proxy
|
||||
# Point Cursor to: https://your-domain.com/v1
|
||||
```
|
||||
|
||||
**Other CLI tools work with localhost:**
|
||||
- Cline ✅
|
||||
- Claude Desktop ✅
|
||||
- Codex CLI ✅
|
||||
- Continue ✅
|
||||
- RooCode ✅
|
||||
|
||||
See [Cursor integration guide](integration/cursor.md) for details.
|
||||
|
||||
---
|
||||
|
||||
## Can I self-host 9Router?
|
||||
|
||||
**Yes! 9Router supports multiple deployment options:**
|
||||
|
||||
### Localhost (Default)
|
||||
```bash
|
||||
npm install -g 9router
|
||||
9router
|
||||
→ Dashboard: http://localhost:3000
|
||||
→ API: http://localhost:20128/v1
|
||||
```
|
||||
|
||||
### VPS/Cloud
|
||||
```bash
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
npm install && npm run build
|
||||
|
||||
export JWT_SECRET="your-secure-secret"
|
||||
export INITIAL_PASSWORD="your-password"
|
||||
export NODE_ENV="production"
|
||||
|
||||
npm start
|
||||
```
|
||||
|
||||
### Docker
|
||||
```bash
|
||||
docker build -t 9router .
|
||||
docker run -d \
|
||||
-p 3000:3000 \
|
||||
-e JWT_SECRET="your-secret" \
|
||||
-v 9router-data:/app/data \
|
||||
9router
|
||||
```
|
||||
|
||||
### Cloudflare Workers
|
||||
```bash
|
||||
cd 9router/app
|
||||
npm run deploy:cloudflare
|
||||
```
|
||||
|
||||
**Environment variables:**
|
||||
- `JWT_SECRET` - **MUST change in production!**
|
||||
- `DATA_DIR` - Database storage path (default: `~/.9router`)
|
||||
- `INITIAL_PASSWORD` - Dashboard login (default: `123456`)
|
||||
- `NODE_ENV` - Set to `production` for deploy
|
||||
|
||||
See [deployment guide](getting-started/installation.md#deployment) for details.
|
||||
|
||||
---
|
||||
|
||||
## Is my data secure?
|
||||
|
||||
**Yes, 9Router prioritizes security and privacy:**
|
||||
|
||||
**Local storage:**
|
||||
- All data stored locally in `~/.9router` (or custom `DATA_DIR`)
|
||||
- No data sent to 9Router servers
|
||||
- OAuth tokens encrypted with JWT
|
||||
|
||||
**No telemetry:**
|
||||
- No usage tracking
|
||||
- No analytics
|
||||
- No phone-home
|
||||
|
||||
**Open source:**
|
||||
- Full source code available on GitHub
|
||||
- Audit security yourself
|
||||
- Community-reviewed
|
||||
|
||||
**Best practices:**
|
||||
- Change `JWT_SECRET` in production
|
||||
- Use strong `INITIAL_PASSWORD`
|
||||
- Enable HTTPS for cloud deployments
|
||||
- Rotate API keys regularly
|
||||
|
||||
**What 9Router stores:**
|
||||
- Provider OAuth tokens (encrypted)
|
||||
- API keys (encrypted)
|
||||
- Usage statistics (local only)
|
||||
- Combo configurations
|
||||
|
||||
**What 9Router does NOT store:**
|
||||
- Your prompts or responses
|
||||
- Code you generate
|
||||
- Personal information
|
||||
|
||||
---
|
||||
|
||||
## How do I update 9Router?
|
||||
|
||||
**Update methods depend on installation type:**
|
||||
|
||||
### Global NPM Install
|
||||
```bash
|
||||
npm update -g 9router
|
||||
```
|
||||
|
||||
### Local Install
|
||||
```bash
|
||||
cd 9router/app
|
||||
git pull origin main
|
||||
npm install
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
### Docker
|
||||
```bash
|
||||
docker pull 9router:latest
|
||||
docker stop 9router
|
||||
docker rm 9router
|
||||
docker run -d \
|
||||
-p 3000:3000 \
|
||||
-v 9router-data:/app/data \
|
||||
9router:latest
|
||||
```
|
||||
|
||||
**Check version:**
|
||||
```bash
|
||||
9router --version
|
||||
```
|
||||
|
||||
**Breaking changes:**
|
||||
- Check [CHANGELOG.md](https://github.com/decolua/9router/blob/main/CHANGELOG.md)
|
||||
- Backup `~/.9router` before major updates
|
||||
- Review migration guides for major versions
|
||||
|
||||
---
|
||||
|
||||
## How can I contribute?
|
||||
|
||||
**We welcome contributions!**
|
||||
|
||||
### Ways to contribute:
|
||||
|
||||
1. **Report bugs:**
|
||||
- [GitHub Issues](https://github.com/decolua/9router/issues)
|
||||
- Include error logs, steps to reproduce
|
||||
|
||||
2. **Request features:**
|
||||
- [GitHub Discussions](https://github.com/decolua/9router/discussions)
|
||||
- Describe use case and benefits
|
||||
|
||||
3. **Submit code:**
|
||||
```bash
|
||||
# Fork repo
|
||||
git clone https://github.com/YOUR_USERNAME/9router.git
|
||||
cd 9router
|
||||
|
||||
# Create branch
|
||||
git checkout -b feature/your-feature
|
||||
|
||||
# Make changes
|
||||
npm install
|
||||
npm run dev
|
||||
|
||||
# Test
|
||||
npm test
|
||||
|
||||
# Commit and push
|
||||
git add .
|
||||
git commit -m "Add your feature"
|
||||
git push origin feature/your-feature
|
||||
|
||||
# Create Pull Request on GitHub
|
||||
```
|
||||
|
||||
4. **Improve docs:**
|
||||
- Fix typos, add examples
|
||||
- Translate to other languages
|
||||
- Write tutorials
|
||||
|
||||
5. **Add providers:**
|
||||
- Implement new provider adapters
|
||||
- See `app/lib/providers/` for examples
|
||||
|
||||
**Contribution guidelines:**
|
||||
- Follow existing code style
|
||||
- Add tests for new features
|
||||
- Update documentation
|
||||
- Keep commits atomic and descriptive
|
||||
|
||||
See [CONTRIBUTING.md](https://github.com/decolua/9router/blob/main/CONTRIBUTING.md) for details.
|
||||
|
||||
---
|
||||
|
||||
## Need More Help?
|
||||
|
||||
- **Documentation:** [9router.com/docs](https://9router.com/docs)
|
||||
- **GitHub:** [github.com/decolua/9router](https://github.com/decolua/9router)
|
||||
- **Issues:** [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
- **Troubleshooting:** [troubleshooting.md](troubleshooting.md)
|
||||
@@ -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
|
||||
@@ -0,0 +1,478 @@
|
||||
# Installation
|
||||
|
||||
Detailed installation guide for 9Router with troubleshooting tips.
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
### System Requirements
|
||||
|
||||
- **Node.js**: Version 20.0.0 or higher
|
||||
- **npm**: Version 10.0.0 or higher (comes with Node.js)
|
||||
- **OS**: macOS, Linux, Windows (WSL recommended)
|
||||
- **Disk Space**: ~200MB for installation
|
||||
|
||||
### Check Your Version
|
||||
|
||||
```bash
|
||||
node --version
|
||||
# Should show v20.x.x or higher
|
||||
|
||||
npm --version
|
||||
# Should show 10.x.x or higher
|
||||
```
|
||||
|
||||
**Don't have Node.js?** Install from [nodejs.org](https://nodejs.org/)
|
||||
|
||||
---
|
||||
|
||||
## Installation Methods
|
||||
|
||||
### Method 1: Global Installation (Recommended)
|
||||
|
||||
Install 9Router globally to use from anywhere:
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
**Start 9Router:**
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
**Benefits:**
|
||||
- ✅ Run from any directory
|
||||
- ✅ Simple command: `9router`
|
||||
- ✅ Auto-updates with `npm update -g 9router`
|
||||
|
||||
### Method 2: Local Installation
|
||||
|
||||
Install in a specific project:
|
||||
|
||||
```bash
|
||||
mkdir my-9router
|
||||
cd my-9router
|
||||
npm install 9router
|
||||
```
|
||||
|
||||
**Start 9Router:**
|
||||
|
||||
```bash
|
||||
npx 9router
|
||||
```
|
||||
|
||||
**Benefits:**
|
||||
- ✅ Isolated per project
|
||||
- ✅ Version control per project
|
||||
- ✅ No global namespace pollution
|
||||
|
||||
### Method 3: From Source (Development)
|
||||
|
||||
Clone and build from GitHub:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
npm install
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
**Benefits:**
|
||||
- ✅ Latest development features
|
||||
- ✅ Contribute to development
|
||||
- ✅ Custom modifications
|
||||
|
||||
---
|
||||
|
||||
## First Run
|
||||
|
||||
### Start the Server
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
**What happens:**
|
||||
1. Server starts on `http://localhost:20128`
|
||||
2. Dashboard opens automatically in browser
|
||||
3. Data directory created at `~/.9router`
|
||||
4. API key generated automatically
|
||||
|
||||
### Dashboard Login
|
||||
|
||||
**Default credentials:**
|
||||
- Password: `123456`
|
||||
|
||||
**⚠️ Change password immediately:**
|
||||
1. Login to dashboard
|
||||
2. Settings → Change Password
|
||||
3. Use strong password
|
||||
|
||||
### Get Your API Key
|
||||
|
||||
```
|
||||
Dashboard → Settings → API Keys
|
||||
→ Copy your API key
|
||||
→ Use in CLI tools
|
||||
```
|
||||
|
||||
**Example API key format:**
|
||||
```
|
||||
9r_1234567890abcdef1234567890abcdef
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Verify Installation
|
||||
|
||||
### Check Server Status
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/health
|
||||
```
|
||||
|
||||
**Expected response:**
|
||||
```json
|
||||
{
|
||||
"status": "ok",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
### List Available Models
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/v1/models \
|
||||
-H "Authorization: Bearer your-api-key"
|
||||
```
|
||||
|
||||
**Expected response:**
|
||||
```json
|
||||
{
|
||||
"object": "list",
|
||||
"data": [
|
||||
{
|
||||
"id": "cc/claude-opus-4-5-20251101",
|
||||
"object": "model",
|
||||
"created": 1234567890,
|
||||
"owned_by": "claude-code"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Test Chat Completion
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/v1/chat/completions \
|
||||
-H "Authorization: Bearer your-api-key" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"model": "cc/claude-opus-4-5-20251101",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello!"}
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Create `.env` file or set environment variables:
|
||||
|
||||
```bash
|
||||
# Security (REQUIRED in production)
|
||||
export JWT_SECRET="your-secure-secret-change-this"
|
||||
export INITIAL_PASSWORD="your-password"
|
||||
|
||||
# Storage
|
||||
export DATA_DIR="~/.9router"
|
||||
|
||||
# Server
|
||||
export PORT="20128"
|
||||
export NODE_ENV="production"
|
||||
|
||||
# Logging
|
||||
export ENABLE_REQUEST_LOGS="false"
|
||||
```
|
||||
|
||||
### Data Directory
|
||||
|
||||
**Default location:** `~/.9router`
|
||||
|
||||
**Contents:**
|
||||
```
|
||||
~/.9router/
|
||||
├── db.json # Database (providers, combos, usage)
|
||||
├── api-keys.json # API keys
|
||||
└── logs/ # Request logs (if enabled)
|
||||
```
|
||||
|
||||
**Change location:**
|
||||
|
||||
```bash
|
||||
export DATA_DIR="/custom/path"
|
||||
9router
|
||||
```
|
||||
|
||||
### Port Configuration
|
||||
|
||||
**Default port:** `20128`
|
||||
|
||||
**Change port:**
|
||||
|
||||
```bash
|
||||
export PORT="3000"
|
||||
9router
|
||||
```
|
||||
|
||||
**Or use command line:**
|
||||
|
||||
```bash
|
||||
9router --port 3000
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Port Already in Use
|
||||
|
||||
**Error:**
|
||||
```
|
||||
Error: listen EADDRINUSE: address already in use :::20128
|
||||
```
|
||||
|
||||
**Solution 1: Kill existing process**
|
||||
|
||||
```bash
|
||||
# Find process using port 20128
|
||||
lsof -i :20128
|
||||
|
||||
# Kill process
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
**Solution 2: Use different port**
|
||||
|
||||
```bash
|
||||
9router --port 3000
|
||||
```
|
||||
|
||||
### Permission Denied
|
||||
|
||||
**Error:**
|
||||
```
|
||||
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/9router'
|
||||
```
|
||||
|
||||
**Solution: Use sudo (not recommended) or fix npm permissions**
|
||||
|
||||
```bash
|
||||
# Fix npm permissions (recommended)
|
||||
mkdir ~/.npm-global
|
||||
npm config set prefix '~/.npm-global'
|
||||
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
|
||||
# Then install again
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
### Node.js Version Too Old
|
||||
|
||||
**Error:**
|
||||
```
|
||||
Error: The engine "node" is incompatible with this module
|
||||
```
|
||||
|
||||
**Solution: Update Node.js**
|
||||
|
||||
```bash
|
||||
# Using nvm (recommended)
|
||||
nvm install 20
|
||||
nvm use 20
|
||||
|
||||
# Or download from nodejs.org
|
||||
```
|
||||
|
||||
### Dashboard Not Opening
|
||||
|
||||
**Issue:** Dashboard doesn't open automatically
|
||||
|
||||
**Solution 1: Open manually**
|
||||
|
||||
```
|
||||
http://localhost:20128
|
||||
```
|
||||
|
||||
**Solution 2: Check firewall**
|
||||
|
||||
```bash
|
||||
# macOS: Allow Node.js in System Preferences → Security
|
||||
# Linux: Check iptables
|
||||
# Windows: Check Windows Firewall
|
||||
```
|
||||
|
||||
### Cannot Connect to Providers
|
||||
|
||||
**Issue:** OAuth login fails or API key invalid
|
||||
|
||||
**Solution 1: Check internet connection**
|
||||
|
||||
```bash
|
||||
ping google.com
|
||||
```
|
||||
|
||||
**Solution 2: Check provider status**
|
||||
|
||||
- Claude Code: [status.anthropic.com](https://status.anthropic.com)
|
||||
- OpenAI: [status.openai.com](https://status.openai.com)
|
||||
- Gemini: [status.cloud.google.com](https://status.cloud.google.com)
|
||||
|
||||
**Solution 3: Regenerate API key**
|
||||
|
||||
```
|
||||
Dashboard → Provider → Disconnect → Reconnect
|
||||
```
|
||||
|
||||
### High Memory Usage
|
||||
|
||||
**Issue:** 9Router using too much RAM
|
||||
|
||||
**Solution: Restart server**
|
||||
|
||||
```bash
|
||||
# Stop
|
||||
pkill -f 9router
|
||||
|
||||
# Start
|
||||
9router
|
||||
```
|
||||
|
||||
**Or use PM2 for auto-restart:**
|
||||
|
||||
```bash
|
||||
npm install -g pm2
|
||||
pm2 start 9router --name 9router
|
||||
pm2 save
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Deployment Options
|
||||
|
||||
### Local Development
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
9router
|
||||
```
|
||||
|
||||
**Use case:** Personal coding, testing
|
||||
|
||||
### VPS/Cloud Server
|
||||
|
||||
```bash
|
||||
# Install
|
||||
npm install -g 9router
|
||||
|
||||
# Configure
|
||||
export JWT_SECRET="your-secure-secret"
|
||||
export INITIAL_PASSWORD="your-password"
|
||||
export NODE_ENV="production"
|
||||
|
||||
# Start with PM2
|
||||
npm install -g pm2
|
||||
pm2 start 9router --name 9router
|
||||
pm2 save
|
||||
pm2 startup
|
||||
```
|
||||
|
||||
**Use case:** Team access, remote coding
|
||||
|
||||
### Docker
|
||||
|
||||
```bash
|
||||
docker pull 9router/9router:latest
|
||||
|
||||
docker run -d \
|
||||
-p 20128:20128 \
|
||||
-e JWT_SECRET="your-secure-secret" \
|
||||
-e INITIAL_PASSWORD="your-password" \
|
||||
-v 9router-data:/root/.9router \
|
||||
--name 9router \
|
||||
9router/9router:latest
|
||||
```
|
||||
|
||||
**Use case:** Containerized deployment, Kubernetes
|
||||
|
||||
### Reverse Proxy (Nginx)
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name your-domain.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:20128;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
|
||||
# SSE support for streaming
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Use case:** HTTPS, custom domain, load balancing
|
||||
|
||||
---
|
||||
|
||||
## Uninstallation
|
||||
|
||||
### Remove Global Installation
|
||||
|
||||
```bash
|
||||
npm uninstall -g 9router
|
||||
```
|
||||
|
||||
### Remove Data Directory
|
||||
|
||||
```bash
|
||||
rm -rf ~/.9router
|
||||
```
|
||||
|
||||
### Remove Configuration
|
||||
|
||||
```bash
|
||||
# Remove environment variables from shell config
|
||||
nano ~/.bashrc # or ~/.zshrc
|
||||
# Delete 9router-related exports
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Getting Started Guide](../getting-started.md) - Connect providers and start coding
|
||||
- [Features](../features/) - Explore quota tracking, combos, deployment
|
||||
- [Troubleshooting](../troubleshooting.md) - Fix common issues
|
||||
|
||||
---
|
||||
|
||||
## Need Help?
|
||||
|
||||
- **Website**: [9router.com](https://9router.com)
|
||||
- **GitHub**: [github.com/decolua/9router](https://github.com/decolua/9router)
|
||||
- **Issues**: [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
@@ -0,0 +1,247 @@
|
||||
# Getting Started
|
||||
|
||||
Get 9Router running in 5 minutes and start routing AI requests intelligently.
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Install
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
**Requirements:** Node.js 20+ ([Installation details](getting-started/installation.md))
|
||||
|
||||
### 2. Start
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
🎉 **Dashboard opens automatically** at `http://localhost:20128`
|
||||
|
||||
- Default password: `123456` (change in dashboard)
|
||||
- API key generated automatically
|
||||
- Ready to connect providers
|
||||
|
||||
### 3. Connect Providers
|
||||
|
||||
You have 3 ways to connect providers:
|
||||
|
||||
#### Option A: OAuth (Subscription Providers)
|
||||
|
||||
**Best for:** Claude Code, Codex, Gemini CLI, GitHub Copilot
|
||||
|
||||
```
|
||||
Dashboard → Providers → Connect [Provider]
|
||||
→ OAuth login → Auto token refresh
|
||||
→ Quota tracking enabled
|
||||
```
|
||||
|
||||
**Example: Claude Code**
|
||||
1. Click "Connect Claude Code"
|
||||
2. Login with your Claude account
|
||||
3. Authorize 9Router
|
||||
4. ✅ Done! Use model: `cc/claude-opus-4-5-20251101`
|
||||
|
||||
#### Option B: API Key (Cheap Providers)
|
||||
|
||||
**Best for:** GLM, MiniMax, Kimi, OpenRouter
|
||||
|
||||
```
|
||||
Dashboard → Providers → Add API Key
|
||||
→ Select provider
|
||||
→ Paste API key
|
||||
→ Save
|
||||
```
|
||||
|
||||
**Example: GLM-4.7**
|
||||
1. Sign up at [Zhipu AI](https://open.bigmodel.cn/)
|
||||
2. Get API key from Coding Plan
|
||||
3. Dashboard → Add API Key → Provider: `glm` → Paste key
|
||||
4. ✅ Done! Use model: `glm/glm-4.7`
|
||||
|
||||
#### Option C: Free Providers (No Cost)
|
||||
|
||||
**Best for:** iFlow, Qwen, Kiro
|
||||
|
||||
```
|
||||
Dashboard → Providers → Connect [Free Provider]
|
||||
→ Device code or OAuth
|
||||
→ Unlimited usage
|
||||
```
|
||||
|
||||
**Example: iFlow**
|
||||
1. Click "Connect iFlow"
|
||||
2. Login with iFlow account
|
||||
3. Authorize
|
||||
4. ✅ Done! Use 8 models: `if/kimi-k2-thinking`, `if/qwen3-coder-plus`, etc.
|
||||
|
||||
---
|
||||
|
||||
## 4. Use in CLI Tools
|
||||
|
||||
Point your coding tool to 9Router:
|
||||
|
||||
### Cursor IDE
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [from 9router dashboard]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
### Claude Desktop
|
||||
|
||||
Edit `~/.claude/config.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"anthropic_api_base": "http://localhost:20128/v1",
|
||||
"anthropic_api_key": "your-9router-api-key"
|
||||
}
|
||||
```
|
||||
|
||||
### Cline / Continue / RooCode
|
||||
|
||||
```
|
||||
Provider: OpenAI Compatible
|
||||
Base URL: http://localhost:20128/v1
|
||||
API Key: [from dashboard]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
### Codex CLI
|
||||
|
||||
```bash
|
||||
export OPENAI_BASE_URL="http://localhost:20128"
|
||||
export OPENAI_API_KEY="your-9router-api-key"
|
||||
|
||||
codex "your prompt"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Create Smart Combos (Optional)
|
||||
|
||||
Combos enable automatic fallback between models:
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: premium-coding
|
||||
Models:
|
||||
1. cc/claude-opus-4-5-20251101 (Subscription primary)
|
||||
2. glm/glm-4.7 (Cheap backup, $0.6/1M)
|
||||
3. if/kimi-k2-thinking (Free fallback)
|
||||
|
||||
Use in CLI: premium-coding
|
||||
```
|
||||
|
||||
**How it works:**
|
||||
1. Tries Claude Opus first (your subscription)
|
||||
2. If quota exhausted → GLM-4.7 (ultra-cheap)
|
||||
3. If budget limit → iFlow (free)
|
||||
4. Zero downtime, automatic switching!
|
||||
|
||||
---
|
||||
|
||||
## Available Models
|
||||
|
||||
### Subscription Models (Maximize First)
|
||||
|
||||
**Claude Code (`cc/`)** - Pro/Max subscription:
|
||||
- `cc/claude-opus-4-5-20251101` - Claude 4.5 Opus
|
||||
- `cc/claude-sonnet-4-5-20250929` - Claude 4.5 Sonnet
|
||||
- `cc/claude-haiku-4-5-20251001` - Claude 4.5 Haiku
|
||||
|
||||
**Codex (`cx/`)** - Plus/Pro subscription:
|
||||
- `cx/gpt-5.2-codex` - GPT 5.2 Codex
|
||||
- `cx/gpt-5.1-codex-max` - GPT 5.1 Codex Max
|
||||
|
||||
**Gemini CLI (`gc/`)** - FREE 180K/month:
|
||||
- `gc/gemini-3-flash-preview` - Gemini 3 Flash Preview
|
||||
- `gc/gemini-2.5-pro` - Gemini 2.5 Pro
|
||||
|
||||
**GitHub Copilot (`gh/`)** - Subscription:
|
||||
- `gh/gpt-5` - GPT-5
|
||||
- `gh/claude-4.5-sonnet` - Claude 4.5 Sonnet
|
||||
|
||||
### Cheap Models (Backup)
|
||||
|
||||
**GLM (`glm/`)** - $0.6/$2.2 per 1M:
|
||||
- `glm/glm-4.7` - GLM 4.7 (daily reset 10AM)
|
||||
|
||||
**MiniMax (`minimax/`)** - $0.20/$1.00 per 1M:
|
||||
- `minimax/MiniMax-M2.1` - MiniMax M2.1 (5h reset)
|
||||
|
||||
**Kimi (`kimi/`)** - $9/month (10M tokens):
|
||||
- `kimi/kimi-latest` - Kimi Latest
|
||||
|
||||
### FREE Models (Emergency)
|
||||
|
||||
**iFlow (`if/`)** - 8 models FREE:
|
||||
- `if/kimi-k2-thinking` - Kimi K2 Thinking
|
||||
- `if/qwen3-coder-plus` - Qwen3 Coder Plus
|
||||
- `if/glm-4.7` - GLM 4.7
|
||||
- `if/deepseek-r1` - DeepSeek R1
|
||||
|
||||
**Qwen (`qw/`)** - 3 models FREE:
|
||||
- `qw/qwen3-coder-plus` - Qwen3 Coder Plus
|
||||
- `qw/qwen3-coder-flash` - Qwen3 Coder Flash
|
||||
|
||||
**Kiro (`kr/`)** - 2 models FREE:
|
||||
- `kr/claude-sonnet-4.5` - Claude Sonnet 4.5
|
||||
- `kr/claude-haiku-4.5` - Claude Haiku 4.5
|
||||
|
||||
---
|
||||
|
||||
## Cost Optimization Strategy
|
||||
|
||||
### Monthly Budget: $10-20/month
|
||||
|
||||
```
|
||||
1. Use Gemini CLI free tier (180K/month) for quick tasks
|
||||
2. Use Claude Code subscription quota fully (you already pay)
|
||||
3. Fallback to GLM ($0.6/1M) when quota out
|
||||
4. Emergency: MiniMax M2.1 ($0.20/1M) or iFlow (free)
|
||||
|
||||
Real example (100M tokens/month):
|
||||
60M via Gemini CLI: $0 (free tier)
|
||||
30M via Claude Code: $0 (subscription you already have)
|
||||
8M via GLM: $4.80
|
||||
2M via MiniMax: $0.40
|
||||
Total: $5.20/month + existing subscriptions
|
||||
```
|
||||
|
||||
### Quota Reset Strategy
|
||||
|
||||
```
|
||||
Daily routine:
|
||||
1. Morning: Fresh Claude Code quota (5h reset)
|
||||
2. Afternoon: Switch to Gemini CLI (1K/day)
|
||||
3. Evening: GLM daily quota (reset 10AM next day)
|
||||
4. Late night: MiniMax (5h rolling) or iFlow (free)
|
||||
|
||||
→ Code 24/7 with minimal extra cost!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Installation Details](getting-started/installation.md) - Requirements, troubleshooting
|
||||
- [Features](features/) - Explore quota tracking, combos, deployment
|
||||
- [FAQ](faq.md) - Common questions and answers
|
||||
- [Troubleshooting](troubleshooting.md) - Fix common issues
|
||||
|
||||
---
|
||||
|
||||
## Need Help?
|
||||
|
||||
- **Website**: [9router.com](https://9router.com)
|
||||
- **GitHub**: [github.com/decolua/9router](https://github.com/decolua/9router)
|
||||
- **Issues**: [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
@@ -0,0 +1,164 @@
|
||||
# Welcome to 9Router
|
||||
|
||||
**Use Claude, Codex, Gemini for FREE • Ultra-cheap alternatives from $0.20/1M tokens**
|
||||
|
||||
9Router is an AI model router that maximizes your subscription value and minimizes costs through intelligent routing and automatic fallback.
|
||||
|
||||
---
|
||||
|
||||
## What is 9Router?
|
||||
|
||||
9Router is a smart proxy that sits between your coding tools (Cursor, Cline, Claude Desktop) and AI providers. It automatically routes requests to the best available model based on quota, cost, and availability.
|
||||
|
||||
**Stop wasting money:**
|
||||
- ❌ Subscription quota expires unused every month
|
||||
- ❌ Rate limits stop you mid-coding
|
||||
- ❌ Expensive APIs ($20-50/month per provider)
|
||||
- ❌ Manual switching between providers
|
||||
|
||||
**Start maximizing value:**
|
||||
- ✅ **Maximize Subscriptions** - Track and use every bit of Claude Code, Codex, Gemini quota
|
||||
- ✅ **FREE Available** - Access iFlow, Qwen, Kiro models via CLI
|
||||
- ✅ **Ultra-Cheap Backup** - GLM ($0.6/1M), MiniMax M2.1 ($0.20/1M)
|
||||
- ✅ **Smart Fallback** - Subscription → Cheap → Free, automatic switching
|
||||
|
||||
---
|
||||
|
||||
## Key Features
|
||||
|
||||
### 🔄 Smart 3-Tier Fallback
|
||||
|
||||
```
|
||||
Setup once, never stop coding:
|
||||
|
||||
Tier 1 (SUBSCRIPTION): Claude Code → Codex → Gemini
|
||||
↓ quota exhausted
|
||||
Tier 2 (CHEAP): GLM-4.7 → MiniMax M2.1 → Kimi
|
||||
↓ budget limit
|
||||
Tier 3 (FREE): iFlow → Qwen → Kiro
|
||||
|
||||
→ Automatic switching, zero downtime!
|
||||
```
|
||||
|
||||
### 📊 Quota Tracking
|
||||
|
||||
- Real-time token consumption per provider
|
||||
- Reset countdown (5-hour, daily, weekly, monthly)
|
||||
- Cost estimation for paid tiers
|
||||
- Monthly spending reports
|
||||
|
||||
### 🎯 Universal CLI Support
|
||||
|
||||
Works with any tool that supports custom OpenAI endpoints:
|
||||
|
||||
✅ **Cursor** • **Cline** • **Claude Desktop** • **Codex** • **RooCode** • **Continue** • **Any OpenAI-compatible tool**
|
||||
|
||||
### 💰 Cost Optimization
|
||||
|
||||
**Real example (100M tokens/month):**
|
||||
```
|
||||
60M via Gemini CLI: $0 (free tier)
|
||||
30M via Claude Code: $0 (subscription you already have)
|
||||
8M via GLM: $4.80
|
||||
2M via MiniMax: $0.40
|
||||
Total: $5.20/month vs $2000 on ChatGPT API!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Why Choose 9Router?
|
||||
|
||||
### Maximize Subscriptions
|
||||
|
||||
Already paying for Claude Code ($20-100/month) or Codex ($20-200/month)? Get full value:
|
||||
|
||||
- Track quota usage in real-time
|
||||
- Auto-switch when quota resets (5-hour, weekly)
|
||||
- Use every token before it expires
|
||||
- Gemini CLI: 180K completions/month **FREE**
|
||||
|
||||
### Ultra-Cheap Backup
|
||||
|
||||
When subscription quota runs out, pay pennies:
|
||||
|
||||
| Provider | Cost per 1M tokens | Reset |
|
||||
|----------|-------------------|-------|
|
||||
| **GLM-4.7** | $0.60 input / $2.20 output | Daily 10:00 AM |
|
||||
| **MiniMax M2.1** | $0.20 input / $1.00 output | 5-hour rolling |
|
||||
| **Kimi K2** | $9/month (10M tokens) | Monthly |
|
||||
|
||||
**~90% cheaper than ChatGPT API ($20/1M)!**
|
||||
|
||||
### Free Forever Fallback
|
||||
|
||||
Emergency backup when everything else is quota-limited:
|
||||
|
||||
- **iFlow**: 8 models (Kimi K2, Qwen3 Coder Plus, GLM 4.7, MiniMax M2)
|
||||
- **Qwen**: 3 models (Qwen3 Coder Plus/Flash, Vision)
|
||||
- **Kiro**: Claude Sonnet 4.5, Haiku 4.5 (AWS Builder ID)
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
Get started in 2 minutes:
|
||||
|
||||
```bash
|
||||
# Install globally
|
||||
npm install -g 9router
|
||||
|
||||
# Start (dashboard opens automatically)
|
||||
9router
|
||||
```
|
||||
|
||||
🎉 **Dashboard opens** → Connect providers → Start coding!
|
||||
|
||||
**Use in your CLI tool:**
|
||||
|
||||
```
|
||||
Endpoint: http://localhost:20128/v1
|
||||
API Key: [from dashboard]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
[→ Full Getting Started Guide](getting-started.md)
|
||||
|
||||
---
|
||||
|
||||
## Use Cases
|
||||
|
||||
### For Individual Developers
|
||||
|
||||
- Maximize your Claude Code/Codex subscription
|
||||
- Use Gemini CLI free tier (180K/month)
|
||||
- Fallback to ultra-cheap models ($0.20/1M)
|
||||
- Code 24/7 without rate limits
|
||||
|
||||
### For Teams
|
||||
|
||||
- Deploy on VPS/Cloud for shared access
|
||||
- Track team spending in real-time
|
||||
- Set budget limits per tier
|
||||
- Centralized provider management
|
||||
|
||||
### For Mobile/Remote Coding
|
||||
|
||||
- Use cloud deployment (https://9router.com)
|
||||
- Access from iPad, phone, anywhere
|
||||
- No localhost limitations
|
||||
- Cloudflare edge network (300+ locations)
|
||||
|
||||
---
|
||||
|
||||
## What's Next?
|
||||
|
||||
- [Getting Started](getting-started.md) - Install and configure in 5 minutes
|
||||
- [Installation Guide](getting-started/installation.md) - Detailed setup instructions
|
||||
- [Features](features/) - Explore all capabilities
|
||||
- [FAQ](faq.md) - Common questions
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<sub>Built with ❤️ for developers maximizing AI value</sub>
|
||||
</div>
|
||||
@@ -0,0 +1,109 @@
|
||||
# Claude Code Integration
|
||||
|
||||
Integrate 9Router with Claude Code CLI to route your Anthropic API requests through 9Router's intelligent routing system.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Claude Code CLI installed
|
||||
- 9Router running locally or cloud endpoint configured
|
||||
- API key from 9Router dashboard
|
||||
|
||||
## Setup
|
||||
|
||||
### 1. Configure Environment Variables
|
||||
|
||||
Set the following environment variables in your shell configuration file (`~/.bashrc`, `~/.zshrc`, or `~/.bash_profile`):
|
||||
|
||||
```bash
|
||||
# Base URL for 9Router
|
||||
export ANTHROPIC_BASE_URL="http://localhost:20128/v1"
|
||||
|
||||
# Optional: Set default models for aliases
|
||||
export ANTHROPIC_DEFAULT_OPUS_MODEL="cc/claude-opus-4-5-20251101"
|
||||
export ANTHROPIC_DEFAULT_SONNET_MODEL="cc/claude-sonnet-4-5-20250929"
|
||||
export ANTHROPIC_DEFAULT_HAIKU_MODEL="cc/claude-haiku-4-5-20251001"
|
||||
```
|
||||
|
||||
### 2. Reload Shell Configuration
|
||||
|
||||
```bash
|
||||
source ~/.zshrc # or ~/.bashrc
|
||||
```
|
||||
|
||||
### 3. Verify Configuration
|
||||
|
||||
Check that the environment variables are set correctly:
|
||||
|
||||
```bash
|
||||
echo $ANTHROPIC_BASE_URL
|
||||
```
|
||||
|
||||
## Model Aliases
|
||||
|
||||
Claude Code supports the following model aliases that map to 9Router models:
|
||||
|
||||
| Alias | Model | Environment Variable |
|
||||
|-------|-------|---------------------|
|
||||
| `opus` | Claude Opus 4.5 | `ANTHROPIC_DEFAULT_OPUS_MODEL` |
|
||||
| `sonnet` | Claude Sonnet 4.5 | `ANTHROPIC_DEFAULT_SONNET_MODEL` |
|
||||
| `haiku` | Claude Haiku 4.5 | `ANTHROPIC_DEFAULT_HAIKU_MODEL` |
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Using Model Aliases
|
||||
|
||||
```bash
|
||||
# Use Opus model
|
||||
claude --model opus "Explain quantum computing"
|
||||
|
||||
# Use Sonnet model
|
||||
claude --model sonnet "Write a Python function"
|
||||
|
||||
# Use Haiku model
|
||||
claude --model haiku "Quick code review"
|
||||
```
|
||||
|
||||
### Using Full Model Names
|
||||
|
||||
```bash
|
||||
claude --model cc/claude-opus-4-5-20251101 "Your prompt here"
|
||||
```
|
||||
|
||||
## Settings File
|
||||
|
||||
Claude Code stores its configuration in `~/.claude/settings.json`. You can manually edit this file if needed:
|
||||
|
||||
```json
|
||||
{
|
||||
"baseUrl": "http://localhost:20128/v1",
|
||||
"defaultModel": "sonnet"
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Connection Issues
|
||||
|
||||
If you encounter connection errors:
|
||||
|
||||
1. Verify 9Router is running: `curl http://localhost:20128/health`
|
||||
2. Check environment variables are set correctly
|
||||
3. Ensure no firewall is blocking port 20128
|
||||
|
||||
### Model Not Found
|
||||
|
||||
If you get "model not found" errors:
|
||||
|
||||
1. Verify the model name matches your 9Router configuration
|
||||
2. Check that the provider connection is active in 9Router dashboard
|
||||
3. Ensure the model is available in your connected providers
|
||||
|
||||
## Cloud Endpoint
|
||||
|
||||
To use 9Router cloud endpoint instead of localhost:
|
||||
|
||||
```bash
|
||||
export ANTHROPIC_BASE_URL="https://9router.com"
|
||||
```
|
||||
|
||||
Make sure you have configured your API key in the 9Router cloud dashboard.
|
||||
@@ -0,0 +1,201 @@
|
||||
# Cline Integration
|
||||
|
||||
Integrate 9Router with Cline VSCode extension to route your AI requests through 9Router's intelligent routing system.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Visual Studio Code installed
|
||||
- Cline extension installed from VSCode marketplace
|
||||
- 9Router running locally or cloud endpoint configured
|
||||
- API key from 9Router dashboard
|
||||
|
||||
## Setup
|
||||
|
||||
### 1. Open Cline Settings
|
||||
|
||||
1. Open Visual Studio Code
|
||||
2. Open the Cline extension panel (click the Cline icon in the sidebar)
|
||||
3. Click the **Settings** icon (gear icon) in the Cline panel
|
||||
|
||||
### 2. Select API Provider
|
||||
|
||||
1. In the Cline settings, find **API Provider** dropdown
|
||||
2. Select **Ollama** from the list
|
||||
- Note: We use Ollama provider type because it's compatible with OpenAI-style APIs
|
||||
|
||||
### 3. Configure Base URL
|
||||
|
||||
Set the base URL to your 9Router endpoint:
|
||||
|
||||
**For Local 9Router:**
|
||||
```
|
||||
http://localhost:20128/v1
|
||||
```
|
||||
|
||||
**For Cloud 9Router:**
|
||||
```
|
||||
https://9router.com
|
||||
```
|
||||
|
||||
**Steps:**
|
||||
1. In the **Base URL** field, enter your 9Router endpoint
|
||||
2. Make sure to include `/v1` at the end
|
||||
|
||||
### 4. Add API Key
|
||||
|
||||
1. In the **API Key** field, enter your 9Router API key
|
||||
2. You can find your API key in the 9Router dashboard under **Settings → API Keys**
|
||||
3. The key should start with `sk-9router-`
|
||||
|
||||
### 5. Select Model
|
||||
|
||||
1. In the **Model** dropdown, you can either:
|
||||
- Select from available models (if Cline auto-detects them)
|
||||
- Manually enter the model name from your 9Router configuration
|
||||
|
||||
2. Common model names:
|
||||
- `gpt-4`
|
||||
- `gpt-4o`
|
||||
- `claude-opus-4-5`
|
||||
- `claude-sonnet-4-5`
|
||||
- `gemini-2.0-flash`
|
||||
|
||||
### 6. Save Configuration
|
||||
|
||||
Click **Save** or close the settings panel. Cline will automatically save your configuration.
|
||||
|
||||
## Configuration Example
|
||||
|
||||
Your Cline settings should look like this:
|
||||
|
||||
```
|
||||
API Provider: Ollama
|
||||
Base URL: http://localhost:20128/v1
|
||||
API Key: sk-9router-xxxxxxxxxxxxx
|
||||
Model: gpt-4
|
||||
```
|
||||
|
||||
## Available Models
|
||||
|
||||
You can use any model configured in your 9Router dashboard. Common examples:
|
||||
|
||||
| Model Name | Provider | Description |
|
||||
|------------|----------|-------------|
|
||||
| `gpt-4` | OpenAI | GPT-4 Turbo |
|
||||
| `gpt-4o` | OpenAI | GPT-4 Optimized |
|
||||
| `claude-opus-4-5` | Anthropic | Claude Opus 4.5 |
|
||||
| `claude-sonnet-4-5` | Anthropic | Claude Sonnet 4.5 |
|
||||
| `gemini-2.0-flash` | Google | Gemini 2.0 Flash |
|
||||
|
||||
## Usage
|
||||
|
||||
### Chat with AI
|
||||
|
||||
1. Open the Cline panel in VSCode
|
||||
2. Type your message in the chat input
|
||||
3. Press Enter to send
|
||||
4. Cline will use 9Router to process your request
|
||||
|
||||
### Code Generation
|
||||
|
||||
1. Ask Cline to generate code: "Create a React component for a login form"
|
||||
2. Cline will generate code using 9Router
|
||||
3. Review and accept the generated code
|
||||
|
||||
### Code Explanation
|
||||
|
||||
1. Select code in your editor
|
||||
2. Ask Cline: "Explain this code"
|
||||
3. Get AI-powered explanations through 9Router
|
||||
|
||||
### File Operations
|
||||
|
||||
1. Ask Cline to create, modify, or delete files
|
||||
2. Cline will use 9Router to understand context and make changes
|
||||
3. Review changes before accepting
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Connection Failed" Error
|
||||
|
||||
1. Verify 9Router is running: `curl http://localhost:20128/health`
|
||||
2. Check that the base URL is correct and includes `/v1`
|
||||
3. Ensure no firewall is blocking port 20128
|
||||
4. Try restarting VSCode
|
||||
|
||||
### "Invalid API Key" Error
|
||||
|
||||
1. Verify your API key in 9Router dashboard
|
||||
2. Make sure you copied the entire key including the `sk-9router-` prefix
|
||||
3. Check that the API key has not expired
|
||||
4. Try regenerating a new API key
|
||||
|
||||
### "Model Not Found" Error
|
||||
|
||||
1. Verify the model name matches exactly with your 9Router configuration
|
||||
2. Check that the provider connection is active in 9Router dashboard
|
||||
3. Ensure the model is available in your connected providers
|
||||
4. Try using the full model name (e.g., `openai/gpt-4` instead of `gpt-4`)
|
||||
|
||||
### Cline Not Responding
|
||||
|
||||
1. Check the Cline output panel for error messages
|
||||
2. Verify your 9Router instance is running and healthy
|
||||
3. Try reloading VSCode window (Cmd/Ctrl + Shift + P → "Reload Window")
|
||||
4. Check 9Router logs for any errors
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
### Using Cloud Endpoint
|
||||
|
||||
To use 9Router cloud endpoint instead of localhost:
|
||||
|
||||
1. In Cline settings, set Base URL to: `https://9router.com`
|
||||
2. Make sure you have configured your API key in the 9Router cloud dashboard
|
||||
3. Ensure your cloud endpoint is active and accessible
|
||||
|
||||
### Multiple Models
|
||||
|
||||
You can quickly switch between models:
|
||||
|
||||
1. Open Cline settings
|
||||
2. Change the **Model** field to a different model
|
||||
3. Save and continue chatting with the new model
|
||||
|
||||
### Custom Timeout
|
||||
|
||||
If you experience timeout issues with large requests:
|
||||
|
||||
1. Open VSCode settings (Cmd/Ctrl + ,)
|
||||
2. Search for "Cline timeout"
|
||||
3. Increase the timeout value (default is usually 30 seconds)
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use Appropriate Models**: Choose faster models (like Haiku or Flash) for simple tasks, and more powerful models (like Opus or GPT-4) for complex tasks
|
||||
2. **Monitor Usage**: Check 9Router dashboard for usage statistics and costs
|
||||
3. **Context Management**: Keep your conversations focused to reduce token usage
|
||||
4. **Model Switching**: Switch models based on task complexity to optimize cost and performance
|
||||
5. **API Key Security**: Never commit your API key to version control
|
||||
|
||||
## Integration with 9Router Features
|
||||
|
||||
### Model Routing
|
||||
|
||||
9Router automatically routes your requests to the best available provider based on:
|
||||
- Model availability
|
||||
- Provider health status
|
||||
- Cost optimization
|
||||
- Load balancing
|
||||
|
||||
### Fallback Support
|
||||
|
||||
If a provider fails, 9Router automatically falls back to alternative providers configured in your dashboard.
|
||||
|
||||
### Usage Tracking
|
||||
|
||||
Monitor your Cline usage through 9Router dashboard:
|
||||
- Total requests
|
||||
- Token usage
|
||||
- Cost per model
|
||||
- Provider distribution
|
||||
@@ -0,0 +1,136 @@
|
||||
# OpenAI Codex CLI Integration
|
||||
|
||||
Integrate 9Router with OpenAI Codex CLI to route your OpenAI API requests through 9Router's intelligent routing system.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- OpenAI Codex CLI installed
|
||||
- 9Router running locally or cloud endpoint configured
|
||||
- API key from 9Router dashboard
|
||||
|
||||
## Setup
|
||||
|
||||
### 1. Configure Environment Variables
|
||||
|
||||
Set the following environment variables in your shell configuration file (`~/.bashrc`, `~/.zshrc`, or `~/.bash_profile`):
|
||||
|
||||
```bash
|
||||
# Base URL for 9Router
|
||||
export OPENAI_BASE_URL="http://localhost:20128/v1"
|
||||
|
||||
# API Key from 9Router dashboard
|
||||
export OPENAI_API_KEY="your-9router-api-key"
|
||||
```
|
||||
|
||||
### 2. Reload Shell Configuration
|
||||
|
||||
```bash
|
||||
source ~/.zshrc # or ~/.bashrc
|
||||
```
|
||||
|
||||
### 3. Verify Configuration
|
||||
|
||||
Check that the environment variables are set correctly:
|
||||
|
||||
```bash
|
||||
echo $OPENAI_BASE_URL
|
||||
echo $OPENAI_API_KEY
|
||||
```
|
||||
|
||||
## Available Models
|
||||
|
||||
9Router provides the following Codex models:
|
||||
|
||||
| Model ID | Description |
|
||||
|----------|-------------|
|
||||
| `cx/gpt-5.2-codex` | GPT-5.2 Codex - Latest version |
|
||||
| `cx/gpt-5.1-codex-max` | GPT-5.1 Codex Max - Extended context |
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```bash
|
||||
# Use GPT-5.2 Codex
|
||||
codex --model cx/gpt-5.2-codex "Write a function to sort an array"
|
||||
|
||||
# Use GPT-5.1 Codex Max
|
||||
codex --model cx/gpt-5.1-codex-max "Explain this complex algorithm"
|
||||
```
|
||||
|
||||
### Code Generation
|
||||
|
||||
```bash
|
||||
codex --model cx/gpt-5.2-codex "Create a REST API endpoint for user authentication"
|
||||
```
|
||||
|
||||
### Code Explanation
|
||||
|
||||
```bash
|
||||
codex --model cx/gpt-5.1-codex-max "Explain what this code does: $(cat myfile.js)"
|
||||
```
|
||||
|
||||
## Configuration File
|
||||
|
||||
You can also configure Codex CLI using a configuration file. Create or edit `~/.codex/config.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"baseUrl": "http://localhost:20128/v1",
|
||||
"apiKey": "your-9router-api-key",
|
||||
"defaultModel": "cx/gpt-5.2-codex"
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Authentication Errors
|
||||
|
||||
If you encounter authentication errors:
|
||||
|
||||
1. Verify your API key is correct in 9Router dashboard
|
||||
2. Check that `OPENAI_API_KEY` environment variable is set
|
||||
3. Ensure the API key has not expired
|
||||
|
||||
### Connection Issues
|
||||
|
||||
If you encounter connection errors:
|
||||
|
||||
1. Verify 9Router is running: `curl http://localhost:20128/health`
|
||||
2. Check environment variables are set correctly
|
||||
3. Ensure no firewall is blocking port 20128
|
||||
|
||||
### Model Not Available
|
||||
|
||||
If you get "model not available" errors:
|
||||
|
||||
1. Verify the model name matches your 9Router configuration
|
||||
2. Check that the OpenAI provider connection is active in 9Router dashboard
|
||||
3. Ensure the model is available in your connected providers
|
||||
|
||||
## Cloud Endpoint
|
||||
|
||||
To use 9Router cloud endpoint instead of localhost:
|
||||
|
||||
```bash
|
||||
export OPENAI_BASE_URL="https://9router.com"
|
||||
```
|
||||
|
||||
Make sure you have configured your API key in the 9Router cloud dashboard.
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
### Custom Timeout
|
||||
|
||||
```bash
|
||||
export OPENAI_TIMEOUT=60 # seconds
|
||||
```
|
||||
|
||||
### Debug Mode
|
||||
|
||||
Enable debug mode to see detailed request/response logs:
|
||||
|
||||
```bash
|
||||
export CODEX_DEBUG=true
|
||||
codex --model cx/gpt-5.2-codex "Your prompt"
|
||||
```
|
||||
@@ -0,0 +1,249 @@
|
||||
# Continue VSCode Extension Integration
|
||||
|
||||
Integrate 9Router with Continue extension to bring AI assistance directly into Visual Studio Code.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Visual Studio Code installed
|
||||
- Continue extension installed from VSCode marketplace
|
||||
- 9Router API key from [dashboard](https://9router.com/dashboard)
|
||||
- 9Router running (local or cloud)
|
||||
|
||||
## Configuration Steps
|
||||
|
||||
### 1. Open Continue Configuration
|
||||
|
||||
1. Open VSCode
|
||||
2. Press `Cmd+Shift+P` (Mac) or `Ctrl+Shift+P` (Windows/Linux)
|
||||
3. Type "Continue: Open Config" and select it
|
||||
4. This opens `~/.continue/config.json`
|
||||
|
||||
### 2. Add 9Router Model Configuration
|
||||
|
||||
Add the following configuration to your `config.json`:
|
||||
|
||||
**Single Model Setup:**
|
||||
```json
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "9Router - Claude Opus",
|
||||
"provider": "openai",
|
||||
"model": "cc/claude-opus-4-5-20251101",
|
||||
"apiKey": "your-api-key-from-dashboard",
|
||||
"apiBase": "http://localhost:20128/v1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Multiple Models Setup:**
|
||||
```json
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "9Router - Claude Opus (Best)",
|
||||
"provider": "openai",
|
||||
"model": "cc/claude-opus-4-5-20251101",
|
||||
"apiKey": "your-api-key-from-dashboard",
|
||||
"apiBase": "http://localhost:20128/v1"
|
||||
},
|
||||
{
|
||||
"title": "9Router - Claude Sonnet (Balanced)",
|
||||
"provider": "openai",
|
||||
"model": "cc/claude-sonnet-4-20250514",
|
||||
"apiKey": "your-api-key-from-dashboard",
|
||||
"apiBase": "http://localhost:20128/v1"
|
||||
},
|
||||
{
|
||||
"title": "9Router - DeepSeek Chat (Code)",
|
||||
"provider": "openai",
|
||||
"model": "cx/deepseek-chat",
|
||||
"apiKey": "your-api-key-from-dashboard",
|
||||
"apiBase": "http://localhost:20128/v1"
|
||||
},
|
||||
{
|
||||
"title": "9Router - Claude Haiku (Fast)",
|
||||
"provider": "openai",
|
||||
"model": "cc/claude-haiku-4-20250514",
|
||||
"apiKey": "your-api-key-from-dashboard",
|
||||
"apiBase": "http://localhost:20128/v1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**For Cloud 9Router:**
|
||||
Replace `apiBase` with:
|
||||
```json
|
||||
"apiBase": "https://9router.com/v1"
|
||||
```
|
||||
|
||||
### 3. Save and Reload
|
||||
|
||||
1. Save the configuration file
|
||||
2. Reload VSCode window: `Cmd+Shift+P` → "Developer: Reload Window"
|
||||
3. Continue extension will load the new configuration
|
||||
|
||||
### 4. Select Model
|
||||
|
||||
1. Open Continue sidebar (click Continue icon in left panel)
|
||||
2. Click model selector dropdown at the top
|
||||
3. Choose your preferred 9Router model
|
||||
|
||||
## Available Models
|
||||
|
||||
### Claude Models (Anthropic)
|
||||
- `cc/claude-opus-4-5-20251101` - Most capable, best for complex tasks
|
||||
- `cc/claude-sonnet-4-20250514` - Balanced performance and speed
|
||||
- `cc/claude-haiku-4-20250514` - Fastest, good for simple tasks
|
||||
|
||||
### DeepSeek Models
|
||||
- `cx/deepseek-chat` - Excellent for code generation
|
||||
- `cx/deepseek-reasoner` - Best for complex problem solving
|
||||
|
||||
### GLM Models (Zhipu AI)
|
||||
- `glm/glm-4-plus` - Advanced Chinese and English
|
||||
- `glm/glm-4-flash` - Fast responses
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Code Explanation
|
||||
1. Select code in editor
|
||||
2. Open Continue sidebar
|
||||
3. Type: "Explain this code"
|
||||
4. Model: `cc/claude-sonnet-4-20250514`
|
||||
|
||||
### Code Generation
|
||||
1. Open Continue sidebar
|
||||
2. Type: "Create a React component for user profile card"
|
||||
3. Model: `cx/deepseek-chat`
|
||||
|
||||
### Refactoring
|
||||
1. Select code to refactor
|
||||
2. Type: "Refactor this to use async/await"
|
||||
3. Model: `cc/claude-sonnet-4-20250514`
|
||||
|
||||
### Bug Fixing
|
||||
1. Select problematic code
|
||||
2. Type: "Find and fix the bug in this code"
|
||||
3. Model: `cx/deepseek-reasoner`
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
### Custom System Prompts
|
||||
|
||||
Add custom system prompts for specific behaviors:
|
||||
|
||||
```json
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "9Router - Code Expert",
|
||||
"provider": "openai",
|
||||
"model": "cx/deepseek-chat",
|
||||
"apiKey": "your-api-key",
|
||||
"apiBase": "http://localhost:20128/v1",
|
||||
"systemMessage": "You are an expert programmer. Always provide clean, well-documented code with best practices."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Temperature and Parameters
|
||||
|
||||
Adjust model behavior with parameters:
|
||||
|
||||
```json
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "9Router - Creative Writer",
|
||||
"provider": "openai",
|
||||
"model": "cc/claude-opus-4-5-20251101",
|
||||
"apiKey": "your-api-key",
|
||||
"apiBase": "http://localhost:20128/v1",
|
||||
"temperature": 0.9,
|
||||
"topP": 0.95
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Context Providers
|
||||
|
||||
Configure what context Continue sends to the model:
|
||||
|
||||
```json
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "code",
|
||||
"params": {
|
||||
"maxLines": 100
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "diff",
|
||||
"params": {}
|
||||
},
|
||||
{
|
||||
"name": "terminal",
|
||||
"params": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Keyboard Shortcuts
|
||||
|
||||
- `Cmd+L` (Mac) / `Ctrl+L` (Windows/Linux) - Open Continue chat
|
||||
- `Cmd+I` (Mac) / `Ctrl+I` (Windows/Linux) - Inline edit
|
||||
- `Cmd+Shift+R` (Mac) / `Ctrl+Shift+R` (Windows/Linux) - Regenerate response
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Model Not Responding
|
||||
- Check 9Router is running: `curl http://localhost:20128/health`
|
||||
- Verify API key in config.json
|
||||
- Check VSCode Developer Console for errors: `Help` → `Toggle Developer Tools`
|
||||
|
||||
### Wrong Model Selected
|
||||
- Click model dropdown in Continue sidebar
|
||||
- Select correct 9Router model
|
||||
- Model name must match exactly (case-sensitive)
|
||||
|
||||
### Configuration Not Loading
|
||||
- Verify JSON syntax is valid (use JSON validator)
|
||||
- Check file location: `~/.continue/config.json`
|
||||
- Reload VSCode window after changes
|
||||
|
||||
### Slow Performance
|
||||
- Switch to faster models (haiku, flash)
|
||||
- Reduce context size in contextProviders
|
||||
- Check network latency to 9Router
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Model Selection Strategy
|
||||
- **Quick edits**: Use `cc/claude-haiku-4-20250514`
|
||||
- **Code generation**: Use `cx/deepseek-chat`
|
||||
- **Complex refactoring**: Use `cc/claude-opus-4-5-20251101`
|
||||
- **Problem solving**: Use `cx/deepseek-reasoner`
|
||||
|
||||
### Context Management
|
||||
- Select only relevant code before asking
|
||||
- Use specific, clear prompts
|
||||
- Break complex tasks into smaller steps
|
||||
|
||||
### Cost Optimization
|
||||
- Use faster/cheaper models for simple tasks
|
||||
- Limit context size when possible
|
||||
- Cache frequently used responses
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Configure Cursor](cursor.md) for enhanced IDE integration
|
||||
- [Set up Roo](roo.md) for AI assistant
|
||||
- [Explore CLI usage](../cli/basic-usage.md)
|
||||
- [Learn about model selection](../models/overview.md)
|
||||
@@ -0,0 +1,149 @@
|
||||
# Cursor Integration
|
||||
|
||||
Integrate 9Router with Cursor IDE to route your AI requests through 9Router's intelligent routing system.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Cursor IDE installed
|
||||
- Cursor Pro account (required for custom API endpoints)
|
||||
- 9Router cloud endpoint configured
|
||||
- API key from 9Router dashboard
|
||||
|
||||
## ⚠️ Important Notes
|
||||
|
||||
> **Cloud Endpoint Required**: Cursor routes requests through its own server and does not support localhost endpoints. You must use the 9Router cloud endpoint: `https://9router.com`
|
||||
|
||||
> **Cursor Pro Required**: This feature requires a Cursor Pro account to use custom API endpoints.
|
||||
|
||||
## Setup
|
||||
|
||||
### 1. Open Cursor Settings
|
||||
|
||||
1. Open Cursor IDE
|
||||
2. Go to **Settings** (Cmd/Ctrl + ,)
|
||||
3. Navigate to **Models** section
|
||||
|
||||
### 2. Enable OpenAI API
|
||||
|
||||
1. Find the **OpenAI API key** option
|
||||
2. Enable the toggle to activate custom API configuration
|
||||
|
||||
### 3. Configure Base URL
|
||||
|
||||
Set the base URL to 9Router cloud endpoint:
|
||||
|
||||
```
|
||||
https://9router.com
|
||||
```
|
||||
|
||||
**Steps:**
|
||||
1. In the Models settings, locate the **Base URL** field
|
||||
2. Enter: `https://9router.com`
|
||||
3. Click **Save**
|
||||
|
||||
### 4. Add API Key
|
||||
|
||||
1. In the **API Key** field, enter your 9Router API key
|
||||
2. You can find your API key in the 9Router dashboard under **Settings → API Keys**
|
||||
3. Click **Save**
|
||||
|
||||
### 5. Add Custom Model
|
||||
|
||||
1. Click **View All Models** button
|
||||
2. Click **Add Custom Model**
|
||||
3. Enter the model name from your 9Router configuration (e.g., `gpt-4`, `claude-opus-4-5`, etc.)
|
||||
4. Click **Add**
|
||||
|
||||
### 6. Select Model
|
||||
|
||||
1. In the Cursor chat interface, click the model selector dropdown
|
||||
2. Choose your custom model from the list
|
||||
3. Start using 9Router with Cursor!
|
||||
|
||||
## Configuration Example
|
||||
|
||||
Your Cursor settings should look like this:
|
||||
|
||||
```
|
||||
OpenAI API: ✓ Enabled
|
||||
Base URL: https://9router.com
|
||||
API Key: sk-9router-xxxxxxxxxxxxx
|
||||
Custom Models: gpt-4, claude-opus-4-5, gemini-2.0-flash
|
||||
```
|
||||
|
||||
## Available Models
|
||||
|
||||
You can use any model configured in your 9Router dashboard. Common examples:
|
||||
|
||||
| Model Name | Provider | Description |
|
||||
|------------|----------|-------------|
|
||||
| `gpt-4` | OpenAI | GPT-4 Turbo |
|
||||
| `gpt-4o` | OpenAI | GPT-4 Optimized |
|
||||
| `claude-opus-4-5` | Anthropic | Claude Opus 4.5 |
|
||||
| `claude-sonnet-4-5` | Anthropic | Claude Sonnet 4.5 |
|
||||
| `gemini-2.0-flash` | Google | Gemini 2.0 Flash |
|
||||
|
||||
## Usage
|
||||
|
||||
### Chat Interface
|
||||
|
||||
1. Open Cursor chat (Cmd/Ctrl + L)
|
||||
2. Select your model from the dropdown
|
||||
3. Start chatting with AI through 9Router
|
||||
|
||||
### Inline Code Generation
|
||||
|
||||
1. Select code in your editor
|
||||
2. Press Cmd/Ctrl + K
|
||||
3. Enter your prompt
|
||||
4. Cursor will use 9Router to generate code
|
||||
|
||||
### Code Explanation
|
||||
|
||||
1. Select code in your editor
|
||||
2. Press Cmd/Ctrl + L
|
||||
3. Ask "Explain this code"
|
||||
4. Get AI-powered explanations through 9Router
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Invalid API Key" Error
|
||||
|
||||
1. Verify your API key in 9Router dashboard
|
||||
2. Make sure you copied the entire key including the `sk-9router-` prefix
|
||||
3. Check that the API key has not expired
|
||||
4. Try regenerating a new API key
|
||||
|
||||
### "Model Not Found" Error
|
||||
|
||||
1. Verify the model name matches exactly with your 9Router configuration
|
||||
2. Check that the provider connection is active in 9Router dashboard
|
||||
3. Ensure the model is available in your connected providers
|
||||
4. Try using the full model name (e.g., `openai/gpt-4` instead of `gpt-4`)
|
||||
|
||||
### Connection Issues
|
||||
|
||||
1. Verify you are using the cloud endpoint: `https://9router.com`
|
||||
2. Check your internet connection
|
||||
3. Ensure 9Router cloud service is operational
|
||||
4. Try disabling VPN or proxy if enabled
|
||||
|
||||
### Localhost Not Working
|
||||
|
||||
> **Remember**: Cursor does not support localhost endpoints. You must use the cloud endpoint `https://9router.com`. If you need to use a local 9Router instance, consider using a tunneling service like ngrok to expose your local endpoint.
|
||||
|
||||
## Cloud Endpoint Setup
|
||||
|
||||
If you're running 9Router locally and want to use it with Cursor:
|
||||
|
||||
1. Enable cloud endpoint in 9Router settings
|
||||
2. Configure your cloud endpoint URL in 9Router dashboard
|
||||
3. Use the cloud URL in Cursor settings
|
||||
4. Ensure your local 9Router instance is accessible from the internet
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use Model Aliases**: Create short aliases for frequently used models in 9Router
|
||||
2. **Monitor Usage**: Check 9Router dashboard for usage statistics and costs
|
||||
3. **Rotate API Keys**: Regularly rotate your API keys for security
|
||||
4. **Test Models**: Try different models to find the best one for your use case
|
||||
@@ -0,0 +1,416 @@
|
||||
# Other Tools Integration
|
||||
|
||||
9Router is compatible with any tool that supports the OpenAI API format. This guide covers generic integration patterns for various tools and custom applications.
|
||||
|
||||
## Overview
|
||||
|
||||
9Router provides an OpenAI-compatible API endpoint that works with:
|
||||
- Custom scripts and applications
|
||||
- API clients and testing tools
|
||||
- CLI tools and utilities
|
||||
- Third-party integrations
|
||||
- Development frameworks
|
||||
|
||||
## Generic Setup Pattern
|
||||
|
||||
Any OpenAI-compatible tool can connect to 9Router using these settings:
|
||||
|
||||
**Local 9Router:**
|
||||
```
|
||||
Base URL: http://localhost:20128/v1
|
||||
API Key: your-api-key-from-dashboard
|
||||
Model: any 9Router model (cc/*, cx/*, glm/*, etc.)
|
||||
```
|
||||
|
||||
**Cloud 9Router:**
|
||||
```
|
||||
Base URL: https://9router.com/v1
|
||||
API Key: your-api-key-from-dashboard
|
||||
Model: any 9Router model (cc/*, cx/*, glm/*, etc.)
|
||||
```
|
||||
|
||||
## Available Models
|
||||
|
||||
### Claude Models (Anthropic)
|
||||
- `cc/claude-opus-4-5-20251101`
|
||||
- `cc/claude-sonnet-4-20250514`
|
||||
- `cc/claude-haiku-4-20250514`
|
||||
|
||||
### DeepSeek Models
|
||||
- `cx/deepseek-chat`
|
||||
- `cx/deepseek-reasoner`
|
||||
|
||||
### GLM Models (Zhipu AI)
|
||||
- `glm/glm-4-plus`
|
||||
- `glm/glm-4-flash`
|
||||
|
||||
## Integration Examples
|
||||
|
||||
### Python with OpenAI SDK
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(
|
||||
api_key="your-api-key-from-dashboard",
|
||||
base_url="http://localhost:20128/v1"
|
||||
)
|
||||
|
||||
response = client.chat.completions.create(
|
||||
model="cc/claude-sonnet-4-20250514",
|
||||
messages=[
|
||||
{"role": "user", "content": "Hello, how are you?"}
|
||||
]
|
||||
)
|
||||
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
|
||||
### Node.js with OpenAI SDK
|
||||
|
||||
```javascript
|
||||
import OpenAI from "openai";
|
||||
|
||||
const client = new OpenAI({
|
||||
apiKey: "your-api-key-from-dashboard",
|
||||
baseURL: "http://localhost:20128/v1"
|
||||
});
|
||||
|
||||
const response = await client.chat.completions.create({
|
||||
model: "cc/claude-sonnet-4-20250514",
|
||||
messages: [
|
||||
{ role: "user", content: "Hello, how are you?" }
|
||||
]
|
||||
});
|
||||
|
||||
console.log(response.choices[0].message.content);
|
||||
```
|
||||
|
||||
### cURL Command
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/v1/chat/completions \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer your-api-key-from-dashboard" \
|
||||
-d '{
|
||||
"model": "cc/claude-sonnet-4-20250514",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello, how are you?"}
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
### HTTP Client (Postman, Insomnia)
|
||||
|
||||
**Request:**
|
||||
```
|
||||
POST http://localhost:20128/v1/chat/completions
|
||||
```
|
||||
|
||||
**Headers:**
|
||||
```
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer your-api-key-from-dashboard
|
||||
```
|
||||
|
||||
**Body:**
|
||||
```json
|
||||
{
|
||||
"model": "cc/claude-sonnet-4-20250514",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello, how are you?"}
|
||||
],
|
||||
"temperature": 0.7,
|
||||
"max_tokens": 1000
|
||||
}
|
||||
```
|
||||
|
||||
### LangChain Integration
|
||||
|
||||
```python
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain.schema import HumanMessage
|
||||
|
||||
llm = ChatOpenAI(
|
||||
model_name="cc/claude-sonnet-4-20250514",
|
||||
openai_api_key="your-api-key-from-dashboard",
|
||||
openai_api_base="http://localhost:20128/v1",
|
||||
temperature=0.7
|
||||
)
|
||||
|
||||
messages = [HumanMessage(content="Explain quantum computing")]
|
||||
response = llm(messages)
|
||||
print(response.content)
|
||||
```
|
||||
|
||||
### LlamaIndex Integration
|
||||
|
||||
```python
|
||||
from llama_index.llms import OpenAI
|
||||
|
||||
llm = OpenAI(
|
||||
model="cc/claude-sonnet-4-20250514",
|
||||
api_key="your-api-key-from-dashboard",
|
||||
api_base="http://localhost:20128/v1"
|
||||
)
|
||||
|
||||
response = llm.complete("What is machine learning?")
|
||||
print(response.text)
|
||||
```
|
||||
|
||||
## Custom Script Examples
|
||||
|
||||
### Batch Processing Script
|
||||
|
||||
```python
|
||||
import openai
|
||||
import json
|
||||
|
||||
openai.api_key = "your-api-key-from-dashboard"
|
||||
openai.api_base = "http://localhost:20128/v1"
|
||||
|
||||
def process_batch(prompts, model="cx/deepseek-chat"):
|
||||
results = []
|
||||
for prompt in prompts:
|
||||
response = openai.ChatCompletion.create(
|
||||
model=model,
|
||||
messages=[{"role": "user", "content": prompt}]
|
||||
)
|
||||
results.append({
|
||||
"prompt": prompt,
|
||||
"response": response.choices[0].message.content
|
||||
})
|
||||
return results
|
||||
|
||||
prompts = [
|
||||
"Explain AI in one sentence",
|
||||
"What is machine learning?",
|
||||
"Define neural networks"
|
||||
]
|
||||
|
||||
results = process_batch(prompts)
|
||||
print(json.dumps(results, indent=2))
|
||||
```
|
||||
|
||||
### Streaming Response Handler
|
||||
|
||||
```javascript
|
||||
import OpenAI from "openai";
|
||||
|
||||
const client = new OpenAI({
|
||||
apiKey: "your-api-key-from-dashboard",
|
||||
baseURL: "http://localhost:20128/v1"
|
||||
});
|
||||
|
||||
async function streamResponse(prompt) {
|
||||
const stream = await client.chat.completions.create({
|
||||
model: "cc/claude-sonnet-4-20250514",
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
stream: true
|
||||
});
|
||||
|
||||
for await (const chunk of stream) {
|
||||
const content = chunk.choices[0]?.delta?.content || "";
|
||||
process.stdout.write(content);
|
||||
}
|
||||
}
|
||||
|
||||
streamResponse("Write a short story about AI");
|
||||
```
|
||||
|
||||
### Multi-Model Comparison
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(
|
||||
api_key="your-api-key-from-dashboard",
|
||||
base_url="http://localhost:20128/v1"
|
||||
)
|
||||
|
||||
models = [
|
||||
"cc/claude-sonnet-4-20250514",
|
||||
"cx/deepseek-chat",
|
||||
"glm/glm-4-plus"
|
||||
]
|
||||
|
||||
prompt = "Explain quantum computing in simple terms"
|
||||
|
||||
for model in models:
|
||||
response = client.chat.completions.create(
|
||||
model=model,
|
||||
messages=[{"role": "user", "content": prompt}]
|
||||
)
|
||||
print(f"\n=== {model} ===")
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
|
||||
## Common Integration Patterns
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Store credentials securely:
|
||||
|
||||
```bash
|
||||
# .env file
|
||||
ROUTER_API_KEY=your-api-key-from-dashboard
|
||||
ROUTER_BASE_URL=http://localhost:20128/v1
|
||||
ROUTER_MODEL=cc/claude-sonnet-4-20250514
|
||||
```
|
||||
|
||||
```python
|
||||
import os
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(
|
||||
api_key=os.getenv("ROUTER_API_KEY"),
|
||||
base_url=os.getenv("ROUTER_BASE_URL")
|
||||
)
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
|
||||
```python
|
||||
from openai import OpenAI, OpenAIError
|
||||
|
||||
client = OpenAI(
|
||||
api_key="your-api-key",
|
||||
base_url="http://localhost:20128/v1"
|
||||
)
|
||||
|
||||
try:
|
||||
response = client.chat.completions.create(
|
||||
model="cc/claude-sonnet-4-20250514",
|
||||
messages=[{"role": "user", "content": "Hello"}]
|
||||
)
|
||||
print(response.choices[0].message.content)
|
||||
except OpenAIError as e:
|
||||
print(f"Error: {e}")
|
||||
```
|
||||
|
||||
### Retry Logic
|
||||
|
||||
```python
|
||||
import time
|
||||
from openai import OpenAI, RateLimitError
|
||||
|
||||
client = OpenAI(
|
||||
api_key="your-api-key",
|
||||
base_url="http://localhost:20128/v1"
|
||||
)
|
||||
|
||||
def chat_with_retry(prompt, max_retries=3):
|
||||
for attempt in range(max_retries):
|
||||
try:
|
||||
response = client.chat.completions.create(
|
||||
model="cc/claude-sonnet-4-20250514",
|
||||
messages=[{"role": "user", "content": prompt}]
|
||||
)
|
||||
return response.choices[0].message.content
|
||||
except RateLimitError:
|
||||
if attempt < max_retries - 1:
|
||||
time.sleep(2 ** attempt) # Exponential backoff
|
||||
else:
|
||||
raise
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Connection Issues
|
||||
|
||||
**Problem:** Cannot connect to 9Router
|
||||
```bash
|
||||
# Check if 9Router is running
|
||||
curl http://localhost:20128/health
|
||||
|
||||
# Expected response:
|
||||
{"status": "ok"}
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
- Verify 9Router is running
|
||||
- Check port 20128 is not blocked
|
||||
- Ensure correct base URL (include `/v1`)
|
||||
|
||||
### Authentication Errors
|
||||
|
||||
**Problem:** 401 Unauthorized
|
||||
```
|
||||
Error: Invalid API key
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
- Verify API key from dashboard
|
||||
- Check Authorization header format: `Bearer your-api-key`
|
||||
- Ensure no extra spaces or newlines in API key
|
||||
|
||||
### Model Not Found
|
||||
|
||||
**Problem:** 404 Model not found
|
||||
```
|
||||
Error: Model 'cc/claude-opus' not found
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
- Use exact model name (case-sensitive)
|
||||
- Check available models: `curl http://localhost:20128/v1/models`
|
||||
- Verify model is enabled in your plan
|
||||
|
||||
### Timeout Issues
|
||||
|
||||
**Problem:** Request timeout
|
||||
```
|
||||
Error: Request timed out after 30s
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
- Increase timeout in client configuration
|
||||
- Use faster models for time-sensitive tasks
|
||||
- Check network connection to 9Router
|
||||
|
||||
### Rate Limiting
|
||||
|
||||
**Problem:** 429 Too Many Requests
|
||||
```
|
||||
Error: Rate limit exceeded
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
- Implement exponential backoff
|
||||
- Reduce request frequency
|
||||
- Check rate limits in dashboard
|
||||
- Consider upgrading plan
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Security
|
||||
- Store API keys in environment variables
|
||||
- Never commit API keys to version control
|
||||
- Use HTTPS for cloud deployments
|
||||
- Rotate API keys regularly
|
||||
|
||||
### Performance
|
||||
- Use appropriate models for task complexity
|
||||
- Implement caching for repeated queries
|
||||
- Use streaming for long responses
|
||||
- Batch requests when possible
|
||||
|
||||
### Error Handling
|
||||
- Always implement try-catch blocks
|
||||
- Add retry logic with exponential backoff
|
||||
- Log errors for debugging
|
||||
- Provide fallback mechanisms
|
||||
|
||||
### Cost Optimization
|
||||
- Choose cost-effective models for simple tasks
|
||||
- Cache responses when appropriate
|
||||
- Monitor usage in dashboard
|
||||
- Set request limits in code
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Configure Cursor](cursor.md) for IDE integration
|
||||
- [Set up Continue](continue.md) for VSCode
|
||||
- [Explore CLI usage](../cli/basic-usage.md)
|
||||
- [Learn about model selection](../models/overview.md)
|
||||
- [API Reference](../api/reference.md)
|
||||
@@ -0,0 +1,127 @@
|
||||
# Roo AI Assistant Integration
|
||||
|
||||
Integrate 9Router with Roo AI Assistant to access multiple AI models through a unified interface.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Roo AI Assistant installed
|
||||
- 9Router API key from [dashboard](https://9router.com/dashboard)
|
||||
- 9Router running (local or cloud)
|
||||
|
||||
## Configuration Steps
|
||||
|
||||
### 1. Open Roo Settings
|
||||
|
||||
Launch Roo AI Assistant and open the settings panel.
|
||||
|
||||
### 2. Configure API Provider
|
||||
|
||||
1. Navigate to **API Provider** settings
|
||||
2. Select **Ollama** as the provider type
|
||||
3. Configure the following settings:
|
||||
|
||||
**For Local 9Router:**
|
||||
```
|
||||
Base URL: http://localhost:20128/v1
|
||||
API Key: your-api-key-from-dashboard
|
||||
```
|
||||
|
||||
**For Cloud 9Router:**
|
||||
```
|
||||
Base URL: https://9router.com/v1
|
||||
API Key: your-api-key-from-dashboard
|
||||
```
|
||||
|
||||
### 3. Select Model
|
||||
|
||||
Choose from available 9Router models:
|
||||
|
||||
**Claude Models:**
|
||||
- `cc/claude-opus-4-5-20251101` - Most capable
|
||||
- `cc/claude-sonnet-4-20250514` - Balanced
|
||||
- `cc/claude-haiku-4-20250514` - Fast
|
||||
|
||||
**DeepSeek Models:**
|
||||
- `cx/deepseek-chat` - General purpose
|
||||
- `cx/deepseek-reasoner` - Complex reasoning
|
||||
|
||||
**GLM Models:**
|
||||
- `glm/glm-4-plus` - Advanced
|
||||
- `glm/glm-4-flash` - Fast responses
|
||||
|
||||
### 4. Test Connection
|
||||
|
||||
Send a test message to verify the integration:
|
||||
|
||||
```
|
||||
Hello! Can you confirm you're connected through 9Router?
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Basic Chat
|
||||
```
|
||||
Ask Roo: "Explain quantum computing in simple terms"
|
||||
Model: cc/claude-sonnet-4-20250514
|
||||
```
|
||||
|
||||
### Code Generation
|
||||
```
|
||||
Ask Roo: "Write a Python function to calculate Fibonacci numbers"
|
||||
Model: cx/deepseek-chat
|
||||
```
|
||||
|
||||
### Complex Reasoning
|
||||
```
|
||||
Ask Roo: "Analyze the trade-offs between microservices and monolithic architecture"
|
||||
Model: cx/deepseek-reasoner
|
||||
```
|
||||
|
||||
## Model Selection Tips
|
||||
|
||||
- **Quick tasks**: Use `cc/claude-haiku-4-20250514` or `glm/glm-4-flash`
|
||||
- **Balanced performance**: Use `cc/claude-sonnet-4-20250514` or `cx/deepseek-chat`
|
||||
- **Complex reasoning**: Use `cc/claude-opus-4-5-20251101` or `cx/deepseek-reasoner`
|
||||
- **Cost optimization**: Use DeepSeek or GLM models
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Connection Failed
|
||||
- Verify 9Router is running: `curl http://localhost:20128/health`
|
||||
- Check API key is correct
|
||||
- Ensure Base URL includes `/v1` suffix
|
||||
|
||||
### Model Not Available
|
||||
- Check model name matches exactly (case-sensitive)
|
||||
- Verify model is enabled in your 9Router plan
|
||||
- Try a different model from the list
|
||||
|
||||
### Slow Responses
|
||||
- Switch to faster models (haiku, flash)
|
||||
- Check network connection
|
||||
- Monitor 9Router logs for issues
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
### Custom Model Aliases
|
||||
|
||||
You can create shortcuts for frequently used models in Roo settings:
|
||||
|
||||
```
|
||||
Alias: "fast" → cc/claude-haiku-4-20250514
|
||||
Alias: "smart" → cc/claude-opus-4-5-20251101
|
||||
Alias: "code" → cx/deepseek-chat
|
||||
```
|
||||
|
||||
### Multiple Profiles
|
||||
|
||||
Set up different profiles for different use cases:
|
||||
- **Development**: DeepSeek models for code
|
||||
- **Writing**: Claude models for content
|
||||
- **Research**: Reasoner models for analysis
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Configure Cursor](cursor.md) for IDE integration
|
||||
- [Set up Continue](continue.md) for VSCode
|
||||
- [Explore CLI usage](../cli/basic-usage.md)
|
||||
@@ -0,0 +1,462 @@
|
||||
# Cheap Providers - Ultra-Cheap Backup
|
||||
|
||||
When subscription quota runs out, pay pennies instead of dollars. ~90% cheaper than ChatGPT API!
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Cheap tier providers are your **backup** when subscription quota exhausted:
|
||||
|
||||
- 💰 **GLM-4.7** - $0.6/$2.2 per 1M tokens (daily reset)
|
||||
- 💰 **MiniMax M2.1** - $0.2/$1.0 per 1M tokens (5h reset)
|
||||
- 💰 **Kimi K2** - $9/month flat (10M tokens)
|
||||
|
||||
**Strategy:** Use after subscription quota out, before free tier. Massive cost savings vs ChatGPT API ($20/1M).
|
||||
|
||||
---
|
||||
|
||||
## GLM-4.7 (Daily Reset)
|
||||
|
||||
### Pricing
|
||||
|
||||
| Tier | Input | Output | Reset |
|
||||
|------|-------|--------|-------|
|
||||
| Standard | $0.60/1M | $2.20/1M | Daily 10:00 AM |
|
||||
| Coding Plan | $0.60/1M | $2.20/1M | Daily 10:00 AM (3× quota) |
|
||||
|
||||
**Cost Example (10M tokens):**
|
||||
- Input: 10M × $0.60 = $6
|
||||
- Output: 10M × $2.20 = $22
|
||||
- **Total: $6-22** vs $200 on ChatGPT API!
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Sign Up**
|
||||
|
||||
1. Visit [Zhipu AI](https://open.bigmodel.cn/)
|
||||
2. Create account (phone verification)
|
||||
3. Choose **Coding Plan** for 3× quota at same price
|
||||
|
||||
**Step 2: Get API Key**
|
||||
|
||||
```bash
|
||||
Dashboard → API Keys → Create New
|
||||
→ Copy API key (starts with "zhipu-")
|
||||
```
|
||||
|
||||
**Step 3: Add to 9Router**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Add API Key
|
||||
|
||||
Provider: glm
|
||||
API Key: zhipu-your-api-key-here
|
||||
```
|
||||
|
||||
**Step 4: Use in CLI**
|
||||
|
||||
```
|
||||
Model: glm/glm-4.7
|
||||
glm/glm-4.6v (vision)
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Context | Best For |
|
||||
|----------|-------------|---------|----------|
|
||||
| `glm/glm-4.7` | GLM 4.7 | 128K | Coding, general tasks |
|
||||
| `glm/glm-4.6v` | GLM 4.6V Vision | 128K | Image analysis |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Coding Plan** - 3× quota at same price ($0.6/$2.2)
|
||||
- **Daily reset** - Fresh quota at 10:00 AM Beijing time
|
||||
- **Best for coding** - Optimized for code generation
|
||||
- **128K context** - Handle large files
|
||||
|
||||
### Quota Reset
|
||||
|
||||
```
|
||||
Daily reset: 10:00 AM Beijing Time (UTC+8)
|
||||
→ 2:00 AM UTC
|
||||
→ 6:00 PM PST (previous day)
|
||||
→ 9:00 PM EST (previous day)
|
||||
|
||||
Plan your heavy tasks around reset time!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## MiniMax M2.1 (5-Hour Reset)
|
||||
|
||||
### Pricing
|
||||
|
||||
| Tier | Input | Output | Reset |
|
||||
|------|-------|--------|-------|
|
||||
| Standard | $0.20/1M | $1.00/1M | 5-hour rolling |
|
||||
|
||||
**Cost Example (10M tokens):**
|
||||
- Input: 10M × $0.20 = $2
|
||||
- Output: 10M × $1.00 = $10
|
||||
- **Total: $2-10** - Cheapest option!
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Sign Up**
|
||||
|
||||
1. Visit [MiniMax](https://www.minimax.io/)
|
||||
2. Create account
|
||||
3. Verify email/phone
|
||||
|
||||
**Step 2: Get API Key**
|
||||
|
||||
```bash
|
||||
Dashboard → API Management → Create Key
|
||||
→ Copy API key
|
||||
```
|
||||
|
||||
**Step 3: Add to 9Router**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Add API Key
|
||||
|
||||
Provider: minimax
|
||||
API Key: your-minimax-api-key
|
||||
```
|
||||
|
||||
**Step 4: Use in CLI**
|
||||
|
||||
```
|
||||
Model: minimax/MiniMax-M2.1
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Context | Best For |
|
||||
|----------|-------------|---------|----------|
|
||||
| `minimax/MiniMax-M2.1` | MiniMax M2.1 | 1M tokens | Long context, coding |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Cheapest option** - $0.20/1M input (90% cheaper than ChatGPT)
|
||||
- **5-hour rolling** - Quota resets every 5 hours
|
||||
- **1M context** - Massive context window
|
||||
- **Best for long files** - Handle entire codebases
|
||||
|
||||
### Quota Reset
|
||||
|
||||
```
|
||||
5-hour rolling window:
|
||||
→ Use quota → Wait 5 hours → Fresh quota
|
||||
|
||||
Example:
|
||||
10:00 AM - Use 5M tokens
|
||||
3:00 PM - Fresh quota available
|
||||
8:00 PM - Fresh quota available
|
||||
|
||||
Code 24/7 with minimal cost!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Kimi K2 (Flat $9/month)
|
||||
|
||||
### Pricing
|
||||
|
||||
| Plan | Monthly Cost | Included Tokens | Effective Cost |
|
||||
|------|--------------|-----------------|----------------|
|
||||
| Subscription | $9 | 10M tokens | $0.90/1M |
|
||||
|
||||
**Cost Example:**
|
||||
- $9/month flat
|
||||
- 10M tokens included
|
||||
- **Effective: $0.90/1M** - Best value for consistent usage!
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Subscribe**
|
||||
|
||||
1. Visit [Moonshot AI](https://platform.moonshot.ai/)
|
||||
2. Create account
|
||||
3. Subscribe to $9/month plan
|
||||
|
||||
**Step 2: Get API Key**
|
||||
|
||||
```bash
|
||||
Dashboard → API Keys → Create New
|
||||
→ Copy API key
|
||||
```
|
||||
|
||||
**Step 3: Add to 9Router**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Add API Key
|
||||
|
||||
Provider: kimi
|
||||
API Key: your-kimi-api-key
|
||||
```
|
||||
|
||||
**Step 4: Use in CLI**
|
||||
|
||||
```
|
||||
Model: kimi/kimi-latest
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Context | Best For |
|
||||
|----------|-------------|---------|----------|
|
||||
| `kimi/kimi-latest` | Kimi Latest | 200K | General coding |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Fixed cost** - $9/month regardless of usage (up to 10M)
|
||||
- **Best for consistent usage** - If you use 10M/month, only $0.90/1M
|
||||
- **Monthly reset** - 10M tokens reset monthly
|
||||
- **Predictable billing** - No surprise costs
|
||||
|
||||
### Quota Reset
|
||||
|
||||
```
|
||||
Monthly reset: 1st of each month
|
||||
→ 10M tokens refresh
|
||||
|
||||
Example monthly usage:
|
||||
Week 1: 3M tokens
|
||||
Week 2: 2M tokens
|
||||
Week 3: 3M tokens
|
||||
Week 4: 2M tokens
|
||||
Total: 10M tokens = $9 flat
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pricing Comparison
|
||||
|
||||
| Provider | Input/1M | Output/1M | Reset | 10M Cost | Best For |
|
||||
|----------|----------|-----------|-------|----------|----------|
|
||||
| **GLM-4.7** | $0.60 | $2.20 | Daily 10AM | $6-22 | Daily quota users |
|
||||
| **MiniMax M2.1** | $0.20 | $1.00 | 5-hour | $2-10 | **Cheapest!** |
|
||||
| **Kimi K2** | $0.90 | $0.90 | Monthly | **$9 flat** | Consistent usage |
|
||||
| ChatGPT API | $20.00 | $20.00 | None | $200 | ❌ Expensive |
|
||||
|
||||
**Savings:** 90-95% cheaper than ChatGPT API!
|
||||
|
||||
---
|
||||
|
||||
## Usage Example
|
||||
|
||||
### Cursor IDE Setup
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [from 9router dashboard]
|
||||
Model: glm/glm-4.7
|
||||
```
|
||||
|
||||
### Create Combo (Recommended)
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: cheap-backup
|
||||
Models:
|
||||
1. cc/claude-opus-4-5 (Subscription primary)
|
||||
2. glm/glm-4.7 (Cheap backup, daily reset)
|
||||
3. minimax/MiniMax-M2.1 (Cheapest fallback)
|
||||
4. if/kimi-k2-thinking (FREE emergency)
|
||||
|
||||
Use in CLI: cheap-backup
|
||||
```
|
||||
|
||||
**Result:** Subscription → Cheap → Cheapest → Free
|
||||
|
||||
---
|
||||
|
||||
## Cost Optimization
|
||||
|
||||
### Strategy 1: Daily Reset Routine
|
||||
|
||||
```
|
||||
Morning (10AM): Fresh GLM quota
|
||||
→ Use GLM for heavy tasks
|
||||
→ Save subscription quota
|
||||
|
||||
Afternoon: Subscription quota
|
||||
→ Use Claude/Codex for complex tasks
|
||||
|
||||
Evening: MiniMax (5h reset)
|
||||
→ Cheap fallback for late work
|
||||
|
||||
Night: Free tier (iFlow)
|
||||
→ Zero cost emergency backup
|
||||
```
|
||||
|
||||
### Strategy 2: Budget-First
|
||||
|
||||
```
|
||||
Set monthly budget: $20
|
||||
|
||||
Allocation:
|
||||
- $9 Kimi K2 (10M tokens flat)
|
||||
- $6 GLM daily quota (10M tokens)
|
||||
- $5 MiniMax overflow (25M tokens)
|
||||
|
||||
Total: 45M tokens for $20
|
||||
vs 1M tokens for $20 on ChatGPT API!
|
||||
```
|
||||
|
||||
### Strategy 3: Maximize Subscriptions First
|
||||
|
||||
```
|
||||
Priority:
|
||||
1. Gemini CLI (180K/month FREE)
|
||||
2. Claude Code (subscription you already pay)
|
||||
3. GLM-4.7 (cheap backup, $0.6/1M)
|
||||
4. MiniMax M2.1 (cheapest, $0.2/1M)
|
||||
5. iFlow (FREE emergency)
|
||||
|
||||
Monthly cost example (100M tokens):
|
||||
- 60M via Gemini CLI: $0 (free)
|
||||
- 30M via Claude Code: $0 (subscription)
|
||||
- 8M via GLM: $4.80
|
||||
- 2M via MiniMax: $0.40
|
||||
Total: $5.20/month!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Real-World Examples
|
||||
|
||||
### Example 1: Heavy Coding Month (100M tokens)
|
||||
|
||||
```
|
||||
Breakdown:
|
||||
- 60M via subscription (Claude/Codex): $0 extra
|
||||
- 30M via GLM-4.7: $18
|
||||
- 10M via MiniMax M2.1: $2
|
||||
|
||||
Total: $20/month
|
||||
vs $2000 on ChatGPT API!
|
||||
|
||||
Savings: 99% cheaper!
|
||||
```
|
||||
|
||||
### Example 2: Budget Coder ($10/month)
|
||||
|
||||
```
|
||||
Strategy:
|
||||
- $9 Kimi K2 (10M tokens)
|
||||
- $1 MiniMax overflow (5M tokens)
|
||||
|
||||
Total: 15M tokens for $10
|
||||
vs 0.5M tokens for $10 on ChatGPT API!
|
||||
|
||||
30× more tokens!
|
||||
```
|
||||
|
||||
### Example 3: Freelancer (Variable Usage)
|
||||
|
||||
```
|
||||
Light month (20M tokens):
|
||||
- 15M via subscription: $0
|
||||
- 5M via GLM: $3
|
||||
Total: $3
|
||||
|
||||
Heavy month (150M tokens):
|
||||
- 60M via subscription: $0
|
||||
- 60M via GLM: $36
|
||||
- 30M via MiniMax: $6
|
||||
Total: $42
|
||||
|
||||
Average: $22.50/month
|
||||
vs $3400 on ChatGPT API!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Track Daily Quota
|
||||
|
||||
```
|
||||
Dashboard shows:
|
||||
- GLM quota: 75% used (reset in 6h)
|
||||
- MiniMax quota: 50% used (reset in 2h)
|
||||
- Kimi quota: 8M/10M used (reset in 15 days)
|
||||
|
||||
Plan heavy tasks around reset times!
|
||||
```
|
||||
|
||||
### 2. Use Coding Plan (GLM)
|
||||
|
||||
```
|
||||
Standard: 1× quota
|
||||
Coding Plan: 3× quota (same price!)
|
||||
|
||||
→ Always choose Coding Plan
|
||||
```
|
||||
|
||||
### 3. Combine with Free Tier
|
||||
|
||||
```
|
||||
Combo:
|
||||
1. gc/gemini-3-flash (FREE primary)
|
||||
2. glm/glm-4.7 (cheap backup)
|
||||
3. minimax/MiniMax-M2.1 (cheapest)
|
||||
4. if/kimi-k2-thinking (FREE emergency)
|
||||
|
||||
Result: Minimize costs, maximize uptime
|
||||
```
|
||||
|
||||
### 4. Set Budget Alerts
|
||||
|
||||
```
|
||||
Dashboard → Settings → Budget Alerts
|
||||
|
||||
Daily: $2 limit
|
||||
Weekly: $10 limit
|
||||
Monthly: $30 limit
|
||||
|
||||
→ Auto switch to free tier when limit reached
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Quota exhausted"
|
||||
|
||||
**Solution:**
|
||||
- GLM: Wait until 10:00 AM Beijing time
|
||||
- MiniMax: Wait 5 hours from first use
|
||||
- Kimi: Wait until 1st of next month
|
||||
- Use combo fallback to free tier
|
||||
|
||||
### "API key invalid"
|
||||
|
||||
**Solution:**
|
||||
- Check API key copied correctly
|
||||
- Verify account has credits
|
||||
- Regenerate API key if needed
|
||||
|
||||
### "High costs"
|
||||
|
||||
**Solution:**
|
||||
- Check usage stats in Dashboard
|
||||
- Set budget alerts
|
||||
- Switch to MiniMax ($0.2/1M cheapest)
|
||||
- Use free tier for non-critical tasks
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
- **Add free fallback:** [Free Providers](./free.md)
|
||||
- **Setup subscriptions:** [Subscription Providers](./subscription.md)
|
||||
- **Create combos:** Dashboard → Combos → Create New
|
||||
@@ -0,0 +1,442 @@
|
||||
# Free Providers - Zero Cost Fallback
|
||||
|
||||
Emergency backup when everything else is quota-limited. Code 24/7 with zero cost!
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Free tier providers are your **fallback** when subscription and cheap quota exhausted:
|
||||
|
||||
- 🆓 **iFlow** - 8 models FREE (Kimi K2, Qwen3, GLM 4.7, MiniMax M2...)
|
||||
- 🆓 **Qwen** - 3 models FREE (Qwen3 Coder Plus/Flash, Vision)
|
||||
- 🆓 **Kiro** - 2 models FREE (Claude Sonnet 4.5, Haiku 4.5)
|
||||
|
||||
**Strategy:** Use as emergency backup. Unlimited usage, zero cost forever!
|
||||
|
||||
---
|
||||
|
||||
## iFlow (8 FREE Models)
|
||||
|
||||
### Pricing
|
||||
|
||||
| Plan | Monthly Cost | Models | Quota |
|
||||
|------|--------------|--------|-------|
|
||||
| FREE | $0 | 8 models | Unlimited |
|
||||
|
||||
**Best Value:** Most models in free tier! Kimi K2, Qwen3, GLM, MiniMax, DeepSeek.
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Connect via Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect iFlow
|
||||
```
|
||||
|
||||
**Step 2: iFlow OAuth Login**
|
||||
|
||||
- Click "Connect iFlow"
|
||||
- Browser opens → iFlow login page
|
||||
- Create account or login
|
||||
- Grant permissions
|
||||
- Auto token refresh enabled
|
||||
|
||||
**Step 3: Use in CLI**
|
||||
|
||||
```
|
||||
Model: if/kimi-k2-thinking
|
||||
if/kimi-k2
|
||||
if/qwen3-coder-plus
|
||||
if/glm-4.7
|
||||
if/minimax-m2
|
||||
if/deepseek-r1
|
||||
if/deepseek-v3.2-chat
|
||||
if/deepseek-v3.2-reasoner
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Best For |
|
||||
|----------|-------------|----------|
|
||||
| `if/kimi-k2-thinking` | Kimi K2 Thinking | Complex reasoning |
|
||||
| `if/kimi-k2` | Kimi K2 | General coding |
|
||||
| `if/qwen3-coder-plus` | Qwen3 Coder Plus | Code generation |
|
||||
| `if/glm-4.7` | GLM 4.7 | Chinese + English |
|
||||
| `if/minimax-m2` | MiniMax M2 | Long context |
|
||||
| `if/deepseek-r1` | DeepSeek R1 | Reasoning tasks |
|
||||
| `if/deepseek-v3.2-chat` | DeepSeek V3.2 Chat | Conversational |
|
||||
| `if/deepseek-v3.2-reasoner` | DeepSeek V3.2 Reasoner | Complex logic |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **8 models FREE** - Most variety in free tier
|
||||
- **Unlimited usage** - No quota limits
|
||||
- **Kimi K2 Thinking** - Best for complex reasoning
|
||||
- **DeepSeek R1** - Strong reasoning capabilities
|
||||
|
||||
---
|
||||
|
||||
## Qwen (3 FREE Models)
|
||||
|
||||
### Pricing
|
||||
|
||||
| Plan | Monthly Cost | Models | Quota |
|
||||
|------|--------------|--------|-------|
|
||||
| FREE | $0 | 3 models | Unlimited |
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Connect via Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect Qwen
|
||||
```
|
||||
|
||||
**Step 2: Device Code Authorization**
|
||||
|
||||
- Click "Connect Qwen"
|
||||
- Dashboard shows device code
|
||||
- Visit authorization URL
|
||||
- Enter device code
|
||||
- Login to Qwen account
|
||||
- Auto token refresh enabled
|
||||
|
||||
**Step 3: Use in CLI**
|
||||
|
||||
```
|
||||
Model: qw/qwen3-coder-plus
|
||||
qw/qwen3-coder-flash
|
||||
qw/vision-model
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Best For |
|
||||
|----------|-------------|----------|
|
||||
| `qw/qwen3-coder-plus` | Qwen3 Coder Plus | Advanced coding |
|
||||
| `qw/qwen3-coder-flash` | Qwen3 Coder Flash | Fast responses |
|
||||
| `qw/vision-model` | Qwen3 Vision | Image analysis |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Qwen3 Coder Plus** - Strong coding capabilities
|
||||
- **Qwen3 Coder Flash** - Fast for quick tasks
|
||||
- **Vision model** - FREE image analysis
|
||||
- **Unlimited usage** - No quota limits
|
||||
|
||||
---
|
||||
|
||||
## Kiro (Claude FREE)
|
||||
|
||||
### Pricing
|
||||
|
||||
| Plan | Monthly Cost | Models | Quota |
|
||||
|------|--------------|--------|-------|
|
||||
| FREE | $0 | Claude Sonnet 4.5, Haiku 4.5 | Unlimited |
|
||||
|
||||
**Best Value:** FREE Claude! Same quality as paid Claude Code.
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Connect via Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect Kiro
|
||||
```
|
||||
|
||||
**Step 2: AWS Builder ID or OAuth**
|
||||
|
||||
- Click "Connect Kiro"
|
||||
- Choose login method:
|
||||
- AWS Builder ID (recommended)
|
||||
- Google account
|
||||
- GitHub account
|
||||
- Grant permissions
|
||||
- Auto token refresh enabled
|
||||
|
||||
**Step 3: Use in CLI**
|
||||
|
||||
```
|
||||
Model: kr/claude-sonnet-4.5
|
||||
kr/claude-haiku-4.5
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Best For |
|
||||
|----------|-------------|----------|
|
||||
| `kr/claude-sonnet-4.5` | Claude Sonnet 4.5 | Balanced quality/speed |
|
||||
| `kr/claude-haiku-4.5` | Claude Haiku 4.5 | Fast responses |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **FREE Claude** - Same quality as paid tier
|
||||
- **AWS Builder ID** - Easy setup with AWS account
|
||||
- **Unlimited usage** - No quota limits
|
||||
- **Best quality** - Claude 4.5 for free!
|
||||
|
||||
---
|
||||
|
||||
## Feature Comparison
|
||||
|
||||
| Provider | Models | Best Model | Setup | Quota |
|
||||
|----------|--------|------------|-------|-------|
|
||||
| **iFlow** | 8 | Kimi K2 Thinking | OAuth | Unlimited |
|
||||
| **Qwen** | 3 | Qwen3 Coder Plus | Device Code | Unlimited |
|
||||
| **Kiro** | 2 | Claude Sonnet 4.5 | AWS Builder ID | Unlimited |
|
||||
|
||||
**Winner:** iFlow for variety, Kiro for quality!
|
||||
|
||||
---
|
||||
|
||||
## Usage Example
|
||||
|
||||
### Cursor IDE Setup
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [from 9router dashboard]
|
||||
Model: if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### Create Combo (Recommended)
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: free-combo
|
||||
Models:
|
||||
1. if/kimi-k2-thinking (iFlow primary)
|
||||
2. qw/qwen3-coder-plus (Qwen backup)
|
||||
3. kr/claude-sonnet-4.5 (Kiro quality)
|
||||
|
||||
Use in CLI: free-combo
|
||||
```
|
||||
|
||||
**Result:** Zero cost, maximum uptime!
|
||||
|
||||
---
|
||||
|
||||
## Full Fallback Strategy
|
||||
|
||||
### Complete 3-Tier Combo
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: complete-fallback
|
||||
Models:
|
||||
1. gc/gemini-3-flash-preview (FREE subscription)
|
||||
2. cc/claude-opus-4-5 (Paid subscription)
|
||||
3. glm/glm-4.7 (Cheap backup, $0.6/1M)
|
||||
4. minimax/MiniMax-M2.1 (Cheapest, $0.2/1M)
|
||||
5. if/kimi-k2-thinking (FREE fallback)
|
||||
6. kr/claude-sonnet-4.5 (FREE quality)
|
||||
|
||||
Use in CLI: complete-fallback
|
||||
```
|
||||
|
||||
**Result:**
|
||||
- Tier 1: FREE subscription (Gemini CLI)
|
||||
- Tier 2: Paid subscription (Claude Code)
|
||||
- Tier 3: Cheap backup (GLM, MiniMax)
|
||||
- Tier 4: FREE fallback (iFlow, Kiro)
|
||||
|
||||
**Never stop coding!**
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Use as Emergency Backup
|
||||
|
||||
```
|
||||
Priority:
|
||||
1. Subscription tier (maximize paid quota)
|
||||
2. Cheap tier (pennies per 1M tokens)
|
||||
3. FREE tier (unlimited, zero cost)
|
||||
|
||||
Only use free tier when:
|
||||
- Subscription quota exhausted
|
||||
- Budget limit reached
|
||||
- Testing/non-critical tasks
|
||||
```
|
||||
|
||||
### 2. Choose Right Model
|
||||
|
||||
```
|
||||
Complex reasoning: if/kimi-k2-thinking
|
||||
Fast coding: qw/qwen3-coder-flash
|
||||
Best quality: kr/claude-sonnet-4.5
|
||||
Long context: if/minimax-m2
|
||||
Vision tasks: qw/vision-model
|
||||
```
|
||||
|
||||
### 3. Create Free-Only Combo
|
||||
|
||||
```
|
||||
For zero-cost coding:
|
||||
|
||||
Name: zero-cost
|
||||
Models:
|
||||
1. kr/claude-sonnet-4.5 (Best quality)
|
||||
2. if/kimi-k2-thinking (Complex tasks)
|
||||
3. qw/qwen3-coder-plus (Fast coding)
|
||||
|
||||
Cost: $0 forever!
|
||||
```
|
||||
|
||||
### 4. Test Before Production
|
||||
|
||||
```
|
||||
Use free tier to:
|
||||
- Test prompts
|
||||
- Prototype features
|
||||
- Learn new frameworks
|
||||
- Non-critical tasks
|
||||
|
||||
Save paid quota for:
|
||||
- Production code
|
||||
- Complex refactoring
|
||||
- Critical features
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Real-World Examples
|
||||
|
||||
### Example 1: Student/Learner (Zero Budget)
|
||||
|
||||
```
|
||||
Setup:
|
||||
1. kr/claude-sonnet-4.5 (Best quality)
|
||||
2. if/kimi-k2-thinking (Complex reasoning)
|
||||
3. qw/qwen3-coder-plus (Fast coding)
|
||||
|
||||
Monthly cost: $0
|
||||
Usage: Unlimited
|
||||
|
||||
Perfect for:
|
||||
- Learning to code
|
||||
- Personal projects
|
||||
- Homework/assignments
|
||||
```
|
||||
|
||||
### Example 2: Freelancer (Budget-Conscious)
|
||||
|
||||
```
|
||||
Setup:
|
||||
1. gc/gemini-3-flash-preview (FREE 180K/month)
|
||||
2. glm/glm-4.7 (Cheap backup, $0.6/1M)
|
||||
3. if/kimi-k2-thinking (FREE fallback)
|
||||
|
||||
Monthly cost: $5-10
|
||||
Usage: 100M+ tokens
|
||||
|
||||
Perfect for:
|
||||
- Client projects (paid tier)
|
||||
- Testing (free tier)
|
||||
- Emergency backup
|
||||
```
|
||||
|
||||
### Example 3: Heavy User (Maximize Everything)
|
||||
|
||||
```
|
||||
Setup:
|
||||
1. gc/gemini-3-flash-preview (FREE 180K/month)
|
||||
2. cc/claude-opus-4-5 (Subscription $20-100)
|
||||
3. cx/gpt-5.2-codex (Subscription $20-200)
|
||||
4. glm/glm-4.7 (Cheap $0.6/1M)
|
||||
5. minimax/MiniMax-M2.1 (Cheapest $0.2/1M)
|
||||
6. if/kimi-k2-thinking (FREE unlimited)
|
||||
7. kr/claude-sonnet-4.5 (FREE quality)
|
||||
|
||||
Monthly cost: $40-320 (subscriptions) + $10-20 (cheap tier)
|
||||
Usage: 500M+ tokens
|
||||
|
||||
Perfect for:
|
||||
- Professional development
|
||||
- Team projects
|
||||
- 24/7 coding
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cost Comparison
|
||||
|
||||
### Scenario: 100M tokens/month
|
||||
|
||||
**Option 1: ChatGPT API Only**
|
||||
```
|
||||
100M × $20/1M = $2,000/month
|
||||
```
|
||||
|
||||
**Option 2: 9Router Free Tier Only**
|
||||
```
|
||||
100M via free tier = $0/month
|
||||
Savings: $2,000/month (100%)
|
||||
```
|
||||
|
||||
**Option 3: 9Router Complete Strategy**
|
||||
```
|
||||
60M via Gemini CLI (FREE): $0
|
||||
30M via Claude Code (subscription): $0 extra
|
||||
8M via GLM (cheap): $4.80
|
||||
2M via iFlow (FREE): $0
|
||||
Total: $4.80/month + subscriptions you already have
|
||||
Savings: $1,995/month (99.76%)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "OAuth failed"
|
||||
|
||||
**Solution:**
|
||||
- Check internet connection
|
||||
- Try different browser
|
||||
- Clear browser cache
|
||||
- Reconnect in dashboard
|
||||
|
||||
### "Model not available"
|
||||
|
||||
**Solution:**
|
||||
- Check provider connected in dashboard
|
||||
- Verify OAuth token valid
|
||||
- Reconnect provider if needed
|
||||
|
||||
### "Slow responses"
|
||||
|
||||
**Solution:**
|
||||
- Free tier may have lower priority
|
||||
- Use during off-peak hours
|
||||
- Switch to different free provider
|
||||
- Upgrade to cheap tier for speed
|
||||
|
||||
---
|
||||
|
||||
## Limitations
|
||||
|
||||
### Free Tier Considerations
|
||||
|
||||
- **Speed** - May be slower than paid tiers
|
||||
- **Priority** - Lower priority during peak hours
|
||||
- **Rate limits** - Possible rate limiting (but unlimited quota)
|
||||
- **Availability** - May have occasional downtime
|
||||
|
||||
**Solution:** Use 3-tier fallback strategy for reliability!
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
- **Setup subscriptions:** [Subscription Providers](./subscription.md)
|
||||
- **Add cheap backup:** [Cheap Providers](./cheap.md)
|
||||
- **Create combos:** Dashboard → Combos → Create New
|
||||
- **Start coding:** Use `complete-fallback` combo for maximum reliability
|
||||
@@ -0,0 +1,404 @@
|
||||
# Subscription Providers - Maximize Your Value
|
||||
|
||||
Maximize your existing AI subscriptions with smart quota tracking and automatic fallback. Use every bit of your subscription before it resets!
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Subscription tier providers are your **primary** choice - you're already paying for them, so get full value:
|
||||
|
||||
- ✅ **Claude Code** (Pro/Max) - Claude 4.5 Opus/Sonnet/Haiku
|
||||
- ✅ **OpenAI Codex** (Plus/Pro) - GPT 5.2 Codex, GPT 5.1 Codex Max
|
||||
- ✅ **Gemini CLI** (FREE tier!) - 180K completions/month
|
||||
- ✅ **GitHub Copilot** - GPT-5, Claude 4.5, Gemini 3
|
||||
- ✅ **Antigravity** (Google) - Gemini 3 Pro, Claude Sonnet 4.5
|
||||
|
||||
**Strategy:** Use these first, track quota in real-time, fallback to cheap/free when exhausted.
|
||||
|
||||
---
|
||||
|
||||
## Claude Code (Pro/Max)
|
||||
|
||||
### Pricing
|
||||
|
||||
| Plan | Monthly Cost | Quota Reset | Models |
|
||||
|------|--------------|-------------|--------|
|
||||
| Pro | $20 | 5-hour + Weekly | Opus, Sonnet, Haiku |
|
||||
| Max | $100 | 5-hour + Weekly | Opus, Sonnet, Haiku |
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Connect via Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard opens → Providers → Connect Claude Code
|
||||
```
|
||||
|
||||
**Step 2: OAuth Login**
|
||||
|
||||
- Click "Connect Claude Code"
|
||||
- Browser opens → Login to Claude.ai
|
||||
- Auto token refresh enabled
|
||||
- Quota tracking starts
|
||||
|
||||
**Step 3: Use in CLI**
|
||||
|
||||
```
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
cc/claude-sonnet-4-5-20250929
|
||||
cc/claude-haiku-4-5-20251001
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Best For |
|
||||
|----------|-------------|----------|
|
||||
| `cc/claude-opus-4-5-20251101` | Claude 4.5 Opus | Complex tasks, architecture |
|
||||
| `cc/claude-sonnet-4-5-20250929` | Claude 4.5 Sonnet | Balanced speed/quality |
|
||||
| `cc/claude-haiku-4-5-20251001` | Claude 4.5 Haiku | Fast responses |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Use Opus for complex tasks** - Architecture decisions, refactoring
|
||||
- **Use Sonnet for speed** - Quick edits, code generation
|
||||
- **Track quota per model** - Dashboard shows usage per model
|
||||
- **5-hour reset** - Fresh quota every 5 hours + weekly reset
|
||||
|
||||
---
|
||||
|
||||
## OpenAI Codex (Plus/Pro)
|
||||
|
||||
### Pricing
|
||||
|
||||
| Plan | Monthly Cost | Quota Reset | Models |
|
||||
|------|--------------|-------------|--------|
|
||||
| Plus | $20 | 5-hour + Weekly | GPT 5.2, GPT 5.1 |
|
||||
| Pro | $200 | 5-hour + Weekly | GPT 5.2 Codex, GPT 5.1 Max |
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Connect via Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect Codex
|
||||
```
|
||||
|
||||
**Step 2: OAuth Login**
|
||||
|
||||
- Click "Connect Codex"
|
||||
- Browser opens to `http://localhost:1455`
|
||||
- Login to OpenAI account
|
||||
- Auto token refresh enabled
|
||||
|
||||
**Step 3: Use in CLI**
|
||||
|
||||
```
|
||||
Model: cx/gpt-5.2-codex
|
||||
cx/gpt-5.1-codex-max
|
||||
cx/gpt-5.2
|
||||
cx/gpt-5.1-codex
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Best For |
|
||||
|----------|-------------|----------|
|
||||
| `cx/gpt-5.2-codex` | GPT 5.2 Codex | Latest coding model |
|
||||
| `cx/gpt-5.1-codex-max` | GPT 5.1 Codex Max | Maximum context |
|
||||
| `cx/gpt-5.2` | GPT 5.2 | General tasks |
|
||||
| `cx/gpt-5.1-codex` | GPT 5.1 Codex | Stable coding |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **5-hour rolling quota** - Fresh quota every 5 hours
|
||||
- **Weekly reset** - Full quota reset weekly
|
||||
- **Pro tier** - 10× more quota than Plus
|
||||
|
||||
---
|
||||
|
||||
## Gemini CLI (FREE 180K/month!)
|
||||
|
||||
### Pricing
|
||||
|
||||
| Plan | Monthly Cost | Quota | Reset |
|
||||
|------|--------------|-------|-------|
|
||||
| FREE | $0 | 180K completions/month + 1K/day | Daily + Monthly |
|
||||
|
||||
**Best Value:** Huge free tier! Use this before paid tiers.
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Connect via Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect Gemini CLI
|
||||
```
|
||||
|
||||
**Step 2: Google OAuth**
|
||||
|
||||
- Click "Connect Gemini CLI"
|
||||
- Browser opens → Login to Google account
|
||||
- Grant permissions
|
||||
- Auto token refresh enabled
|
||||
|
||||
**Step 3: Use in CLI**
|
||||
|
||||
```
|
||||
Model: gc/gemini-3-flash-preview
|
||||
gc/gemini-3-pro-preview
|
||||
gc/gemini-2.5-pro
|
||||
gc/gemini-2.5-flash
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Best For |
|
||||
|----------|-------------|----------|
|
||||
| `gc/gemini-3-flash-preview` | Gemini 3 Flash Preview | Fast responses |
|
||||
| `gc/gemini-3-pro-preview` | Gemini 3 Pro Preview | Complex tasks |
|
||||
| `gc/gemini-2.5-pro` | Gemini 2.5 Pro | Stable production |
|
||||
| `gc/gemini-2.5-flash` | Gemini 2.5 Flash | Quick tasks |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **180K completions/month** - Massive free tier
|
||||
- **1K/day limit** - Daily quota resets at midnight
|
||||
- **Use first** - Free tier, use before paid subscriptions
|
||||
- **No credit card** - Completely free with Google account
|
||||
|
||||
---
|
||||
|
||||
## GitHub Copilot
|
||||
|
||||
### Pricing
|
||||
|
||||
| Plan | Monthly Cost | Quota Reset | Models |
|
||||
|------|--------------|-------------|--------|
|
||||
| Individual | $10 | Monthly (1st) | GPT-5, Claude 4.5, Gemini 3 |
|
||||
| Business | $19 | Monthly (1st) | GPT-5, Claude 4.5, Gemini 3 |
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Connect via Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect GitHub
|
||||
```
|
||||
|
||||
**Step 2: OAuth via GitHub**
|
||||
|
||||
- Click "Connect GitHub"
|
||||
- Browser opens → Login to GitHub
|
||||
- Authorize GitHub Copilot
|
||||
- Auto token refresh enabled
|
||||
|
||||
**Step 3: Use in CLI**
|
||||
|
||||
```
|
||||
Model: gh/gpt-5
|
||||
gh/gpt-5.1-codex-max
|
||||
gh/claude-4.5-sonnet
|
||||
gh/gemini-3-pro
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Best For |
|
||||
|----------|-------------|----------|
|
||||
| `gh/gpt-5` | GPT-5 | Latest OpenAI model |
|
||||
| `gh/gpt-5.1-codex-max` | GPT-5.1 Codex Max | Maximum context |
|
||||
| `gh/claude-4.5-sonnet` | Claude 4.5 Sonnet | Anthropic quality |
|
||||
| `gh/gemini-3-pro` | Gemini 3 Pro | Google quality |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Monthly reset** - Full quota reset on 1st of month
|
||||
- **Multiple models** - Access GPT, Claude, Gemini in one subscription
|
||||
- **Business tier** - Higher quota for teams
|
||||
|
||||
---
|
||||
|
||||
## Antigravity (Google Account)
|
||||
|
||||
### Pricing
|
||||
|
||||
| Plan | Monthly Cost | Quota | Models |
|
||||
|------|--------------|-------|--------|
|
||||
| FREE | $0 | Similar to Gemini CLI | Gemini 3 Pro, Claude Sonnet 4.5 |
|
||||
|
||||
### Setup
|
||||
|
||||
**Step 1: Connect via Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect Antigravity
|
||||
```
|
||||
|
||||
**Step 2: Google OAuth**
|
||||
|
||||
- Click "Connect Antigravity"
|
||||
- Browser opens → Login to Google account
|
||||
- Grant permissions
|
||||
- Auto token refresh enabled
|
||||
|
||||
**Step 3: Use in CLI**
|
||||
|
||||
```
|
||||
Model: ag/gemini-3-pro-high
|
||||
ag/claude-sonnet-4-5
|
||||
ag/claude-opus-4-5-thinking
|
||||
```
|
||||
|
||||
### Available Models
|
||||
|
||||
| Model ID | Description | Best For |
|
||||
|----------|-------------|----------|
|
||||
| `ag/gemini-3-pro-high` | Gemini 3 Pro High | High-quality responses |
|
||||
| `ag/claude-sonnet-4-5` | Claude Sonnet 4.5 | Anthropic quality |
|
||||
| `ag/claude-opus-4-5-thinking` | Claude Opus 4.5 Thinking | Complex reasoning |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Free tier** - No cost with Google account
|
||||
- **Claude access** - Free Claude Sonnet/Opus
|
||||
- **Quota similar to Gemini CLI** - Daily/monthly limits
|
||||
|
||||
---
|
||||
|
||||
## Pricing Comparison
|
||||
|
||||
| Provider | Monthly Cost | Quota Reset | Value |
|
||||
|----------|--------------|-------------|-------|
|
||||
| **Claude Code Pro** | $20 | 5-hour + Weekly | ⭐⭐⭐⭐⭐ Best quality |
|
||||
| **Claude Code Max** | $100 | 5-hour + Weekly | ⭐⭐⭐⭐⭐ Highest quota |
|
||||
| **Codex Plus** | $20 | 5-hour + Weekly | ⭐⭐⭐⭐ Good value |
|
||||
| **Codex Pro** | $200 | 5-hour + Weekly | ⭐⭐⭐⭐⭐ 10× quota |
|
||||
| **Gemini CLI** | **$0** | Daily + Monthly | ⭐⭐⭐⭐⭐ FREE 180K/month! |
|
||||
| **GitHub Copilot** | $10-19 | Monthly (1st) | ⭐⭐⭐⭐ Multi-model |
|
||||
| **Antigravity** | **$0** | Daily + Monthly | ⭐⭐⭐⭐ FREE Claude! |
|
||||
|
||||
---
|
||||
|
||||
## Usage Example
|
||||
|
||||
### Cursor IDE Setup
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [from 9router dashboard]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
### Create Combo (Recommended)
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: premium-coding
|
||||
Models:
|
||||
1. gc/gemini-3-flash-preview (FREE, use first)
|
||||
2. cc/claude-opus-4-5-20251101 (Subscription)
|
||||
3. cx/gpt-5.2-codex (Subscription backup)
|
||||
|
||||
Use in CLI: premium-coding
|
||||
```
|
||||
|
||||
**Result:** Maximize free tier → Use subscription → Auto fallback
|
||||
|
||||
---
|
||||
|
||||
## Quota Tracking
|
||||
|
||||
9Router tracks quota in real-time:
|
||||
|
||||
- **Token consumption** - Input/output tokens per request
|
||||
- **Reset countdown** - Time until next quota reset
|
||||
- **Usage percentage** - How much quota used
|
||||
- **Auto fallback** - Switch to next tier when exhausted
|
||||
|
||||
**Dashboard view:**
|
||||
|
||||
```
|
||||
Claude Code Pro
|
||||
├─ Quota: 75% used
|
||||
├─ Reset: 2h 15m (5-hour)
|
||||
├─ Weekly reset: 3 days
|
||||
└─ Fallback: glm/glm-4.7 (cheap tier)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Use Free Tier First
|
||||
|
||||
```
|
||||
Priority:
|
||||
1. Gemini CLI (180K/month FREE)
|
||||
2. Antigravity (FREE Claude)
|
||||
3. Claude Code/Codex (paid subscriptions)
|
||||
```
|
||||
|
||||
### 2. Track Quota Daily
|
||||
|
||||
- Check dashboard every morning
|
||||
- Plan heavy tasks around quota resets
|
||||
- Use cheap/free tier for non-critical tasks
|
||||
|
||||
### 3. Create Smart Combos
|
||||
|
||||
```
|
||||
Example combo:
|
||||
1. gc/gemini-3-flash-preview (FREE primary)
|
||||
2. cc/claude-opus-4-5 (Complex tasks)
|
||||
3. glm/glm-4.7 (Cheap backup)
|
||||
4. if/kimi-k2-thinking (FREE fallback)
|
||||
```
|
||||
|
||||
### 4. Optimize by Time
|
||||
|
||||
```
|
||||
Morning: Fresh 5-hour quota (Claude/Codex)
|
||||
Afternoon: Gemini CLI (1K/day)
|
||||
Evening: Subscription quota
|
||||
Night: Cheap/free tier
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Quota exhausted"
|
||||
|
||||
**Solution:**
|
||||
- Check dashboard quota tracker
|
||||
- Wait for reset (5-hour or daily)
|
||||
- Use combo fallback to cheap/free tier
|
||||
|
||||
### "OAuth token expired"
|
||||
|
||||
**Solution:**
|
||||
- Auto-refreshed by 9Router
|
||||
- If issues: Dashboard → Provider → Reconnect
|
||||
|
||||
### "Rate limiting"
|
||||
|
||||
**Solution:**
|
||||
- Subscription quota out
|
||||
- Add fallback: `cc/claude-opus → glm/glm-4.7`
|
||||
- Use free tier: `if/kimi-k2-thinking`
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
- **Setup cheap backup:** [Cheap Providers](./cheap.md)
|
||||
- **Add free fallback:** [Free Providers](./free.md)
|
||||
- **Create combos:** Dashboard → Combos → Create New
|
||||
@@ -0,0 +1,351 @@
|
||||
# Troubleshooting
|
||||
|
||||
Common issues and solutions when using 9Router.
|
||||
|
||||
---
|
||||
|
||||
## "Language model did not provide messages"
|
||||
|
||||
**Problem:** Request fails with empty response or error message.
|
||||
|
||||
**Causes:**
|
||||
- Provider quota exhausted
|
||||
- API key invalid or expired
|
||||
- Model not available
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Check quota status:**
|
||||
```
|
||||
Dashboard → Providers → View quota tracker
|
||||
```
|
||||
If quota is exhausted, wait for reset or switch provider.
|
||||
|
||||
2. **Use combo fallback:**
|
||||
```
|
||||
Dashboard → Combos → Create fallback chain
|
||||
Example: cc/claude-opus → glm/glm-4.7 → if/kimi-k2
|
||||
```
|
||||
|
||||
3. **Verify provider connection:**
|
||||
```
|
||||
Dashboard → Providers → Reconnect if needed
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
**Problem:** "Rate limit exceeded" or "Too many requests" errors.
|
||||
|
||||
**Causes:**
|
||||
- Subscription quota depleted (5-hour/daily/weekly limits)
|
||||
- API rate limits hit
|
||||
- Too many concurrent requests
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Check reset time:**
|
||||
```
|
||||
Dashboard → Quota Tracking → View reset countdown
|
||||
```
|
||||
|
||||
2. **Switch to cheap tier:**
|
||||
```
|
||||
Use: glm/glm-4.7 ($0.6/1M tokens)
|
||||
minimax/MiniMax-M2.1 ($0.20/1M tokens)
|
||||
```
|
||||
|
||||
3. **Add fallback combo:**
|
||||
```
|
||||
Dashboard → Combos → Add backup models
|
||||
Primary: cc/claude-opus (subscription)
|
||||
Backup: glm/glm-4.7 (cheap)
|
||||
Emergency: if/kimi-k2 (free)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## OAuth Token Expired
|
||||
|
||||
**Problem:** "Unauthorized" or "Token expired" errors.
|
||||
|
||||
**Causes:**
|
||||
- OAuth token expired (auto-refresh failed)
|
||||
- Provider session invalidated
|
||||
- Network issues during refresh
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Auto-refresh (default):**
|
||||
9Router automatically refreshes tokens. Wait 30 seconds and retry.
|
||||
|
||||
2. **Manual reconnect:**
|
||||
```
|
||||
Dashboard → Providers → [Provider Name] → Reconnect
|
||||
→ Complete OAuth flow again
|
||||
```
|
||||
|
||||
3. **Check provider status:**
|
||||
Verify provider service is online (Claude Code, Codex, etc.)
|
||||
|
||||
---
|
||||
|
||||
## High Costs
|
||||
|
||||
**Problem:** Unexpected high usage or costs.
|
||||
|
||||
**Causes:**
|
||||
- Using expensive models unnecessarily
|
||||
- No fallback to cheaper tiers
|
||||
- Large context windows
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Check usage stats:**
|
||||
```
|
||||
Dashboard → Usage Stats → View token consumption
|
||||
→ Identify high-cost models
|
||||
```
|
||||
|
||||
2. **Switch to cheaper models:**
|
||||
```
|
||||
Replace: cc/claude-opus ($20-100/month subscription)
|
||||
With: glm/glm-4.7 ($0.6/1M tokens)
|
||||
minimax/MiniMax-M2.1 ($0.20/1M tokens)
|
||||
```
|
||||
|
||||
3. **Use free tier:**
|
||||
```
|
||||
if/kimi-k2-thinking (FREE)
|
||||
qw/qwen3-coder-plus (FREE)
|
||||
kr/claude-sonnet-4.5 (FREE)
|
||||
gc/gemini-3-flash-preview (FREE 180K/month)
|
||||
```
|
||||
|
||||
4. **Optimize prompts:**
|
||||
- Reduce context size
|
||||
- Use streaming for long responses
|
||||
- Cache common prompts
|
||||
|
||||
---
|
||||
|
||||
## Connection Refused
|
||||
|
||||
**Problem:** "ECONNREFUSED" or "Cannot connect to localhost:20128".
|
||||
|
||||
**Causes:**
|
||||
- 9Router not running
|
||||
- Port 20128 blocked
|
||||
- Firewall blocking connection
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Start 9Router:**
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
Dashboard should open at http://localhost:3000
|
||||
|
||||
2. **Verify port 20128:**
|
||||
```bash
|
||||
# Check if port is listening
|
||||
lsof -i :20128
|
||||
|
||||
# Or on Windows
|
||||
netstat -ano | findstr :20128
|
||||
```
|
||||
|
||||
3. **Check firewall:**
|
||||
- macOS: System Settings → Network → Firewall
|
||||
- Windows: Windows Defender Firewall → Allow app
|
||||
- Linux: `sudo ufw allow 20128`
|
||||
|
||||
4. **Use cloud endpoint:**
|
||||
If localhost doesn't work (e.g., Cursor IDE):
|
||||
```
|
||||
Endpoint: https://9router.com/v1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Dashboard Not Opening
|
||||
|
||||
**Problem:** Dashboard doesn't load at http://localhost:3000.
|
||||
|
||||
**Causes:**
|
||||
- Port 3000 already in use
|
||||
- 9Router crashed
|
||||
- Browser cache issues
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Check if 9Router is running:**
|
||||
```bash
|
||||
# Check process
|
||||
ps aux | grep 9router
|
||||
|
||||
# Check port 3000
|
||||
lsof -i :3000
|
||||
```
|
||||
|
||||
2. **Kill conflicting process:**
|
||||
```bash
|
||||
# macOS/Linux
|
||||
lsof -ti:3000 | xargs kill -9
|
||||
|
||||
# Windows
|
||||
netstat -ano | findstr :3000
|
||||
taskkill /PID <PID> /F
|
||||
```
|
||||
|
||||
3. **Restart 9Router:**
|
||||
```bash
|
||||
# Stop
|
||||
pkill -f 9router
|
||||
|
||||
# Start
|
||||
9router
|
||||
```
|
||||
|
||||
4. **Clear browser cache:**
|
||||
- Chrome: Ctrl+Shift+Delete → Clear cache
|
||||
- Try incognito mode
|
||||
|
||||
5. **Check firewall settings:**
|
||||
Ensure port 3000 is not blocked.
|
||||
|
||||
---
|
||||
|
||||
## Model Not Found
|
||||
|
||||
**Problem:** "Model not found" or "Invalid model" errors.
|
||||
|
||||
**Causes:**
|
||||
- Provider not connected
|
||||
- Model ID typo
|
||||
- Provider inactive
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Verify provider connection:**
|
||||
```
|
||||
Dashboard → Providers → Check status (green = active)
|
||||
```
|
||||
|
||||
2. **Check model ID format:**
|
||||
```
|
||||
Correct: cc/claude-opus-4-5-20251101
|
||||
Wrong: claude-opus-4-5-20251101
|
||||
|
||||
Format: [provider-prefix]/[model-name]
|
||||
```
|
||||
|
||||
3. **List available models:**
|
||||
```bash
|
||||
curl http://localhost:20128/v1/models \
|
||||
-H "Authorization: Bearer your-api-key"
|
||||
```
|
||||
|
||||
4. **Reconnect provider:**
|
||||
```
|
||||
Dashboard → Providers → [Provider] → Reconnect
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Slow Response
|
||||
|
||||
**Problem:** Requests take too long or timeout.
|
||||
|
||||
**Causes:**
|
||||
- Provider latency
|
||||
- Network issues
|
||||
- Large context/response
|
||||
- Provider rate limiting
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Check provider status:**
|
||||
```
|
||||
Dashboard → Providers → View latency stats
|
||||
```
|
||||
|
||||
2. **Switch to faster model:**
|
||||
```
|
||||
Fast: cc/claude-haiku-4-5 (Haiku is faster than Opus)
|
||||
gc/gemini-3-flash-preview
|
||||
qw/qwen3-coder-flash
|
||||
```
|
||||
|
||||
3. **Use streaming:**
|
||||
```json
|
||||
{
|
||||
"model": "cc/claude-opus-4-5",
|
||||
"messages": [...],
|
||||
"stream": true
|
||||
}
|
||||
```
|
||||
|
||||
4. **Check network:**
|
||||
```bash
|
||||
# Test latency
|
||||
ping api.anthropic.com
|
||||
ping api.openai.com
|
||||
```
|
||||
|
||||
5. **Reduce context size:**
|
||||
- Trim message history
|
||||
- Use smaller prompts
|
||||
- Enable context pruning in CLI tool
|
||||
|
||||
---
|
||||
|
||||
## API Key Invalid
|
||||
|
||||
**Problem:** "Invalid API key" or "Authentication failed" errors.
|
||||
|
||||
**Causes:**
|
||||
- Wrong API key copied
|
||||
- API key expired
|
||||
- API key not generated
|
||||
|
||||
**Solutions:**
|
||||
|
||||
1. **Regenerate API key:**
|
||||
```
|
||||
Dashboard → Settings → API Keys → Generate New Key
|
||||
→ Copy and use new key
|
||||
```
|
||||
|
||||
2. **Verify key format:**
|
||||
```
|
||||
Correct: 9r_xxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Wrong: Missing 9r_ prefix
|
||||
```
|
||||
|
||||
3. **Check key in CLI config:**
|
||||
```bash
|
||||
# Cursor
|
||||
Settings → Models → OpenAI API Key
|
||||
|
||||
# Cline
|
||||
Settings → API Key
|
||||
|
||||
# Environment variable
|
||||
export OPENAI_API_KEY="9r_your_key"
|
||||
```
|
||||
|
||||
4. **Test API key:**
|
||||
```bash
|
||||
curl http://localhost:20128/v1/models \
|
||||
-H "Authorization: Bearer 9r_your_key"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Need More Help?
|
||||
|
||||
- **GitHub Issues:** [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
- **Documentation:** [9router.com/docs](https://9router.com/docs)
|
||||
- **FAQ:** [faq.md](faq.md)
|
||||
@@ -0,0 +1,473 @@
|
||||
# ☁️ Despliegue en la nube
|
||||
|
||||
Despliega 9Router en VPS o Docker para acceso remoto y uso en producción.
|
||||
|
||||
---
|
||||
|
||||
## 🖥️ Despliegue en VPS
|
||||
|
||||
### Requisitos previos
|
||||
|
||||
- Ubuntu 20.04+ o distribución Linux similar
|
||||
- Node.js 20+
|
||||
- Git
|
||||
- Acceso root o sudo
|
||||
|
||||
### Paso 1: Clonar el repositorio
|
||||
|
||||
```bash
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
```
|
||||
|
||||
### Paso 2: Instalar dependencias
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
### Paso 3: Compilar la aplicación
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Paso 4: Configurar variables de entorno
|
||||
|
||||
Crea un archivo `.env` o exporta variables:
|
||||
|
||||
```bash
|
||||
export JWT_SECRET="your-secure-secret-change-this-to-random-string"
|
||||
export INITIAL_PASSWORD="your-secure-password"
|
||||
export DATA_DIR="/var/lib/9router"
|
||||
export NODE_ENV="production"
|
||||
```
|
||||
|
||||
**Variables de entorno:**
|
||||
|
||||
| Variable | Por defecto | Descripción |
|
||||
|----------|---------|-------------|
|
||||
| `JWT_SECRET` | Auto-generado | **¡DEBE cambiarse en producción!** Usado para firmar tokens JWT |
|
||||
| `INITIAL_PASSWORD` | `123456` | Contraseña de login del dashboard |
|
||||
| `DATA_DIR` | `~/.9router` | Ruta de almacenamiento de la base de datos |
|
||||
| `NODE_ENV` | `development` | Establece a `production` para despliegue |
|
||||
| `ENABLE_REQUEST_LOGS` | `false` | Habilita logs de debug de request/response |
|
||||
|
||||
### Paso 5: Crear el directorio de datos
|
||||
|
||||
```bash
|
||||
sudo mkdir -p /var/lib/9router
|
||||
sudo chown $USER:$USER /var/lib/9router
|
||||
```
|
||||
|
||||
### Paso 6: Iniciar la aplicación
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
### Paso 7: Configurar PM2 para producción
|
||||
|
||||
PM2 mantiene tu aplicación corriendo y la reinicia en caso de crash:
|
||||
|
||||
```bash
|
||||
# Instalar PM2 globalmente
|
||||
npm install -g pm2
|
||||
|
||||
# Iniciar 9Router con PM2
|
||||
pm2 start npm --name 9router -- start
|
||||
|
||||
# Guardar la configuración de PM2
|
||||
pm2 save
|
||||
|
||||
# Configurar PM2 para iniciar al arrancar el sistema
|
||||
pm2 startup
|
||||
# Sigue las instrucciones impresas por el comando anterior
|
||||
```
|
||||
|
||||
**Comandos de gestión de PM2:**
|
||||
|
||||
```bash
|
||||
# Ver logs
|
||||
pm2 logs 9router
|
||||
|
||||
# Reiniciar aplicación
|
||||
pm2 restart 9router
|
||||
|
||||
# Detener aplicación
|
||||
pm2 stop 9router
|
||||
|
||||
# Ver estado
|
||||
pm2 status
|
||||
|
||||
# Monitorear recursos
|
||||
pm2 monit
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🐳 Despliegue con Docker
|
||||
|
||||
### Opción 1: Usando Dockerfile
|
||||
|
||||
Crea un `Dockerfile` en el directorio `app`:
|
||||
|
||||
```dockerfile
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy application files
|
||||
COPY . .
|
||||
|
||||
# Build application
|
||||
RUN npm run build
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 3000 20128
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV DATA_DIR=/app/data
|
||||
|
||||
# Create data directory
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
# Start application
|
||||
CMD ["npm", "run", "start"]
|
||||
```
|
||||
|
||||
**Build y Run:**
|
||||
|
||||
```bash
|
||||
# Construir imagen
|
||||
docker build -t 9router .
|
||||
|
||||
# Ejecutar contenedor
|
||||
docker run -d \
|
||||
--name 9router \
|
||||
-p 3000:3000 \
|
||||
-p 20128:20128 \
|
||||
-e JWT_SECRET="your-secure-secret-change-this" \
|
||||
-e INITIAL_PASSWORD="your-secure-password" \
|
||||
-v 9router-data:/app/data \
|
||||
9router
|
||||
```
|
||||
|
||||
### Opción 2: Docker Compose
|
||||
|
||||
Crea `docker-compose.yml`:
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
9router:
|
||||
build: .
|
||||
container_name: 9router
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "20128:20128"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- JWT_SECRET=your-secure-secret-change-this
|
||||
- INITIAL_PASSWORD=your-secure-password
|
||||
- DATA_DIR=/app/data
|
||||
volumes:
|
||||
- 9router-data:/app/data
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
9router-data:
|
||||
```
|
||||
|
||||
**Ejecutar con Docker Compose:**
|
||||
|
||||
```bash
|
||||
# Iniciar servicios
|
||||
docker-compose up -d
|
||||
|
||||
# Ver logs
|
||||
docker-compose logs -f
|
||||
|
||||
# Detener servicios
|
||||
docker-compose down
|
||||
|
||||
# Reconstruir y reiniciar
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Proxy reverso con Nginx
|
||||
|
||||
### ¿Por qué usar Nginx?
|
||||
|
||||
- Terminación SSL/TLS
|
||||
- Mapeo de nombre de dominio
|
||||
- Balanceo de carga
|
||||
- Mejor seguridad
|
||||
|
||||
### Paso 1: Instalar Nginx
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install nginx
|
||||
```
|
||||
|
||||
### Paso 2: Configurar Nginx
|
||||
|
||||
Crea `/etc/nginx/sites-available/9router`:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name your-domain.com;
|
||||
|
||||
# Redirect HTTP to HTTPS
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name your-domain.com;
|
||||
|
||||
# SSL certificates (use certbot to generate)
|
||||
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
|
||||
|
||||
# SSL configuration
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Proxy to 9Router
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
|
||||
# SSE support - CRITICAL for streaming
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
# API endpoint
|
||||
location /v1 {
|
||||
proxy_pass http://localhost:20128;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# SSE support - CRITICAL for streaming
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Paso 3: Habilitar el sitio
|
||||
|
||||
```bash
|
||||
# Crear enlace simbólico
|
||||
sudo ln -s /etc/nginx/sites-available/9router /etc/nginx/sites-enabled/
|
||||
|
||||
# Probar configuración
|
||||
sudo nginx -t
|
||||
|
||||
# Recargar Nginx
|
||||
sudo systemctl reload nginx
|
||||
```
|
||||
|
||||
### Paso 4: Configurar SSL con Let's Encrypt
|
||||
|
||||
```bash
|
||||
# Instalar certbot
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
|
||||
# Obtener certificado SSL
|
||||
sudo certbot --nginx -d your-domain.com
|
||||
|
||||
# La auto-renovación se configura automáticamente
|
||||
# Probar renovación
|
||||
sudo certbot renew --dry-run
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔒 Consideraciones de seguridad
|
||||
|
||||
### 1. Cambiar credenciales por defecto
|
||||
|
||||
**CRÍTICO:** Cambia `JWT_SECRET` y `INITIAL_PASSWORD` antes del despliegue:
|
||||
|
||||
```bash
|
||||
# Generar JWT secret seguro
|
||||
openssl rand -base64 32
|
||||
|
||||
# Usa este valor para JWT_SECRET
|
||||
export JWT_SECRET="generated-secret-here"
|
||||
```
|
||||
|
||||
### 2. Configuración del firewall
|
||||
|
||||
```bash
|
||||
# Permitir SSH
|
||||
sudo ufw allow 22/tcp
|
||||
|
||||
# Permitir HTTP/HTTPS (si usas Nginx)
|
||||
sudo ufw allow 80/tcp
|
||||
sudo ufw allow 443/tcp
|
||||
|
||||
# Si NO usas proxy reverso, permite los puertos de 9Router
|
||||
sudo ufw allow 3000/tcp
|
||||
sudo ufw allow 20128/tcp
|
||||
|
||||
# Habilitar firewall
|
||||
sudo ufw enable
|
||||
```
|
||||
|
||||
### 3. Restringir el acceso al dashboard
|
||||
|
||||
Si solo necesitas acceso por API, restringe el puerto del dashboard:
|
||||
|
||||
```bash
|
||||
# Solo permitir acceso localhost al dashboard
|
||||
sudo ufw deny 3000/tcp
|
||||
```
|
||||
|
||||
Accede al dashboard vía túnel SSH:
|
||||
|
||||
```bash
|
||||
ssh -L 3000:localhost:3000 user@your-server.com
|
||||
# Luego abre http://localhost:3000 en tu navegador
|
||||
```
|
||||
|
||||
### 4. Actualizaciones regulares
|
||||
|
||||
```bash
|
||||
# Actualizar paquetes del sistema
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
|
||||
# Actualizar 9Router
|
||||
cd /path/to/9router/app
|
||||
git pull
|
||||
npm install
|
||||
npm run build
|
||||
pm2 restart 9router
|
||||
```
|
||||
|
||||
### 5. Estrategia de respaldo
|
||||
|
||||
```bash
|
||||
# Respaldar el directorio de datos
|
||||
tar -czf 9router-backup-$(date +%Y%m%d).tar.gz /var/lib/9router
|
||||
|
||||
# Respaldo automatizado diario (agregar a crontab)
|
||||
0 2 * * * tar -czf /backups/9router-$(date +\%Y\%m\%d).tar.gz /var/lib/9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Monitoreo
|
||||
|
||||
### Verificar el estado de la aplicación
|
||||
|
||||
```bash
|
||||
# Estado PM2
|
||||
pm2 status
|
||||
|
||||
# Ver logs
|
||||
pm2 logs 9router --lines 100
|
||||
|
||||
# Monitorear recursos
|
||||
pm2 monit
|
||||
```
|
||||
|
||||
### Logs de Nginx
|
||||
|
||||
```bash
|
||||
# Logs de acceso
|
||||
sudo tail -f /var/log/nginx/access.log
|
||||
|
||||
# Logs de error
|
||||
sudo tail -f /var/log/nginx/error.log
|
||||
```
|
||||
|
||||
### Recursos del sistema
|
||||
|
||||
```bash
|
||||
# Uso de CPU y memoria
|
||||
htop
|
||||
|
||||
# Uso de disco
|
||||
df -h
|
||||
|
||||
# Conexiones de red
|
||||
netstat -tulpn | grep -E '3000|20128'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Solución de problemas
|
||||
|
||||
### La aplicación no inicia
|
||||
|
||||
```bash
|
||||
# Verificar logs
|
||||
pm2 logs 9router
|
||||
|
||||
# Verificar si los puertos están en uso
|
||||
sudo lsof -i :3000
|
||||
sudo lsof -i :20128
|
||||
|
||||
# Verificar variables de entorno
|
||||
pm2 env 9router
|
||||
```
|
||||
|
||||
### Nginx 502 Bad Gateway
|
||||
|
||||
```bash
|
||||
# Verificar si 9Router está corriendo
|
||||
pm2 status
|
||||
|
||||
# Verificar logs de error de Nginx
|
||||
sudo tail -f /var/log/nginx/error.log
|
||||
|
||||
# Probar configuración de Nginx
|
||||
sudo nginx -t
|
||||
```
|
||||
|
||||
### El streaming SSE no funciona
|
||||
|
||||
Asegúrate de que `proxy_buffering off` esté configurado en Nginx para soporte SSE.
|
||||
|
||||
### Errores de permiso denegado
|
||||
|
||||
```bash
|
||||
# Corregir permisos del directorio de datos
|
||||
sudo chown -R $USER:$USER /var/lib/9router
|
||||
chmod 755 /var/lib/9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔗 Próximos pasos
|
||||
|
||||
- [Conectar proveedores](/providers/subscription.md)
|
||||
- [Configurar combos](/features/combos.md)
|
||||
- [Integrar con herramientas](/integration/cursor.md)
|
||||
@@ -0,0 +1,164 @@
|
||||
# 🏠 Despliegue en localhost
|
||||
|
||||
Ejecuta 9Router en tu máquina local para desarrollo y uso personal.
|
||||
|
||||
---
|
||||
|
||||
## 📦 Instalación
|
||||
|
||||
Instala 9Router globalmente vía npm:
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
**Requisitos:**
|
||||
- Node.js 20 o superior
|
||||
- npm 9 o superior
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Iniciar el servidor
|
||||
|
||||
Inicia 9Router con un solo comando:
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
El dashboard se abrirá automáticamente en tu navegador en `http://localhost:3000`
|
||||
|
||||
**Configuración por defecto:**
|
||||
- **Dashboard**: `http://localhost:3000`
|
||||
- **API Endpoint**: `http://localhost:20128/v1`
|
||||
- **Directorio de datos**: `~/.9router`
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Configuración
|
||||
|
||||
### Directorio de datos personalizado
|
||||
|
||||
Establece un directorio de datos personalizado usando una variable de entorno:
|
||||
|
||||
```bash
|
||||
DATA_DIR=/path/to/data 9router
|
||||
```
|
||||
|
||||
### Puerto personalizado
|
||||
|
||||
El puerto de API (20128) y el puerto del dashboard (3000) están configurados en la aplicación. Para cambiarlos, necesitarás modificar el código fuente o usar variables de entorno si se soportan.
|
||||
|
||||
---
|
||||
|
||||
## 🛑 Detener el servidor
|
||||
|
||||
Presiona `Ctrl+C` en la terminal donde 9Router se está ejecutando.
|
||||
|
||||
```bash
|
||||
# En la terminal ejecutando 9router
|
||||
^C # Presiona Ctrl+C
|
||||
```
|
||||
|
||||
El servidor se apagará correctamente y guardará todos los datos.
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Reiniciar el servidor
|
||||
|
||||
Simplemente ejecuta el comando de inicio nuevamente:
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
Todas tus configuraciones, API keys y combos se preservan en el directorio de datos.
|
||||
|
||||
---
|
||||
|
||||
## 📊 Actualizar 9Router
|
||||
|
||||
Actualiza a la última versión:
|
||||
|
||||
```bash
|
||||
npm update -g 9router
|
||||
```
|
||||
|
||||
Verifica tu versión actual:
|
||||
|
||||
```bash
|
||||
npm list -g 9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Solución de problemas
|
||||
|
||||
### Puerto ya en uso
|
||||
|
||||
Si el puerto 20128 o 3000 ya está en uso:
|
||||
|
||||
```bash
|
||||
# Encontrar proceso usando el puerto (macOS/Linux)
|
||||
lsof -i :20128
|
||||
lsof -i :3000
|
||||
|
||||
# Matar el proceso
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
### Errores de permisos
|
||||
|
||||
Si encuentras errores de permisos durante la instalación:
|
||||
|
||||
```bash
|
||||
# Usar sudo (no recomendado)
|
||||
sudo npm install -g 9router
|
||||
|
||||
# O corregir los permisos de npm (recomendado)
|
||||
mkdir ~/.npm-global
|
||||
npm config set prefix '~/.npm-global'
|
||||
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
### Problemas con el directorio de datos
|
||||
|
||||
Si el directorio de datos no es accesible:
|
||||
|
||||
```bash
|
||||
# Verificar permisos
|
||||
ls -la ~/.9router
|
||||
|
||||
# Corregir permisos
|
||||
chmod 755 ~/.9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📁 Estructura del directorio de datos
|
||||
|
||||
```
|
||||
~/.9router/
|
||||
├── db.json # Main database (providers, combos, settings)
|
||||
├── logs/ # Application logs
|
||||
└── cache/ # Temporary cache files
|
||||
```
|
||||
|
||||
**Respaldar tus datos:**
|
||||
|
||||
```bash
|
||||
# Respaldo
|
||||
cp -r ~/.9router ~/.9router.backup
|
||||
|
||||
# Restaurar
|
||||
cp -r ~/.9router.backup ~/.9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔗 Próximos pasos
|
||||
|
||||
- [Conectar proveedores](/providers/subscription.md)
|
||||
- [Crear combos](/features/combos.md)
|
||||
- [Integrar con herramientas CLI](/integration/cursor.md)
|
||||
@@ -0,0 +1,387 @@
|
||||
# Preguntas frecuentes
|
||||
|
||||
Preguntas comunes sobre 9Router.
|
||||
|
||||
---
|
||||
|
||||
## ¿Qué es 9Router?
|
||||
|
||||
**9Router es un router de modelos de IA que maximiza el valor de tu suscripción y minimiza los costos.**
|
||||
|
||||
Enruta inteligentemente las solicitudes a través de múltiples proveedores de IA usando un sistema de fallback de 3 niveles:
|
||||
1. **Nivel de suscripción** - Maximiza las cuotas de Claude Code, Codex, Gemini que ya pagas
|
||||
2. **Nivel barato** - Alternativas ultra-baratas ($0.20-$0.60 por 1M tokens)
|
||||
3. **Nivel gratis** - Respaldo de emergencia con modelos gratis ilimitados
|
||||
|
||||
**Beneficios clave:**
|
||||
- Nunca desperdicies la cuota de suscripción
|
||||
- Fallback automático cuando se agota la cuota
|
||||
- Seguimiento de cuota en tiempo real
|
||||
- 90% de ahorro en costos vs uso directo de API
|
||||
|
||||
---
|
||||
|
||||
## ¿Cómo funciona el precio?
|
||||
|
||||
**9Router usa una estrategia de precios de 3 niveles:**
|
||||
|
||||
### Nivel 1: Suscripción (Maximiza primero)
|
||||
- **Claude Code** (Pro/Max): $20-100/mes - Cuota de 5 horas + semanal
|
||||
- **OpenAI Codex** (Plus/Pro): $20-200/mes - Cuota de 5 horas + semanal
|
||||
- **Gemini CLI**: GRATIS - 180K completados/mes + 1K/día
|
||||
- **GitHub Copilot**: $10-19/mes - Reinicio mensual
|
||||
- **Antigravity**: GRATIS - Similar a Gemini
|
||||
|
||||
**Objetivo:** ¡Usa cada bit de cuota antes de que se reinicie!
|
||||
|
||||
### Nivel 2: Barato (Respaldo)
|
||||
- **GLM-4.7**: $0.60/$2.20 por 1M tokens - Reinicio diario 10AM
|
||||
- **MiniMax M2.1**: $0.20/$1.00 por 1M tokens - 5 horas rolling
|
||||
- **Kimi K2**: $9/mes plano (10M tokens)
|
||||
|
||||
**Objetivo:** ¡90% más barato que ChatGPT API ($20/1M)!
|
||||
|
||||
### Nivel 3: Gratis (Emergencia)
|
||||
- **iFlow**: 8 modelos GRATIS (Kimi K2, Qwen3, GLM, MiniMax...)
|
||||
- **Qwen**: 3 modelos GRATIS (Qwen3 Coder Plus/Flash, Vision)
|
||||
- **Kiro**: 2 modelos GRATIS (Claude Sonnet 4.5, Haiku 4.5)
|
||||
|
||||
**Objetivo:** ¡Fallback de cero costo cuando todo lo demás está limitado por cuota!
|
||||
|
||||
---
|
||||
|
||||
## ¿9Router es gratis?
|
||||
|
||||
**Sí, 9Router en sí es 100% gratis y open source.**
|
||||
|
||||
**Proveedores de nivel gratis disponibles:**
|
||||
- **Gemini CLI** - 180K completados/mes (cuenta Google GRATIS)
|
||||
- **iFlow** - 8 modelos ilimitados (OAuth GRATIS)
|
||||
- **Qwen** - 3 modelos ilimitados (OAuth GRATIS)
|
||||
- **Kiro** - Claude Sonnet/Haiku (AWS Builder ID GRATIS)
|
||||
|
||||
**¡Puedes codificar GRATIS para siempre usando solo proveedores de nivel gratis!**
|
||||
|
||||
**Proveedores de pago opcionales:**
|
||||
- Servicios de suscripción que ya puedes tener (Claude Code, Codex, Copilot)
|
||||
- Alternativas ultra-baratas ($0.20-$0.60 por 1M tokens)
|
||||
|
||||
---
|
||||
|
||||
## ¿Qué proveedores son compatibles?
|
||||
|
||||
### Proveedores de suscripción
|
||||
- **Claude Code** (Pro/Max) - Claude 4.5 Opus/Sonnet/Haiku
|
||||
- **OpenAI Codex** (Plus/Pro) - GPT 5.2 Codex, GPT 5.1 Codex Max
|
||||
- **Gemini CLI** (GRATIS) - Gemini 3 Flash/Pro, 2.5 Pro/Flash
|
||||
- **GitHub Copilot** - GPT-5, Claude 4.5, Gemini 3
|
||||
- **Antigravity** (Google) - Gemini 3 Pro, Claude Sonnet 4.5
|
||||
|
||||
### Proveedores baratos
|
||||
- **GLM** (Zhipu AI) - GLM 4.7, GLM 4.6V Vision
|
||||
- **MiniMax** - MiniMax M2.1
|
||||
- **Kimi** (Moonshot AI) - Kimi Latest
|
||||
- **OpenRouter** - Passthrough a cualquier modelo de OpenRouter
|
||||
|
||||
### Proveedores gratis
|
||||
- **iFlow** - 8 modelos (Kimi K2, Qwen3, GLM, MiniMax, DeepSeek...)
|
||||
- **Qwen** - 3 modelos (Qwen3 Coder Plus/Flash, Vision)
|
||||
- **Kiro** - 2 modelos (Claude Sonnet 4.5, Haiku 4.5)
|
||||
|
||||
**Total: 15+ proveedores, 50+ modelos**
|
||||
|
||||
Consulta la [documentación de proveedores](providers/subscription.md) para más detalles.
|
||||
|
||||
---
|
||||
|
||||
## ¿Puedo usar múltiples proveedores?
|
||||
|
||||
**¡Sí! Esta es la característica principal de 9Router.**
|
||||
|
||||
**Los combos te permiten encadenar múltiples proveedores con fallback automático:**
|
||||
|
||||
```
|
||||
Ejemplo de combo: "premium-coding"
|
||||
1. cc/claude-opus-4-5 (Suscripción principal)
|
||||
2. glm/glm-4.7 (Respaldo barato)
|
||||
3. if/kimi-k2 (Emergencia gratis)
|
||||
|
||||
→ Cambio automático cuando se agota la cuota
|
||||
→ Nunca para de codificar
|
||||
→ Costo extra mínimo
|
||||
```
|
||||
|
||||
**Cómo crear combos:**
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
→ Agrega modelos en orden de prioridad
|
||||
→ Usa el nombre del combo en CLI: "premium-coding"
|
||||
```
|
||||
|
||||
**Beneficios:**
|
||||
- Cero tiempo de inactividad cuando se agota la cuota
|
||||
- Optimización automática de costos
|
||||
- Un solo nombre de modelo para todas las herramientas
|
||||
|
||||
Consulta la [documentación de combos](features/combos.md) para ejemplos.
|
||||
|
||||
---
|
||||
|
||||
## ¿Cómo funciona el seguimiento de cuota?
|
||||
|
||||
**9Router rastrea la cuota en tiempo real para todos los proveedores:**
|
||||
|
||||
**Características:**
|
||||
- **Consumo de tokens** - Tokens de entrada/salida por solicitud
|
||||
- **Cuenta regresiva de reinicio** - Tiempo hasta que se refresca la cuota
|
||||
- **Estadísticas de uso** - Reportes diarios/semanales/mensuales
|
||||
- **Estimación de costos** - Gasto proyectado (niveles de pago)
|
||||
- **Alertas de cuota** - Notificaciones cuando la cuota es baja
|
||||
|
||||
**Tipos de cuota:**
|
||||
- **5 horas rolling** - Claude Code, Codex, MiniMax
|
||||
- **Reinicio diario** - Gemini CLI (1K/día), GLM (10AM)
|
||||
- **Reinicio semanal** - Claude Code, Codex (cuota adicional)
|
||||
- **Reinicio mensual** - Gemini CLI (180K), GitHub Copilot (día 1)
|
||||
|
||||
**Ver cuota:**
|
||||
```
|
||||
Dashboard → Providers → Quota Tracking
|
||||
→ Uso en tiempo real + cuenta regresiva de reinicio
|
||||
```
|
||||
|
||||
Consulta la [documentación de seguimiento de cuota](features/quota-tracking.md) para detalles.
|
||||
|
||||
---
|
||||
|
||||
## ¿9Router funciona con Cursor?
|
||||
|
||||
**Sí, pero Cursor requiere un endpoint en la nube.**
|
||||
|
||||
**Problema:** Cursor IDE no soporta endpoints en localhost.
|
||||
|
||||
**Solución:** Usa el despliegue en la nube de 9Router:
|
||||
|
||||
```
|
||||
Cursor Settings → Models → Advanced:
|
||||
OpenAI API Base URL: https://9router.com/v1
|
||||
OpenAI API Key: [desde el dashboard]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
**Alternativa:** Auto-hospéda en VPS con dominio público:
|
||||
```bash
|
||||
# Despliega en VPS
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
npm install && npm run build
|
||||
npm start
|
||||
|
||||
# Configura proxy reverso Nginx
|
||||
# Apunta Cursor a: https://your-domain.com/v1
|
||||
```
|
||||
|
||||
**Otras herramientas CLI funcionan con localhost:**
|
||||
- Cline ✅
|
||||
- Claude Desktop ✅
|
||||
- Codex CLI ✅
|
||||
- Continue ✅
|
||||
- RooCode ✅
|
||||
|
||||
Consulta la [guía de integración de Cursor](integration/cursor.md) para detalles.
|
||||
|
||||
---
|
||||
|
||||
## ¿Puedo auto-hospedar 9Router?
|
||||
|
||||
**¡Sí! 9Router soporta múltiples opciones de despliegue:**
|
||||
|
||||
### Localhost (Por defecto)
|
||||
```bash
|
||||
npm install -g 9router
|
||||
9router
|
||||
→ Dashboard: http://localhost:3000
|
||||
→ API: http://localhost:20128/v1
|
||||
```
|
||||
|
||||
### VPS/Cloud
|
||||
```bash
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
npm install && npm run build
|
||||
|
||||
export JWT_SECRET="your-secure-secret"
|
||||
export INITIAL_PASSWORD="your-password"
|
||||
export NODE_ENV="production"
|
||||
|
||||
npm start
|
||||
```
|
||||
|
||||
### Docker
|
||||
```bash
|
||||
docker build -t 9router .
|
||||
docker run -d \
|
||||
-p 3000:3000 \
|
||||
-e JWT_SECRET="your-secret" \
|
||||
-v 9router-data:/app/data \
|
||||
9router
|
||||
```
|
||||
|
||||
### Cloudflare Workers
|
||||
```bash
|
||||
cd 9router/app
|
||||
npm run deploy:cloudflare
|
||||
```
|
||||
|
||||
**Variables de entorno:**
|
||||
- `JWT_SECRET` - **¡DEBE cambiarse en producción!**
|
||||
- `DATA_DIR` - Ruta de almacenamiento de la base de datos (por defecto: `~/.9router`)
|
||||
- `INITIAL_PASSWORD` - Login del dashboard (por defecto: `123456`)
|
||||
- `NODE_ENV` - Establece en `production` para desplegar
|
||||
|
||||
Consulta la [guía de despliegue](getting-started/installation.md#deployment) para detalles.
|
||||
|
||||
---
|
||||
|
||||
## ¿Mis datos están seguros?
|
||||
|
||||
**Sí, 9Router prioriza la seguridad y privacidad:**
|
||||
|
||||
**Almacenamiento local:**
|
||||
- Todos los datos se almacenan localmente en `~/.9router` (o `DATA_DIR` personalizado)
|
||||
- No se envían datos a los servidores de 9Router
|
||||
- Tokens OAuth cifrados con JWT
|
||||
|
||||
**Sin telemetría:**
|
||||
- Sin seguimiento de uso
|
||||
- Sin analítica
|
||||
- Sin phone-home
|
||||
|
||||
**Open source:**
|
||||
- Código fuente completo disponible en GitHub
|
||||
- Audita la seguridad tú mismo
|
||||
- Revisado por la comunidad
|
||||
|
||||
**Mejores prácticas:**
|
||||
- Cambia `JWT_SECRET` en producción
|
||||
- Usa un `INITIAL_PASSWORD` fuerte
|
||||
- Habilita HTTPS para despliegues en la nube
|
||||
- Rota las API keys regularmente
|
||||
|
||||
**Lo que 9Router almacena:**
|
||||
- Tokens OAuth de proveedores (cifrados)
|
||||
- API keys (cifradas)
|
||||
- Estadísticas de uso (solo locales)
|
||||
- Configuraciones de combos
|
||||
|
||||
**Lo que 9Router NO almacena:**
|
||||
- Tus prompts o respuestas
|
||||
- El código que generas
|
||||
- Información personal
|
||||
|
||||
---
|
||||
|
||||
## ¿Cómo actualizo 9Router?
|
||||
|
||||
**Los métodos de actualización dependen del tipo de instalación:**
|
||||
|
||||
### Instalación global NPM
|
||||
```bash
|
||||
npm update -g 9router
|
||||
```
|
||||
|
||||
### Instalación local
|
||||
```bash
|
||||
cd 9router/app
|
||||
git pull origin main
|
||||
npm install
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
### Docker
|
||||
```bash
|
||||
docker pull 9router:latest
|
||||
docker stop 9router
|
||||
docker rm 9router
|
||||
docker run -d \
|
||||
-p 3000:3000 \
|
||||
-v 9router-data:/app/data \
|
||||
9router:latest
|
||||
```
|
||||
|
||||
**Verificar versión:**
|
||||
```bash
|
||||
9router --version
|
||||
```
|
||||
|
||||
**Cambios disruptivos:**
|
||||
- Revisa [CHANGELOG.md](https://github.com/decolua/9router/blob/main/CHANGELOG.md)
|
||||
- Respalda `~/.9router` antes de actualizaciones mayores
|
||||
- Revisa las guías de migración para versiones mayores
|
||||
|
||||
---
|
||||
|
||||
## ¿Cómo puedo contribuir?
|
||||
|
||||
**¡Damos la bienvenida a las contribuciones!**
|
||||
|
||||
### Formas de contribuir:
|
||||
|
||||
1. **Reportar bugs:**
|
||||
- [GitHub Issues](https://github.com/decolua/9router/issues)
|
||||
- Incluye logs de error, pasos para reproducir
|
||||
|
||||
2. **Solicitar características:**
|
||||
- [GitHub Discussions](https://github.com/decolua/9router/discussions)
|
||||
- Describe el caso de uso y los beneficios
|
||||
|
||||
3. **Enviar código:**
|
||||
```bash
|
||||
# Fork del repo
|
||||
git clone https://github.com/YOUR_USERNAME/9router.git
|
||||
cd 9router
|
||||
|
||||
# Crea una rama
|
||||
git checkout -b feature/your-feature
|
||||
|
||||
# Haz cambios
|
||||
npm install
|
||||
npm run dev
|
||||
|
||||
# Prueba
|
||||
npm test
|
||||
|
||||
# Commit y push
|
||||
git add .
|
||||
git commit -m "Add your feature"
|
||||
git push origin feature/your-feature
|
||||
|
||||
# Crea un Pull Request en GitHub
|
||||
```
|
||||
|
||||
4. **Mejorar docs:**
|
||||
- Corrige errores tipográficos, agrega ejemplos
|
||||
- Traduce a otros idiomas
|
||||
- Escribe tutoriales
|
||||
|
||||
5. **Agregar proveedores:**
|
||||
- Implementa nuevos adaptadores de proveedores
|
||||
- Consulta `app/lib/providers/` para ejemplos
|
||||
|
||||
**Directrices de contribución:**
|
||||
- Sigue el estilo de código existente
|
||||
- Agrega tests para nuevas características
|
||||
- Actualiza la documentación
|
||||
- Mantén los commits atómicos y descriptivos
|
||||
|
||||
Consulta [CONTRIBUTING.md](https://github.com/decolua/9router/blob/main/CONTRIBUTING.md) para detalles.
|
||||
|
||||
---
|
||||
|
||||
## ¿Necesitas más ayuda?
|
||||
|
||||
- **Documentación:** [9router.com/docs](https://9router.com/docs)
|
||||
- **GitHub:** [github.com/decolua/9router](https://github.com/decolua/9router)
|
||||
- **Issues:** [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
- **Troubleshooting:** [troubleshooting.md](troubleshooting.md)
|
||||
@@ -0,0 +1,537 @@
|
||||
# Combos - Cadenas de fallback personalizadas
|
||||
|
||||
Crea combinaciones de modelos personalizadas con fallback automático. Los combos te permiten definir tu propia estrategia de enrutamiento basada en costo, calidad y disponibilidad.
|
||||
|
||||
---
|
||||
|
||||
## ¿Qué son los combos?
|
||||
|
||||
Los combos son **cadenas de fallback personalizadas** que creas en el dashboard. En lugar de usar un solo modelo, defines una secuencia de modelos que 9Router intenta en orden.
|
||||
|
||||
**Ejemplo:**
|
||||
```
|
||||
Nombre del combo: premium-coding
|
||||
Modelos:
|
||||
1. cc/claude-opus-4-5-20251101 (intentar primero)
|
||||
2. glm/glm-4.7 (si #1 tiene cuota agotada)
|
||||
3. minimax/MiniMax-M2.1 (si #2 tiene cuota agotada)
|
||||
```
|
||||
|
||||
**Uso en CLI:**
|
||||
```
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
9Router intenta automáticamente cada modelo en secuencia hasta que uno tenga éxito.
|
||||
|
||||
---
|
||||
|
||||
## ¿Por qué usar combos?
|
||||
|
||||
### 1. Maximiza el valor de la suscripción
|
||||
```
|
||||
cc/claude-opus → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
→ Usa la suscripción primero, respaldo barato, emergencia gratis
|
||||
→ Obtén el valor completo de las suscripciones que ya pagas
|
||||
```
|
||||
|
||||
### 2. Minimiza costos
|
||||
```
|
||||
glm/glm-4.7 → minimax/MiniMax-M2.1 → if/kimi-k2-thinking
|
||||
|
||||
→ Comienza con la opción de pago más barata ($0.60/1M)
|
||||
→ Fallback a una aún más barata ($0.20/1M)
|
||||
→ Nivel de emergencia gratis
|
||||
→ Costo total: ~$5-10/mes vs $2000 en ChatGPT API
|
||||
```
|
||||
|
||||
### 3. Garantiza disponibilidad 24/7
|
||||
```
|
||||
cc/claude-opus → cx/gpt-5.2-codex → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
→ Siempre incluye el nivel gratis al final
|
||||
→ Nunca te quedes sin cuota
|
||||
→ Codifica en cualquier momento, en cualquier lugar
|
||||
```
|
||||
|
||||
### 4. Optimiza por calidad
|
||||
```
|
||||
cc/claude-opus-4-5 → cx/gpt-5.2-codex → gc/gemini-3-pro
|
||||
|
||||
→ Mejores modelos primero
|
||||
→ Fallback a otros modelos premium
|
||||
→ Mantén alta calidad en toda la cadena de fallback
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cómo crear combos
|
||||
|
||||
### Paso 1: Abrir el dashboard
|
||||
|
||||
```
|
||||
http://localhost:20128
|
||||
→ Inicia sesión con tu contraseña
|
||||
```
|
||||
|
||||
### Paso 2: Navegar a Combos
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New Combo
|
||||
```
|
||||
|
||||
### Paso 3: Configurar el combo
|
||||
|
||||
**Nombre del combo:**
|
||||
```
|
||||
premium-coding
|
||||
```
|
||||
|
||||
**Descripción (opcional):**
|
||||
```
|
||||
Suscripción primero, respaldo barato, emergencia gratis
|
||||
```
|
||||
|
||||
**Seleccionar modelos:**
|
||||
```
|
||||
1. cc/claude-opus-4-5-20251101
|
||||
2. glm/glm-4.7
|
||||
3. minimax/MiniMax-M2.1
|
||||
```
|
||||
|
||||
**Arrastra para reordenar** - Prioridad de arriba a abajo.
|
||||
|
||||
### Paso 4: Guardar
|
||||
|
||||
```
|
||||
Clic en "Save Combo"
|
||||
→ El combo aparece en la lista de modelos
|
||||
```
|
||||
|
||||
### Paso 5: Usar en CLI
|
||||
|
||||
```
|
||||
Cursor/Cline/Cualquier herramienta:
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Combos de ejemplo
|
||||
|
||||
### Ejemplo 1: Premium Coding (Suscripción → Barato → Gratis)
|
||||
|
||||
**Objetivo**: Maximizar el valor de la suscripción, minimizar costos extras.
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
**Uso:**
|
||||
```
|
||||
Cursor IDE:
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
**Comportamiento:**
|
||||
```
|
||||
Mañana (cuota fresca):
|
||||
Solicitud → cc/claude-opus-4-5 ✅
|
||||
|
||||
Tarde (cuota de Claude agotada):
|
||||
Solicitud → glm/glm-4.7 ✅ (cambio automático)
|
||||
|
||||
Noche (cuota de GLM agotada):
|
||||
Solicitud → minimax/MiniMax-M2.1 ✅ (cambio automático)
|
||||
```
|
||||
|
||||
**Costo mensual (100M tokens):**
|
||||
```
|
||||
80M vía Claude Code: $0 (suscripción)
|
||||
15M vía GLM: $9
|
||||
5M vía MiniMax: $1
|
||||
Total: $10 + tu suscripción
|
||||
```
|
||||
|
||||
**Ahorros**: ~99% vs ChatGPT API ($2000).
|
||||
|
||||
---
|
||||
|
||||
### Ejemplo 2: Combo de presupuesto (Barato → Gratis)
|
||||
|
||||
**Objetivo**: Minimizar costos, usar el nivel gratis como respaldo.
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: budget-combo
|
||||
Models:
|
||||
1. glm/glm-4.7
|
||||
2. minimax/MiniMax-M2.1
|
||||
3. if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
**Uso:**
|
||||
```
|
||||
Cline:
|
||||
Provider: OpenAI Compatible
|
||||
Base URL: http://localhost:20128/v1
|
||||
Model: budget-combo
|
||||
```
|
||||
|
||||
**Comportamiento:**
|
||||
```
|
||||
Solicitud → glm/glm-4.7
|
||||
✅ Cuota diaria disponible → Usa GLM ($0.60/1M)
|
||||
❌ Cuota agotada → Intenta MiniMax ($0.20/1M)
|
||||
❌ Cuota de MiniMax agotada → Usa iFlow (GRATIS)
|
||||
```
|
||||
|
||||
**Costo mensual (100M tokens):**
|
||||
```
|
||||
70M vía GLM: $42
|
||||
20M vía MiniMax: $4
|
||||
10M vía iFlow: $0
|
||||
Total: $46 vs $2000 en ChatGPT API
|
||||
```
|
||||
|
||||
**Ahorros**: 97%.
|
||||
|
||||
---
|
||||
|
||||
### Ejemplo 3: Combo gratis (Cero costo)
|
||||
|
||||
**Objetivo**: 100% gratis, sin costos nunca.
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: free-combo
|
||||
Models:
|
||||
1. if/kimi-k2-thinking
|
||||
2. qw/qwen3-coder-plus
|
||||
3. kr/claude-sonnet-4.5
|
||||
```
|
||||
|
||||
**Uso:**
|
||||
```
|
||||
Claude Desktop:
|
||||
Model: free-combo
|
||||
```
|
||||
|
||||
**Comportamiento:**
|
||||
```
|
||||
Solicitud → if/kimi-k2-thinking
|
||||
✅ Disponible → Usa iFlow
|
||||
❌ Error → Intenta Qwen
|
||||
❌ Error → Intenta Kiro
|
||||
```
|
||||
|
||||
**Costo mensual:**
|
||||
```
|
||||
100M tokens vía proveedores gratis: $0
|
||||
Total: $0 para siempre
|
||||
```
|
||||
|
||||
**Caso de uso**: Proyectos personales, aprendizaje, experimentación.
|
||||
|
||||
---
|
||||
|
||||
### Ejemplo 4: Calidad primero (Solo modelos premium)
|
||||
|
||||
**Objetivo**: Mejor calidad, sin fallback barato.
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
**Uso:**
|
||||
```
|
||||
Codex CLI:
|
||||
export OPENAI_BASE_URL="http://localhost:20128"
|
||||
Model: quality-first
|
||||
```
|
||||
|
||||
**Comportamiento:**
|
||||
```
|
||||
Solicitud → cc/claude-opus-4-5
|
||||
❌ Cuota agotada → cx/gpt-5.2-codex
|
||||
❌ Cuota agotada → gc/gemini-3-pro-preview
|
||||
❌ Todo agotado → Devuelve error (sin fallback barato)
|
||||
```
|
||||
|
||||
**Caso de uso**: Código crítico de producción, refactoring complejo.
|
||||
|
||||
---
|
||||
|
||||
### Ejemplo 5: Multi-suscripción (Maximiza todo)
|
||||
|
||||
**Objetivo**: Usa todas las suscripciones antes de pagar extra.
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: multi-sub
|
||||
Models:
|
||||
1. gc/gemini-3-flash-preview (GRATIS 180K/mes)
|
||||
2. cc/claude-opus-4-5-20251101 (suscripción Pro)
|
||||
3. cx/gpt-5.2-codex (suscripción Plus)
|
||||
4. gh/gpt-5 (suscripción Copilot)
|
||||
5. glm/glm-4.7 (respaldo barato)
|
||||
6. if/kimi-k2-thinking (emergencia gratis)
|
||||
```
|
||||
|
||||
**Costo mensual (200M tokens):**
|
||||
```
|
||||
50M vía Gemini CLI: $0 (nivel gratis)
|
||||
80M vía Claude Code: $0 (suscripción)
|
||||
40M vía Codex: $0 (suscripción)
|
||||
20M vía Copilot: $0 (suscripción)
|
||||
8M vía GLM: $4.80
|
||||
2M vía iFlow: $0
|
||||
Total: $4.80 + suscripciones existentes
|
||||
```
|
||||
|
||||
**Resultado**: Usa 190M tokens de suscripciones, solo $4.80 extra.
|
||||
|
||||
---
|
||||
|
||||
### Ejemplo 6: Optimización de reinicio de cuota
|
||||
|
||||
**Objetivo**: Distribuir el uso según los tiempos de reinicio.
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: reset-optimized
|
||||
Models:
|
||||
1. cc/claude-opus-4-5 (reinicio 5h, usar mañana)
|
||||
2. gc/gemini-3-flash (1K/día, usar tarde)
|
||||
3. glm/glm-4.7 (reinicio diario 10AM, usar noche)
|
||||
4. minimax/MiniMax-M2.1 (rolling 5h, usar madrugada)
|
||||
5. if/kimi-k2-thinking (ilimitado, emergencia)
|
||||
```
|
||||
|
||||
**Rutina diaria:**
|
||||
```
|
||||
08:00 - 13:00: Claude Code (cuota fresca de 5h)
|
||||
13:00 - 18:00: Gemini CLI (cuota 1K/día)
|
||||
18:00 - 22:00: GLM (se reinicia 10AM del día siguiente)
|
||||
22:00 - 08:00: MiniMax (rolling 5h) o iFlow
|
||||
```
|
||||
|
||||
**Resultado**: Codifica 24/7 con costos mínimos.
|
||||
|
||||
---
|
||||
|
||||
## Usar combos en herramientas CLI
|
||||
|
||||
### Cursor IDE
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [desde el dashboard]
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
### Claude Desktop
|
||||
|
||||
Edita `~/.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: [desde el dashboard]
|
||||
Model: free-combo
|
||||
```
|
||||
|
||||
### Solicitud por API
|
||||
|
||||
```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
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
### 1. Siempre incluye el nivel gratis
|
||||
|
||||
```
|
||||
✅ Bueno:
|
||||
cc/claude-opus → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
❌ Malo:
|
||||
cc/claude-opus → glm/glm-4.7
|
||||
(sin fallback gratis, puede quedarse sin cuota)
|
||||
```
|
||||
|
||||
**Por qué**: Garantiza disponibilidad 24/7, nunca bloqueado por cuota.
|
||||
|
||||
### 2. Ordena por costo (Barato a costoso)
|
||||
|
||||
```
|
||||
✅ Bueno:
|
||||
glm/glm-4.7 → minimax/MiniMax-M2.1 → cc/claude-opus
|
||||
|
||||
❌ Malo:
|
||||
cc/claude-opus → glm/glm-4.7
|
||||
(desperdicia cuota de suscripción en tareas simples)
|
||||
```
|
||||
|
||||
**Excepción**: Si quieres maximizar el valor de la suscripción, pon la suscripción primero.
|
||||
|
||||
### 3. Coincide con los requisitos de calidad
|
||||
|
||||
```
|
||||
Para código de producción:
|
||||
cc/claude-opus → cx/gpt-5.2-codex → glm/glm-4.7
|
||||
|
||||
Para tareas rápidas:
|
||||
glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
Para experimentación:
|
||||
if/kimi-k2-thinking → qw/qwen3-coder-plus
|
||||
```
|
||||
|
||||
### 4. Considera los tiempos de reinicio de cuota
|
||||
|
||||
```
|
||||
Combo matutino (cuotas frescas):
|
||||
cc/claude-opus → cx/gpt-5.2-codex
|
||||
|
||||
Combo nocturno (cuotas probablemente agotadas):
|
||||
glm/glm-4.7 → minimax/MiniMax-M2.1 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### 5. Crea múltiples combos para diferentes casos de uso
|
||||
|
||||
```
|
||||
premium-coding: Para tareas complejas
|
||||
budget-combo: Para tareas simples
|
||||
free-combo: Para experimentación
|
||||
quality-first: Para código de producción
|
||||
```
|
||||
|
||||
**Cambia entre combos** según los requisitos de la tarea.
|
||||
|
||||
### 6. Monitorea el desempeño del combo
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Combo Usage:
|
||||
premium-coding:
|
||||
80% vía cc/claude-opus (bueno, usando suscripción)
|
||||
15% vía glm/glm-4.7 (respaldo aceptable)
|
||||
5% vía minimax (fallback raro)
|
||||
```
|
||||
|
||||
**Optimiza**: Si hay demasiado uso de fallback, aumenta la cuota principal o reordena modelos.
|
||||
|
||||
---
|
||||
|
||||
## Configuración avanzada
|
||||
|
||||
### Establecer límites de presupuesto por combo
|
||||
|
||||
```
|
||||
Dashboard → Combos → Edit → Budget:
|
||||
Daily limit: $5
|
||||
Monthly limit: $50
|
||||
```
|
||||
|
||||
Cuando se alcanza el límite, 9Router omite los modelos de pago y usa solo el nivel gratis.
|
||||
|
||||
### Habilitar/Deshabilitar modelos en un combo
|
||||
|
||||
```
|
||||
Dashboard → Combos → Edit → Models:
|
||||
✅ cc/claude-opus-4-5 (habilitado)
|
||||
❌ glm/glm-4.7 (deshabilitado temporalmente)
|
||||
✅ if/kimi-k2-thinking (habilitado)
|
||||
```
|
||||
|
||||
**Caso de uso**: Deshabilitar temporalmente modelos costosos sin eliminar el combo.
|
||||
|
||||
### Clonar un combo existente
|
||||
|
||||
```
|
||||
Dashboard → Combos → Clone "premium-coding"
|
||||
→ Crea una copia con sufijo "-copy"
|
||||
→ Modifica y guarda como nuevo combo
|
||||
```
|
||||
|
||||
**Caso de uso**: Crear variaciones para diferentes escenarios.
|
||||
|
||||
---
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
**Problema: El combo no aparece en la lista de modelos**
|
||||
|
||||
**Solución:**
|
||||
1. Refresca el dashboard
|
||||
2. Verifica que el combo esté guardado (marca verde)
|
||||
3. Reinicia la herramienta CLI para refrescar la lista de modelos
|
||||
|
||||
**Problema: El combo siempre usa el último modelo (nivel gratis)**
|
||||
|
||||
**Solución:**
|
||||
1. Verifica la cuota de los modelos principales (Dashboard → Quota)
|
||||
2. Verifica que las API keys sean válidas (Dashboard → Providers)
|
||||
3. Verifica que no se hayan excedido los límites de presupuesto
|
||||
|
||||
**Problema: El combo cuesta más de lo esperado**
|
||||
|
||||
**Solución:**
|
||||
1. Dashboard → Analytics → Revisa el uso del combo
|
||||
2. Verifica si los modelos principales tienen cuota agotada
|
||||
3. Reordena los modelos (pon los más baratos primero)
|
||||
4. Establece límites de presupuesto
|
||||
|
||||
---
|
||||
|
||||
## Relacionado
|
||||
|
||||
- [Enrutamiento inteligente](./smart-routing.md) - Cómo funciona el fallback automático
|
||||
- [Seguimiento de cuota](./quota-tracking.md) - Monitorea uso y costos
|
||||
@@ -0,0 +1,687 @@
|
||||
# Seguimiento de cuota y monitoreo de uso
|
||||
|
||||
Rastrea el consumo de tokens en tiempo real, monitorea los límites de cuota, estima costos y recibe alertas antes de quedarte sin recursos. Nunca desperdicies cuota de suscripción ni excedas los límites de presupuesto.
|
||||
|
||||
---
|
||||
|
||||
## Resumen
|
||||
|
||||
9Router proporciona un seguimiento de cuota integral para todos los proveedores:
|
||||
|
||||
- **Consumo de tokens en tiempo real** - Mira los tokens usados por solicitud
|
||||
- **Límites de cuota y restantes** - Rastrea el uso vs límites
|
||||
- **Cuenta regresiva de reinicio** - Sabe cuándo se refresca la cuota
|
||||
- **Estimación de costos** - Calcula el gasto para niveles de pago
|
||||
- **Reportes mensuales** - Analiza patrones de uso
|
||||
- **Alertas y notificaciones** - Recibe advertencias antes de los límites
|
||||
|
||||
---
|
||||
|
||||
## Resumen del dashboard
|
||||
|
||||
### Resumen de cuota
|
||||
|
||||
```
|
||||
Dashboard → Home → Quota Overview
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ Claude Code (cc/) │
|
||||
│ ████████████░░░░░░░░ 2.5h / 5h (50%) │
|
||||
│ Se reinicia en: 2h 30m │
|
||||
│ Costo: $0 (suscripción) │
|
||||
└─────────────────────────────────────────────┘
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ Gemini CLI (gc/) │
|
||||
│ ████████░░░░░░░░░░░░ 450 / 1000 (45%) │
|
||||
│ Reinicio diario en: 18h 30m │
|
||||
│ Mensual: 45K / 180K (25%) │
|
||||
│ Costo: $0 (nivel gratis) │
|
||||
└─────────────────────────────────────────────┘
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ GLM-4.7 (glm/) │
|
||||
│ ██████████████░░░░░░ 7M / 10M tokens (70%) │
|
||||
│ Se reinicia: Diario 10:00 AM (en 5h 35m) │
|
||||
│ Costo hoy: $4.20 │
|
||||
└─────────────────────────────────────────────┘
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ MiniMax M2.1 (minimax/) │
|
||||
│ ████████████████░░░░ 4M / 5M tokens (80%) │
|
||||
│ Ventana rolling 5h │
|
||||
│ Costo (5h): $0.80 │
|
||||
└─────────────────────────────────────────────┘
|
||||
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ iFlow (if/) │
|
||||
│ ████████████████████ Ilimitado │
|
||||
│ Costo: $0 (gratis para siempre) │
|
||||
└─────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Consumo de tokens en tiempo real
|
||||
|
||||
### Seguimiento por solicitud
|
||||
|
||||
Cada solicitud muestra el uso detallado de tokens:
|
||||
|
||||
```
|
||||
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 (cuota de suscripción)
|
||||
Duration: 3.2s
|
||||
Status: ✅ Success
|
||||
```
|
||||
|
||||
### Monitor de uso en vivo
|
||||
|
||||
```
|
||||
Dashboard → Live Monitor
|
||||
|
||||
Solicitud actual:
|
||||
Model: glm/glm-4.7
|
||||
Tokens transmitidos: 450 / ~800 estimados
|
||||
Costo hasta ahora: $0.0009
|
||||
Duración: 1.8s
|
||||
```
|
||||
|
||||
### Desglose de tokens por modelo
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Token Usage
|
||||
|
||||
Hoy (4 feb 2026):
|
||||
cc/claude-opus-4-5: 15M tokens ($0, suscripción)
|
||||
glm/glm-4.7: 8M tokens ($4.80)
|
||||
if/kimi-k2-thinking: 3M tokens ($0, gratis)
|
||||
|
||||
Total: 26M tokens
|
||||
Costo: $4.80
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Límites de cuota y tiempos de reinicio
|
||||
|
||||
### Proveedores de suscripción
|
||||
|
||||
**Claude Code (Pro/Max)**
|
||||
```
|
||||
Tipo de cuota: Basado en tiempo (rolling 5 horas)
|
||||
Límite: 5 horas de uso
|
||||
Reinicio: Ventana rolling 5 horas + refresh semanal
|
||||
Seguimiento: Tiempo de uso por modelo
|
||||
|
||||
El dashboard muestra:
|
||||
Opus: 2.5h / 5h usados
|
||||
Sonnet: 1.2h / 5h usados
|
||||
Haiku: 0.8h / 5h usados
|
||||
|
||||
Reinicio semanal: Todos los lunes 00:00 UTC
|
||||
```
|
||||
|
||||
**OpenAI Codex (Plus/Pro)**
|
||||
```
|
||||
Tipo de cuota: Basado en tiempo (rolling 5 horas)
|
||||
Límite: 5 horas (Plus) / 10 horas (Pro)
|
||||
Reinicio: Ventana rolling 5 horas + refresh semanal
|
||||
|
||||
El dashboard muestra:
|
||||
GPT-5.2 Codex: 3.5h / 5h usados
|
||||
Se reinicia en: 1h 30m
|
||||
```
|
||||
|
||||
**Gemini CLI (GRATIS)**
|
||||
```
|
||||
Tipo de cuota: Conteo de solicitudes + tokens mensuales
|
||||
Límite diario: 1,000 solicitudes
|
||||
Límite mensual: 180,000 completados
|
||||
Reinicio: Diario 00:00 UTC + Mensual día 1
|
||||
|
||||
El dashboard muestra:
|
||||
Hoy: 450 / 1,000 solicitudes (45%)
|
||||
Este mes: 45K / 180K completados (25%)
|
||||
Reinicio diario en: 18h 30m
|
||||
Reinicio mensual en: 26 días
|
||||
```
|
||||
|
||||
**GitHub Copilot**
|
||||
```
|
||||
Tipo de cuota: Uso mensual
|
||||
Límite: Varía según el plan
|
||||
Reinicio: 1ro de cada mes
|
||||
|
||||
El dashboard muestra:
|
||||
Uso: 60% de la cuota mensual
|
||||
Se reinicia: 1 mar 2026 (en 25 días)
|
||||
```
|
||||
|
||||
### Proveedores baratos
|
||||
|
||||
**GLM-4.7**
|
||||
```
|
||||
Tipo de cuota: Límite diario de tokens
|
||||
Límite: 10M tokens/día (Coding Plan)
|
||||
Reinicio: Diario 10:00 AM hora de Beijing (UTC+8)
|
||||
|
||||
El dashboard muestra:
|
||||
Usados: 7M / 10M tokens (70%)
|
||||
Restantes: 3M tokens
|
||||
Se reinicia en: 5h 35m
|
||||
Costo hoy: $4.20
|
||||
```
|
||||
|
||||
**MiniMax M2.1**
|
||||
```
|
||||
Tipo de cuota: Ventana rolling 5 horas
|
||||
Límite: 5M tokens por 5 horas
|
||||
Reinicio: Ventana rolling continua
|
||||
|
||||
El dashboard muestra:
|
||||
Usados (5h): 4M / 5M tokens (80%)
|
||||
El uso más antiguo expira en: 45m
|
||||
Costo (5h): $0.80
|
||||
```
|
||||
|
||||
**Kimi K2**
|
||||
```
|
||||
Tipo de cuota: Suscripción mensual
|
||||
Límite: 10M tokens/mes ($9 plano)
|
||||
Reinicio: Mensual en la fecha de suscripción
|
||||
|
||||
El dashboard muestra:
|
||||
Usados: 6M / 10M tokens (60%)
|
||||
Se reinicia: 15 feb 2026 (en 11 días)
|
||||
Costo: $9/mes (pagado por adelantado)
|
||||
```
|
||||
|
||||
### Proveedores gratis
|
||||
|
||||
**iFlow / Qwen / Kiro**
|
||||
```
|
||||
Tipo de cuota: Ilimitado (con rate-limit)
|
||||
Límite: Sin límite duro
|
||||
Reinicio: N/A
|
||||
|
||||
El dashboard muestra:
|
||||
Usados hoy: 5M tokens
|
||||
Costo: $0 (gratis para siempre)
|
||||
Estado: ✅ Disponible
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Estimación de costos
|
||||
|
||||
### Seguimiento de costos en tiempo real
|
||||
|
||||
```
|
||||
Dashboard → Costs → Today
|
||||
|
||||
Proveedores de suscripción: $0
|
||||
Claude Code: 15M tokens ($0, incluido)
|
||||
Gemini CLI: 3M tokens ($0, nivel gratis)
|
||||
|
||||
Proveedores de pago: $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
|
||||
|
||||
Proveedores gratis: $0
|
||||
iFlow: 3M tokens ($0)
|
||||
|
||||
Total hoy: $4.80
|
||||
```
|
||||
|
||||
### Reporte de gasto mensual
|
||||
|
||||
```
|
||||
Dashboard → Costs → This Month (Febrero 2026)
|
||||
|
||||
Semana 1 (1-7 feb):
|
||||
Suscripción: $0 (80M tokens)
|
||||
Pago: $15.20 (25M tokens)
|
||||
Gratis: $0 (10M tokens)
|
||||
Total: $15.20
|
||||
|
||||
Semana 2 (8-14 feb):
|
||||
Suscripción: $0 (75M tokens)
|
||||
Pago: $12.80 (20M tokens)
|
||||
Gratis: $0 (8M tokens)
|
||||
Total: $12.80
|
||||
|
||||
Mes hasta la fecha: $28.00
|
||||
Proyectado (30 días): ~$120
|
||||
|
||||
Desglose por proveedor:
|
||||
GLM-4.7: $22.00 (78%)
|
||||
MiniMax M2.1: $6.00 (22%)
|
||||
|
||||
Costo promedio por 1M tokens: $0.62
|
||||
Ahorros vs ChatGPT API: 97% ($4,000 → $120)
|
||||
```
|
||||
|
||||
### Proyección de costos
|
||||
|
||||
```
|
||||
Dashboard → Costs → Projections
|
||||
|
||||
Basado en uso de los últimos 7 días:
|
||||
Promedio diario: 50M tokens
|
||||
Costo diario: $4.50
|
||||
|
||||
Proyección mensual:
|
||||
Tokens: 1,500M (1.5B)
|
||||
Costo: $135
|
||||
|
||||
Desglose:
|
||||
Suscripción: 900M tokens ($0)
|
||||
GLM-4.7: 450M tokens ($90)
|
||||
MiniMax: 120M tokens ($24)
|
||||
Gratis: 30M tokens ($0)
|
||||
|
||||
Estado del presupuesto:
|
||||
Límite diario: $5 → 90% usado hoy
|
||||
Límite mensual: $150 → 90% proyectado
|
||||
⚠️ Advertencia: Puede exceder el presupuesto mensual
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Dashboard de uso
|
||||
|
||||
### Estadísticas generales
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Overview
|
||||
|
||||
Hoy (4 feb 2026):
|
||||
Solicitudes: 1,234
|
||||
Tokens: 26M
|
||||
Costo: $4.80
|
||||
Tiempo promedio de respuesta: 2.1s
|
||||
|
||||
Esta semana:
|
||||
Solicitudes: 8,456
|
||||
Tokens: 180M
|
||||
Costo: $28.00
|
||||
Tasa de éxito: 99.2%
|
||||
|
||||
Este mes:
|
||||
Solicitudes: 15,234
|
||||
Tokens: 320M
|
||||
Costo: $52.00
|
||||
Modelo principal: cc/claude-opus-4-5 (45%)
|
||||
```
|
||||
|
||||
### Uso por modelo
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Models
|
||||
|
||||
Modelos principales (este mes):
|
||||
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%)
|
||||
|
||||
Desglose de costos:
|
||||
cc/claude-opus: $0 (suscripción)
|
||||
glm/glm-4.7: $45.00
|
||||
if/kimi-k2-thinking: $0 (gratis)
|
||||
minimax/MiniMax-M2.1: $7.00
|
||||
gc/gemini-3-flash: $0 (gratis)
|
||||
```
|
||||
|
||||
### Uso por tiempo
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Timeline
|
||||
|
||||
Uso por hora (hoy):
|
||||
00:00 - 01:00: 0.5M tokens
|
||||
01:00 - 02:00: 0.2M tokens
|
||||
...
|
||||
08:00 - 09:00: 3.2M tokens (pico)
|
||||
09:00 - 10:00: 2.8M tokens
|
||||
...
|
||||
23:00 - 00:00: 0.8M tokens
|
||||
|
||||
Horas pico: 08:00 - 12:00 (codificación matutina)
|
||||
Horas bajas: 00:00 - 06:00 (noche)
|
||||
```
|
||||
|
||||
### Uso por combo
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Combos
|
||||
|
||||
premium-coding:
|
||||
Solicitudes: 456
|
||||
Tokens: 12M
|
||||
Costo: $2.40
|
||||
|
||||
Desglose:
|
||||
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:
|
||||
Solicitudes: 234
|
||||
Tokens: 6M
|
||||
Costo: $1.20
|
||||
|
||||
Desglose:
|
||||
glm/glm-4.7: 4M tokens (67%, $2.40)
|
||||
if/kimi-k2-thinking: 2M tokens (33%, $0)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Alertas y notificaciones
|
||||
|
||||
### Alertas de cuota
|
||||
|
||||
```
|
||||
Dashboard → Settings → Alerts
|
||||
|
||||
Advertencias de cuota:
|
||||
✅ Alerta al 80% de cuota usada
|
||||
✅ Alerta al 90% de cuota usada
|
||||
✅ Alerta cuando la cuota se agota
|
||||
✅ Notificar cuando la cuota se reinicia
|
||||
|
||||
Entrega:
|
||||
✅ Notificación del dashboard
|
||||
✅ Email (opcional)
|
||||
✅ Webhook (opcional)
|
||||
```
|
||||
|
||||
**Ejemplo de notificaciones:**
|
||||
```
|
||||
⚠️ Cuota de Claude Code 80% usada
|
||||
2.5h restantes (se reinicia en 1h 30m)
|
||||
|
||||
⚠️ Cuota de GLM-4.7 90% usada
|
||||
1M tokens restantes (se reinicia en 5h)
|
||||
|
||||
✅ Cuota de Gemini CLI reiniciada
|
||||
1,000 solicitudes disponibles (límite diario)
|
||||
```
|
||||
|
||||
### Alertas de presupuesto
|
||||
|
||||
```
|
||||
Dashboard → Settings → Budget Alerts
|
||||
|
||||
Presupuesto diario: $5
|
||||
✅ Alerta al 80% ($4)
|
||||
✅ Alerta al 100% ($5)
|
||||
✅ Cambio automático al nivel gratis cuando se excede
|
||||
|
||||
Presupuesto mensual: $150
|
||||
✅ Alerta al 50% ($75)
|
||||
✅ Alerta al 80% ($120)
|
||||
✅ Alerta al 100% ($150)
|
||||
```
|
||||
|
||||
**Ejemplo de notificaciones:**
|
||||
```
|
||||
⚠️ Presupuesto diario 80% usado
|
||||
$4.00 / $5.00 gastados hoy
|
||||
|
||||
⚠️ Presupuesto mensual 50% alcanzado
|
||||
$75 / $150 gastados este mes
|
||||
Proyectado: $135 (dentro del presupuesto)
|
||||
|
||||
🚨 Presupuesto diario excedido
|
||||
$5.20 / $5.00 gastados hoy
|
||||
Cambio automático al nivel gratis
|
||||
```
|
||||
|
||||
### Detección de anomalías de costo
|
||||
|
||||
```
|
||||
Dashboard → Settings → Anomaly Detection
|
||||
|
||||
✅ Detectar patrones de gasto inusuales
|
||||
✅ Alerta en picos de costo (>2× promedio diario)
|
||||
✅ Advertencia en patrones de agotamiento de cuota
|
||||
|
||||
Ejemplo de alerta:
|
||||
⚠️ Pico de costo detectado
|
||||
Hoy: $12.50 (2.5× promedio diario)
|
||||
Razón: Alto uso de GLM-4.7 (20M tokens)
|
||||
Sugerencia: Verifica si los modelos principales tienen cuota agotada
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
### 1. Monitorea la cuota diariamente
|
||||
|
||||
```
|
||||
Rutina diaria:
|
||||
1. Revisa el resumen de cuota del dashboard (30 segundos)
|
||||
2. Revisa los tiempos de reinicio
|
||||
3. Planifica el uso según la disponibilidad de cuota
|
||||
```
|
||||
|
||||
**Ejemplo:**
|
||||
```
|
||||
Revisión matutina:
|
||||
✅ Claude Code: 5h disponibles (reinicio fresco)
|
||||
✅ Gemini CLI: 1K solicitudes disponibles
|
||||
⚠️ GLM-4.7: 2M tokens restantes (se reinicia 10AM)
|
||||
|
||||
Acción: Usar Claude Code para el trabajo matutino
|
||||
```
|
||||
|
||||
### 2. Establece límites de presupuesto
|
||||
|
||||
```
|
||||
Dashboard → Settings → Budget:
|
||||
Diario: $5 (previene gastos excesivos)
|
||||
Mensual: $150 (alinea con el presupuesto)
|
||||
```
|
||||
|
||||
**Resultado**: Cambio automático al nivel gratis cuando se alcanza el límite.
|
||||
|
||||
### 3. Optimiza el uso de combos
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Combos:
|
||||
Revisa qué modelos se usan más
|
||||
Ajusta el orden del combo para minimizar costos
|
||||
```
|
||||
|
||||
**Ejemplo:**
|
||||
```
|
||||
Actual: cc/claude-opus → glm/glm-4.7
|
||||
80% vía Claude (bueno)
|
||||
20% vía GLM ($12/mes)
|
||||
|
||||
Optimizado: gc/gemini-3-flash → cc/claude-opus → glm/glm-4.7
|
||||
50% vía Gemini (gratis)
|
||||
40% vía Claude (suscripción)
|
||||
10% vía GLM ($6/mes)
|
||||
|
||||
Ahorros: $6/mes
|
||||
```
|
||||
|
||||
### 4. Rastrea los tiempos de reinicio
|
||||
|
||||
```
|
||||
Dashboard → Quota → Reset Schedule:
|
||||
Claude Code: 5h rolling + Semanal lunes
|
||||
Gemini CLI: Diario 00:00 UTC + Mensual día 1
|
||||
GLM-4.7: Diario 10:00 AM hora Beijing
|
||||
MiniMax: Ventana rolling 5h
|
||||
```
|
||||
|
||||
**Estrategia**: Usa proveedores cuando la cuota esté fresca.
|
||||
|
||||
### 5. Revisa los reportes mensuales
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Monthly Report:
|
||||
Total de tokens: 1.5B
|
||||
Costo total: $120
|
||||
Ahorros: 97% vs ChatGPT API
|
||||
|
||||
Insights:
|
||||
- 60% de uso vía suscripciones ($0)
|
||||
- 30% vía GLM ($90)
|
||||
- 10% vía nivel gratis ($0)
|
||||
|
||||
Optimización:
|
||||
- Aumentar el uso de Gemini CLI (gratis)
|
||||
- Reducir el uso de GLM (costoso)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Acceso por API
|
||||
|
||||
### Obtener estado de cuota
|
||||
|
||||
```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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Obtener estadísticas de uso
|
||||
|
||||
```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
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
**Problema: La cuota muestra 0% pero las solicitudes fallan**
|
||||
|
||||
**Solución:**
|
||||
1. Verifica la conexión del proveedor (Dashboard → Providers)
|
||||
2. Verifica que las API keys sean válidas
|
||||
3. Verifica si el proveedor está caído (página de estado)
|
||||
4. Intenta reconectar los proveedores OAuth
|
||||
|
||||
**Problema: Estimación de costos incorrecta**
|
||||
|
||||
**Solución:**
|
||||
1. Dashboard → Settings → Pricing
|
||||
2. Verifica que el precio por proveedor coincida con las tarifas actuales
|
||||
3. Actualiza el precio si el proveedor cambió las tarifas
|
||||
4. Contacta a soporte si la discrepancia persiste
|
||||
|
||||
**Problema: El tiempo de reinicio no se actualiza**
|
||||
|
||||
**Solución:**
|
||||
1. Refresca el dashboard (F5)
|
||||
2. Verifica que la hora del sistema sea correcta
|
||||
3. Verifica la configuración de zona horaria
|
||||
4. Reinicia 9Router si el problema persiste
|
||||
|
||||
**Problema: No se reciben alertas**
|
||||
|
||||
**Solución:**
|
||||
1. Dashboard → Settings → Alerts
|
||||
2. Verifica que la dirección de email sea correcta
|
||||
3. Revisa la carpeta de spam
|
||||
4. Prueba la notificación (botón Send Test)
|
||||
|
||||
---
|
||||
|
||||
## Relacionado
|
||||
|
||||
- [Enrutamiento inteligente](./smart-routing.md) - Fallback automático según cuota
|
||||
- [Combos](./combos.md) - Crea cadenas de fallback personalizadas
|
||||
@@ -0,0 +1,407 @@
|
||||
# Enrutamiento inteligente y fallback automático
|
||||
|
||||
9Router enruta automáticamente tus solicitudes a través del mejor proveedor disponible usando un sistema de fallback de 3 niveles. Nunca dejes de codificar debido a límites de cuota o rate-limiting.
|
||||
|
||||
---
|
||||
|
||||
## Cómo funciona
|
||||
|
||||
9Router usa enrutamiento inteligente para maximizar tus suscripciones existentes, minimizar costos y garantizar disponibilidad 24/7:
|
||||
|
||||
```
|
||||
Solicitud → 9Router → Verificar Nivel 1 (Suscripción)
|
||||
↓ cuota agotada
|
||||
Verificar Nivel 2 (Barato)
|
||||
↓ límite de presupuesto
|
||||
Verificar Nivel 3 (Gratis)
|
||||
↓
|
||||
Respuesta
|
||||
```
|
||||
|
||||
### Sistema de fallback de 3 niveles
|
||||
|
||||
**Nivel 1: SUSCRIPCIÓN (Primario)**
|
||||
- Claude Code (Pro/Max)
|
||||
- OpenAI Codex (Plus/Pro)
|
||||
- Gemini CLI (GRATIS 180K/mes)
|
||||
- GitHub Copilot
|
||||
- Antigravity (Google)
|
||||
|
||||
**Objetivo**: Maximizar el valor de las suscripciones que ya pagas.
|
||||
|
||||
**Nivel 2: BARATO (Respaldo)**
|
||||
- GLM-4.7 ($0.60/1M entrada)
|
||||
- MiniMax M2.1 ($0.20/1M entrada)
|
||||
- Kimi K2 ($9/mes plano)
|
||||
|
||||
**Objetivo**: Respaldo ultra-barato cuando se agota la cuota de suscripción (~90% más barato que ChatGPT API).
|
||||
|
||||
**Nivel 3: GRATIS (Emergencia)**
|
||||
- iFlow (8 modelos)
|
||||
- Qwen (3 modelos)
|
||||
- Kiro (Claude GRATIS)
|
||||
|
||||
**Objetivo**: Fallback de cero costo para codificación ilimitada.
|
||||
|
||||
---
|
||||
|
||||
## Cambio automático
|
||||
|
||||
9Router monitorea la cuota en tiempo real y cambia de proveedor automáticamente:
|
||||
|
||||
### Escenario 1: Cuota de suscripción agotada
|
||||
|
||||
```
|
||||
Solicitud del usuario → cc/claude-opus-4-5
|
||||
↓ cuota agotada (límite de 5 horas alcanzado)
|
||||
Cambio automático → glm/glm-4.7
|
||||
↓ cuota diaria agotada
|
||||
Cambio automático → minimax/MiniMax-M2.1
|
||||
↓ cuota de 5 horas agotada
|
||||
Cambio automático → if/kimi-k2-thinking (GRATIS)
|
||||
↓
|
||||
Respuesta entregada ✅
|
||||
```
|
||||
|
||||
**Resultado**: Cero tiempo de inactividad, experiencia sin interrupciones.
|
||||
|
||||
### Escenario 2: Rate limiting
|
||||
|
||||
```
|
||||
Solicitud del usuario → cx/gpt-5.2-codex
|
||||
↓ rate limited (demasiadas solicitudes)
|
||||
Cambio automático → glm/glm-4.7
|
||||
↓
|
||||
Respuesta entregada ✅
|
||||
```
|
||||
|
||||
### Escenario 3: Proveedor no disponible
|
||||
|
||||
```
|
||||
Solicitud del usuario → cc/claude-opus-4-5
|
||||
↓ error del proveedor (503)
|
||||
Cambio automático → siguiente modelo disponible
|
||||
↓
|
||||
Respuesta entregada ✅
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Lógica de selección de modelo
|
||||
|
||||
9Router selecciona el mejor modelo según:
|
||||
|
||||
1. **Disponibilidad de cuota** - Verifica si el proveedor tiene cuota restante
|
||||
2. **Nivel de costo** - Prefiere suscripción → barato → gratis
|
||||
3. **Tiempo de reinicio** - Considera cuándo se reinicia la cuota
|
||||
4. **Salud del proveedor** - Omite proveedores con errores
|
||||
|
||||
### Ejemplo de orden de prioridad
|
||||
|
||||
Para una solicitud a `cc/claude-opus-4-5`:
|
||||
|
||||
```
|
||||
1. Verificar cuota de Claude Code
|
||||
✅ Disponible → Usa cc/claude-opus-4-5
|
||||
❌ Agotada → Continúa al paso 2
|
||||
|
||||
2. Verificar nivel de fallback (si está configurado)
|
||||
✅ Cuota de GLM disponible → Usa glm/glm-4.7
|
||||
❌ Agotada → Continúa al paso 3
|
||||
|
||||
3. Verificar nivel gratis
|
||||
✅ iFlow disponible → Usa if/kimi-k2-thinking
|
||||
❌ Todo agotado → Devuelve error de cuota
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Opciones de configuración
|
||||
|
||||
### Configuración del dashboard
|
||||
|
||||
**1. Habilitar/Deshabilitar fallback automático**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Smart Routing
|
||||
→ Toggle "Auto Fallback" ON/OFF
|
||||
```
|
||||
|
||||
- **ON** (por defecto): Cambio automático de nivel
|
||||
- **OFF**: Modo estricto, devuelve error si el modelo principal no está disponible
|
||||
|
||||
**2. Establecer límites de presupuesto**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Budget Control
|
||||
→ Límite diario: $5
|
||||
→ Límite mensual: $50
|
||||
```
|
||||
|
||||
Cuando se alcanza el presupuesto, 9Router cambia automáticamente al nivel gratis.
|
||||
|
||||
**3. Configurar el orden de fallback**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Fallback Priority
|
||||
→ Arrastra para reordenar proveedores dentro de cada nivel
|
||||
```
|
||||
|
||||
Ejemplo de orden personalizado:
|
||||
```
|
||||
Nivel 1: Gemini CLI → Claude Code → Codex
|
||||
Nivel 2: MiniMax → GLM → Kimi
|
||||
Nivel 3: iFlow → Kiro → Qwen
|
||||
```
|
||||
|
||||
**4. Notificaciones de reinicio de cuota**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Notifications
|
||||
→ Email cuando se reinicia la cuota
|
||||
→ Alerta cuando se usa 80% de cuota
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Ejemplos
|
||||
|
||||
### Ejemplo 1: Fallback automático básico
|
||||
|
||||
**Configuración:**
|
||||
```
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
Fallback: Auto (3 niveles por defecto)
|
||||
```
|
||||
|
||||
**Comportamiento:**
|
||||
```
|
||||
Mañana (cuota fresca):
|
||||
Solicitud → cc/claude-opus-4-5 ✅
|
||||
|
||||
Tarde (cuota agotada):
|
||||
Solicitud → glm/glm-4.7 ✅ (cambio automático)
|
||||
|
||||
Noche (cuota de GLM agotada):
|
||||
Solicitud → minimax/MiniMax-M2.1 ✅ (cambio automático)
|
||||
|
||||
Madrugada (toda la cuota de pago agotada):
|
||||
Solicitud → if/kimi-k2-thinking ✅ (nivel gratis)
|
||||
```
|
||||
|
||||
**Costo**: ~$5-10/mes extra (en su mayoría cubierto por la suscripción).
|
||||
|
||||
### Ejemplo 2: Enrutamiento consciente del presupuesto
|
||||
|
||||
**Configuración:**
|
||||
```
|
||||
Dashboard → Settings:
|
||||
Presupuesto diario: $2
|
||||
Presupuesto mensual: $20
|
||||
Fallback: Habilitado
|
||||
```
|
||||
|
||||
**Comportamiento:**
|
||||
```
|
||||
Día 1-15 (dentro del presupuesto):
|
||||
Solicitudes → glm/glm-4.7 (nivel barato)
|
||||
Costo: $1.50/día
|
||||
|
||||
Día 16 (presupuesto alcanzado):
|
||||
Solicitudes → if/kimi-k2-thinking (nivel gratis)
|
||||
Costo: $0
|
||||
|
||||
Mes siguiente (presupuesto se reinicia):
|
||||
Solicitudes → glm/glm-4.7 nuevamente
|
||||
```
|
||||
|
||||
**Resultado**: Nunca excede $20/mes, siempre disponible.
|
||||
|
||||
### Ejemplo 3: Modo solo suscripción
|
||||
|
||||
**Configuración:**
|
||||
```
|
||||
Dashboard → Settings:
|
||||
Fallback automático: OFF
|
||||
Modo estricto: ON
|
||||
```
|
||||
|
||||
**Comportamiento:**
|
||||
```
|
||||
Solicitud → cc/claude-opus-4-5
|
||||
✅ Cuota disponible → Éxito
|
||||
❌ Cuota agotada → Devuelve error (sin fallback)
|
||||
```
|
||||
|
||||
**Caso de uso**: Cuando solo quieres usar suscripciones de pago, sin costos extras.
|
||||
|
||||
### Ejemplo 4: Modo solo gratis
|
||||
|
||||
**Configuración:**
|
||||
```
|
||||
Model: if/kimi-k2-thinking
|
||||
Fallback: qw/qwen3-coder-plus → kr/claude-sonnet-4.5
|
||||
```
|
||||
|
||||
**Comportamiento:**
|
||||
```
|
||||
Todas las solicitudes → Solo nivel gratis
|
||||
Costo: $0 para siempre
|
||||
```
|
||||
|
||||
**Caso de uso**: Proyectos personales, aprendizaje, experimentación.
|
||||
|
||||
---
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
### 1. Maximiza el valor de la suscripción
|
||||
|
||||
```
|
||||
Estrategia:
|
||||
- Establece modelos de suscripción como Nivel 1
|
||||
- Monitorea el uso de cuota en el dashboard
|
||||
- Usa el nivel barato solo cuando la suscripción se agote
|
||||
```
|
||||
|
||||
**Ejemplo de combo:**
|
||||
```
|
||||
cc/claude-opus-4-5 → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### 2. Optimiza por costo
|
||||
|
||||
```
|
||||
Estrategia:
|
||||
- Usa el nivel gratis de Gemini CLI primero (180K/mes)
|
||||
- Fallback a GLM/MiniMax (ultra-baratos)
|
||||
- Emergencia: iFlow (gratis)
|
||||
```
|
||||
|
||||
**Ejemplo de combo:**
|
||||
```
|
||||
gc/gemini-3-flash-preview → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### 3. Optimiza por calidad
|
||||
|
||||
```
|
||||
Estrategia:
|
||||
- Usa los mejores modelos (Claude Opus, GPT-5.2)
|
||||
- Fallback a modelos baratos buenos (GLM-4.7)
|
||||
- Último recurso: Nivel gratis
|
||||
```
|
||||
|
||||
**Ejemplo de combo:**
|
||||
```
|
||||
cc/claude-opus-4-5 → cx/gpt-5.2-codex → glm/glm-4.7
|
||||
```
|
||||
|
||||
### 4. Disponibilidad 24/7
|
||||
|
||||
```
|
||||
Estrategia:
|
||||
- Siempre incluye el nivel gratis en el fallback
|
||||
- Monitorea los tiempos de reinicio de cuota
|
||||
- Distribuye el uso entre proveedores
|
||||
```
|
||||
|
||||
**Ejemplo de combo:**
|
||||
```
|
||||
cc/claude-opus-4-5 → glm/glm-4.7 → minimax/MiniMax-M2.1 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
**Resultado**: Nunca te quedas sin cuota, codifica en cualquier momento.
|
||||
|
||||
---
|
||||
|
||||
## Estrategia de reinicio de cuota
|
||||
|
||||
Planifica tu uso según los tiempos de reinicio de cuota:
|
||||
|
||||
| Proveedor | Reinicio de cuota | Estrategia |
|
||||
|----------|-------------|----------|
|
||||
| **Claude Code** | 5 horas + semanal | Usar en la mañana, cuota fresca |
|
||||
| **Codex** | 5 horas + semanal | Usar después de cuota de Claude |
|
||||
| **Gemini CLI** | Diario (1K) + Mensual (180K) | Usar durante el día |
|
||||
| **GLM-4.7** | Diario 10:00 AM | Usar en la noche, se reinicia al día siguiente |
|
||||
| **MiniMax M2.1** | Rolling 5 horas | Usar cuando sea, rastrea ventana rolling |
|
||||
| **iFlow/Qwen/Kiro** | Sin límite | Respaldo de emergencia |
|
||||
|
||||
**Ejemplo de rutina diaria:**
|
||||
```
|
||||
08:00 - 13:00: Claude Code (cuota fresca 5h)
|
||||
13:00 - 18:00: Gemini CLI (cuota 1K/día)
|
||||
18:00 - 22:00: GLM-4.7 (barato, se reinicia 10AM)
|
||||
22:00 - 08:00: MiniMax o iFlow (rolling 5h o gratis)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Monitoreo y alertas
|
||||
|
||||
### Rastreador de cuota del dashboard
|
||||
|
||||
```
|
||||
Dashboard → Quota Overview:
|
||||
Claude Code: 2.5h / 5h restantes (50%)
|
||||
Gemini CLI: 450 / 1000 solicitudes hoy
|
||||
GLM-4.7: 5M / 10M tokens (se reinicia en 8h)
|
||||
MiniMax: 3M / 5M tokens (rolling 5h)
|
||||
```
|
||||
|
||||
### Notificaciones en tiempo real
|
||||
|
||||
```
|
||||
Dashboard → Notifications:
|
||||
⚠️ Cuota de Claude Code 80% usada (1h restante)
|
||||
✅ Cuota de GLM-4.7 reiniciada (10M tokens disponibles)
|
||||
💰 Presupuesto diario 50% usado ($2.50 / $5)
|
||||
```
|
||||
|
||||
### Analítica de uso
|
||||
|
||||
```
|
||||
Dashboard → Analytics:
|
||||
Hoy: 50M tokens
|
||||
- 30M vía Claude Code (suscripción)
|
||||
- 15M vía GLM-4.7 ($9)
|
||||
- 5M vía iFlow (gratis)
|
||||
|
||||
Costo: $9 (vs $1000 en ChatGPT API)
|
||||
Ahorros: 99%
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
**Problema: "All providers quota exhausted"**
|
||||
|
||||
**Solución:**
|
||||
1. Verifica el rastreador de cuota del dashboard
|
||||
2. Espera el reinicio de cuota (mira la cuenta regresiva)
|
||||
3. Agrega el nivel gratis a la cadena de fallback
|
||||
4. O aumenta el límite de presupuesto
|
||||
|
||||
**Problema: "Demasiados cambios de fallback"**
|
||||
|
||||
**Solución:**
|
||||
1. Verifica si el proveedor principal está caído
|
||||
2. Aumenta los límites de cuota (mejora la suscripción)
|
||||
3. Usa un modelo principal más barato (GLM en lugar de Claude)
|
||||
|
||||
**Problema: "Costos inesperados"**
|
||||
|
||||
**Solución:**
|
||||
1. Dashboard → Analytics → Revisa el uso
|
||||
2. Establece límites de presupuesto diarios/mensuales
|
||||
3. Cambia al nivel gratis para tareas no críticas
|
||||
4. Usa combos con fallback gratis
|
||||
|
||||
---
|
||||
|
||||
## Relacionado
|
||||
|
||||
- [Combos](./combos.md) - Crea cadenas de fallback personalizadas
|
||||
- [Seguimiento de cuota](./quota-tracking.md) - Monitorea uso y costos
|
||||
@@ -0,0 +1,478 @@
|
||||
# Instalación
|
||||
|
||||
Guía detallada de instalación de 9Router con consejos de solución de problemas.
|
||||
|
||||
---
|
||||
|
||||
## Requisitos
|
||||
|
||||
### Requisitos del sistema
|
||||
|
||||
- **Node.js**: Versión 20.0.0 o superior
|
||||
- **npm**: Versión 10.0.0 o superior (viene con Node.js)
|
||||
- **OS**: macOS, Linux, Windows (WSL recomendado)
|
||||
- **Espacio en disco**: ~200MB para la instalación
|
||||
|
||||
### Verifica tu versión
|
||||
|
||||
```bash
|
||||
node --version
|
||||
# Debería mostrar v20.x.x o superior
|
||||
|
||||
npm --version
|
||||
# Debería mostrar 10.x.x o superior
|
||||
```
|
||||
|
||||
**¿No tienes Node.js?** Instálalo desde [nodejs.org](https://nodejs.org/)
|
||||
|
||||
---
|
||||
|
||||
## Métodos de instalación
|
||||
|
||||
### Método 1: Instalación global (Recomendado)
|
||||
|
||||
Instala 9Router globalmente para usar desde cualquier lugar:
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
**Iniciar 9Router:**
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
**Beneficios:**
|
||||
- ✅ Ejecuta desde cualquier directorio
|
||||
- ✅ Comando simple: `9router`
|
||||
- ✅ Auto-actualizaciones con `npm update -g 9router`
|
||||
|
||||
### Método 2: Instalación local
|
||||
|
||||
Instala en un proyecto específico:
|
||||
|
||||
```bash
|
||||
mkdir my-9router
|
||||
cd my-9router
|
||||
npm install 9router
|
||||
```
|
||||
|
||||
**Iniciar 9Router:**
|
||||
|
||||
```bash
|
||||
npx 9router
|
||||
```
|
||||
|
||||
**Beneficios:**
|
||||
- ✅ Aislado por proyecto
|
||||
- ✅ Control de versiones por proyecto
|
||||
- ✅ Sin contaminación del namespace global
|
||||
|
||||
### Método 3: Desde el código fuente (Desarrollo)
|
||||
|
||||
Clona y compila desde GitHub:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
npm install
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
**Beneficios:**
|
||||
- ✅ Últimas características de desarrollo
|
||||
- ✅ Contribuir al desarrollo
|
||||
- ✅ Modificaciones personalizadas
|
||||
|
||||
---
|
||||
|
||||
## Primera ejecución
|
||||
|
||||
### Iniciar el servidor
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
**Qué sucede:**
|
||||
1. El servidor inicia en `http://localhost:20128`
|
||||
2. El dashboard se abre automáticamente en el navegador
|
||||
3. Se crea el directorio de datos en `~/.9router`
|
||||
4. API key generada automáticamente
|
||||
|
||||
### Login del dashboard
|
||||
|
||||
**Credenciales por defecto:**
|
||||
- Contraseña: `123456`
|
||||
|
||||
**⚠️ Cambia la contraseña inmediatamente:**
|
||||
1. Inicia sesión en el dashboard
|
||||
2. Settings → Change Password
|
||||
3. Usa una contraseña fuerte
|
||||
|
||||
### Obtén tu API key
|
||||
|
||||
```
|
||||
Dashboard → Settings → API Keys
|
||||
→ Copia tu API key
|
||||
→ Úsala en herramientas CLI
|
||||
```
|
||||
|
||||
**Ejemplo de formato de API key:**
|
||||
```
|
||||
9r_1234567890abcdef1234567890abcdef
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Verificar la instalación
|
||||
|
||||
### Verifica el estado del servidor
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/health
|
||||
```
|
||||
|
||||
**Respuesta esperada:**
|
||||
```json
|
||||
{
|
||||
"status": "ok",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
### Lista los modelos disponibles
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/v1/models \
|
||||
-H "Authorization: Bearer your-api-key"
|
||||
```
|
||||
|
||||
**Respuesta esperada:**
|
||||
```json
|
||||
{
|
||||
"object": "list",
|
||||
"data": [
|
||||
{
|
||||
"id": "cc/claude-opus-4-5-20251101",
|
||||
"object": "model",
|
||||
"created": 1234567890,
|
||||
"owned_by": "claude-code"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Prueba el chat completion
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/v1/chat/completions \
|
||||
-H "Authorization: Bearer your-api-key" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"model": "cc/claude-opus-4-5-20251101",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello!"}
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configuración
|
||||
|
||||
### Variables de entorno
|
||||
|
||||
Crea un archivo `.env` o establece variables de entorno:
|
||||
|
||||
```bash
|
||||
# Security (REQUIRED in production)
|
||||
export JWT_SECRET="your-secure-secret-change-this"
|
||||
export INITIAL_PASSWORD="your-password"
|
||||
|
||||
# Storage
|
||||
export DATA_DIR="~/.9router"
|
||||
|
||||
# Server
|
||||
export PORT="20128"
|
||||
export NODE_ENV="production"
|
||||
|
||||
# Logging
|
||||
export ENABLE_REQUEST_LOGS="false"
|
||||
```
|
||||
|
||||
### Directorio de datos
|
||||
|
||||
**Ubicación por defecto:** `~/.9router`
|
||||
|
||||
**Contenido:**
|
||||
```
|
||||
~/.9router/
|
||||
├── db.json # Database (providers, combos, usage)
|
||||
├── api-keys.json # API keys
|
||||
└── logs/ # Request logs (if enabled)
|
||||
```
|
||||
|
||||
**Cambiar ubicación:**
|
||||
|
||||
```bash
|
||||
export DATA_DIR="/custom/path"
|
||||
9router
|
||||
```
|
||||
|
||||
### Configuración de puerto
|
||||
|
||||
**Puerto por defecto:** `20128`
|
||||
|
||||
**Cambiar puerto:**
|
||||
|
||||
```bash
|
||||
export PORT="3000"
|
||||
9router
|
||||
```
|
||||
|
||||
**O usa la línea de comandos:**
|
||||
|
||||
```bash
|
||||
9router --port 3000
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### Puerto ya en uso
|
||||
|
||||
**Error:**
|
||||
```
|
||||
Error: listen EADDRINUSE: address already in use :::20128
|
||||
```
|
||||
|
||||
**Solución 1: Mata el proceso existente**
|
||||
|
||||
```bash
|
||||
# Encuentra proceso usando el puerto 20128
|
||||
lsof -i :20128
|
||||
|
||||
# Mata el proceso
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
**Solución 2: Usa otro puerto**
|
||||
|
||||
```bash
|
||||
9router --port 3000
|
||||
```
|
||||
|
||||
### Permiso denegado
|
||||
|
||||
**Error:**
|
||||
```
|
||||
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/9router'
|
||||
```
|
||||
|
||||
**Solución: Usa sudo (no recomendado) o corrige los permisos de npm**
|
||||
|
||||
```bash
|
||||
# Corregir permisos de npm (recomendado)
|
||||
mkdir ~/.npm-global
|
||||
npm config set prefix '~/.npm-global'
|
||||
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
|
||||
# Luego instalar nuevamente
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
### Versión de Node.js muy antigua
|
||||
|
||||
**Error:**
|
||||
```
|
||||
Error: The engine "node" is incompatible with this module
|
||||
```
|
||||
|
||||
**Solución: Actualizar Node.js**
|
||||
|
||||
```bash
|
||||
# Usando nvm (recomendado)
|
||||
nvm install 20
|
||||
nvm use 20
|
||||
|
||||
# O descargar desde nodejs.org
|
||||
```
|
||||
|
||||
### El dashboard no se abre
|
||||
|
||||
**Problema:** El dashboard no se abre automáticamente
|
||||
|
||||
**Solución 1: Abrir manualmente**
|
||||
|
||||
```
|
||||
http://localhost:20128
|
||||
```
|
||||
|
||||
**Solución 2: Verifica el firewall**
|
||||
|
||||
```bash
|
||||
# macOS: Permitir Node.js en System Preferences → Security
|
||||
# Linux: Verificar iptables
|
||||
# Windows: Verificar Windows Firewall
|
||||
```
|
||||
|
||||
### No se puede conectar a proveedores
|
||||
|
||||
**Problema:** El login OAuth falla o la API key es inválida
|
||||
|
||||
**Solución 1: Verifica la conexión a internet**
|
||||
|
||||
```bash
|
||||
ping google.com
|
||||
```
|
||||
|
||||
**Solución 2: Verifica el estado del proveedor**
|
||||
|
||||
- Claude Code: [status.anthropic.com](https://status.anthropic.com)
|
||||
- OpenAI: [status.openai.com](https://status.openai.com)
|
||||
- Gemini: [status.cloud.google.com](https://status.cloud.google.com)
|
||||
|
||||
**Solución 3: Regenera la API key**
|
||||
|
||||
```
|
||||
Dashboard → Provider → Disconnect → Reconnect
|
||||
```
|
||||
|
||||
### Uso alto de memoria
|
||||
|
||||
**Problema:** 9Router usa demasiada RAM
|
||||
|
||||
**Solución: Reinicia el servidor**
|
||||
|
||||
```bash
|
||||
# Detener
|
||||
pkill -f 9router
|
||||
|
||||
# Iniciar
|
||||
9router
|
||||
```
|
||||
|
||||
**O usa PM2 para auto-reinicio:**
|
||||
|
||||
```bash
|
||||
npm install -g pm2
|
||||
pm2 start 9router --name 9router
|
||||
pm2 save
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Opciones de despliegue
|
||||
|
||||
### Desarrollo local
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
9router
|
||||
```
|
||||
|
||||
**Caso de uso:** Codificación personal, pruebas
|
||||
|
||||
### Servidor VPS/Cloud
|
||||
|
||||
```bash
|
||||
# Instalar
|
||||
npm install -g 9router
|
||||
|
||||
# Configurar
|
||||
export JWT_SECRET="your-secure-secret"
|
||||
export INITIAL_PASSWORD="your-password"
|
||||
export NODE_ENV="production"
|
||||
|
||||
# Iniciar con PM2
|
||||
npm install -g pm2
|
||||
pm2 start 9router --name 9router
|
||||
pm2 save
|
||||
pm2 startup
|
||||
```
|
||||
|
||||
**Caso de uso:** Acceso de equipo, codificación remota
|
||||
|
||||
### Docker
|
||||
|
||||
```bash
|
||||
docker pull 9router/9router:latest
|
||||
|
||||
docker run -d \
|
||||
-p 20128:20128 \
|
||||
-e JWT_SECRET="your-secure-secret" \
|
||||
-e INITIAL_PASSWORD="your-password" \
|
||||
-v 9router-data:/root/.9router \
|
||||
--name 9router \
|
||||
9router/9router:latest
|
||||
```
|
||||
|
||||
**Caso de uso:** Despliegue containerizado, Kubernetes
|
||||
|
||||
### Proxy reverso (Nginx)
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name your-domain.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:20128;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
|
||||
# SSE support for streaming
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Caso de uso:** HTTPS, dominio personalizado, balanceo de carga
|
||||
|
||||
---
|
||||
|
||||
## Desinstalación
|
||||
|
||||
### Eliminar instalación global
|
||||
|
||||
```bash
|
||||
npm uninstall -g 9router
|
||||
```
|
||||
|
||||
### Eliminar el directorio de datos
|
||||
|
||||
```bash
|
||||
rm -rf ~/.9router
|
||||
```
|
||||
|
||||
### Eliminar la configuración
|
||||
|
||||
```bash
|
||||
# Eliminar variables de entorno del archivo de configuración del shell
|
||||
nano ~/.bashrc # o ~/.zshrc
|
||||
# Eliminar exports relacionados con 9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Próximos pasos
|
||||
|
||||
- [Guía para empezar](../getting-started.md) - Conecta proveedores y comienza a codificar
|
||||
- [Características](../features/) - Explora seguimiento de cuota, combos, despliegue
|
||||
- [Solución de problemas](../troubleshooting.md) - Resuelve problemas comunes
|
||||
|
||||
---
|
||||
|
||||
## ¿Necesitas ayuda?
|
||||
|
||||
- **Sitio web**: [9router.com](https://9router.com)
|
||||
- **GitHub**: [github.com/decolua/9router](https://github.com/decolua/9router)
|
||||
- **Issues**: [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
@@ -0,0 +1,247 @@
|
||||
# Empezar
|
||||
|
||||
Pon en marcha 9Router en 5 minutos y comienza a enrutar solicitudes de IA de forma inteligente.
|
||||
|
||||
---
|
||||
|
||||
## Inicio rápido
|
||||
|
||||
### 1. Instalar
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
**Requisitos:** Node.js 20+ ([Detalles de instalación](getting-started/installation.md))
|
||||
|
||||
### 2. Iniciar
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
🎉 **El dashboard se abre automáticamente** en `http://localhost:20128`
|
||||
|
||||
- Contraseña por defecto: `123456` (cámbiala en el dashboard)
|
||||
- API key generada automáticamente
|
||||
- Listo para conectar proveedores
|
||||
|
||||
### 3. Conectar proveedores
|
||||
|
||||
Tienes 3 formas de conectar proveedores:
|
||||
|
||||
#### Opción A: OAuth (Proveedores de suscripción)
|
||||
|
||||
**Ideal para:** Claude Code, Codex, Gemini CLI, GitHub Copilot
|
||||
|
||||
```
|
||||
Dashboard → Providers → Connect [Provider]
|
||||
→ Login OAuth → Refresh automático de token
|
||||
→ Seguimiento de cuota habilitado
|
||||
```
|
||||
|
||||
**Ejemplo: Claude Code**
|
||||
1. Clic en "Connect Claude Code"
|
||||
2. Inicia sesión con tu cuenta de Claude
|
||||
3. Autoriza 9Router
|
||||
4. ✅ ¡Listo! Usa el modelo: `cc/claude-opus-4-5-20251101`
|
||||
|
||||
#### Opción B: API Key (Proveedores baratos)
|
||||
|
||||
**Ideal para:** GLM, MiniMax, Kimi, OpenRouter
|
||||
|
||||
```
|
||||
Dashboard → Providers → Add API Key
|
||||
→ Selecciona proveedor
|
||||
→ Pega API key
|
||||
→ Guardar
|
||||
```
|
||||
|
||||
**Ejemplo: GLM-4.7**
|
||||
1. Regístrate en [Zhipu AI](https://open.bigmodel.cn/)
|
||||
2. Obtén la API key del Coding Plan
|
||||
3. Dashboard → Add API Key → Provider: `glm` → Pega la key
|
||||
4. ✅ ¡Listo! Usa el modelo: `glm/glm-4.7`
|
||||
|
||||
#### Opción C: Proveedores gratis (Sin costo)
|
||||
|
||||
**Ideal para:** iFlow, Qwen, Kiro
|
||||
|
||||
```
|
||||
Dashboard → Providers → Connect [Free Provider]
|
||||
→ Device code u OAuth
|
||||
→ Uso ilimitado
|
||||
```
|
||||
|
||||
**Ejemplo: iFlow**
|
||||
1. Clic en "Connect iFlow"
|
||||
2. Inicia sesión con tu cuenta de iFlow
|
||||
3. Autoriza
|
||||
4. ✅ ¡Listo! Usa 8 modelos: `if/kimi-k2-thinking`, `if/qwen3-coder-plus`, etc.
|
||||
|
||||
---
|
||||
|
||||
## 4. Usar en herramientas CLI
|
||||
|
||||
Apunta tu herramienta de codificación a 9Router:
|
||||
|
||||
### Cursor IDE
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [desde el dashboard de 9router]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
### Claude Desktop
|
||||
|
||||
Edita `~/.claude/config.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"anthropic_api_base": "http://localhost:20128/v1",
|
||||
"anthropic_api_key": "your-9router-api-key"
|
||||
}
|
||||
```
|
||||
|
||||
### Cline / Continue / RooCode
|
||||
|
||||
```
|
||||
Provider: OpenAI Compatible
|
||||
Base URL: http://localhost:20128/v1
|
||||
API Key: [desde el dashboard]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
### Codex CLI
|
||||
|
||||
```bash
|
||||
export OPENAI_BASE_URL="http://localhost:20128"
|
||||
export OPENAI_API_KEY="your-9router-api-key"
|
||||
|
||||
codex "your prompt"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Crear combos inteligentes (Opcional)
|
||||
|
||||
Los combos habilitan el fallback automático entre modelos:
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: premium-coding
|
||||
Models:
|
||||
1. cc/claude-opus-4-5-20251101 (Suscripción principal)
|
||||
2. glm/glm-4.7 (Respaldo barato, $0.6/1M)
|
||||
3. if/kimi-k2-thinking (Fallback gratis)
|
||||
|
||||
Usar en CLI: premium-coding
|
||||
```
|
||||
|
||||
**Cómo funciona:**
|
||||
1. Intenta primero Claude Opus (tu suscripción)
|
||||
2. Si la cuota se agota → GLM-4.7 (ultra-barato)
|
||||
3. Si llega al límite de presupuesto → iFlow (gratis)
|
||||
4. ¡Cero tiempo de inactividad, cambio automático!
|
||||
|
||||
---
|
||||
|
||||
## Modelos disponibles
|
||||
|
||||
### Modelos de suscripción (Maximiza primero)
|
||||
|
||||
**Claude Code (`cc/`)** - Suscripción Pro/Max:
|
||||
- `cc/claude-opus-4-5-20251101` - Claude 4.5 Opus
|
||||
- `cc/claude-sonnet-4-5-20250929` - Claude 4.5 Sonnet
|
||||
- `cc/claude-haiku-4-5-20251001` - Claude 4.5 Haiku
|
||||
|
||||
**Codex (`cx/`)** - Suscripción Plus/Pro:
|
||||
- `cx/gpt-5.2-codex` - GPT 5.2 Codex
|
||||
- `cx/gpt-5.1-codex-max` - GPT 5.1 Codex Max
|
||||
|
||||
**Gemini CLI (`gc/`)** - GRATIS 180K/mes:
|
||||
- `gc/gemini-3-flash-preview` - Gemini 3 Flash Preview
|
||||
- `gc/gemini-2.5-pro` - Gemini 2.5 Pro
|
||||
|
||||
**GitHub Copilot (`gh/`)** - Suscripción:
|
||||
- `gh/gpt-5` - GPT-5
|
||||
- `gh/claude-4.5-sonnet` - Claude 4.5 Sonnet
|
||||
|
||||
### Modelos baratos (Respaldo)
|
||||
|
||||
**GLM (`glm/`)** - $0.6/$2.2 por 1M:
|
||||
- `glm/glm-4.7` - GLM 4.7 (reinicio diario 10AM)
|
||||
|
||||
**MiniMax (`minimax/`)** - $0.20/$1.00 por 1M:
|
||||
- `minimax/MiniMax-M2.1` - MiniMax M2.1 (reinicio 5h)
|
||||
|
||||
**Kimi (`kimi/`)** - $9/mes (10M tokens):
|
||||
- `kimi/kimi-latest` - Kimi Latest
|
||||
|
||||
### Modelos GRATIS (Emergencia)
|
||||
|
||||
**iFlow (`if/`)** - 8 modelos GRATIS:
|
||||
- `if/kimi-k2-thinking` - Kimi K2 Thinking
|
||||
- `if/qwen3-coder-plus` - Qwen3 Coder Plus
|
||||
- `if/glm-4.7` - GLM 4.7
|
||||
- `if/deepseek-r1` - DeepSeek R1
|
||||
|
||||
**Qwen (`qw/`)** - 3 modelos GRATIS:
|
||||
- `qw/qwen3-coder-plus` - Qwen3 Coder Plus
|
||||
- `qw/qwen3-coder-flash` - Qwen3 Coder Flash
|
||||
|
||||
**Kiro (`kr/`)** - 2 modelos GRATIS:
|
||||
- `kr/claude-sonnet-4.5` - Claude Sonnet 4.5
|
||||
- `kr/claude-haiku-4.5` - Claude Haiku 4.5
|
||||
|
||||
---
|
||||
|
||||
## Estrategia de optimización de costos
|
||||
|
||||
### Presupuesto mensual: $10-20/mes
|
||||
|
||||
```
|
||||
1. Usa el nivel gratis de Gemini CLI (180K/mes) para tareas rápidas
|
||||
2. Usa la cuota de suscripción de Claude Code al máximo (ya pagas)
|
||||
3. Fallback a GLM ($0.6/1M) cuando se agote la cuota
|
||||
4. Emergencia: MiniMax M2.1 ($0.20/1M) o iFlow (gratis)
|
||||
|
||||
Ejemplo real (100M tokens/mes):
|
||||
60M vía Gemini CLI: $0 (nivel gratis)
|
||||
30M vía Claude Code: $0 (suscripción que ya tienes)
|
||||
8M vía GLM: $4.80
|
||||
2M vía MiniMax: $0.40
|
||||
Total: $5.20/mes + suscripciones existentes
|
||||
```
|
||||
|
||||
### Estrategia de reinicio de cuota
|
||||
|
||||
```
|
||||
Rutina diaria:
|
||||
1. Mañana: Cuota fresca de Claude Code (reinicio 5h)
|
||||
2. Tarde: Cambia a Gemini CLI (1K/día)
|
||||
3. Noche: Cuota diaria de GLM (reinicio 10AM del día siguiente)
|
||||
4. Madrugada: MiniMax (rolling 5h) o iFlow (gratis)
|
||||
|
||||
→ ¡Codifica 24/7 con costo extra mínimo!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Próximos pasos
|
||||
|
||||
- [Detalles de instalación](getting-started/installation.md) - Requisitos, troubleshooting
|
||||
- [Características](features/) - Explora seguimiento de cuota, combos, despliegue
|
||||
- [FAQ](faq.md) - Preguntas y respuestas comunes
|
||||
- [Troubleshooting](troubleshooting.md) - Soluciona problemas comunes
|
||||
|
||||
---
|
||||
|
||||
## ¿Necesitas ayuda?
|
||||
|
||||
- **Sitio web**: [9router.com](https://9router.com)
|
||||
- **GitHub**: [github.com/decolua/9router](https://github.com/decolua/9router)
|
||||
- **Issues**: [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
@@ -0,0 +1,164 @@
|
||||
# Bienvenido a 9Router
|
||||
|
||||
**Usa Claude, Codex, Gemini GRATIS • Alternativas ultra-baratas desde $0.20/1M tokens**
|
||||
|
||||
9Router es un router de modelos de IA que maximiza el valor de tus suscripciones y minimiza los costos mediante enrutamiento inteligente y fallback automático.
|
||||
|
||||
---
|
||||
|
||||
## ¿Qué es 9Router?
|
||||
|
||||
9Router es un proxy inteligente que se sitúa entre tus herramientas de codificación (Cursor, Cline, Claude Desktop) y los proveedores de IA. Enruta automáticamente las solicitudes al mejor modelo disponible según la cuota, el costo y la disponibilidad.
|
||||
|
||||
**Deja de desperdiciar dinero:**
|
||||
- ❌ La cuota de suscripción expira sin usar cada mes
|
||||
- ❌ Los límites de tasa te detienen a mitad de la codificación
|
||||
- ❌ APIs costosas ($20-50/mes por proveedor)
|
||||
- ❌ Cambio manual entre proveedores
|
||||
|
||||
**Empieza a maximizar el valor:**
|
||||
- ✅ **Maximiza tus suscripciones** - Rastrea y usa cada bit de cuota de Claude Code, Codex, Gemini
|
||||
- ✅ **GRATIS disponible** - Accede a modelos iFlow, Qwen, Kiro vía CLI
|
||||
- ✅ **Respaldo ultra-barato** - GLM ($0.6/1M), MiniMax M2.1 ($0.20/1M)
|
||||
- ✅ **Fallback inteligente** - Suscripción → Barato → Gratis, cambio automático
|
||||
|
||||
---
|
||||
|
||||
## Características clave
|
||||
|
||||
### 🔄 Fallback inteligente de 3 niveles
|
||||
|
||||
```
|
||||
Configura una vez, nunca dejes de codificar:
|
||||
|
||||
Nivel 1 (SUSCRIPCIÓN): Claude Code → Codex → Gemini
|
||||
↓ cuota agotada
|
||||
Nivel 2 (BARATO): GLM-4.7 → MiniMax M2.1 → Kimi
|
||||
↓ límite de presupuesto
|
||||
Nivel 3 (GRATIS): iFlow → Qwen → Kiro
|
||||
|
||||
→ Cambio automático, sin tiempo de inactividad!
|
||||
```
|
||||
|
||||
### 📊 Seguimiento de cuota
|
||||
|
||||
- Consumo de tokens en tiempo real por proveedor
|
||||
- Cuenta regresiva de reinicio (5 horas, diario, semanal, mensual)
|
||||
- Estimación de costos para niveles de pago
|
||||
- Reportes de gasto mensual
|
||||
|
||||
### 🎯 Soporte universal de CLI
|
||||
|
||||
Funciona con cualquier herramienta que soporte endpoints personalizados de OpenAI:
|
||||
|
||||
✅ **Cursor** • **Cline** • **Claude Desktop** • **Codex** • **RooCode** • **Continue** • **Cualquier herramienta compatible con OpenAI**
|
||||
|
||||
### 💰 Optimización de costos
|
||||
|
||||
**Ejemplo real (100M tokens/mes):**
|
||||
```
|
||||
60M vía Gemini CLI: $0 (nivel gratis)
|
||||
30M vía Claude Code: $0 (suscripción que ya tienes)
|
||||
8M vía GLM: $4.80
|
||||
2M vía MiniMax: $0.40
|
||||
Total: $5.20/mes vs $2000 en ChatGPT API!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ¿Por qué elegir 9Router?
|
||||
|
||||
### Maximiza tus suscripciones
|
||||
|
||||
¿Ya pagas Claude Code ($20-100/mes) o Codex ($20-200/mes)? Obtén el valor completo:
|
||||
|
||||
- Rastrea el uso de cuota en tiempo real
|
||||
- Cambio automático cuando se reinicia la cuota (5 horas, semanal)
|
||||
- Usa cada token antes de que expire
|
||||
- Gemini CLI: 180K completados/mes **GRATIS**
|
||||
|
||||
### Respaldo ultra-barato
|
||||
|
||||
Cuando se agota la cuota de suscripción, paga centavos:
|
||||
|
||||
| Proveedor | Costo por 1M tokens | Reinicio |
|
||||
|----------|-------------------|-------|
|
||||
| **GLM-4.7** | $0.60 entrada / $2.20 salida | Diario 10:00 AM |
|
||||
| **MiniMax M2.1** | $0.20 entrada / $1.00 salida | 5 horas rolling |
|
||||
| **Kimi K2** | $9/mes (10M tokens) | Mensual |
|
||||
|
||||
**~90% más barato que ChatGPT API ($20/1M)!**
|
||||
|
||||
### Fallback gratis para siempre
|
||||
|
||||
Respaldo de emergencia cuando todo lo demás está limitado por cuota:
|
||||
|
||||
- **iFlow**: 8 modelos (Kimi K2, Qwen3 Coder Plus, GLM 4.7, MiniMax M2)
|
||||
- **Qwen**: 3 modelos (Qwen3 Coder Plus/Flash, Vision)
|
||||
- **Kiro**: Claude Sonnet 4.5, Haiku 4.5 (AWS Builder ID)
|
||||
|
||||
---
|
||||
|
||||
## Inicio rápido
|
||||
|
||||
Comienza en 2 minutos:
|
||||
|
||||
```bash
|
||||
# Instala globalmente
|
||||
npm install -g 9router
|
||||
|
||||
# Inicia (el dashboard se abre automáticamente)
|
||||
9router
|
||||
```
|
||||
|
||||
🎉 **Se abre el dashboard** → Conecta proveedores → ¡Empieza a codificar!
|
||||
|
||||
**Úsalo en tu herramienta CLI:**
|
||||
|
||||
```
|
||||
Endpoint: http://localhost:20128/v1
|
||||
API Key: [desde el dashboard]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
[→ Guía completa para empezar](getting-started.md)
|
||||
|
||||
---
|
||||
|
||||
## Casos de uso
|
||||
|
||||
### Para desarrolladores individuales
|
||||
|
||||
- Maximiza tu suscripción de Claude Code/Codex
|
||||
- Usa el nivel gratis de Gemini CLI (180K/mes)
|
||||
- Fallback a modelos ultra-baratos ($0.20/1M)
|
||||
- Codifica 24/7 sin límites de tasa
|
||||
|
||||
### Para equipos
|
||||
|
||||
- Despliega en VPS/Cloud para acceso compartido
|
||||
- Rastrea el gasto del equipo en tiempo real
|
||||
- Establece límites de presupuesto por nivel
|
||||
- Gestión centralizada de proveedores
|
||||
|
||||
### Para codificación móvil/remota
|
||||
|
||||
- Usa el despliegue en la nube (https://9router.com)
|
||||
- Accede desde iPad, teléfono, donde sea
|
||||
- Sin limitaciones de localhost
|
||||
- Red edge de Cloudflare (300+ ubicaciones)
|
||||
|
||||
---
|
||||
|
||||
## ¿Qué sigue?
|
||||
|
||||
- [Empezar](getting-started.md) - Instala y configura en 5 minutos
|
||||
- [Guía de instalación](getting-started/installation.md) - Instrucciones detalladas
|
||||
- [Características](features/) - Explora todas las capacidades
|
||||
- [FAQ](faq.md) - Preguntas comunes
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<sub>Construido con ❤️ para desarrolladores que maximizan el valor de la IA</sub>
|
||||
</div>
|
||||
@@ -0,0 +1,109 @@
|
||||
# Integración con Claude Code
|
||||
|
||||
Integra 9Router con Claude Code CLI para enrutar tus solicitudes de la API de Anthropic a través del sistema de enrutamiento inteligente de 9Router.
|
||||
|
||||
## Requisitos previos
|
||||
|
||||
- Claude Code CLI instalado
|
||||
- 9Router ejecutándose localmente o endpoint en la nube configurado
|
||||
- API key del dashboard de 9Router
|
||||
|
||||
## Configuración
|
||||
|
||||
### 1. Configurar variables de entorno
|
||||
|
||||
Establece las siguientes variables de entorno en tu archivo de configuración del shell (`~/.bashrc`, `~/.zshrc`, o `~/.bash_profile`):
|
||||
|
||||
```bash
|
||||
# Base URL for 9Router
|
||||
export ANTHROPIC_BASE_URL="http://localhost:20128/v1"
|
||||
|
||||
# Optional: Set default models for aliases
|
||||
export ANTHROPIC_DEFAULT_OPUS_MODEL="cc/claude-opus-4-5-20251101"
|
||||
export ANTHROPIC_DEFAULT_SONNET_MODEL="cc/claude-sonnet-4-5-20250929"
|
||||
export ANTHROPIC_DEFAULT_HAIKU_MODEL="cc/claude-haiku-4-5-20251001"
|
||||
```
|
||||
|
||||
### 2. Recargar la configuración del shell
|
||||
|
||||
```bash
|
||||
source ~/.zshrc # o ~/.bashrc
|
||||
```
|
||||
|
||||
### 3. Verificar la configuración
|
||||
|
||||
Verifica que las variables de entorno estén configuradas correctamente:
|
||||
|
||||
```bash
|
||||
echo $ANTHROPIC_BASE_URL
|
||||
```
|
||||
|
||||
## Aliases de modelos
|
||||
|
||||
Claude Code soporta los siguientes aliases de modelos que mapean a modelos de 9Router:
|
||||
|
||||
| Alias | Modelo | Variable de entorno |
|
||||
|-------|-------|---------------------|
|
||||
| `opus` | Claude Opus 4.5 | `ANTHROPIC_DEFAULT_OPUS_MODEL` |
|
||||
| `sonnet` | Claude Sonnet 4.5 | `ANTHROPIC_DEFAULT_SONNET_MODEL` |
|
||||
| `haiku` | Claude Haiku 4.5 | `ANTHROPIC_DEFAULT_HAIKU_MODEL` |
|
||||
|
||||
## Ejemplos de uso
|
||||
|
||||
### Usando aliases de modelos
|
||||
|
||||
```bash
|
||||
# Usar modelo Opus
|
||||
claude --model opus "Explain quantum computing"
|
||||
|
||||
# Usar modelo Sonnet
|
||||
claude --model sonnet "Write a Python function"
|
||||
|
||||
# Usar modelo Haiku
|
||||
claude --model haiku "Quick code review"
|
||||
```
|
||||
|
||||
### Usando nombres completos de modelos
|
||||
|
||||
```bash
|
||||
claude --model cc/claude-opus-4-5-20251101 "Your prompt here"
|
||||
```
|
||||
|
||||
## Archivo de configuración
|
||||
|
||||
Claude Code almacena su configuración en `~/.claude/settings.json`. Puedes editar este archivo manualmente si es necesario:
|
||||
|
||||
```json
|
||||
{
|
||||
"baseUrl": "http://localhost:20128/v1",
|
||||
"defaultModel": "sonnet"
|
||||
}
|
||||
```
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### Problemas de conexión
|
||||
|
||||
Si encuentras errores de conexión:
|
||||
|
||||
1. Verifica que 9Router esté corriendo: `curl http://localhost:20128/health`
|
||||
2. Verifica que las variables de entorno estén configuradas correctamente
|
||||
3. Asegúrate de que ningún firewall esté bloqueando el puerto 20128
|
||||
|
||||
### Modelo no encontrado
|
||||
|
||||
Si obtienes errores de "modelo no encontrado":
|
||||
|
||||
1. Verifica que el nombre del modelo coincida con tu configuración de 9Router
|
||||
2. Verifica que la conexión del proveedor esté activa en el dashboard de 9Router
|
||||
3. Asegúrate de que el modelo esté disponible en tus proveedores conectados
|
||||
|
||||
## Endpoint en la nube
|
||||
|
||||
Para usar el endpoint en la nube de 9Router en lugar de localhost:
|
||||
|
||||
```bash
|
||||
export ANTHROPIC_BASE_URL="https://9router.com"
|
||||
```
|
||||
|
||||
Asegúrate de haber configurado tu API key en el dashboard en la nube de 9Router.
|
||||
@@ -0,0 +1,201 @@
|
||||
# Integración con Cline
|
||||
|
||||
Integra 9Router con la extensión Cline de VSCode para enrutar tus solicitudes de IA a través del sistema de enrutamiento inteligente de 9Router.
|
||||
|
||||
## Requisitos previos
|
||||
|
||||
- Visual Studio Code instalado
|
||||
- Extensión Cline instalada desde el marketplace de VSCode
|
||||
- 9Router ejecutándose localmente o endpoint en la nube configurado
|
||||
- API key del dashboard de 9Router
|
||||
|
||||
## Configuración
|
||||
|
||||
### 1. Abrir la configuración de Cline
|
||||
|
||||
1. Abre Visual Studio Code
|
||||
2. Abre el panel de la extensión Cline (clic en el ícono de Cline en la barra lateral)
|
||||
3. Clic en el ícono de **Settings** (engranaje) en el panel de Cline
|
||||
|
||||
### 2. Seleccionar el proveedor de API
|
||||
|
||||
1. En la configuración de Cline, encuentra el dropdown **API Provider**
|
||||
2. Selecciona **Ollama** de la lista
|
||||
- Nota: Usamos el tipo de proveedor Ollama porque es compatible con APIs estilo OpenAI
|
||||
|
||||
### 3. Configurar Base URL
|
||||
|
||||
Establece la URL base a tu endpoint de 9Router:
|
||||
|
||||
**Para 9Router local:**
|
||||
```
|
||||
http://localhost:20128/v1
|
||||
```
|
||||
|
||||
**Para 9Router en la nube:**
|
||||
```
|
||||
https://9router.com
|
||||
```
|
||||
|
||||
**Pasos:**
|
||||
1. En el campo **Base URL**, ingresa tu endpoint de 9Router
|
||||
2. Asegúrate de incluir `/v1` al final
|
||||
|
||||
### 4. Agregar API Key
|
||||
|
||||
1. En el campo **API Key**, ingresa tu API key de 9Router
|
||||
2. Puedes encontrar tu API key en el dashboard de 9Router en **Settings → API Keys**
|
||||
3. La key debe comenzar con `sk-9router-`
|
||||
|
||||
### 5. Seleccionar modelo
|
||||
|
||||
1. En el dropdown **Model**, puedes:
|
||||
- Seleccionar de los modelos disponibles (si Cline los auto-detecta)
|
||||
- Ingresar manualmente el nombre del modelo desde tu configuración de 9Router
|
||||
|
||||
2. Nombres comunes de modelos:
|
||||
- `gpt-4`
|
||||
- `gpt-4o`
|
||||
- `claude-opus-4-5`
|
||||
- `claude-sonnet-4-5`
|
||||
- `gemini-2.0-flash`
|
||||
|
||||
### 6. Guardar la configuración
|
||||
|
||||
Clic en **Save** o cierra el panel de configuración. Cline guardará automáticamente tu configuración.
|
||||
|
||||
## Ejemplo de configuración
|
||||
|
||||
Tu configuración de Cline debería verse así:
|
||||
|
||||
```
|
||||
API Provider: Ollama
|
||||
Base URL: http://localhost:20128/v1
|
||||
API Key: sk-9router-xxxxxxxxxxxxx
|
||||
Model: gpt-4
|
||||
```
|
||||
|
||||
## Modelos disponibles
|
||||
|
||||
Puedes usar cualquier modelo configurado en tu dashboard de 9Router. Ejemplos comunes:
|
||||
|
||||
| Nombre del modelo | Proveedor | Descripción |
|
||||
|------------|----------|-------------|
|
||||
| `gpt-4` | OpenAI | GPT-4 Turbo |
|
||||
| `gpt-4o` | OpenAI | GPT-4 Optimized |
|
||||
| `claude-opus-4-5` | Anthropic | Claude Opus 4.5 |
|
||||
| `claude-sonnet-4-5` | Anthropic | Claude Sonnet 4.5 |
|
||||
| `gemini-2.0-flash` | Google | Gemini 2.0 Flash |
|
||||
|
||||
## Uso
|
||||
|
||||
### Chat con IA
|
||||
|
||||
1. Abre el panel de Cline en VSCode
|
||||
2. Escribe tu mensaje en el input del chat
|
||||
3. Presiona Enter para enviar
|
||||
4. Cline usará 9Router para procesar tu solicitud
|
||||
|
||||
### Generación de código
|
||||
|
||||
1. Pide a Cline que genere código: "Create a React component for a login form"
|
||||
2. Cline generará código usando 9Router
|
||||
3. Revisa y acepta el código generado
|
||||
|
||||
### Explicación de código
|
||||
|
||||
1. Selecciona código en tu editor
|
||||
2. Pregunta a Cline: "Explain this code"
|
||||
3. Obtén explicaciones potenciadas por IA a través de 9Router
|
||||
|
||||
### Operaciones con archivos
|
||||
|
||||
1. Pide a Cline que cree, modifique o elimine archivos
|
||||
2. Cline usará 9Router para entender el contexto y hacer cambios
|
||||
3. Revisa los cambios antes de aceptar
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### Error "Connection Failed"
|
||||
|
||||
1. Verifica que 9Router esté corriendo: `curl http://localhost:20128/health`
|
||||
2. Verifica que la URL base sea correcta e incluya `/v1`
|
||||
3. Asegúrate de que ningún firewall esté bloqueando el puerto 20128
|
||||
4. Intenta reiniciar VSCode
|
||||
|
||||
### Error "Invalid API Key"
|
||||
|
||||
1. Verifica tu API key en el dashboard de 9Router
|
||||
2. Asegúrate de haber copiado la key completa incluyendo el prefijo `sk-9router-`
|
||||
3. Verifica que la API key no haya expirado
|
||||
4. Intenta regenerar una nueva API key
|
||||
|
||||
### Error "Model Not Found"
|
||||
|
||||
1. Verifica que el nombre del modelo coincida exactamente con tu configuración de 9Router
|
||||
2. Verifica que la conexión del proveedor esté activa en el dashboard de 9Router
|
||||
3. Asegúrate de que el modelo esté disponible en tus proveedores conectados
|
||||
4. Intenta usar el nombre completo del modelo (ej. `openai/gpt-4` en lugar de `gpt-4`)
|
||||
|
||||
### Cline no responde
|
||||
|
||||
1. Revisa el panel de output de Cline para mensajes de error
|
||||
2. Verifica que tu instancia de 9Router esté ejecutándose y saludable
|
||||
3. Intenta recargar la ventana de VSCode (Cmd/Ctrl + Shift + P → "Reload Window")
|
||||
4. Revisa los logs de 9Router para cualquier error
|
||||
|
||||
## Configuración avanzada
|
||||
|
||||
### Usar endpoint en la nube
|
||||
|
||||
Para usar el endpoint en la nube de 9Router en lugar de localhost:
|
||||
|
||||
1. En la configuración de Cline, establece Base URL a: `https://9router.com`
|
||||
2. Asegúrate de haber configurado tu API key en el dashboard en la nube de 9Router
|
||||
3. Asegúrate de que tu endpoint en la nube esté activo y accesible
|
||||
|
||||
### Múltiples modelos
|
||||
|
||||
Puedes cambiar rápidamente entre modelos:
|
||||
|
||||
1. Abre la configuración de Cline
|
||||
2. Cambia el campo **Model** a otro modelo
|
||||
3. Guarda y continúa chateando con el nuevo modelo
|
||||
|
||||
### Timeout personalizado
|
||||
|
||||
Si experimentas problemas de timeout con solicitudes grandes:
|
||||
|
||||
1. Abre la configuración de VSCode (Cmd/Ctrl + ,)
|
||||
2. Busca "Cline timeout"
|
||||
3. Aumenta el valor de timeout (por defecto suele ser 30 segundos)
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
1. **Usa modelos apropiados**: Elige modelos rápidos (como Haiku o Flash) para tareas simples, y modelos más potentes (como Opus o GPT-4) para tareas complejas
|
||||
2. **Monitorea el uso**: Revisa el dashboard de 9Router para estadísticas de uso y costos
|
||||
3. **Gestión de contexto**: Mantén tus conversaciones enfocadas para reducir el uso de tokens
|
||||
4. **Cambio de modelo**: Cambia modelos según la complejidad de la tarea para optimizar costo y rendimiento
|
||||
5. **Seguridad de API Key**: Nunca subas tu API key al control de versiones
|
||||
|
||||
## Integración con características de 9Router
|
||||
|
||||
### Enrutamiento de modelos
|
||||
|
||||
9Router enruta automáticamente tus solicitudes al mejor proveedor disponible según:
|
||||
- Disponibilidad del modelo
|
||||
- Estado de salud del proveedor
|
||||
- Optimización de costos
|
||||
- Balanceo de carga
|
||||
|
||||
### Soporte de fallback
|
||||
|
||||
Si un proveedor falla, 9Router automáticamente cambia a proveedores alternativos configurados en tu dashboard.
|
||||
|
||||
### Seguimiento de uso
|
||||
|
||||
Monitorea tu uso de Cline a través del dashboard de 9Router:
|
||||
- Total de solicitudes
|
||||
- Uso de tokens
|
||||
- Costo por modelo
|
||||
- Distribución por proveedor
|
||||
@@ -0,0 +1,136 @@
|
||||
# Integración con OpenAI Codex CLI
|
||||
|
||||
Integra 9Router con OpenAI Codex CLI para enrutar tus solicitudes de la API de OpenAI a través del sistema de enrutamiento inteligente de 9Router.
|
||||
|
||||
## Requisitos previos
|
||||
|
||||
- OpenAI Codex CLI instalado
|
||||
- 9Router ejecutándose localmente o endpoint en la nube configurado
|
||||
- API key del dashboard de 9Router
|
||||
|
||||
## Configuración
|
||||
|
||||
### 1. Configurar variables de entorno
|
||||
|
||||
Establece las siguientes variables de entorno en tu archivo de configuración del shell (`~/.bashrc`, `~/.zshrc`, o `~/.bash_profile`):
|
||||
|
||||
```bash
|
||||
# Base URL for 9Router
|
||||
export OPENAI_BASE_URL="http://localhost:20128/v1"
|
||||
|
||||
# API Key from 9Router dashboard
|
||||
export OPENAI_API_KEY="your-9router-api-key"
|
||||
```
|
||||
|
||||
### 2. Recargar la configuración del shell
|
||||
|
||||
```bash
|
||||
source ~/.zshrc # o ~/.bashrc
|
||||
```
|
||||
|
||||
### 3. Verificar la configuración
|
||||
|
||||
Verifica que las variables de entorno estén configuradas correctamente:
|
||||
|
||||
```bash
|
||||
echo $OPENAI_BASE_URL
|
||||
echo $OPENAI_API_KEY
|
||||
```
|
||||
|
||||
## Modelos disponibles
|
||||
|
||||
9Router proporciona los siguientes modelos de Codex:
|
||||
|
||||
| ID del modelo | Descripción |
|
||||
|----------|-------------|
|
||||
| `cx/gpt-5.2-codex` | GPT-5.2 Codex - Última versión |
|
||||
| `cx/gpt-5.1-codex-max` | GPT-5.1 Codex Max - Contexto extendido |
|
||||
|
||||
## Ejemplos de uso
|
||||
|
||||
### Uso básico
|
||||
|
||||
```bash
|
||||
# Usar GPT-5.2 Codex
|
||||
codex --model cx/gpt-5.2-codex "Write a function to sort an array"
|
||||
|
||||
# Usar GPT-5.1 Codex Max
|
||||
codex --model cx/gpt-5.1-codex-max "Explain this complex algorithm"
|
||||
```
|
||||
|
||||
### Generación de código
|
||||
|
||||
```bash
|
||||
codex --model cx/gpt-5.2-codex "Create a REST API endpoint for user authentication"
|
||||
```
|
||||
|
||||
### Explicación de código
|
||||
|
||||
```bash
|
||||
codex --model cx/gpt-5.1-codex-max "Explain what this code does: $(cat myfile.js)"
|
||||
```
|
||||
|
||||
## Archivo de configuración
|
||||
|
||||
También puedes configurar Codex CLI usando un archivo de configuración. Crea o edita `~/.codex/config.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"baseUrl": "http://localhost:20128/v1",
|
||||
"apiKey": "your-9router-api-key",
|
||||
"defaultModel": "cx/gpt-5.2-codex"
|
||||
}
|
||||
```
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### Errores de autenticación
|
||||
|
||||
Si encuentras errores de autenticación:
|
||||
|
||||
1. Verifica que tu API key sea correcta en el dashboard de 9Router
|
||||
2. Verifica que la variable de entorno `OPENAI_API_KEY` esté configurada
|
||||
3. Asegúrate de que la API key no haya expirado
|
||||
|
||||
### Problemas de conexión
|
||||
|
||||
Si encuentras errores de conexión:
|
||||
|
||||
1. Verifica que 9Router esté corriendo: `curl http://localhost:20128/health`
|
||||
2. Verifica que las variables de entorno estén configuradas correctamente
|
||||
3. Asegúrate de que ningún firewall esté bloqueando el puerto 20128
|
||||
|
||||
### Modelo no disponible
|
||||
|
||||
Si obtienes errores de "modelo no disponible":
|
||||
|
||||
1. Verifica que el nombre del modelo coincida con tu configuración de 9Router
|
||||
2. Verifica que la conexión del proveedor de OpenAI esté activa en el dashboard de 9Router
|
||||
3. Asegúrate de que el modelo esté disponible en tus proveedores conectados
|
||||
|
||||
## Endpoint en la nube
|
||||
|
||||
Para usar el endpoint en la nube de 9Router en lugar de localhost:
|
||||
|
||||
```bash
|
||||
export OPENAI_BASE_URL="https://9router.com"
|
||||
```
|
||||
|
||||
Asegúrate de haber configurado tu API key en el dashboard en la nube de 9Router.
|
||||
|
||||
## Configuración avanzada
|
||||
|
||||
### Timeout personalizado
|
||||
|
||||
```bash
|
||||
export OPENAI_TIMEOUT=60 # segundos
|
||||
```
|
||||
|
||||
### Modo debug
|
||||
|
||||
Habilita el modo debug para ver logs detallados de request/response:
|
||||
|
||||
```bash
|
||||
export CODEX_DEBUG=true
|
||||
codex --model cx/gpt-5.2-codex "Your prompt"
|
||||
```
|
||||
@@ -0,0 +1,249 @@
|
||||
# Integración con la extensión Continue de VSCode
|
||||
|
||||
Integra 9Router con la extensión Continue para llevar la asistencia de IA directamente a Visual Studio Code.
|
||||
|
||||
## Requisitos previos
|
||||
|
||||
- Visual Studio Code instalado
|
||||
- Extensión Continue instalada desde el marketplace de VSCode
|
||||
- API key de 9Router desde el [dashboard](https://9router.com/dashboard)
|
||||
- 9Router ejecutándose (local o en la nube)
|
||||
|
||||
## Pasos de configuración
|
||||
|
||||
### 1. Abrir la configuración de Continue
|
||||
|
||||
1. Abre VSCode
|
||||
2. Presiona `Cmd+Shift+P` (Mac) o `Ctrl+Shift+P` (Windows/Linux)
|
||||
3. Escribe "Continue: Open Config" y selecciónalo
|
||||
4. Esto abre `~/.continue/config.json`
|
||||
|
||||
### 2. Agregar configuración de modelo de 9Router
|
||||
|
||||
Agrega la siguiente configuración a tu `config.json`:
|
||||
|
||||
**Configuración de un solo modelo:**
|
||||
```json
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "9Router - Claude Opus",
|
||||
"provider": "openai",
|
||||
"model": "cc/claude-opus-4-5-20251101",
|
||||
"apiKey": "your-api-key-from-dashboard",
|
||||
"apiBase": "http://localhost:20128/v1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Configuración de múltiples modelos:**
|
||||
```json
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "9Router - Claude Opus (Best)",
|
||||
"provider": "openai",
|
||||
"model": "cc/claude-opus-4-5-20251101",
|
||||
"apiKey": "your-api-key-from-dashboard",
|
||||
"apiBase": "http://localhost:20128/v1"
|
||||
},
|
||||
{
|
||||
"title": "9Router - Claude Sonnet (Balanced)",
|
||||
"provider": "openai",
|
||||
"model": "cc/claude-sonnet-4-20250514",
|
||||
"apiKey": "your-api-key-from-dashboard",
|
||||
"apiBase": "http://localhost:20128/v1"
|
||||
},
|
||||
{
|
||||
"title": "9Router - DeepSeek Chat (Code)",
|
||||
"provider": "openai",
|
||||
"model": "cx/deepseek-chat",
|
||||
"apiKey": "your-api-key-from-dashboard",
|
||||
"apiBase": "http://localhost:20128/v1"
|
||||
},
|
||||
{
|
||||
"title": "9Router - Claude Haiku (Fast)",
|
||||
"provider": "openai",
|
||||
"model": "cc/claude-haiku-4-20250514",
|
||||
"apiKey": "your-api-key-from-dashboard",
|
||||
"apiBase": "http://localhost:20128/v1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Para 9Router en la nube:**
|
||||
Reemplaza `apiBase` con:
|
||||
```json
|
||||
"apiBase": "https://9router.com/v1"
|
||||
```
|
||||
|
||||
### 3. Guardar y recargar
|
||||
|
||||
1. Guarda el archivo de configuración
|
||||
2. Recarga la ventana de VSCode: `Cmd+Shift+P` → "Developer: Reload Window"
|
||||
3. La extensión Continue cargará la nueva configuración
|
||||
|
||||
### 4. Seleccionar modelo
|
||||
|
||||
1. Abre la barra lateral de Continue (clic en el ícono de Continue en el panel izquierdo)
|
||||
2. Clic en el dropdown selector de modelo en la parte superior
|
||||
3. Elige tu modelo preferido de 9Router
|
||||
|
||||
## Modelos disponibles
|
||||
|
||||
### Modelos Claude (Anthropic)
|
||||
- `cc/claude-opus-4-5-20251101` - El más capaz, ideal para tareas complejas
|
||||
- `cc/claude-sonnet-4-20250514` - Rendimiento y velocidad equilibrados
|
||||
- `cc/claude-haiku-4-20250514` - El más rápido, bueno para tareas simples
|
||||
|
||||
### Modelos DeepSeek
|
||||
- `cx/deepseek-chat` - Excelente para generación de código
|
||||
- `cx/deepseek-reasoner` - Mejor para resolución de problemas complejos
|
||||
|
||||
### Modelos GLM (Zhipu AI)
|
||||
- `glm/glm-4-plus` - Chino e inglés avanzado
|
||||
- `glm/glm-4-flash` - Respuestas rápidas
|
||||
|
||||
## Ejemplos de uso
|
||||
|
||||
### Explicación de código
|
||||
1. Selecciona código en el editor
|
||||
2. Abre la barra lateral de Continue
|
||||
3. Escribe: "Explain this code"
|
||||
4. Modelo: `cc/claude-sonnet-4-20250514`
|
||||
|
||||
### Generación de código
|
||||
1. Abre la barra lateral de Continue
|
||||
2. Escribe: "Create a React component for user profile card"
|
||||
3. Modelo: `cx/deepseek-chat`
|
||||
|
||||
### Refactorización
|
||||
1. Selecciona código para refactorizar
|
||||
2. Escribe: "Refactor this to use async/await"
|
||||
3. Modelo: `cc/claude-sonnet-4-20250514`
|
||||
|
||||
### Corrección de bugs
|
||||
1. Selecciona código problemático
|
||||
2. Escribe: "Find and fix the bug in this code"
|
||||
3. Modelo: `cx/deepseek-reasoner`
|
||||
|
||||
## Configuración avanzada
|
||||
|
||||
### Prompts de sistema personalizados
|
||||
|
||||
Agrega prompts de sistema personalizados para comportamientos específicos:
|
||||
|
||||
```json
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "9Router - Code Expert",
|
||||
"provider": "openai",
|
||||
"model": "cx/deepseek-chat",
|
||||
"apiKey": "your-api-key",
|
||||
"apiBase": "http://localhost:20128/v1",
|
||||
"systemMessage": "You are an expert programmer. Always provide clean, well-documented code with best practices."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Temperatura y parámetros
|
||||
|
||||
Ajusta el comportamiento del modelo con parámetros:
|
||||
|
||||
```json
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "9Router - Creative Writer",
|
||||
"provider": "openai",
|
||||
"model": "cc/claude-opus-4-5-20251101",
|
||||
"apiKey": "your-api-key",
|
||||
"apiBase": "http://localhost:20128/v1",
|
||||
"temperature": 0.9,
|
||||
"topP": 0.95
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Proveedores de contexto
|
||||
|
||||
Configura qué contexto envía Continue al modelo:
|
||||
|
||||
```json
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "code",
|
||||
"params": {
|
||||
"maxLines": 100
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "diff",
|
||||
"params": {}
|
||||
},
|
||||
{
|
||||
"name": "terminal",
|
||||
"params": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Atajos de teclado
|
||||
|
||||
- `Cmd+L` (Mac) / `Ctrl+L` (Windows/Linux) - Abrir chat de Continue
|
||||
- `Cmd+I` (Mac) / `Ctrl+I` (Windows/Linux) - Edición inline
|
||||
- `Cmd+Shift+R` (Mac) / `Ctrl+Shift+R` (Windows/Linux) - Regenerar respuesta
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### El modelo no responde
|
||||
- Verifica que 9Router esté corriendo: `curl http://localhost:20128/health`
|
||||
- Verifica la API key en config.json
|
||||
- Revisa la consola de desarrollador de VSCode por errores: `Help` → `Toggle Developer Tools`
|
||||
|
||||
### Modelo incorrecto seleccionado
|
||||
- Clic en el dropdown de modelo en la barra lateral de Continue
|
||||
- Selecciona el modelo correcto de 9Router
|
||||
- El nombre del modelo debe coincidir exactamente (sensible a mayúsculas)
|
||||
|
||||
### La configuración no se carga
|
||||
- Verifica que la sintaxis JSON sea válida (usa un validador de JSON)
|
||||
- Verifica la ubicación del archivo: `~/.continue/config.json`
|
||||
- Recarga la ventana de VSCode después de cambios
|
||||
|
||||
### Rendimiento lento
|
||||
- Cambia a modelos más rápidos (haiku, flash)
|
||||
- Reduce el tamaño del contexto en contextProviders
|
||||
- Verifica la latencia de red hacia 9Router
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
### Estrategia de selección de modelo
|
||||
- **Ediciones rápidas**: Usa `cc/claude-haiku-4-20250514`
|
||||
- **Generación de código**: Usa `cx/deepseek-chat`
|
||||
- **Refactoring complejo**: Usa `cc/claude-opus-4-5-20251101`
|
||||
- **Resolución de problemas**: Usa `cx/deepseek-reasoner`
|
||||
|
||||
### Gestión de contexto
|
||||
- Selecciona solo el código relevante antes de preguntar
|
||||
- Usa prompts específicos y claros
|
||||
- Divide tareas complejas en pasos más pequeños
|
||||
|
||||
### Optimización de costos
|
||||
- Usa modelos más rápidos/baratos para tareas simples
|
||||
- Limita el tamaño del contexto cuando sea posible
|
||||
- Cachea respuestas usadas con frecuencia
|
||||
|
||||
## Próximos pasos
|
||||
|
||||
- [Configurar Cursor](cursor.md) para integración mejorada con IDE
|
||||
- [Configurar Roo](roo.md) para asistente de IA
|
||||
- [Explorar uso de CLI](../cli/basic-usage.md)
|
||||
- [Aprende sobre la selección de modelos](../models/overview.md)
|
||||
@@ -0,0 +1,149 @@
|
||||
# Integración con Cursor
|
||||
|
||||
Integra 9Router con Cursor IDE para enrutar tus solicitudes de IA a través del sistema de enrutamiento inteligente de 9Router.
|
||||
|
||||
## Requisitos previos
|
||||
|
||||
- Cursor IDE instalado
|
||||
- Cuenta Cursor Pro (requerida para endpoints de API personalizados)
|
||||
- Endpoint en la nube de 9Router configurado
|
||||
- API key del dashboard de 9Router
|
||||
|
||||
## ⚠️ Notas importantes
|
||||
|
||||
> **Endpoint en la nube requerido**: Cursor enruta solicitudes a través de su propio servidor y no soporta endpoints localhost. Debes usar el endpoint en la nube de 9Router: `https://9router.com`
|
||||
|
||||
> **Cursor Pro requerido**: Esta característica requiere una cuenta Cursor Pro para usar endpoints de API personalizados.
|
||||
|
||||
## Configuración
|
||||
|
||||
### 1. Abrir la configuración de Cursor
|
||||
|
||||
1. Abre Cursor IDE
|
||||
2. Ve a **Settings** (Cmd/Ctrl + ,)
|
||||
3. Navega a la sección **Models**
|
||||
|
||||
### 2. Habilitar OpenAI API
|
||||
|
||||
1. Encuentra la opción **OpenAI API key**
|
||||
2. Activa el toggle para habilitar la configuración de API personalizada
|
||||
|
||||
### 3. Configurar Base URL
|
||||
|
||||
Establece la URL base al endpoint en la nube de 9Router:
|
||||
|
||||
```
|
||||
https://9router.com
|
||||
```
|
||||
|
||||
**Pasos:**
|
||||
1. En la configuración de Models, localiza el campo **Base URL**
|
||||
2. Ingresa: `https://9router.com`
|
||||
3. Clic en **Save**
|
||||
|
||||
### 4. Agregar API Key
|
||||
|
||||
1. En el campo **API Key**, ingresa tu API key de 9Router
|
||||
2. Puedes encontrar tu API key en el dashboard de 9Router en **Settings → API Keys**
|
||||
3. Clic en **Save**
|
||||
|
||||
### 5. Agregar modelo personalizado
|
||||
|
||||
1. Clic en el botón **View All Models**
|
||||
2. Clic en **Add Custom Model**
|
||||
3. Ingresa el nombre del modelo desde tu configuración de 9Router (ej. `gpt-4`, `claude-opus-4-5`, etc.)
|
||||
4. Clic en **Add**
|
||||
|
||||
### 6. Seleccionar modelo
|
||||
|
||||
1. En la interfaz de chat de Cursor, clic en el dropdown selector de modelo
|
||||
2. Elige tu modelo personalizado de la lista
|
||||
3. ¡Empieza a usar 9Router con Cursor!
|
||||
|
||||
## Ejemplo de configuración
|
||||
|
||||
Tu configuración de Cursor debería verse así:
|
||||
|
||||
```
|
||||
OpenAI API: ✓ Enabled
|
||||
Base URL: https://9router.com
|
||||
API Key: sk-9router-xxxxxxxxxxxxx
|
||||
Custom Models: gpt-4, claude-opus-4-5, gemini-2.0-flash
|
||||
```
|
||||
|
||||
## Modelos disponibles
|
||||
|
||||
Puedes usar cualquier modelo configurado en tu dashboard de 9Router. Ejemplos comunes:
|
||||
|
||||
| Nombre del modelo | Proveedor | Descripción |
|
||||
|------------|----------|-------------|
|
||||
| `gpt-4` | OpenAI | GPT-4 Turbo |
|
||||
| `gpt-4o` | OpenAI | GPT-4 Optimized |
|
||||
| `claude-opus-4-5` | Anthropic | Claude Opus 4.5 |
|
||||
| `claude-sonnet-4-5` | Anthropic | Claude Sonnet 4.5 |
|
||||
| `gemini-2.0-flash` | Google | Gemini 2.0 Flash |
|
||||
|
||||
## Uso
|
||||
|
||||
### Interfaz de chat
|
||||
|
||||
1. Abre el chat de Cursor (Cmd/Ctrl + L)
|
||||
2. Selecciona tu modelo del dropdown
|
||||
3. Comienza a chatear con IA a través de 9Router
|
||||
|
||||
### Generación de código inline
|
||||
|
||||
1. Selecciona código en tu editor
|
||||
2. Presiona Cmd/Ctrl + K
|
||||
3. Ingresa tu prompt
|
||||
4. Cursor usará 9Router para generar código
|
||||
|
||||
### Explicación de código
|
||||
|
||||
1. Selecciona código en tu editor
|
||||
2. Presiona Cmd/Ctrl + L
|
||||
3. Pregunta "Explain this code"
|
||||
4. Obtén explicaciones potenciadas por IA a través de 9Router
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### Error "Invalid API Key"
|
||||
|
||||
1. Verifica tu API key en el dashboard de 9Router
|
||||
2. Asegúrate de haber copiado la key completa incluyendo el prefijo `sk-9router-`
|
||||
3. Verifica que la API key no haya expirado
|
||||
4. Intenta regenerar una nueva API key
|
||||
|
||||
### Error "Model Not Found"
|
||||
|
||||
1. Verifica que el nombre del modelo coincida exactamente con tu configuración de 9Router
|
||||
2. Verifica que la conexión del proveedor esté activa en el dashboard de 9Router
|
||||
3. Asegúrate de que el modelo esté disponible en tus proveedores conectados
|
||||
4. Intenta usar el nombre completo del modelo (ej. `openai/gpt-4` en lugar de `gpt-4`)
|
||||
|
||||
### Problemas de conexión
|
||||
|
||||
1. Verifica que estés usando el endpoint en la nube: `https://9router.com`
|
||||
2. Verifica tu conexión a internet
|
||||
3. Asegúrate de que el servicio en la nube de 9Router esté operativo
|
||||
4. Intenta deshabilitar VPN o proxy si está habilitado
|
||||
|
||||
### Localhost no funciona
|
||||
|
||||
> **Recuerda**: Cursor no soporta endpoints localhost. Debes usar el endpoint en la nube `https://9router.com`. Si necesitas usar una instancia local de 9Router, considera usar un servicio de tunneling como ngrok para exponer tu endpoint local.
|
||||
|
||||
## Configuración del endpoint en la nube
|
||||
|
||||
Si estás ejecutando 9Router localmente y quieres usarlo con Cursor:
|
||||
|
||||
1. Habilita el endpoint en la nube en la configuración de 9Router
|
||||
2. Configura tu URL del endpoint en la nube en el dashboard de 9Router
|
||||
3. Usa la URL en la nube en la configuración de Cursor
|
||||
4. Asegúrate de que tu instancia local de 9Router sea accesible desde internet
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
1. **Usa aliases de modelos**: Crea aliases cortos para modelos usados con frecuencia en 9Router
|
||||
2. **Monitorea el uso**: Revisa el dashboard de 9Router para estadísticas de uso y costos
|
||||
3. **Rota las API Keys**: Rota tus API keys regularmente por seguridad
|
||||
4. **Prueba modelos**: Prueba diferentes modelos para encontrar el mejor para tu caso de uso
|
||||
@@ -0,0 +1,416 @@
|
||||
# Integración con otras herramientas
|
||||
|
||||
9Router es compatible con cualquier herramienta que soporte el formato de API de OpenAI. Esta guía cubre patrones de integración genéricos para varias herramientas y aplicaciones personalizadas.
|
||||
|
||||
## Resumen
|
||||
|
||||
9Router proporciona un endpoint de API compatible con OpenAI que funciona con:
|
||||
- Scripts y aplicaciones personalizadas
|
||||
- Clientes de API y herramientas de testing
|
||||
- Herramientas CLI y utilidades
|
||||
- Integraciones de terceros
|
||||
- Frameworks de desarrollo
|
||||
|
||||
## Patrón de configuración genérico
|
||||
|
||||
Cualquier herramienta compatible con OpenAI puede conectarse a 9Router usando estas configuraciones:
|
||||
|
||||
**9Router local:**
|
||||
```
|
||||
Base URL: http://localhost:20128/v1
|
||||
API Key: your-api-key-from-dashboard
|
||||
Model: cualquier modelo de 9Router (cc/*, cx/*, glm/*, etc.)
|
||||
```
|
||||
|
||||
**9Router en la nube:**
|
||||
```
|
||||
Base URL: https://9router.com/v1
|
||||
API Key: your-api-key-from-dashboard
|
||||
Model: cualquier modelo de 9Router (cc/*, cx/*, glm/*, etc.)
|
||||
```
|
||||
|
||||
## Modelos disponibles
|
||||
|
||||
### Modelos Claude (Anthropic)
|
||||
- `cc/claude-opus-4-5-20251101`
|
||||
- `cc/claude-sonnet-4-20250514`
|
||||
- `cc/claude-haiku-4-20250514`
|
||||
|
||||
### Modelos DeepSeek
|
||||
- `cx/deepseek-chat`
|
||||
- `cx/deepseek-reasoner`
|
||||
|
||||
### Modelos GLM (Zhipu AI)
|
||||
- `glm/glm-4-plus`
|
||||
- `glm/glm-4-flash`
|
||||
|
||||
## Ejemplos de integración
|
||||
|
||||
### Python con OpenAI SDK
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(
|
||||
api_key="your-api-key-from-dashboard",
|
||||
base_url="http://localhost:20128/v1"
|
||||
)
|
||||
|
||||
response = client.chat.completions.create(
|
||||
model="cc/claude-sonnet-4-20250514",
|
||||
messages=[
|
||||
{"role": "user", "content": "Hello, how are you?"}
|
||||
]
|
||||
)
|
||||
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
|
||||
### Node.js con OpenAI SDK
|
||||
|
||||
```javascript
|
||||
import OpenAI from "openai";
|
||||
|
||||
const client = new OpenAI({
|
||||
apiKey: "your-api-key-from-dashboard",
|
||||
baseURL: "http://localhost:20128/v1"
|
||||
});
|
||||
|
||||
const response = await client.chat.completions.create({
|
||||
model: "cc/claude-sonnet-4-20250514",
|
||||
messages: [
|
||||
{ role: "user", content: "Hello, how are you?" }
|
||||
]
|
||||
});
|
||||
|
||||
console.log(response.choices[0].message.content);
|
||||
```
|
||||
|
||||
### Comando cURL
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/v1/chat/completions \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer your-api-key-from-dashboard" \
|
||||
-d '{
|
||||
"model": "cc/claude-sonnet-4-20250514",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello, how are you?"}
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
### Cliente HTTP (Postman, Insomnia)
|
||||
|
||||
**Solicitud:**
|
||||
```
|
||||
POST http://localhost:20128/v1/chat/completions
|
||||
```
|
||||
|
||||
**Headers:**
|
||||
```
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer your-api-key-from-dashboard
|
||||
```
|
||||
|
||||
**Body:**
|
||||
```json
|
||||
{
|
||||
"model": "cc/claude-sonnet-4-20250514",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello, how are you?"}
|
||||
],
|
||||
"temperature": 0.7,
|
||||
"max_tokens": 1000
|
||||
}
|
||||
```
|
||||
|
||||
### Integración con LangChain
|
||||
|
||||
```python
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain.schema import HumanMessage
|
||||
|
||||
llm = ChatOpenAI(
|
||||
model_name="cc/claude-sonnet-4-20250514",
|
||||
openai_api_key="your-api-key-from-dashboard",
|
||||
openai_api_base="http://localhost:20128/v1",
|
||||
temperature=0.7
|
||||
)
|
||||
|
||||
messages = [HumanMessage(content="Explain quantum computing")]
|
||||
response = llm(messages)
|
||||
print(response.content)
|
||||
```
|
||||
|
||||
### Integración con LlamaIndex
|
||||
|
||||
```python
|
||||
from llama_index.llms import OpenAI
|
||||
|
||||
llm = OpenAI(
|
||||
model="cc/claude-sonnet-4-20250514",
|
||||
api_key="your-api-key-from-dashboard",
|
||||
api_base="http://localhost:20128/v1"
|
||||
)
|
||||
|
||||
response = llm.complete("What is machine learning?")
|
||||
print(response.text)
|
||||
```
|
||||
|
||||
## Ejemplos de scripts personalizados
|
||||
|
||||
### Script de procesamiento por lotes
|
||||
|
||||
```python
|
||||
import openai
|
||||
import json
|
||||
|
||||
openai.api_key = "your-api-key-from-dashboard"
|
||||
openai.api_base = "http://localhost:20128/v1"
|
||||
|
||||
def process_batch(prompts, model="cx/deepseek-chat"):
|
||||
results = []
|
||||
for prompt in prompts:
|
||||
response = openai.ChatCompletion.create(
|
||||
model=model,
|
||||
messages=[{"role": "user", "content": prompt}]
|
||||
)
|
||||
results.append({
|
||||
"prompt": prompt,
|
||||
"response": response.choices[0].message.content
|
||||
})
|
||||
return results
|
||||
|
||||
prompts = [
|
||||
"Explain AI in one sentence",
|
||||
"What is machine learning?",
|
||||
"Define neural networks"
|
||||
]
|
||||
|
||||
results = process_batch(prompts)
|
||||
print(json.dumps(results, indent=2))
|
||||
```
|
||||
|
||||
### Manejador de respuestas streaming
|
||||
|
||||
```javascript
|
||||
import OpenAI from "openai";
|
||||
|
||||
const client = new OpenAI({
|
||||
apiKey: "your-api-key-from-dashboard",
|
||||
baseURL: "http://localhost:20128/v1"
|
||||
});
|
||||
|
||||
async function streamResponse(prompt) {
|
||||
const stream = await client.chat.completions.create({
|
||||
model: "cc/claude-sonnet-4-20250514",
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
stream: true
|
||||
});
|
||||
|
||||
for await (const chunk of stream) {
|
||||
const content = chunk.choices[0]?.delta?.content || "";
|
||||
process.stdout.write(content);
|
||||
}
|
||||
}
|
||||
|
||||
streamResponse("Write a short story about AI");
|
||||
```
|
||||
|
||||
### Comparación multi-modelo
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(
|
||||
api_key="your-api-key-from-dashboard",
|
||||
base_url="http://localhost:20128/v1"
|
||||
)
|
||||
|
||||
models = [
|
||||
"cc/claude-sonnet-4-20250514",
|
||||
"cx/deepseek-chat",
|
||||
"glm/glm-4-plus"
|
||||
]
|
||||
|
||||
prompt = "Explain quantum computing in simple terms"
|
||||
|
||||
for model in models:
|
||||
response = client.chat.completions.create(
|
||||
model=model,
|
||||
messages=[{"role": "user", "content": prompt}]
|
||||
)
|
||||
print(f"\n=== {model} ===")
|
||||
print(response.choices[0].message.content)
|
||||
```
|
||||
|
||||
## Patrones comunes de integración
|
||||
|
||||
### Variables de entorno
|
||||
|
||||
Almacena credenciales de forma segura:
|
||||
|
||||
```bash
|
||||
# .env file
|
||||
ROUTER_API_KEY=your-api-key-from-dashboard
|
||||
ROUTER_BASE_URL=http://localhost:20128/v1
|
||||
ROUTER_MODEL=cc/claude-sonnet-4-20250514
|
||||
```
|
||||
|
||||
```python
|
||||
import os
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(
|
||||
api_key=os.getenv("ROUTER_API_KEY"),
|
||||
base_url=os.getenv("ROUTER_BASE_URL")
|
||||
)
|
||||
```
|
||||
|
||||
### Manejo de errores
|
||||
|
||||
```python
|
||||
from openai import OpenAI, OpenAIError
|
||||
|
||||
client = OpenAI(
|
||||
api_key="your-api-key",
|
||||
base_url="http://localhost:20128/v1"
|
||||
)
|
||||
|
||||
try:
|
||||
response = client.chat.completions.create(
|
||||
model="cc/claude-sonnet-4-20250514",
|
||||
messages=[{"role": "user", "content": "Hello"}]
|
||||
)
|
||||
print(response.choices[0].message.content)
|
||||
except OpenAIError as e:
|
||||
print(f"Error: {e}")
|
||||
```
|
||||
|
||||
### Lógica de reintentos
|
||||
|
||||
```python
|
||||
import time
|
||||
from openai import OpenAI, RateLimitError
|
||||
|
||||
client = OpenAI(
|
||||
api_key="your-api-key",
|
||||
base_url="http://localhost:20128/v1"
|
||||
)
|
||||
|
||||
def chat_with_retry(prompt, max_retries=3):
|
||||
for attempt in range(max_retries):
|
||||
try:
|
||||
response = client.chat.completions.create(
|
||||
model="cc/claude-sonnet-4-20250514",
|
||||
messages=[{"role": "user", "content": prompt}]
|
||||
)
|
||||
return response.choices[0].message.content
|
||||
except RateLimitError:
|
||||
if attempt < max_retries - 1:
|
||||
time.sleep(2 ** attempt) # Exponential backoff
|
||||
else:
|
||||
raise
|
||||
```
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### Problemas de conexión
|
||||
|
||||
**Problema:** No se puede conectar a 9Router
|
||||
```bash
|
||||
# Verifica si 9Router está corriendo
|
||||
curl http://localhost:20128/health
|
||||
|
||||
# Respuesta esperada:
|
||||
{"status": "ok"}
|
||||
```
|
||||
|
||||
**Solución:**
|
||||
- Verifica que 9Router esté corriendo
|
||||
- Verifica que el puerto 20128 no esté bloqueado
|
||||
- Asegúrate de tener la URL base correcta (incluir `/v1`)
|
||||
|
||||
### Errores de autenticación
|
||||
|
||||
**Problema:** 401 Unauthorized
|
||||
```
|
||||
Error: Invalid API key
|
||||
```
|
||||
|
||||
**Solución:**
|
||||
- Verifica la API key desde el dashboard
|
||||
- Verifica el formato del header de Authorization: `Bearer your-api-key`
|
||||
- Asegúrate de no tener espacios extras o saltos de línea en la API key
|
||||
|
||||
### Modelo no encontrado
|
||||
|
||||
**Problema:** 404 Model not found
|
||||
```
|
||||
Error: Model 'cc/claude-opus' not found
|
||||
```
|
||||
|
||||
**Solución:**
|
||||
- Usa el nombre exacto del modelo (sensible a mayúsculas)
|
||||
- Verifica los modelos disponibles: `curl http://localhost:20128/v1/models`
|
||||
- Verifica que el modelo esté habilitado en tu plan
|
||||
|
||||
### Problemas de timeout
|
||||
|
||||
**Problema:** Request timeout
|
||||
```
|
||||
Error: Request timed out after 30s
|
||||
```
|
||||
|
||||
**Solución:**
|
||||
- Aumenta el timeout en la configuración del cliente
|
||||
- Usa modelos más rápidos para tareas sensibles al tiempo
|
||||
- Verifica la conexión de red a 9Router
|
||||
|
||||
### Rate limiting
|
||||
|
||||
**Problema:** 429 Too Many Requests
|
||||
```
|
||||
Error: Rate limit exceeded
|
||||
```
|
||||
|
||||
**Solución:**
|
||||
- Implementa exponential backoff
|
||||
- Reduce la frecuencia de solicitudes
|
||||
- Verifica los límites de tasa en el dashboard
|
||||
- Considera actualizar tu plan
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
### Seguridad
|
||||
- Almacena las API keys en variables de entorno
|
||||
- Nunca subas las API keys al control de versiones
|
||||
- Usa HTTPS para despliegues en la nube
|
||||
- Rota las API keys regularmente
|
||||
|
||||
### Rendimiento
|
||||
- Usa modelos apropiados para la complejidad de la tarea
|
||||
- Implementa caché para consultas repetidas
|
||||
- Usa streaming para respuestas largas
|
||||
- Agrupa solicitudes cuando sea posible
|
||||
|
||||
### Manejo de errores
|
||||
- Siempre implementa bloques try-catch
|
||||
- Agrega lógica de reintento con exponential backoff
|
||||
- Registra errores para debugging
|
||||
- Proporciona mecanismos de fallback
|
||||
|
||||
### Optimización de costos
|
||||
- Elige modelos costo-efectivos para tareas simples
|
||||
- Cachea respuestas cuando sea apropiado
|
||||
- Monitorea el uso en el dashboard
|
||||
- Establece límites de solicitudes en el código
|
||||
|
||||
## Próximos pasos
|
||||
|
||||
- [Configurar Cursor](cursor.md) para integración con IDE
|
||||
- [Configurar Continue](continue.md) para VSCode
|
||||
- [Explorar uso de CLI](../cli/basic-usage.md)
|
||||
- [Aprende sobre la selección de modelos](../models/overview.md)
|
||||
- [Referencia de API](../api/reference.md)
|
||||
@@ -0,0 +1,127 @@
|
||||
# Integración con Roo AI Assistant
|
||||
|
||||
Integra 9Router con Roo AI Assistant para acceder a múltiples modelos de IA a través de una interfaz unificada.
|
||||
|
||||
## Requisitos previos
|
||||
|
||||
- Roo AI Assistant instalado
|
||||
- API key de 9Router desde el [dashboard](https://9router.com/dashboard)
|
||||
- 9Router ejecutándose (local o en la nube)
|
||||
|
||||
## Pasos de configuración
|
||||
|
||||
### 1. Abrir la configuración de Roo
|
||||
|
||||
Inicia Roo AI Assistant y abre el panel de configuración.
|
||||
|
||||
### 2. Configurar el proveedor de API
|
||||
|
||||
1. Navega a la configuración de **API Provider**
|
||||
2. Selecciona **Ollama** como tipo de proveedor
|
||||
3. Configura los siguientes ajustes:
|
||||
|
||||
**Para 9Router local:**
|
||||
```
|
||||
Base URL: http://localhost:20128/v1
|
||||
API Key: your-api-key-from-dashboard
|
||||
```
|
||||
|
||||
**Para 9Router en la nube:**
|
||||
```
|
||||
Base URL: https://9router.com/v1
|
||||
API Key: your-api-key-from-dashboard
|
||||
```
|
||||
|
||||
### 3. Seleccionar modelo
|
||||
|
||||
Elige entre los modelos disponibles de 9Router:
|
||||
|
||||
**Modelos Claude:**
|
||||
- `cc/claude-opus-4-5-20251101` - El más capaz
|
||||
- `cc/claude-sonnet-4-20250514` - Equilibrado
|
||||
- `cc/claude-haiku-4-20250514` - Rápido
|
||||
|
||||
**Modelos DeepSeek:**
|
||||
- `cx/deepseek-chat` - Propósito general
|
||||
- `cx/deepseek-reasoner` - Razonamiento complejo
|
||||
|
||||
**Modelos GLM:**
|
||||
- `glm/glm-4-plus` - Avanzado
|
||||
- `glm/glm-4-flash` - Respuestas rápidas
|
||||
|
||||
### 4. Probar la conexión
|
||||
|
||||
Envía un mensaje de prueba para verificar la integración:
|
||||
|
||||
```
|
||||
Hello! Can you confirm you're connected through 9Router?
|
||||
```
|
||||
|
||||
## Ejemplos de uso
|
||||
|
||||
### Chat básico
|
||||
```
|
||||
Pregunta a Roo: "Explain quantum computing in simple terms"
|
||||
Modelo: cc/claude-sonnet-4-20250514
|
||||
```
|
||||
|
||||
### Generación de código
|
||||
```
|
||||
Pregunta a Roo: "Write a Python function to calculate Fibonacci numbers"
|
||||
Modelo: cx/deepseek-chat
|
||||
```
|
||||
|
||||
### Razonamiento complejo
|
||||
```
|
||||
Pregunta a Roo: "Analyze the trade-offs between microservices and monolithic architecture"
|
||||
Modelo: cx/deepseek-reasoner
|
||||
```
|
||||
|
||||
## Consejos de selección de modelo
|
||||
|
||||
- **Tareas rápidas**: Usa `cc/claude-haiku-4-20250514` o `glm/glm-4-flash`
|
||||
- **Rendimiento equilibrado**: Usa `cc/claude-sonnet-4-20250514` o `cx/deepseek-chat`
|
||||
- **Razonamiento complejo**: Usa `cc/claude-opus-4-5-20251101` o `cx/deepseek-reasoner`
|
||||
- **Optimización de costos**: Usa modelos DeepSeek o GLM
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### Connection Failed
|
||||
- Verifica que 9Router esté corriendo: `curl http://localhost:20128/health`
|
||||
- Verifica que la API key sea correcta
|
||||
- Asegúrate de que la Base URL incluya el sufijo `/v1`
|
||||
|
||||
### Modelo no disponible
|
||||
- Verifica que el nombre del modelo coincida exactamente (sensible a mayúsculas)
|
||||
- Verifica que el modelo esté habilitado en tu plan de 9Router
|
||||
- Intenta otro modelo de la lista
|
||||
|
||||
### Respuestas lentas
|
||||
- Cambia a modelos más rápidos (haiku, flash)
|
||||
- Verifica la conexión de red
|
||||
- Monitorea los logs de 9Router por problemas
|
||||
|
||||
## Configuración avanzada
|
||||
|
||||
### Aliases personalizados de modelos
|
||||
|
||||
Puedes crear atajos para modelos usados con frecuencia en la configuración de Roo:
|
||||
|
||||
```
|
||||
Alias: "fast" → cc/claude-haiku-4-20250514
|
||||
Alias: "smart" → cc/claude-opus-4-5-20251101
|
||||
Alias: "code" → cx/deepseek-chat
|
||||
```
|
||||
|
||||
### Múltiples perfiles
|
||||
|
||||
Configura diferentes perfiles para distintos casos de uso:
|
||||
- **Desarrollo**: Modelos DeepSeek para código
|
||||
- **Escritura**: Modelos Claude para contenido
|
||||
- **Investigación**: Modelos reasoner para análisis
|
||||
|
||||
## Próximos pasos
|
||||
|
||||
- [Configurar Cursor](cursor.md) para integración con IDE
|
||||
- [Configurar Continue](continue.md) para VSCode
|
||||
- [Explorar uso de CLI](../cli/basic-usage.md)
|
||||
@@ -0,0 +1,462 @@
|
||||
# Proveedores baratos - Respaldo ultra-barato
|
||||
|
||||
Cuando se agota la cuota de suscripción, paga centavos en lugar de dólares. ¡~90% más barato que ChatGPT API!
|
||||
|
||||
---
|
||||
|
||||
## Resumen
|
||||
|
||||
Los proveedores del nivel barato son tu **respaldo** cuando se agota la cuota de suscripción:
|
||||
|
||||
- 💰 **GLM-4.7** - $0.6/$2.2 por 1M tokens (reinicio diario)
|
||||
- 💰 **MiniMax M2.1** - $0.2/$1.0 por 1M tokens (reinicio 5h)
|
||||
- 💰 **Kimi K2** - $9/mes plano (10M tokens)
|
||||
|
||||
**Estrategia:** Úsalos después de agotar la cuota de suscripción, antes del nivel gratis. Ahorros masivos vs ChatGPT API ($20/1M).
|
||||
|
||||
---
|
||||
|
||||
## GLM-4.7 (Reinicio diario)
|
||||
|
||||
### Precios
|
||||
|
||||
| Nivel | Entrada | Salida | Reinicio |
|
||||
|------|-------|--------|-------|
|
||||
| Standard | $0.60/1M | $2.20/1M | Diario 10:00 AM |
|
||||
| Coding Plan | $0.60/1M | $2.20/1M | Diario 10:00 AM (3× cuota) |
|
||||
|
||||
**Ejemplo de costo (10M tokens):**
|
||||
- Entrada: 10M × $0.60 = $6
|
||||
- Salida: 10M × $2.20 = $22
|
||||
- **Total: $6-22** ¡vs $200 en ChatGPT API!
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Registrarse**
|
||||
|
||||
1. Visita [Zhipu AI](https://open.bigmodel.cn/)
|
||||
2. Crea cuenta (verificación por teléfono)
|
||||
3. Elige **Coding Plan** para 3× cuota al mismo precio
|
||||
|
||||
**Paso 2: Obtener API Key**
|
||||
|
||||
```bash
|
||||
Dashboard → API Keys → Create New
|
||||
→ Copia la API key (comienza con "zhipu-")
|
||||
```
|
||||
|
||||
**Paso 3: Agregar a 9Router**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Add API Key
|
||||
|
||||
Provider: glm
|
||||
API Key: zhipu-your-api-key-here
|
||||
```
|
||||
|
||||
**Paso 4: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: glm/glm-4.7
|
||||
glm/glm-4.6v (vision)
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Contexto | Ideal para |
|
||||
|----------|-------------|---------|----------|
|
||||
| `glm/glm-4.7` | GLM 4.7 | 128K | Codificación, tareas generales |
|
||||
| `glm/glm-4.6v` | GLM 4.6V Vision | 128K | Análisis de imágenes |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Coding Plan** - 3× cuota al mismo precio ($0.6/$2.2)
|
||||
- **Reinicio diario** - Cuota fresca a las 10:00 AM hora de Beijing
|
||||
- **Ideal para codificación** - Optimizado para generación de código
|
||||
- **128K de contexto** - Maneja archivos grandes
|
||||
|
||||
### Reinicio de cuota
|
||||
|
||||
```
|
||||
Reinicio diario: 10:00 AM hora Beijing (UTC+8)
|
||||
→ 2:00 AM UTC
|
||||
→ 6:00 PM PST (día anterior)
|
||||
→ 9:00 PM EST (día anterior)
|
||||
|
||||
¡Planifica tus tareas pesadas según el tiempo de reinicio!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## MiniMax M2.1 (Reinicio 5 horas)
|
||||
|
||||
### Precios
|
||||
|
||||
| Nivel | Entrada | Salida | Reinicio |
|
||||
|------|-------|--------|-------|
|
||||
| Standard | $0.20/1M | $1.00/1M | Rolling 5 horas |
|
||||
|
||||
**Ejemplo de costo (10M tokens):**
|
||||
- Entrada: 10M × $0.20 = $2
|
||||
- Salida: 10M × $1.00 = $10
|
||||
- **Total: $2-10** - ¡La opción más barata!
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Registrarse**
|
||||
|
||||
1. Visita [MiniMax](https://www.minimax.io/)
|
||||
2. Crea cuenta
|
||||
3. Verifica email/teléfono
|
||||
|
||||
**Paso 2: Obtener API Key**
|
||||
|
||||
```bash
|
||||
Dashboard → API Management → Create Key
|
||||
→ Copia la API key
|
||||
```
|
||||
|
||||
**Paso 3: Agregar a 9Router**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Add API Key
|
||||
|
||||
Provider: minimax
|
||||
API Key: your-minimax-api-key
|
||||
```
|
||||
|
||||
**Paso 4: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: minimax/MiniMax-M2.1
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Contexto | Ideal para |
|
||||
|----------|-------------|---------|----------|
|
||||
| `minimax/MiniMax-M2.1` | MiniMax M2.1 | 1M tokens | Contexto largo, codificación |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **La opción más barata** - $0.20/1M entrada (90% más barato que ChatGPT)
|
||||
- **Rolling 5 horas** - La cuota se reinicia cada 5 horas
|
||||
- **Contexto de 1M** - Ventana de contexto masiva
|
||||
- **Ideal para archivos largos** - Maneja codebases enteras
|
||||
|
||||
### Reinicio de cuota
|
||||
|
||||
```
|
||||
Ventana rolling de 5 horas:
|
||||
→ Usar cuota → Esperar 5 horas → Cuota fresca
|
||||
|
||||
Ejemplo:
|
||||
10:00 AM - Usar 5M tokens
|
||||
3:00 PM - Cuota fresca disponible
|
||||
8:00 PM - Cuota fresca disponible
|
||||
|
||||
¡Codifica 24/7 con costo mínimo!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Kimi K2 ($9/mes plano)
|
||||
|
||||
### Precios
|
||||
|
||||
| Plan | Costo mensual | Tokens incluidos | Costo efectivo |
|
||||
|------|--------------|-----------------|----------------|
|
||||
| Subscription | $9 | 10M tokens | $0.90/1M |
|
||||
|
||||
**Ejemplo de costo:**
|
||||
- $9/mes plano
|
||||
- 10M tokens incluidos
|
||||
- **Efectivo: $0.90/1M** - ¡Mejor valor para uso constante!
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Suscribirse**
|
||||
|
||||
1. Visita [Moonshot AI](https://platform.moonshot.ai/)
|
||||
2. Crea cuenta
|
||||
3. Suscríbete al plan $9/mes
|
||||
|
||||
**Paso 2: Obtener API Key**
|
||||
|
||||
```bash
|
||||
Dashboard → API Keys → Create New
|
||||
→ Copia la API key
|
||||
```
|
||||
|
||||
**Paso 3: Agregar a 9Router**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Add API Key
|
||||
|
||||
Provider: kimi
|
||||
API Key: your-kimi-api-key
|
||||
```
|
||||
|
||||
**Paso 4: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: kimi/kimi-latest
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Contexto | Ideal para |
|
||||
|----------|-------------|---------|----------|
|
||||
| `kimi/kimi-latest` | Kimi Latest | 200K | Codificación general |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Costo fijo** - $9/mes sin importar el uso (hasta 10M)
|
||||
- **Ideal para uso constante** - Si usas 10M/mes, solo $0.90/1M
|
||||
- **Reinicio mensual** - 10M tokens se reinician mensualmente
|
||||
- **Facturación predecible** - Sin costos sorpresa
|
||||
|
||||
### Reinicio de cuota
|
||||
|
||||
```
|
||||
Reinicio mensual: 1ro de cada mes
|
||||
→ 10M tokens se refrescan
|
||||
|
||||
Ejemplo de uso mensual:
|
||||
Semana 1: 3M tokens
|
||||
Semana 2: 2M tokens
|
||||
Semana 3: 3M tokens
|
||||
Semana 4: 2M tokens
|
||||
Total: 10M tokens = $9 plano
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Comparación de precios
|
||||
|
||||
| Proveedor | Entrada/1M | Salida/1M | Reinicio | Costo 10M | Ideal para |
|
||||
|----------|----------|-----------|-------|----------|----------|
|
||||
| **GLM-4.7** | $0.60 | $2.20 | Diario 10AM | $6-22 | Usuarios con cuota diaria |
|
||||
| **MiniMax M2.1** | $0.20 | $1.00 | 5 horas | $2-10 | **¡La más barata!** |
|
||||
| **Kimi K2** | $0.90 | $0.90 | Mensual | **$9 plano** | Uso constante |
|
||||
| ChatGPT API | $20.00 | $20.00 | Ninguno | $200 | ❌ Costoso |
|
||||
|
||||
**Ahorros:** ¡90-95% más barato que ChatGPT API!
|
||||
|
||||
---
|
||||
|
||||
## Ejemplo de uso
|
||||
|
||||
### Configuración en Cursor IDE
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [desde el dashboard de 9router]
|
||||
Model: glm/glm-4.7
|
||||
```
|
||||
|
||||
### Crear combo (Recomendado)
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: cheap-backup
|
||||
Models:
|
||||
1. cc/claude-opus-4-5 (Suscripción principal)
|
||||
2. glm/glm-4.7 (Respaldo barato, reinicio diario)
|
||||
3. minimax/MiniMax-M2.1 (Fallback más barato)
|
||||
4. if/kimi-k2-thinking (Emergencia GRATIS)
|
||||
|
||||
Usar en CLI: cheap-backup
|
||||
```
|
||||
|
||||
**Resultado:** Suscripción → Barato → Más barato → Gratis
|
||||
|
||||
---
|
||||
|
||||
## Optimización de costos
|
||||
|
||||
### Estrategia 1: Rutina de reinicio diario
|
||||
|
||||
```
|
||||
Mañana (10AM): Cuota fresca de GLM
|
||||
→ Usa GLM para tareas pesadas
|
||||
→ Ahorra cuota de suscripción
|
||||
|
||||
Tarde: Cuota de suscripción
|
||||
→ Usa Claude/Codex para tareas complejas
|
||||
|
||||
Noche: MiniMax (reinicio 5h)
|
||||
→ Respaldo barato para trabajo nocturno
|
||||
|
||||
Madrugada: Nivel gratis (iFlow)
|
||||
→ Respaldo de emergencia cero costo
|
||||
```
|
||||
|
||||
### Estrategia 2: Presupuesto primero
|
||||
|
||||
```
|
||||
Establece presupuesto mensual: $20
|
||||
|
||||
Asignación:
|
||||
- $9 Kimi K2 (10M tokens plano)
|
||||
- $6 cuota diaria de GLM (10M tokens)
|
||||
- $5 overflow de MiniMax (25M tokens)
|
||||
|
||||
Total: 45M tokens por $20
|
||||
¡vs 1M tokens por $20 en ChatGPT API!
|
||||
```
|
||||
|
||||
### Estrategia 3: Maximiza suscripciones primero
|
||||
|
||||
```
|
||||
Prioridad:
|
||||
1. Gemini CLI (180K/mes GRATIS)
|
||||
2. Claude Code (suscripción que ya pagas)
|
||||
3. GLM-4.7 (respaldo barato, $0.6/1M)
|
||||
4. MiniMax M2.1 (más barato, $0.2/1M)
|
||||
5. iFlow (emergencia GRATIS)
|
||||
|
||||
Ejemplo de costo mensual (100M tokens):
|
||||
- 60M vía Gemini CLI: $0 (gratis)
|
||||
- 30M vía Claude Code: $0 (suscripción)
|
||||
- 8M vía GLM: $4.80
|
||||
- 2M vía MiniMax: $0.40
|
||||
¡Total: $5.20/mes!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Ejemplos reales
|
||||
|
||||
### Ejemplo 1: Mes de codificación intensa (100M tokens)
|
||||
|
||||
```
|
||||
Desglose:
|
||||
- 60M vía suscripción (Claude/Codex): $0 extra
|
||||
- 30M vía GLM-4.7: $18
|
||||
- 10M vía MiniMax M2.1: $2
|
||||
|
||||
Total: $20/mes
|
||||
¡vs $2000 en ChatGPT API!
|
||||
|
||||
Ahorros: ¡99% más barato!
|
||||
```
|
||||
|
||||
### Ejemplo 2: Codificador con presupuesto ($10/mes)
|
||||
|
||||
```
|
||||
Estrategia:
|
||||
- $9 Kimi K2 (10M tokens)
|
||||
- $1 overflow de MiniMax (5M tokens)
|
||||
|
||||
Total: 15M tokens por $10
|
||||
¡vs 0.5M tokens por $10 en ChatGPT API!
|
||||
|
||||
¡30× más tokens!
|
||||
```
|
||||
|
||||
### Ejemplo 3: Freelancer (Uso variable)
|
||||
|
||||
```
|
||||
Mes ligero (20M tokens):
|
||||
- 15M vía suscripción: $0
|
||||
- 5M vía GLM: $3
|
||||
Total: $3
|
||||
|
||||
Mes intenso (150M tokens):
|
||||
- 60M vía suscripción: $0
|
||||
- 60M vía GLM: $36
|
||||
- 30M vía MiniMax: $6
|
||||
Total: $42
|
||||
|
||||
Promedio: $22.50/mes
|
||||
¡vs $3400 en ChatGPT API!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
### 1. Rastrea la cuota diaria
|
||||
|
||||
```
|
||||
El dashboard muestra:
|
||||
- Cuota GLM: 75% usado (reinicio en 6h)
|
||||
- Cuota MiniMax: 50% usado (reinicio en 2h)
|
||||
- Cuota Kimi: 8M/10M usado (reinicio en 15 días)
|
||||
|
||||
¡Planifica tareas pesadas según los tiempos de reinicio!
|
||||
```
|
||||
|
||||
### 2. Usa el Coding Plan (GLM)
|
||||
|
||||
```
|
||||
Standard: 1× cuota
|
||||
Coding Plan: 3× cuota (¡mismo precio!)
|
||||
|
||||
→ Siempre elige Coding Plan
|
||||
```
|
||||
|
||||
### 3. Combina con el nivel gratis
|
||||
|
||||
```
|
||||
Combo:
|
||||
1. gc/gemini-3-flash (GRATIS principal)
|
||||
2. glm/glm-4.7 (respaldo barato)
|
||||
3. minimax/MiniMax-M2.1 (más barato)
|
||||
4. if/kimi-k2-thinking (emergencia GRATIS)
|
||||
|
||||
Resultado: Minimiza costos, maximiza uptime
|
||||
```
|
||||
|
||||
### 4. Establece alertas de presupuesto
|
||||
|
||||
```
|
||||
Dashboard → Settings → Budget Alerts
|
||||
|
||||
Diario: $2 límite
|
||||
Semanal: $10 límite
|
||||
Mensual: $30 límite
|
||||
|
||||
→ Cambio automático al nivel gratis cuando se alcanza el límite
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### "Cuota agotada"
|
||||
|
||||
**Solución:**
|
||||
- GLM: Espera hasta las 10:00 AM hora Beijing
|
||||
- MiniMax: Espera 5 horas desde el primer uso
|
||||
- Kimi: Espera hasta el 1ro del próximo mes
|
||||
- Usa fallback de combo al nivel gratis
|
||||
|
||||
### "API key inválida"
|
||||
|
||||
**Solución:**
|
||||
- Verifica que la API key esté copiada correctamente
|
||||
- Verifica que la cuenta tenga créditos
|
||||
- Regenera la API key si es necesario
|
||||
|
||||
### "Costos altos"
|
||||
|
||||
**Solución:**
|
||||
- Revisa las estadísticas de uso en el dashboard
|
||||
- Establece alertas de presupuesto
|
||||
- Cambia a MiniMax ($0.2/1M, la más barata)
|
||||
- Usa el nivel gratis para tareas no críticas
|
||||
|
||||
---
|
||||
|
||||
## Próximos pasos
|
||||
|
||||
- **Agregar fallback gratis:** [Proveedores gratis](./free.md)
|
||||
- **Configurar suscripciones:** [Proveedores de suscripción](./subscription.md)
|
||||
- **Crear combos:** Dashboard → Combos → Create New
|
||||
@@ -0,0 +1,442 @@
|
||||
# Proveedores gratis - Fallback de cero costo
|
||||
|
||||
Respaldo de emergencia cuando todo lo demás está limitado por cuota. ¡Codifica 24/7 con cero costo!
|
||||
|
||||
---
|
||||
|
||||
## Resumen
|
||||
|
||||
Los proveedores del nivel gratis son tu **fallback** cuando se agota la cuota de suscripción y la del nivel barato:
|
||||
|
||||
- 🆓 **iFlow** - 8 modelos GRATIS (Kimi K2, Qwen3, GLM 4.7, MiniMax M2...)
|
||||
- 🆓 **Qwen** - 3 modelos GRATIS (Qwen3 Coder Plus/Flash, Vision)
|
||||
- 🆓 **Kiro** - 2 modelos GRATIS (Claude Sonnet 4.5, Haiku 4.5)
|
||||
|
||||
**Estrategia:** Úsalos como respaldo de emergencia. ¡Uso ilimitado, cero costo para siempre!
|
||||
|
||||
---
|
||||
|
||||
## iFlow (8 modelos GRATIS)
|
||||
|
||||
### Precios
|
||||
|
||||
| Plan | Costo mensual | Modelos | Cuota |
|
||||
|------|--------------|--------|-------|
|
||||
| FREE | $0 | 8 modelos | Ilimitado |
|
||||
|
||||
**Mejor valor:** ¡La mayoría de modelos en el nivel gratis! Kimi K2, Qwen3, GLM, MiniMax, DeepSeek.
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Conectar vía Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect iFlow
|
||||
```
|
||||
|
||||
**Paso 2: Login OAuth de iFlow**
|
||||
|
||||
- Clic en "Connect iFlow"
|
||||
- El navegador abre → página de login de iFlow
|
||||
- Crea cuenta o inicia sesión
|
||||
- Otorga permisos
|
||||
- Auto-refresh de token habilitado
|
||||
|
||||
**Paso 3: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: if/kimi-k2-thinking
|
||||
if/kimi-k2
|
||||
if/qwen3-coder-plus
|
||||
if/glm-4.7
|
||||
if/minimax-m2
|
||||
if/deepseek-r1
|
||||
if/deepseek-v3.2-chat
|
||||
if/deepseek-v3.2-reasoner
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Ideal para |
|
||||
|----------|-------------|----------|
|
||||
| `if/kimi-k2-thinking` | Kimi K2 Thinking | Razonamiento complejo |
|
||||
| `if/kimi-k2` | Kimi K2 | Codificación general |
|
||||
| `if/qwen3-coder-plus` | Qwen3 Coder Plus | Generación de código |
|
||||
| `if/glm-4.7` | GLM 4.7 | Chino + inglés |
|
||||
| `if/minimax-m2` | MiniMax M2 | Contexto largo |
|
||||
| `if/deepseek-r1` | DeepSeek R1 | Tareas de razonamiento |
|
||||
| `if/deepseek-v3.2-chat` | DeepSeek V3.2 Chat | Conversacional |
|
||||
| `if/deepseek-v3.2-reasoner` | DeepSeek V3.2 Reasoner | Lógica compleja |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **8 modelos GRATIS** - La mayor variedad en el nivel gratis
|
||||
- **Uso ilimitado** - Sin límites de cuota
|
||||
- **Kimi K2 Thinking** - Ideal para razonamiento complejo
|
||||
- **DeepSeek R1** - Fuertes capacidades de razonamiento
|
||||
|
||||
---
|
||||
|
||||
## Qwen (3 modelos GRATIS)
|
||||
|
||||
### Precios
|
||||
|
||||
| Plan | Costo mensual | Modelos | Cuota |
|
||||
|------|--------------|--------|-------|
|
||||
| FREE | $0 | 3 modelos | Ilimitado |
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Conectar vía Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect Qwen
|
||||
```
|
||||
|
||||
**Paso 2: Autorización por código de dispositivo**
|
||||
|
||||
- Clic en "Connect Qwen"
|
||||
- El dashboard muestra el código de dispositivo
|
||||
- Visita la URL de autorización
|
||||
- Ingresa el código de dispositivo
|
||||
- Inicia sesión en la cuenta de Qwen
|
||||
- Auto-refresh de token habilitado
|
||||
|
||||
**Paso 3: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: qw/qwen3-coder-plus
|
||||
qw/qwen3-coder-flash
|
||||
qw/vision-model
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Ideal para |
|
||||
|----------|-------------|----------|
|
||||
| `qw/qwen3-coder-plus` | Qwen3 Coder Plus | Codificación avanzada |
|
||||
| `qw/qwen3-coder-flash` | Qwen3 Coder Flash | Respuestas rápidas |
|
||||
| `qw/vision-model` | Qwen3 Vision | Análisis de imágenes |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Qwen3 Coder Plus** - Fuertes capacidades de codificación
|
||||
- **Qwen3 Coder Flash** - Rápido para tareas rápidas
|
||||
- **Modelo de visión** - Análisis de imágenes GRATIS
|
||||
- **Uso ilimitado** - Sin límites de cuota
|
||||
|
||||
---
|
||||
|
||||
## Kiro (Claude GRATIS)
|
||||
|
||||
### Precios
|
||||
|
||||
| Plan | Costo mensual | Modelos | Cuota |
|
||||
|------|--------------|--------|-------|
|
||||
| FREE | $0 | Claude Sonnet 4.5, Haiku 4.5 | Ilimitado |
|
||||
|
||||
**Mejor valor:** ¡Claude GRATIS! Misma calidad que Claude Code de pago.
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Conectar vía Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect Kiro
|
||||
```
|
||||
|
||||
**Paso 2: AWS Builder ID u OAuth**
|
||||
|
||||
- Clic en "Connect Kiro"
|
||||
- Elige método de login:
|
||||
- AWS Builder ID (recomendado)
|
||||
- Cuenta Google
|
||||
- Cuenta GitHub
|
||||
- Otorga permisos
|
||||
- Auto-refresh de token habilitado
|
||||
|
||||
**Paso 3: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: kr/claude-sonnet-4.5
|
||||
kr/claude-haiku-4.5
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Ideal para |
|
||||
|----------|-------------|----------|
|
||||
| `kr/claude-sonnet-4.5` | Claude Sonnet 4.5 | Calidad/velocidad equilibrada |
|
||||
| `kr/claude-haiku-4.5` | Claude Haiku 4.5 | Respuestas rápidas |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Claude GRATIS** - Misma calidad que el nivel de pago
|
||||
- **AWS Builder ID** - Configuración fácil con cuenta AWS
|
||||
- **Uso ilimitado** - Sin límites de cuota
|
||||
- **Mejor calidad** - ¡Claude 4.5 gratis!
|
||||
|
||||
---
|
||||
|
||||
## Comparación de características
|
||||
|
||||
| Proveedor | Modelos | Mejor modelo | Configuración | Cuota |
|
||||
|----------|--------|------------|-------|-------|
|
||||
| **iFlow** | 8 | Kimi K2 Thinking | OAuth | Ilimitado |
|
||||
| **Qwen** | 3 | Qwen3 Coder Plus | Device Code | Ilimitado |
|
||||
| **Kiro** | 2 | Claude Sonnet 4.5 | AWS Builder ID | Ilimitado |
|
||||
|
||||
**Ganador:** ¡iFlow por variedad, Kiro por calidad!
|
||||
|
||||
---
|
||||
|
||||
## Ejemplo de uso
|
||||
|
||||
### Configuración en Cursor IDE
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [desde el dashboard de 9router]
|
||||
Model: if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### Crear combo (Recomendado)
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: free-combo
|
||||
Models:
|
||||
1. if/kimi-k2-thinking (iFlow principal)
|
||||
2. qw/qwen3-coder-plus (Qwen respaldo)
|
||||
3. kr/claude-sonnet-4.5 (Kiro calidad)
|
||||
|
||||
Usar en CLI: free-combo
|
||||
```
|
||||
|
||||
**Resultado:** ¡Cero costo, máximo uptime!
|
||||
|
||||
---
|
||||
|
||||
## Estrategia de fallback completa
|
||||
|
||||
### Combo completo de 3 niveles
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: complete-fallback
|
||||
Models:
|
||||
1. gc/gemini-3-flash-preview (Suscripción GRATIS)
|
||||
2. cc/claude-opus-4-5 (Suscripción de pago)
|
||||
3. glm/glm-4.7 (Respaldo barato, $0.6/1M)
|
||||
4. minimax/MiniMax-M2.1 (Más barato, $0.2/1M)
|
||||
5. if/kimi-k2-thinking (Fallback GRATIS)
|
||||
6. kr/claude-sonnet-4.5 (Calidad GRATIS)
|
||||
|
||||
Usar en CLI: complete-fallback
|
||||
```
|
||||
|
||||
**Resultado:**
|
||||
- Nivel 1: Suscripción GRATIS (Gemini CLI)
|
||||
- Nivel 2: Suscripción de pago (Claude Code)
|
||||
- Nivel 3: Respaldo barato (GLM, MiniMax)
|
||||
- Nivel 4: Fallback GRATIS (iFlow, Kiro)
|
||||
|
||||
**¡Nunca dejes de codificar!**
|
||||
|
||||
---
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
### 1. Úsalos como respaldo de emergencia
|
||||
|
||||
```
|
||||
Prioridad:
|
||||
1. Nivel de suscripción (maximiza cuota de pago)
|
||||
2. Nivel barato (centavos por 1M tokens)
|
||||
3. Nivel GRATIS (ilimitado, cero costo)
|
||||
|
||||
Usa el nivel gratis solo cuando:
|
||||
- Cuota de suscripción agotada
|
||||
- Límite de presupuesto alcanzado
|
||||
- Pruebas/tareas no críticas
|
||||
```
|
||||
|
||||
### 2. Elige el modelo correcto
|
||||
|
||||
```
|
||||
Razonamiento complejo: if/kimi-k2-thinking
|
||||
Codificación rápida: qw/qwen3-coder-flash
|
||||
Mejor calidad: kr/claude-sonnet-4.5
|
||||
Contexto largo: if/minimax-m2
|
||||
Tareas de visión: qw/vision-model
|
||||
```
|
||||
|
||||
### 3. Crea un combo solo-gratis
|
||||
|
||||
```
|
||||
Para codificación de cero costo:
|
||||
|
||||
Name: zero-cost
|
||||
Models:
|
||||
1. kr/claude-sonnet-4.5 (Mejor calidad)
|
||||
2. if/kimi-k2-thinking (Tareas complejas)
|
||||
3. qw/qwen3-coder-plus (Codificación rápida)
|
||||
|
||||
¡Costo: $0 para siempre!
|
||||
```
|
||||
|
||||
### 4. Prueba antes de producción
|
||||
|
||||
```
|
||||
Usa el nivel gratis para:
|
||||
- Probar prompts
|
||||
- Prototipar características
|
||||
- Aprender nuevos frameworks
|
||||
- Tareas no críticas
|
||||
|
||||
Guarda la cuota de pago para:
|
||||
- Código de producción
|
||||
- Refactoring complejo
|
||||
- Características críticas
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Ejemplos reales
|
||||
|
||||
### Ejemplo 1: Estudiante/Aprendiz (Cero presupuesto)
|
||||
|
||||
```
|
||||
Configuración:
|
||||
1. kr/claude-sonnet-4.5 (Mejor calidad)
|
||||
2. if/kimi-k2-thinking (Razonamiento complejo)
|
||||
3. qw/qwen3-coder-plus (Codificación rápida)
|
||||
|
||||
Costo mensual: $0
|
||||
Uso: Ilimitado
|
||||
|
||||
Perfecto para:
|
||||
- Aprender a programar
|
||||
- Proyectos personales
|
||||
- Tareas/asignaciones
|
||||
```
|
||||
|
||||
### Ejemplo 2: Freelancer (Consciente del presupuesto)
|
||||
|
||||
```
|
||||
Configuración:
|
||||
1. gc/gemini-3-flash-preview (GRATIS 180K/mes)
|
||||
2. glm/glm-4.7 (Respaldo barato, $0.6/1M)
|
||||
3. if/kimi-k2-thinking (Fallback GRATIS)
|
||||
|
||||
Costo mensual: $5-10
|
||||
Uso: 100M+ tokens
|
||||
|
||||
Perfecto para:
|
||||
- Proyectos de cliente (nivel de pago)
|
||||
- Pruebas (nivel gratis)
|
||||
- Respaldo de emergencia
|
||||
```
|
||||
|
||||
### Ejemplo 3: Usuario intensivo (Maximiza todo)
|
||||
|
||||
```
|
||||
Configuración:
|
||||
1. gc/gemini-3-flash-preview (GRATIS 180K/mes)
|
||||
2. cc/claude-opus-4-5 (Suscripción $20-100)
|
||||
3. cx/gpt-5.2-codex (Suscripción $20-200)
|
||||
4. glm/glm-4.7 (Barato $0.6/1M)
|
||||
5. minimax/MiniMax-M2.1 (Más barato $0.2/1M)
|
||||
6. if/kimi-k2-thinking (GRATIS ilimitado)
|
||||
7. kr/claude-sonnet-4.5 (Calidad GRATIS)
|
||||
|
||||
Costo mensual: $40-320 (suscripciones) + $10-20 (nivel barato)
|
||||
Uso: 500M+ tokens
|
||||
|
||||
Perfecto para:
|
||||
- Desarrollo profesional
|
||||
- Proyectos de equipo
|
||||
- Codificación 24/7
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Comparación de costos
|
||||
|
||||
### Escenario: 100M tokens/mes
|
||||
|
||||
**Opción 1: Solo ChatGPT API**
|
||||
```
|
||||
100M × $20/1M = $2,000/mes
|
||||
```
|
||||
|
||||
**Opción 2: Solo nivel gratis de 9Router**
|
||||
```
|
||||
100M vía nivel gratis = $0/mes
|
||||
Ahorros: $2,000/mes (100%)
|
||||
```
|
||||
|
||||
**Opción 3: Estrategia completa de 9Router**
|
||||
```
|
||||
60M vía Gemini CLI (GRATIS): $0
|
||||
30M vía Claude Code (suscripción): $0 extra
|
||||
8M vía GLM (barato): $4.80
|
||||
2M vía iFlow (GRATIS): $0
|
||||
Total: $4.80/mes + suscripciones que ya tienes
|
||||
Ahorros: $1,995/mes (99.76%)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### "OAuth failed"
|
||||
|
||||
**Solución:**
|
||||
- Verifica la conexión a internet
|
||||
- Prueba otro navegador
|
||||
- Limpia la caché del navegador
|
||||
- Reconecta en el dashboard
|
||||
|
||||
### "Modelo no disponible"
|
||||
|
||||
**Solución:**
|
||||
- Verifica que el proveedor esté conectado en el dashboard
|
||||
- Verifica que el token OAuth sea válido
|
||||
- Reconecta el proveedor si es necesario
|
||||
|
||||
### "Respuestas lentas"
|
||||
|
||||
**Solución:**
|
||||
- El nivel gratis puede tener menor prioridad
|
||||
- Úsalo durante horas off-peak
|
||||
- Cambia a otro proveedor gratis
|
||||
- Mejora al nivel barato para velocidad
|
||||
|
||||
---
|
||||
|
||||
## Limitaciones
|
||||
|
||||
### Consideraciones del nivel gratis
|
||||
|
||||
- **Velocidad** - Puede ser más lento que los niveles de pago
|
||||
- **Prioridad** - Menor prioridad en horas pico
|
||||
- **Rate limits** - Posible rate-limiting (pero cuota ilimitada)
|
||||
- **Disponibilidad** - Puede tener tiempo de inactividad ocasional
|
||||
|
||||
**Solución:** ¡Usa la estrategia de fallback de 3 niveles para confiabilidad!
|
||||
|
||||
---
|
||||
|
||||
## Próximos pasos
|
||||
|
||||
- **Configurar suscripciones:** [Proveedores de suscripción](./subscription.md)
|
||||
- **Agregar respaldo barato:** [Proveedores baratos](./cheap.md)
|
||||
- **Crear combos:** Dashboard → Combos → Create New
|
||||
- **Empezar a codificar:** Usa el combo `complete-fallback` para máxima confiabilidad
|
||||
@@ -0,0 +1,404 @@
|
||||
# Proveedores de suscripción - Maximiza tu valor
|
||||
|
||||
Maximiza tus suscripciones de IA existentes con seguimiento inteligente de cuota y fallback automático. ¡Usa cada bit de tu suscripción antes de que se reinicie!
|
||||
|
||||
---
|
||||
|
||||
## Resumen
|
||||
|
||||
Los proveedores del nivel de suscripción son tu opción **principal** - ya estás pagando por ellos, así que obtén el valor completo:
|
||||
|
||||
- ✅ **Claude Code** (Pro/Max) - Claude 4.5 Opus/Sonnet/Haiku
|
||||
- ✅ **OpenAI Codex** (Plus/Pro) - GPT 5.2 Codex, GPT 5.1 Codex Max
|
||||
- ✅ **Gemini CLI** (¡Nivel GRATIS!) - 180K completados/mes
|
||||
- ✅ **GitHub Copilot** - GPT-5, Claude 4.5, Gemini 3
|
||||
- ✅ **Antigravity** (Google) - Gemini 3 Pro, Claude Sonnet 4.5
|
||||
|
||||
**Estrategia:** Úsalos primero, rastrea la cuota en tiempo real, fallback al barato/gratis cuando se agote.
|
||||
|
||||
---
|
||||
|
||||
## Claude Code (Pro/Max)
|
||||
|
||||
### Precios
|
||||
|
||||
| Plan | Costo mensual | Reinicio de cuota | Modelos |
|
||||
|------|--------------|-------------|--------|
|
||||
| Pro | $20 | 5 horas + semanal | Opus, Sonnet, Haiku |
|
||||
| Max | $100 | 5 horas + semanal | Opus, Sonnet, Haiku |
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Conectar vía Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Se abre el dashboard → Providers → Connect Claude Code
|
||||
```
|
||||
|
||||
**Paso 2: Login OAuth**
|
||||
|
||||
- Clic en "Connect Claude Code"
|
||||
- El navegador abre → Inicia sesión en Claude.ai
|
||||
- Auto-refresh de token habilitado
|
||||
- Comienza el seguimiento de cuota
|
||||
|
||||
**Paso 3: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
cc/claude-sonnet-4-5-20250929
|
||||
cc/claude-haiku-4-5-20251001
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Ideal para |
|
||||
|----------|-------------|----------|
|
||||
| `cc/claude-opus-4-5-20251101` | Claude 4.5 Opus | Tareas complejas, arquitectura |
|
||||
| `cc/claude-sonnet-4-5-20250929` | Claude 4.5 Sonnet | Velocidad/calidad equilibrada |
|
||||
| `cc/claude-haiku-4-5-20251001` | Claude 4.5 Haiku | Respuestas rápidas |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Usa Opus para tareas complejas** - Decisiones de arquitectura, refactoring
|
||||
- **Usa Sonnet por velocidad** - Ediciones rápidas, generación de código
|
||||
- **Rastrea cuota por modelo** - El dashboard muestra uso por modelo
|
||||
- **Reinicio de 5 horas** - Cuota fresca cada 5 horas + reinicio semanal
|
||||
|
||||
---
|
||||
|
||||
## OpenAI Codex (Plus/Pro)
|
||||
|
||||
### Precios
|
||||
|
||||
| Plan | Costo mensual | Reinicio de cuota | Modelos |
|
||||
|------|--------------|-------------|--------|
|
||||
| Plus | $20 | 5 horas + semanal | GPT 5.2, GPT 5.1 |
|
||||
| Pro | $200 | 5 horas + semanal | GPT 5.2 Codex, GPT 5.1 Max |
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Conectar vía Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect Codex
|
||||
```
|
||||
|
||||
**Paso 2: Login OAuth**
|
||||
|
||||
- Clic en "Connect Codex"
|
||||
- El navegador abre `http://localhost:1455`
|
||||
- Inicia sesión en la cuenta de OpenAI
|
||||
- Auto-refresh de token habilitado
|
||||
|
||||
**Paso 3: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: cx/gpt-5.2-codex
|
||||
cx/gpt-5.1-codex-max
|
||||
cx/gpt-5.2
|
||||
cx/gpt-5.1-codex
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Ideal para |
|
||||
|----------|-------------|----------|
|
||||
| `cx/gpt-5.2-codex` | GPT 5.2 Codex | Último modelo de codificación |
|
||||
| `cx/gpt-5.1-codex-max` | GPT 5.1 Codex Max | Contexto máximo |
|
||||
| `cx/gpt-5.2` | GPT 5.2 | Tareas generales |
|
||||
| `cx/gpt-5.1-codex` | GPT 5.1 Codex | Codificación estable |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Cuota rolling de 5 horas** - Cuota fresca cada 5 horas
|
||||
- **Reinicio semanal** - Reinicio completo de cuota cada semana
|
||||
- **Nivel Pro** - 10× más cuota que Plus
|
||||
|
||||
---
|
||||
|
||||
## Gemini CLI (¡GRATIS 180K/mes!)
|
||||
|
||||
### Precios
|
||||
|
||||
| Plan | Costo mensual | Cuota | Reinicio |
|
||||
|------|--------------|-------|-------|
|
||||
| FREE | $0 | 180K completados/mes + 1K/día | Diario + Mensual |
|
||||
|
||||
**Mejor valor:** ¡Nivel gratis enorme! Úsalo antes de los niveles de pago.
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Conectar vía Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect Gemini CLI
|
||||
```
|
||||
|
||||
**Paso 2: OAuth de Google**
|
||||
|
||||
- Clic en "Connect Gemini CLI"
|
||||
- El navegador abre → Inicia sesión en cuenta Google
|
||||
- Otorga permisos
|
||||
- Auto-refresh de token habilitado
|
||||
|
||||
**Paso 3: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: gc/gemini-3-flash-preview
|
||||
gc/gemini-3-pro-preview
|
||||
gc/gemini-2.5-pro
|
||||
gc/gemini-2.5-flash
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Ideal para |
|
||||
|----------|-------------|----------|
|
||||
| `gc/gemini-3-flash-preview` | Gemini 3 Flash Preview | Respuestas rápidas |
|
||||
| `gc/gemini-3-pro-preview` | Gemini 3 Pro Preview | Tareas complejas |
|
||||
| `gc/gemini-2.5-pro` | Gemini 2.5 Pro | Producción estable |
|
||||
| `gc/gemini-2.5-flash` | Gemini 2.5 Flash | Tareas rápidas |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **180K completados/mes** - Nivel gratis masivo
|
||||
- **Límite de 1K/día** - La cuota diaria se reinicia a medianoche
|
||||
- **Úsalo primero** - Nivel gratis, úsalo antes de las suscripciones de pago
|
||||
- **Sin tarjeta de crédito** - Completamente gratis con cuenta Google
|
||||
|
||||
---
|
||||
|
||||
## GitHub Copilot
|
||||
|
||||
### Precios
|
||||
|
||||
| Plan | Costo mensual | Reinicio de cuota | Modelos |
|
||||
|------|--------------|-------------|--------|
|
||||
| Individual | $10 | Mensual (día 1) | GPT-5, Claude 4.5, Gemini 3 |
|
||||
| Business | $19 | Mensual (día 1) | GPT-5, Claude 4.5, Gemini 3 |
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Conectar vía Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect GitHub
|
||||
```
|
||||
|
||||
**Paso 2: OAuth vía GitHub**
|
||||
|
||||
- Clic en "Connect GitHub"
|
||||
- El navegador abre → Inicia sesión en GitHub
|
||||
- Autoriza GitHub Copilot
|
||||
- Auto-refresh de token habilitado
|
||||
|
||||
**Paso 3: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: gh/gpt-5
|
||||
gh/gpt-5.1-codex-max
|
||||
gh/claude-4.5-sonnet
|
||||
gh/gemini-3-pro
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Ideal para |
|
||||
|----------|-------------|----------|
|
||||
| `gh/gpt-5` | GPT-5 | Último modelo de OpenAI |
|
||||
| `gh/gpt-5.1-codex-max` | GPT-5.1 Codex Max | Contexto máximo |
|
||||
| `gh/claude-4.5-sonnet` | Claude 4.5 Sonnet | Calidad de Anthropic |
|
||||
| `gh/gemini-3-pro` | Gemini 3 Pro | Calidad de Google |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Reinicio mensual** - Reinicio completo de cuota el 1ro del mes
|
||||
- **Múltiples modelos** - Accede a GPT, Claude, Gemini en una suscripción
|
||||
- **Nivel Business** - Mayor cuota para equipos
|
||||
|
||||
---
|
||||
|
||||
## Antigravity (Cuenta Google)
|
||||
|
||||
### Precios
|
||||
|
||||
| Plan | Costo mensual | Cuota | Modelos |
|
||||
|------|--------------|-------|--------|
|
||||
| FREE | $0 | Similar a Gemini CLI | Gemini 3 Pro, Claude Sonnet 4.5 |
|
||||
|
||||
### Configuración
|
||||
|
||||
**Paso 1: Conectar vía Dashboard**
|
||||
|
||||
```bash
|
||||
9router
|
||||
# Dashboard → Providers → Connect Antigravity
|
||||
```
|
||||
|
||||
**Paso 2: OAuth de Google**
|
||||
|
||||
- Clic en "Connect Antigravity"
|
||||
- El navegador abre → Inicia sesión en cuenta Google
|
||||
- Otorga permisos
|
||||
- Auto-refresh de token habilitado
|
||||
|
||||
**Paso 3: Usar en CLI**
|
||||
|
||||
```
|
||||
Model: ag/gemini-3-pro-high
|
||||
ag/claude-sonnet-4-5
|
||||
ag/claude-opus-4-5-thinking
|
||||
```
|
||||
|
||||
### Modelos disponibles
|
||||
|
||||
| ID del modelo | Descripción | Ideal para |
|
||||
|----------|-------------|----------|
|
||||
| `ag/gemini-3-pro-high` | Gemini 3 Pro High | Respuestas de alta calidad |
|
||||
| `ag/claude-sonnet-4-5` | Claude Sonnet 4.5 | Calidad de Anthropic |
|
||||
| `ag/claude-opus-4-5-thinking` | Claude Opus 4.5 Thinking | Razonamiento complejo |
|
||||
|
||||
### Pro Tips
|
||||
|
||||
- **Nivel gratis** - Sin costo con cuenta Google
|
||||
- **Acceso a Claude** - Claude Sonnet/Opus gratis
|
||||
- **Cuota similar a Gemini CLI** - Límites diarios/mensuales
|
||||
|
||||
---
|
||||
|
||||
## Comparación de precios
|
||||
|
||||
| Proveedor | Costo mensual | Reinicio de cuota | Valor |
|
||||
|----------|--------------|-------------|-------|
|
||||
| **Claude Code Pro** | $20 | 5 horas + semanal | ⭐⭐⭐⭐⭐ Mejor calidad |
|
||||
| **Claude Code Max** | $100 | 5 horas + semanal | ⭐⭐⭐⭐⭐ Mayor cuota |
|
||||
| **Codex Plus** | $20 | 5 horas + semanal | ⭐⭐⭐⭐ Buen valor |
|
||||
| **Codex Pro** | $200 | 5 horas + semanal | ⭐⭐⭐⭐⭐ 10× cuota |
|
||||
| **Gemini CLI** | **$0** | Diario + Mensual | ⭐⭐⭐⭐⭐ ¡GRATIS 180K/mes! |
|
||||
| **GitHub Copilot** | $10-19 | Mensual (día 1) | ⭐⭐⭐⭐ Multi-modelo |
|
||||
| **Antigravity** | **$0** | Diario + Mensual | ⭐⭐⭐⭐ ¡Claude GRATIS! |
|
||||
|
||||
---
|
||||
|
||||
## Ejemplo de uso
|
||||
|
||||
### Configuración en Cursor IDE
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [desde el dashboard de 9router]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
### Crear combo (Recomendado)
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: premium-coding
|
||||
Models:
|
||||
1. gc/gemini-3-flash-preview (GRATIS, usar primero)
|
||||
2. cc/claude-opus-4-5-20251101 (Suscripción)
|
||||
3. cx/gpt-5.2-codex (Respaldo de suscripción)
|
||||
|
||||
Usar en CLI: premium-coding
|
||||
```
|
||||
|
||||
**Resultado:** Maximiza el nivel gratis → Usa suscripción → Fallback automático
|
||||
|
||||
---
|
||||
|
||||
## Seguimiento de cuota
|
||||
|
||||
9Router rastrea la cuota en tiempo real:
|
||||
|
||||
- **Consumo de tokens** - Tokens de entrada/salida por solicitud
|
||||
- **Cuenta regresiva de reinicio** - Tiempo hasta el próximo reinicio de cuota
|
||||
- **Porcentaje de uso** - Cuánta cuota se ha usado
|
||||
- **Fallback automático** - Cambia al siguiente nivel cuando se agota
|
||||
|
||||
**Vista del dashboard:**
|
||||
|
||||
```
|
||||
Claude Code Pro
|
||||
├─ Cuota: 75% usada
|
||||
├─ Reinicio: 2h 15m (5 horas)
|
||||
├─ Reinicio semanal: 3 días
|
||||
└─ Fallback: glm/glm-4.7 (nivel barato)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
### 1. Usa el nivel gratis primero
|
||||
|
||||
```
|
||||
Prioridad:
|
||||
1. Gemini CLI (180K/mes GRATIS)
|
||||
2. Antigravity (Claude GRATIS)
|
||||
3. Claude Code/Codex (suscripciones de pago)
|
||||
```
|
||||
|
||||
### 2. Rastrea la cuota diariamente
|
||||
|
||||
- Revisa el dashboard cada mañana
|
||||
- Planifica tareas pesadas según reinicios de cuota
|
||||
- Usa el nivel barato/gratis para tareas no críticas
|
||||
|
||||
### 3. Crea combos inteligentes
|
||||
|
||||
```
|
||||
Ejemplo de combo:
|
||||
1. gc/gemini-3-flash-preview (GRATIS principal)
|
||||
2. cc/claude-opus-4-5 (Tareas complejas)
|
||||
3. glm/glm-4.7 (Respaldo barato)
|
||||
4. if/kimi-k2-thinking (Fallback GRATIS)
|
||||
```
|
||||
|
||||
### 4. Optimiza por tiempo
|
||||
|
||||
```
|
||||
Mañana: Cuota fresca de 5 horas (Claude/Codex)
|
||||
Tarde: Gemini CLI (1K/día)
|
||||
Noche: Cuota de suscripción
|
||||
Madrugada: Nivel barato/gratis
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Solución de problemas
|
||||
|
||||
### "Cuota agotada"
|
||||
|
||||
**Solución:**
|
||||
- Verifica el rastreador de cuota del dashboard
|
||||
- Espera el reinicio (5 horas o diario)
|
||||
- Usa fallback de combo al nivel barato/gratis
|
||||
|
||||
### "Token OAuth expirado"
|
||||
|
||||
**Solución:**
|
||||
- Auto-refresh por 9Router
|
||||
- Si hay problemas: Dashboard → Provider → Reconnect
|
||||
|
||||
### "Rate limiting"
|
||||
|
||||
**Solución:**
|
||||
- Cuota de suscripción agotada
|
||||
- Agrega fallback: `cc/claude-opus → glm/glm-4.7`
|
||||
- Usa el nivel gratis: `if/kimi-k2-thinking`
|
||||
|
||||
---
|
||||
|
||||
## Próximos pasos
|
||||
|
||||
- **Configurar respaldo barato:** [Proveedores baratos](./cheap.md)
|
||||
- **Agregar fallback gratis:** [Proveedores gratis](./free.md)
|
||||
- **Crear combos:** Dashboard → Combos → Create New
|
||||
@@ -0,0 +1,351 @@
|
||||
# Solución de problemas
|
||||
|
||||
Problemas comunes y soluciones al usar 9Router.
|
||||
|
||||
---
|
||||
|
||||
## "Language model did not provide messages"
|
||||
|
||||
**Problema:** La solicitud falla con una respuesta vacía o un mensaje de error.
|
||||
|
||||
**Causas:**
|
||||
- Cuota del proveedor agotada
|
||||
- API key inválida o expirada
|
||||
- Modelo no disponible
|
||||
|
||||
**Soluciones:**
|
||||
|
||||
1. **Verifica el estado de la cuota:**
|
||||
```
|
||||
Dashboard → Providers → Ver el rastreador de cuota
|
||||
```
|
||||
Si la cuota está agotada, espera el reinicio o cambia de proveedor.
|
||||
|
||||
2. **Usa el fallback con combo:**
|
||||
```
|
||||
Dashboard → Combos → Crea cadena de fallback
|
||||
Ejemplo: cc/claude-opus → glm/glm-4.7 → if/kimi-k2
|
||||
```
|
||||
|
||||
3. **Verifica la conexión del proveedor:**
|
||||
```
|
||||
Dashboard → Providers → Reconecta si es necesario
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
**Problema:** Errores "Rate limit exceeded" o "Too many requests".
|
||||
|
||||
**Causas:**
|
||||
- Cuota de suscripción agotada (límites de 5 horas/diario/semanal)
|
||||
- Límites de tasa de API alcanzados
|
||||
- Demasiadas solicitudes concurrentes
|
||||
|
||||
**Soluciones:**
|
||||
|
||||
1. **Verifica el tiempo de reinicio:**
|
||||
```
|
||||
Dashboard → Quota Tracking → Ver cuenta regresiva
|
||||
```
|
||||
|
||||
2. **Cambia al nivel barato:**
|
||||
```
|
||||
Usa: glm/glm-4.7 ($0.6/1M tokens)
|
||||
minimax/MiniMax-M2.1 ($0.20/1M tokens)
|
||||
```
|
||||
|
||||
3. **Agrega un combo de fallback:**
|
||||
```
|
||||
Dashboard → Combos → Agrega modelos de respaldo
|
||||
Principal: cc/claude-opus (suscripción)
|
||||
Respaldo: glm/glm-4.7 (barato)
|
||||
Emergencia: if/kimi-k2 (gratis)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Token OAuth expirado
|
||||
|
||||
**Problema:** Errores "Unauthorized" o "Token expired".
|
||||
|
||||
**Causas:**
|
||||
- Token OAuth expirado (refresh automático falló)
|
||||
- Sesión del proveedor invalidada
|
||||
- Problemas de red durante el refresh
|
||||
|
||||
**Soluciones:**
|
||||
|
||||
1. **Refresh automático (por defecto):**
|
||||
9Router refresca automáticamente los tokens. Espera 30 segundos y reintenta.
|
||||
|
||||
2. **Reconexión manual:**
|
||||
```
|
||||
Dashboard → Providers → [Nombre del proveedor] → Reconnect
|
||||
→ Completa el flujo OAuth de nuevo
|
||||
```
|
||||
|
||||
3. **Verifica el estado del proveedor:**
|
||||
Verifica que el servicio del proveedor esté en línea (Claude Code, Codex, etc.)
|
||||
|
||||
---
|
||||
|
||||
## Costos altos
|
||||
|
||||
**Problema:** Uso o costos altos inesperados.
|
||||
|
||||
**Causas:**
|
||||
- Uso de modelos costosos innecesariamente
|
||||
- Sin fallback a niveles más baratos
|
||||
- Ventanas de contexto grandes
|
||||
|
||||
**Soluciones:**
|
||||
|
||||
1. **Verifica las estadísticas de uso:**
|
||||
```
|
||||
Dashboard → Usage Stats → Ver consumo de tokens
|
||||
→ Identifica modelos de alto costo
|
||||
```
|
||||
|
||||
2. **Cambia a modelos más baratos:**
|
||||
```
|
||||
Reemplaza: cc/claude-opus (suscripción $20-100/mes)
|
||||
Con: glm/glm-4.7 ($0.6/1M tokens)
|
||||
minimax/MiniMax-M2.1 ($0.20/1M tokens)
|
||||
```
|
||||
|
||||
3. **Usa el nivel gratis:**
|
||||
```
|
||||
if/kimi-k2-thinking (GRATIS)
|
||||
qw/qwen3-coder-plus (GRATIS)
|
||||
kr/claude-sonnet-4.5 (GRATIS)
|
||||
gc/gemini-3-flash-preview (GRATIS 180K/mes)
|
||||
```
|
||||
|
||||
4. **Optimiza los prompts:**
|
||||
- Reduce el tamaño del contexto
|
||||
- Usa streaming para respuestas largas
|
||||
- Cachea prompts comunes
|
||||
|
||||
---
|
||||
|
||||
## Connection Refused
|
||||
|
||||
**Problema:** "ECONNREFUSED" o "Cannot connect to localhost:20128".
|
||||
|
||||
**Causas:**
|
||||
- 9Router no está ejecutándose
|
||||
- Puerto 20128 bloqueado
|
||||
- Firewall bloqueando la conexión
|
||||
|
||||
**Soluciones:**
|
||||
|
||||
1. **Inicia 9Router:**
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
El dashboard debe abrir en http://localhost:3000
|
||||
|
||||
2. **Verifica el puerto 20128:**
|
||||
```bash
|
||||
# Verifica si el puerto está escuchando
|
||||
lsof -i :20128
|
||||
|
||||
# O en Windows
|
||||
netstat -ano | findstr :20128
|
||||
```
|
||||
|
||||
3. **Revisa el firewall:**
|
||||
- macOS: System Settings → Network → Firewall
|
||||
- Windows: Windows Defender Firewall → Allow app
|
||||
- Linux: `sudo ufw allow 20128`
|
||||
|
||||
4. **Usa el endpoint en la nube:**
|
||||
Si localhost no funciona (ej. Cursor IDE):
|
||||
```
|
||||
Endpoint: https://9router.com/v1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## El dashboard no abre
|
||||
|
||||
**Problema:** El dashboard no carga en http://localhost:3000.
|
||||
|
||||
**Causas:**
|
||||
- Puerto 3000 ya en uso
|
||||
- 9Router crasheó
|
||||
- Problemas de caché del navegador
|
||||
|
||||
**Soluciones:**
|
||||
|
||||
1. **Verifica si 9Router está ejecutándose:**
|
||||
```bash
|
||||
# Verifica el proceso
|
||||
ps aux | grep 9router
|
||||
|
||||
# Verifica el puerto 3000
|
||||
lsof -i :3000
|
||||
```
|
||||
|
||||
2. **Mata el proceso en conflicto:**
|
||||
```bash
|
||||
# macOS/Linux
|
||||
lsof -ti:3000 | xargs kill -9
|
||||
|
||||
# Windows
|
||||
netstat -ano | findstr :3000
|
||||
taskkill /PID <PID> /F
|
||||
```
|
||||
|
||||
3. **Reinicia 9Router:**
|
||||
```bash
|
||||
# Detener
|
||||
pkill -f 9router
|
||||
|
||||
# Iniciar
|
||||
9router
|
||||
```
|
||||
|
||||
4. **Limpia la caché del navegador:**
|
||||
- Chrome: Ctrl+Shift+Delete → Limpiar caché
|
||||
- Prueba en modo incógnito
|
||||
|
||||
5. **Verifica la configuración del firewall:**
|
||||
Asegúrate de que el puerto 3000 no esté bloqueado.
|
||||
|
||||
---
|
||||
|
||||
## Modelo no encontrado
|
||||
|
||||
**Problema:** Errores "Model not found" o "Invalid model".
|
||||
|
||||
**Causas:**
|
||||
- Proveedor no conectado
|
||||
- Error tipográfico en el ID del modelo
|
||||
- Proveedor inactivo
|
||||
|
||||
**Soluciones:**
|
||||
|
||||
1. **Verifica la conexión del proveedor:**
|
||||
```
|
||||
Dashboard → Providers → Verifica estado (verde = activo)
|
||||
```
|
||||
|
||||
2. **Revisa el formato del ID del modelo:**
|
||||
```
|
||||
Correcto: cc/claude-opus-4-5-20251101
|
||||
Incorrecto: claude-opus-4-5-20251101
|
||||
|
||||
Formato: [prefijo-proveedor]/[nombre-modelo]
|
||||
```
|
||||
|
||||
3. **Lista los modelos disponibles:**
|
||||
```bash
|
||||
curl http://localhost:20128/v1/models \
|
||||
-H "Authorization: Bearer your-api-key"
|
||||
```
|
||||
|
||||
4. **Reconecta el proveedor:**
|
||||
```
|
||||
Dashboard → Providers → [Proveedor] → Reconnect
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Respuesta lenta
|
||||
|
||||
**Problema:** Las solicitudes tardan demasiado o hacen timeout.
|
||||
|
||||
**Causas:**
|
||||
- Latencia del proveedor
|
||||
- Problemas de red
|
||||
- Contexto/respuesta grande
|
||||
- Rate limiting del proveedor
|
||||
|
||||
**Soluciones:**
|
||||
|
||||
1. **Verifica el estado del proveedor:**
|
||||
```
|
||||
Dashboard → Providers → Ver estadísticas de latencia
|
||||
```
|
||||
|
||||
2. **Cambia a un modelo más rápido:**
|
||||
```
|
||||
Rápidos: cc/claude-haiku-4-5 (Haiku es más rápido que Opus)
|
||||
gc/gemini-3-flash-preview
|
||||
qw/qwen3-coder-flash
|
||||
```
|
||||
|
||||
3. **Usa streaming:**
|
||||
```json
|
||||
{
|
||||
"model": "cc/claude-opus-4-5",
|
||||
"messages": [...],
|
||||
"stream": true
|
||||
}
|
||||
```
|
||||
|
||||
4. **Verifica la red:**
|
||||
```bash
|
||||
# Prueba la latencia
|
||||
ping api.anthropic.com
|
||||
ping api.openai.com
|
||||
```
|
||||
|
||||
5. **Reduce el tamaño del contexto:**
|
||||
- Recorta el historial de mensajes
|
||||
- Usa prompts más pequeños
|
||||
- Habilita el pruning de contexto en la herramienta CLI
|
||||
|
||||
---
|
||||
|
||||
## API Key inválida
|
||||
|
||||
**Problema:** Errores "Invalid API key" o "Authentication failed".
|
||||
|
||||
**Causas:**
|
||||
- API key incorrecta copiada
|
||||
- API key expirada
|
||||
- API key no generada
|
||||
|
||||
**Soluciones:**
|
||||
|
||||
1. **Regenera la API key:**
|
||||
```
|
||||
Dashboard → Settings → API Keys → Generate New Key
|
||||
→ Copia y usa la nueva key
|
||||
```
|
||||
|
||||
2. **Verifica el formato de la key:**
|
||||
```
|
||||
Correcto: 9r_xxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Incorrecto: Falta el prefijo 9r_
|
||||
```
|
||||
|
||||
3. **Verifica la key en la configuración del CLI:**
|
||||
```bash
|
||||
# Cursor
|
||||
Settings → Models → OpenAI API Key
|
||||
|
||||
# Cline
|
||||
Settings → API Key
|
||||
|
||||
# Variable de entorno
|
||||
export OPENAI_API_KEY="9r_your_key"
|
||||
```
|
||||
|
||||
4. **Prueba la API key:**
|
||||
```bash
|
||||
curl http://localhost:20128/v1/models \
|
||||
-H "Authorization: Bearer 9r_your_key"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ¿Necesitas más ayuda?
|
||||
|
||||
- **GitHub Issues:** [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
- **Documentación:** [9router.com/docs](https://9router.com/docs)
|
||||
- **FAQ:** [faq.md](faq.md)
|
||||
@@ -0,0 +1,473 @@
|
||||
# ☁️ クラウドデプロイメント
|
||||
|
||||
リモートアクセスと本番利用のため、VPSまたはDockerに9Routerをデプロイ。
|
||||
|
||||
---
|
||||
|
||||
## 🖥️ VPSデプロイメント
|
||||
|
||||
### 前提条件
|
||||
|
||||
- Ubuntu 20.04+ または同様のLinuxディストリビューション
|
||||
- Node.js 20以上
|
||||
- Git
|
||||
- rootまたはsudoアクセス
|
||||
|
||||
### ステップ1: リポジトリをクローン
|
||||
|
||||
```bash
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
```
|
||||
|
||||
### ステップ2: 依存関係をインストール
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
### ステップ3: アプリケーションをビルド
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
### ステップ4: 環境変数を設定
|
||||
|
||||
`.env` ファイルを作成するか、変数をエクスポート:
|
||||
|
||||
```bash
|
||||
export JWT_SECRET="your-secure-secret-change-this-to-random-string"
|
||||
export INITIAL_PASSWORD="your-secure-password"
|
||||
export DATA_DIR="/var/lib/9router"
|
||||
export NODE_ENV="production"
|
||||
```
|
||||
|
||||
**環境変数:**
|
||||
|
||||
| 変数 | デフォルト | 説明 |
|
||||
|----------|---------|-------------|
|
||||
| `JWT_SECRET` | 自動生成 | **本番環境では必ず変更!** JWTトークンの署名に使用 |
|
||||
| `INITIAL_PASSWORD` | `123456` | ダッシュボードログインパスワード |
|
||||
| `DATA_DIR` | `~/.9router` | データベースとデータの保存パス |
|
||||
| `NODE_ENV` | `development` | デプロイ時は `production` に設定 |
|
||||
| `ENABLE_REQUEST_LOGS` | `false` | デバッグリクエスト/レスポンスログを有効化 |
|
||||
|
||||
### ステップ5: データディレクトリを作成
|
||||
|
||||
```bash
|
||||
sudo mkdir -p /var/lib/9router
|
||||
sudo chown $USER:$USER /var/lib/9router
|
||||
```
|
||||
|
||||
### ステップ6: アプリケーションを起動
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
### ステップ7: 本番環境用にPM2をセットアップ
|
||||
|
||||
PM2はアプリケーションを稼働させ続け、クラッシュ時に再起動します:
|
||||
|
||||
```bash
|
||||
# PM2をグローバルにインストール
|
||||
npm install -g pm2
|
||||
|
||||
# PM2で9Routerを起動
|
||||
pm2 start npm --name 9router -- start
|
||||
|
||||
# PM2設定を保存
|
||||
pm2 save
|
||||
|
||||
# システム起動時にPM2を開始するようセットアップ
|
||||
pm2 startup
|
||||
# 上記コマンドが出力する指示に従ってください
|
||||
```
|
||||
|
||||
**PM2管理コマンド:**
|
||||
|
||||
```bash
|
||||
# ログを表示
|
||||
pm2 logs 9router
|
||||
|
||||
# アプリケーションを再起動
|
||||
pm2 restart 9router
|
||||
|
||||
# アプリケーションを停止
|
||||
pm2 stop 9router
|
||||
|
||||
# ステータスを表示
|
||||
pm2 status
|
||||
|
||||
# リソースをモニタリング
|
||||
pm2 monit
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🐳 Dockerデプロイメント
|
||||
|
||||
### オプション1: Dockerfileを使用
|
||||
|
||||
`app` ディレクトリに `Dockerfile` を作成:
|
||||
|
||||
```dockerfile
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy application files
|
||||
COPY . .
|
||||
|
||||
# Build application
|
||||
RUN npm run build
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 3000 20128
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV DATA_DIR=/app/data
|
||||
|
||||
# Create data directory
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
# Start application
|
||||
CMD ["npm", "run", "start"]
|
||||
```
|
||||
|
||||
**ビルドと実行:**
|
||||
|
||||
```bash
|
||||
# イメージをビルド
|
||||
docker build -t 9router .
|
||||
|
||||
# コンテナを実行
|
||||
docker run -d \
|
||||
--name 9router \
|
||||
-p 3000:3000 \
|
||||
-p 20128:20128 \
|
||||
-e JWT_SECRET="your-secure-secret-change-this" \
|
||||
-e INITIAL_PASSWORD="your-secure-password" \
|
||||
-v 9router-data:/app/data \
|
||||
9router
|
||||
```
|
||||
|
||||
### オプション2: Docker Compose
|
||||
|
||||
`docker-compose.yml` を作成:
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
9router:
|
||||
build: .
|
||||
container_name: 9router
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "20128:20128"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- JWT_SECRET=your-secure-secret-change-this
|
||||
- INITIAL_PASSWORD=your-secure-password
|
||||
- DATA_DIR=/app/data
|
||||
volumes:
|
||||
- 9router-data:/app/data
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
9router-data:
|
||||
```
|
||||
|
||||
**Docker Composeで実行:**
|
||||
|
||||
```bash
|
||||
# サービスを起動
|
||||
docker-compose up -d
|
||||
|
||||
# ログを表示
|
||||
docker-compose logs -f
|
||||
|
||||
# サービスを停止
|
||||
docker-compose down
|
||||
|
||||
# 再ビルドして再起動
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Nginxリバースプロキシ
|
||||
|
||||
### Nginxを使う理由
|
||||
|
||||
- SSL/TLS終端
|
||||
- ドメイン名マッピング
|
||||
- ロードバランシング
|
||||
- セキュリティ強化
|
||||
|
||||
### ステップ1: Nginxをインストール
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install nginx
|
||||
```
|
||||
|
||||
### ステップ2: Nginxを設定
|
||||
|
||||
`/etc/nginx/sites-available/9router` を作成:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name your-domain.com;
|
||||
|
||||
# Redirect HTTP to HTTPS
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name your-domain.com;
|
||||
|
||||
# SSL certificates (use certbot to generate)
|
||||
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
|
||||
|
||||
# SSL configuration
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Proxy to 9Router
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
|
||||
# SSE support - CRITICAL for streaming
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
# API endpoint
|
||||
location /v1 {
|
||||
proxy_pass http://localhost:20128;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# SSE support - CRITICAL for streaming
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### ステップ3: サイトを有効化
|
||||
|
||||
```bash
|
||||
# シンボリックリンクを作成
|
||||
sudo ln -s /etc/nginx/sites-available/9router /etc/nginx/sites-enabled/
|
||||
|
||||
# 設定をテスト
|
||||
sudo nginx -t
|
||||
|
||||
# Nginxをリロード
|
||||
sudo systemctl reload nginx
|
||||
```
|
||||
|
||||
### ステップ4: Let's EncryptでSSLをセットアップ
|
||||
|
||||
```bash
|
||||
# certbotをインストール
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
|
||||
# SSL証明書を取得
|
||||
sudo certbot --nginx -d your-domain.com
|
||||
|
||||
# 自動更新は自動的に設定されます
|
||||
# 更新をテスト
|
||||
sudo certbot renew --dry-run
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔒 セキュリティ考慮事項
|
||||
|
||||
### 1. デフォルト認証情報を変更
|
||||
|
||||
**重要:** デプロイ前に `JWT_SECRET` と `INITIAL_PASSWORD` を変更:
|
||||
|
||||
```bash
|
||||
# 安全なJWTシークレットを生成
|
||||
openssl rand -base64 32
|
||||
|
||||
# この値をJWT_SECRETに使用
|
||||
export JWT_SECRET="generated-secret-here"
|
||||
```
|
||||
|
||||
### 2. ファイアウォール設定
|
||||
|
||||
```bash
|
||||
# SSHを許可
|
||||
sudo ufw allow 22/tcp
|
||||
|
||||
# HTTP/HTTPSを許可 (Nginx使用時)
|
||||
sudo ufw allow 80/tcp
|
||||
sudo ufw allow 443/tcp
|
||||
|
||||
# リバースプロキシを使用しない場合、9Routerポートを許可
|
||||
sudo ufw allow 3000/tcp
|
||||
sudo ufw allow 20128/tcp
|
||||
|
||||
# ファイアウォールを有効化
|
||||
sudo ufw enable
|
||||
```
|
||||
|
||||
### 3. ダッシュボードアクセスを制限
|
||||
|
||||
APIアクセスのみ必要な場合、ダッシュボードポートを制限:
|
||||
|
||||
```bash
|
||||
# ダッシュボードへのlocalhostアクセスのみ許可
|
||||
sudo ufw deny 3000/tcp
|
||||
```
|
||||
|
||||
SSHトンネル経由でダッシュボードにアクセス:
|
||||
|
||||
```bash
|
||||
ssh -L 3000:localhost:3000 user@your-server.com
|
||||
# ブラウザで http://localhost:3000 を開く
|
||||
```
|
||||
|
||||
### 4. 定期的な更新
|
||||
|
||||
```bash
|
||||
# システムパッケージを更新
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
|
||||
# 9Routerを更新
|
||||
cd /path/to/9router/app
|
||||
git pull
|
||||
npm install
|
||||
npm run build
|
||||
pm2 restart 9router
|
||||
```
|
||||
|
||||
### 5. バックアップ戦略
|
||||
|
||||
```bash
|
||||
# データディレクトリをバックアップ
|
||||
tar -czf 9router-backup-$(date +%Y%m%d).tar.gz /var/lib/9router
|
||||
|
||||
# 自動毎日バックアップ (crontabに追加)
|
||||
0 2 * * * tar -czf /backups/9router-$(date +\%Y\%m\%d).tar.gz /var/lib/9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 モニタリング
|
||||
|
||||
### アプリケーションステータスを確認
|
||||
|
||||
```bash
|
||||
# PM2ステータス
|
||||
pm2 status
|
||||
|
||||
# ログを表示
|
||||
pm2 logs 9router --lines 100
|
||||
|
||||
# リソースをモニタリング
|
||||
pm2 monit
|
||||
```
|
||||
|
||||
### Nginxログ
|
||||
|
||||
```bash
|
||||
# アクセスログ
|
||||
sudo tail -f /var/log/nginx/access.log
|
||||
|
||||
# エラーログ
|
||||
sudo tail -f /var/log/nginx/error.log
|
||||
```
|
||||
|
||||
### システムリソース
|
||||
|
||||
```bash
|
||||
# CPUとメモリ使用量
|
||||
htop
|
||||
|
||||
# ディスク使用量
|
||||
df -h
|
||||
|
||||
# ネットワーク接続
|
||||
netstat -tulpn | grep -E '3000|20128'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚨 トラブルシューティング
|
||||
|
||||
### アプリケーションが起動しない
|
||||
|
||||
```bash
|
||||
# ログを確認
|
||||
pm2 logs 9router
|
||||
|
||||
# ポートが使用中か確認
|
||||
sudo lsof -i :3000
|
||||
sudo lsof -i :20128
|
||||
|
||||
# 環境変数を確認
|
||||
pm2 env 9router
|
||||
```
|
||||
|
||||
### Nginx 502 Bad Gateway
|
||||
|
||||
```bash
|
||||
# 9Routerが実行中か確認
|
||||
pm2 status
|
||||
|
||||
# Nginxエラーログを確認
|
||||
sudo tail -f /var/log/nginx/error.log
|
||||
|
||||
# Nginx設定をテスト
|
||||
sudo nginx -t
|
||||
```
|
||||
|
||||
### SSEストリーミングが動作しない
|
||||
|
||||
SSEサポート用にNginx設定で `proxy_buffering off` が設定されていることを確認。
|
||||
|
||||
### Permission Deniedエラー
|
||||
|
||||
```bash
|
||||
# データディレクトリ権限を修正
|
||||
sudo chown -R $USER:$USER /var/lib/9router
|
||||
chmod 755 /var/lib/9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔗 次のステップ
|
||||
|
||||
- [プロバイダーを接続](/providers/subscription.md)
|
||||
- [コンボをセットアップ](/features/combos.md)
|
||||
- [ツールと統合](/integration/cursor.md)
|
||||
@@ -0,0 +1,164 @@
|
||||
# 🏠 ローカルホストデプロイメント
|
||||
|
||||
開発と個人利用のため、ローカルマシンで9Routerを実行。
|
||||
|
||||
---
|
||||
|
||||
## 📦 インストール
|
||||
|
||||
npm経由で9Routerをグローバルインストール:
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
**要件:**
|
||||
- Node.js 20以上
|
||||
- npm 9以上
|
||||
|
||||
---
|
||||
|
||||
## 🚀 サーバーの起動
|
||||
|
||||
一つのコマンドで9Routerを起動:
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
ダッシュボードが自動的にブラウザで `http://localhost:3000` に開きます。
|
||||
|
||||
**デフォルト設定:**
|
||||
- **ダッシュボード**: `http://localhost:3000`
|
||||
- **APIエンドポイント**: `http://localhost:20128/v1`
|
||||
- **データディレクトリ**: `~/.9router`
|
||||
|
||||
---
|
||||
|
||||
## 🔧 設定
|
||||
|
||||
### カスタムデータディレクトリ
|
||||
|
||||
環境変数を使ってカスタムデータディレクトリを設定:
|
||||
|
||||
```bash
|
||||
DATA_DIR=/path/to/data 9router
|
||||
```
|
||||
|
||||
### カスタムポート
|
||||
|
||||
APIポート(20128)とダッシュボードポート(3000)はアプリケーションで設定されています。変更するにはソースコードを修正するか、サポートされている場合は環境変数を使用してください。
|
||||
|
||||
---
|
||||
|
||||
## 🛑 サーバーの停止
|
||||
|
||||
9Routerが実行されているターミナルで `Ctrl+C` を押します。
|
||||
|
||||
```bash
|
||||
# 9routerを実行しているターミナル
|
||||
^C # Ctrl+Cを押す
|
||||
```
|
||||
|
||||
サーバーはグレースフルにシャットダウンし、すべてのデータを保存します。
|
||||
|
||||
---
|
||||
|
||||
## 🔄 サーバーの再起動
|
||||
|
||||
起動コマンドを再度実行するだけです:
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
すべての設定、APIキー、コンボはデータディレクトリに保持されます。
|
||||
|
||||
---
|
||||
|
||||
## 📊 9Routerの更新
|
||||
|
||||
最新バージョンに更新:
|
||||
|
||||
```bash
|
||||
npm update -g 9router
|
||||
```
|
||||
|
||||
現在のバージョンを確認:
|
||||
|
||||
```bash
|
||||
npm list -g 9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔍 トラブルシューティング
|
||||
|
||||
### ポートがすでに使用されている
|
||||
|
||||
ポート20128または3000がすでに使用されている場合:
|
||||
|
||||
```bash
|
||||
# ポートを使用しているプロセスを検索 (macOS/Linux)
|
||||
lsof -i :20128
|
||||
lsof -i :3000
|
||||
|
||||
# プロセスを終了
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
### 権限エラー
|
||||
|
||||
インストール中に権限エラーが発生した場合:
|
||||
|
||||
```bash
|
||||
# sudoを使用 (非推奨)
|
||||
sudo npm install -g 9router
|
||||
|
||||
# またはnpm権限を修正 (推奨)
|
||||
mkdir ~/.npm-global
|
||||
npm config set prefix '~/.npm-global'
|
||||
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
### データディレクトリの問題
|
||||
|
||||
データディレクトリにアクセスできない場合:
|
||||
|
||||
```bash
|
||||
# 権限を確認
|
||||
ls -la ~/.9router
|
||||
|
||||
# 権限を修正
|
||||
chmod 755 ~/.9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📁 データディレクトリ構造
|
||||
|
||||
```
|
||||
~/.9router/
|
||||
├── db.json # メインデータベース (プロバイダー、コンボ、設定)
|
||||
├── logs/ # アプリケーションログ
|
||||
└── cache/ # 一時キャッシュファイル
|
||||
```
|
||||
|
||||
**データのバックアップ:**
|
||||
|
||||
```bash
|
||||
# バックアップ
|
||||
cp -r ~/.9router ~/.9router.backup
|
||||
|
||||
# 復元
|
||||
cp -r ~/.9router.backup ~/.9router
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔗 次のステップ
|
||||
|
||||
- [プロバイダーを接続](/providers/subscription.md)
|
||||
- [コンボを作成](/features/combos.md)
|
||||
- [CLIツールとの統合](/integration/cursor.md)
|
||||
@@ -0,0 +1,387 @@
|
||||
# よくある質問
|
||||
|
||||
9Routerに関する一般的な質問。
|
||||
|
||||
---
|
||||
|
||||
## 9Routerとは?
|
||||
|
||||
**9Routerは、サブスクリプションの価値を最大化し、コストを最小限に抑えるAIモデルルーターです。**
|
||||
|
||||
3階層フォールバックシステムを使用して、複数のAIプロバイダー間でリクエストをインテリジェントにルーティングします:
|
||||
1. **サブスクリプション階層** - すでに支払っているClaude Code、Codex、Geminiのクォータを最大化
|
||||
2. **低価格階層** - 超低価格な代替手段(100万トークンあたり$0.20〜$0.60)
|
||||
3. **無料階層** - 無制限の無料モデルによる緊急バックアップ
|
||||
|
||||
**主な利点:**
|
||||
- サブスクリプションのクォータを無駄にしない
|
||||
- クォータ消費時の自動フォールバック
|
||||
- リアルタイムクォータトラッキング
|
||||
- 直接API利用に対して90%のコスト削減
|
||||
|
||||
---
|
||||
|
||||
## 料金体系はどうなっていますか?
|
||||
|
||||
**9Routerは3階層の料金戦略を使用します:**
|
||||
|
||||
### Tier 1: サブスクリプション(最初に最大化)
|
||||
- **Claude Code** (Pro/Max): 月$20〜100 - 5時間 + 週次クォータ
|
||||
- **OpenAI Codex** (Plus/Pro): 月$20〜200 - 5時間 + 週次クォータ
|
||||
- **Gemini CLI**: 無料 - 月18万コンプリーション + 1K/日
|
||||
- **GitHub Copilot**: 月$10〜19 - 月次リセット
|
||||
- **Antigravity**: 無料 - Geminiと同様
|
||||
|
||||
**目標:** リセット前にクォータを余すことなく使用!
|
||||
|
||||
### Tier 2: 低価格(バックアップ)
|
||||
- **GLM-4.7**: 100万トークンあたり$0.60/$2.20 - 毎日午前10時リセット
|
||||
- **MiniMax M2.1**: 100万トークンあたり$0.20/$1.00 - 5時間ローリング
|
||||
- **Kimi K2**: 月$9固定(1000万トークン)
|
||||
|
||||
**目標:** ChatGPT API(100万あたり$20)より90%安い!
|
||||
|
||||
### Tier 3: 無料(緊急時)
|
||||
- **iFlow**: 8モデル無料(Kimi K2、Qwen3、GLM、MiniMax...)
|
||||
- **Qwen**: 3モデル無料(Qwen3 Coder Plus/Flash、Vision)
|
||||
- **Kiro**: 2モデル無料(Claude Sonnet 4.5、Haiku 4.5)
|
||||
|
||||
**目標:** 他のすべてがクォータ制限に達した時のゼロコストフォールバック!
|
||||
|
||||
---
|
||||
|
||||
## 9Routerは無料ですか?
|
||||
|
||||
**はい、9Router自体は100%無料でオープンソースです。**
|
||||
|
||||
**利用可能な無料階層プロバイダー:**
|
||||
- **Gemini CLI** - 月18万コンプリーション(無料Googleアカウント)
|
||||
- **iFlow** - 8モデル無制限(無料OAuth)
|
||||
- **Qwen** - 3モデル無制限(無料OAuth)
|
||||
- **Kiro** - Claude Sonnet/Haiku(無料AWS Builder ID)
|
||||
|
||||
**無料階層プロバイダーのみを使用して永久に無料でコーディングできます!**
|
||||
|
||||
**オプションの有料プロバイダー:**
|
||||
- すでに持っている可能性のあるサブスクリプションサービス(Claude Code、Codex、Copilot)
|
||||
- 超低価格な代替手段(100万トークンあたり$0.20〜$0.60)
|
||||
|
||||
---
|
||||
|
||||
## どのプロバイダーがサポートされていますか?
|
||||
|
||||
### サブスクリプションプロバイダー
|
||||
- **Claude Code** (Pro/Max) - Claude 4.5 Opus/Sonnet/Haiku
|
||||
- **OpenAI Codex** (Plus/Pro) - GPT 5.2 Codex、GPT 5.1 Codex Max
|
||||
- **Gemini CLI** (無料) - Gemini 3 Flash/Pro、2.5 Pro/Flash
|
||||
- **GitHub Copilot** - GPT-5、Claude 4.5、Gemini 3
|
||||
- **Antigravity** (Google) - Gemini 3 Pro、Claude Sonnet 4.5
|
||||
|
||||
### 低価格プロバイダー
|
||||
- **GLM** (Zhipu AI) - GLM 4.7、GLM 4.6V Vision
|
||||
- **MiniMax** - MiniMax M2.1
|
||||
- **Kimi** (Moonshot AI) - Kimi Latest
|
||||
- **OpenRouter** - 任意のOpenRouterモデルへのパススルー
|
||||
|
||||
### 無料プロバイダー
|
||||
- **iFlow** - 8モデル(Kimi K2、Qwen3、GLM、MiniMax、DeepSeek...)
|
||||
- **Qwen** - 3モデル(Qwen3 Coder Plus/Flash、Vision)
|
||||
- **Kiro** - 2モデル(Claude Sonnet 4.5、Haiku 4.5)
|
||||
|
||||
**合計: 15以上のプロバイダー、50以上のモデル**
|
||||
|
||||
詳細は[プロバイダードキュメント](providers/subscription.md)を参照。
|
||||
|
||||
---
|
||||
|
||||
## 複数のプロバイダーを使用できますか?
|
||||
|
||||
**はい! これは9Routerのコア機能です。**
|
||||
|
||||
**コンボにより、複数のプロバイダーを自動フォールバック付きで連鎖させることができます:**
|
||||
|
||||
```
|
||||
コンボ例: "premium-coding"
|
||||
1. cc/claude-opus-4-5 (サブスクリプション優先)
|
||||
2. glm/glm-4.7 (低価格バックアップ)
|
||||
3. if/kimi-k2 (無料緊急時)
|
||||
|
||||
→ クォータ消費時に自動切替
|
||||
→ コーディングが止まらない
|
||||
→ 最小の追加コスト
|
||||
```
|
||||
|
||||
**コンボの作成方法:**
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
→ 優先順位順にモデルを追加
|
||||
→ CLIでコンボ名を使用: "premium-coding"
|
||||
```
|
||||
|
||||
**利点:**
|
||||
- クォータ切れ時のダウンタイムゼロ
|
||||
- 自動コスト最適化
|
||||
- すべてのツール用の単一モデル名
|
||||
|
||||
例については[コンボドキュメント](features/combos.md)を参照。
|
||||
|
||||
---
|
||||
|
||||
## クォータトラッキングはどのように機能しますか?
|
||||
|
||||
**9Routerはすべてのプロバイダーのクォータをリアルタイムで追跡します:**
|
||||
|
||||
**機能:**
|
||||
- **トークン消費** - リクエストごとの入出力トークン
|
||||
- **リセットカウントダウン** - クォータが更新されるまでの時間
|
||||
- **使用統計** - 日次/週次/月次レポート
|
||||
- **コスト見積もり** - 予測支出(有料階層)
|
||||
- **クォータアラート** - クォータが少ない時の通知
|
||||
|
||||
**クォータタイプ:**
|
||||
- **5時間ローリング** - Claude Code、Codex、MiniMax
|
||||
- **日次リセット** - Gemini CLI(1K/日)、GLM(午前10時)
|
||||
- **週次リセット** - Claude Code、Codex(追加クォータ)
|
||||
- **月次リセット** - Gemini CLI(18万)、GitHub Copilot(1日)
|
||||
|
||||
**クォータを表示:**
|
||||
```
|
||||
Dashboard → Providers → Quota Tracking
|
||||
→ リアルタイム使用量 + リセットカウントダウン
|
||||
```
|
||||
|
||||
詳細は[クォータトラッキングドキュメント](features/quota-tracking.md)を参照。
|
||||
|
||||
---
|
||||
|
||||
## 9RouterはCursorで動作しますか?
|
||||
|
||||
**はい、ただしCursorはクラウドエンドポイントが必要です。**
|
||||
|
||||
**問題:** Cursor IDEはlocalhostエンドポイントをサポートしていません。
|
||||
|
||||
**解決策:** 9Routerクラウドデプロイメントを使用:
|
||||
|
||||
```
|
||||
Cursor Settings → Models → Advanced:
|
||||
OpenAI API Base URL: https://9router.com/v1
|
||||
OpenAI API Key: [ダッシュボードから取得]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
**代替案:** パブリックドメインでVPSにセルフホスト:
|
||||
```bash
|
||||
# VPSへデプロイ
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
npm install && npm run build
|
||||
npm start
|
||||
|
||||
# Nginxリバースプロキシを設定
|
||||
# Cursorを向ける: https://your-domain.com/v1
|
||||
```
|
||||
|
||||
**他のCLIツールはlocalhostで動作:**
|
||||
- Cline ✅
|
||||
- Claude Desktop ✅
|
||||
- Codex CLI ✅
|
||||
- Continue ✅
|
||||
- RooCode ✅
|
||||
|
||||
詳細は[Cursor統合ガイド](integration/cursor.md)を参照。
|
||||
|
||||
---
|
||||
|
||||
## 9Routerをセルフホストできますか?
|
||||
|
||||
**はい! 9Routerは複数のデプロイメントオプションをサポートします:**
|
||||
|
||||
### Localhost(デフォルト)
|
||||
```bash
|
||||
npm install -g 9router
|
||||
9router
|
||||
→ Dashboard: http://localhost:3000
|
||||
→ API: http://localhost:20128/v1
|
||||
```
|
||||
|
||||
### VPS/クラウド
|
||||
```bash
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
npm install && npm run build
|
||||
|
||||
export JWT_SECRET="your-secure-secret"
|
||||
export INITIAL_PASSWORD="your-password"
|
||||
export NODE_ENV="production"
|
||||
|
||||
npm start
|
||||
```
|
||||
|
||||
### Docker
|
||||
```bash
|
||||
docker build -t 9router .
|
||||
docker run -d \
|
||||
-p 3000:3000 \
|
||||
-e JWT_SECRET="your-secret" \
|
||||
-v 9router-data:/app/data \
|
||||
9router
|
||||
```
|
||||
|
||||
### Cloudflare Workers
|
||||
```bash
|
||||
cd 9router/app
|
||||
npm run deploy:cloudflare
|
||||
```
|
||||
|
||||
**環境変数:**
|
||||
- `JWT_SECRET` - **本番環境で必ず変更!**
|
||||
- `DATA_DIR` - データベース保存パス(デフォルト: `~/.9router`)
|
||||
- `INITIAL_PASSWORD` - ダッシュボードログイン(デフォルト: `123456`)
|
||||
- `NODE_ENV` - デプロイ時は`production`に設定
|
||||
|
||||
詳細は[デプロイメントガイド](getting-started/installation.md#deployment)を参照。
|
||||
|
||||
---
|
||||
|
||||
## データは安全ですか?
|
||||
|
||||
**はい、9Routerはセキュリティとプライバシーを優先します:**
|
||||
|
||||
**ローカルストレージ:**
|
||||
- すべてのデータは`~/.9router`(またはカスタム`DATA_DIR`)にローカル保存
|
||||
- 9Routerサーバーへのデータ送信なし
|
||||
- OAuthトークンはJWTで暗号化
|
||||
|
||||
**テレメトリなし:**
|
||||
- 使用状況追跡なし
|
||||
- アナリティクスなし
|
||||
- フォンホームなし
|
||||
|
||||
**オープンソース:**
|
||||
- 完全なソースコードがGitHubで利用可能
|
||||
- 自分でセキュリティを監査可能
|
||||
- コミュニティレビュー済み
|
||||
|
||||
**ベストプラクティス:**
|
||||
- 本番環境で`JWT_SECRET`を変更
|
||||
- 強力な`INITIAL_PASSWORD`を使用
|
||||
- クラウドデプロイでHTTPSを有効化
|
||||
- APIキーを定期的にローテーション
|
||||
|
||||
**9Routerが保存するもの:**
|
||||
- プロバイダーOAuthトークン(暗号化)
|
||||
- APIキー(暗号化)
|
||||
- 使用統計(ローカルのみ)
|
||||
- コンボ設定
|
||||
|
||||
**9Routerが保存しないもの:**
|
||||
- プロンプトやレスポンス
|
||||
- 生成したコード
|
||||
- 個人情報
|
||||
|
||||
---
|
||||
|
||||
## 9Routerを更新するには?
|
||||
|
||||
**更新方法はインストールタイプによって異なります:**
|
||||
|
||||
### グローバルNPMインストール
|
||||
```bash
|
||||
npm update -g 9router
|
||||
```
|
||||
|
||||
### ローカルインストール
|
||||
```bash
|
||||
cd 9router/app
|
||||
git pull origin main
|
||||
npm install
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
### Docker
|
||||
```bash
|
||||
docker pull 9router:latest
|
||||
docker stop 9router
|
||||
docker rm 9router
|
||||
docker run -d \
|
||||
-p 3000:3000 \
|
||||
-v 9router-data:/app/data \
|
||||
9router:latest
|
||||
```
|
||||
|
||||
**バージョンを確認:**
|
||||
```bash
|
||||
9router --version
|
||||
```
|
||||
|
||||
**破壊的変更:**
|
||||
- [CHANGELOG.md](https://github.com/decolua/9router/blob/main/CHANGELOG.md)を確認
|
||||
- メジャー更新前に`~/.9router`をバックアップ
|
||||
- メジャーバージョンの移行ガイドを確認
|
||||
|
||||
---
|
||||
|
||||
## どのように貢献できますか?
|
||||
|
||||
**貢献を歓迎します!**
|
||||
|
||||
### 貢献方法:
|
||||
|
||||
1. **バグを報告:**
|
||||
- [GitHub Issues](https://github.com/decolua/9router/issues)
|
||||
- エラーログ、再現手順を含める
|
||||
|
||||
2. **機能をリクエスト:**
|
||||
- [GitHub Discussions](https://github.com/decolua/9router/discussions)
|
||||
- ユースケースと利点を説明
|
||||
|
||||
3. **コードを提出:**
|
||||
```bash
|
||||
# リポジトリをフォーク
|
||||
git clone https://github.com/YOUR_USERNAME/9router.git
|
||||
cd 9router
|
||||
|
||||
# ブランチを作成
|
||||
git checkout -b feature/your-feature
|
||||
|
||||
# 変更を加える
|
||||
npm install
|
||||
npm run dev
|
||||
|
||||
# テスト
|
||||
npm test
|
||||
|
||||
# コミットしてプッシュ
|
||||
git add .
|
||||
git commit -m "Add your feature"
|
||||
git push origin feature/your-feature
|
||||
|
||||
# GitHubでPull Requestを作成
|
||||
```
|
||||
|
||||
4. **ドキュメントを改善:**
|
||||
- 誤字の修正、例の追加
|
||||
- 他言語への翻訳
|
||||
- チュートリアルの執筆
|
||||
|
||||
5. **プロバイダーを追加:**
|
||||
- 新しいプロバイダーアダプターを実装
|
||||
- 例については`app/lib/providers/`を参照
|
||||
|
||||
**貢献ガイドライン:**
|
||||
- 既存のコードスタイルに従う
|
||||
- 新機能にはテストを追加
|
||||
- ドキュメントを更新
|
||||
- コミットは小さく、わかりやすく
|
||||
|
||||
詳細は[CONTRIBUTING.md](https://github.com/decolua/9router/blob/main/CONTRIBUTING.md)を参照。
|
||||
|
||||
---
|
||||
|
||||
## さらにヘルプが必要?
|
||||
|
||||
- **ドキュメント:** [9router.com/docs](https://9router.com/docs)
|
||||
- **GitHub:** [github.com/decolua/9router](https://github.com/decolua/9router)
|
||||
- **Issues:** [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
- **トラブルシューティング:** [troubleshooting.md](troubleshooting.md)
|
||||
@@ -0,0 +1,537 @@
|
||||
# コンボ - カスタムフォールバックチェーン
|
||||
|
||||
自動フォールバック付きのカスタムモデル組み合わせを作成。コンボを使って、コスト、品質、可用性に基づく独自のルーティング戦略を定義できます。
|
||||
|
||||
---
|
||||
|
||||
## コンボとは?
|
||||
|
||||
コンボはダッシュボードで作成する**カスタムフォールバックチェーン**です。単一モデルを使う代わりに、9Routerが順番に試すモデルのシーケンスを定義します。
|
||||
|
||||
**例:**
|
||||
```
|
||||
コンボ名: premium-coding
|
||||
モデル:
|
||||
1. cc/claude-opus-4-5-20251101 (最初に試行)
|
||||
2. glm/glm-4.7 (#1のクォータ消費時)
|
||||
3. minimax/MiniMax-M2.1 (#2のクォータ消費時)
|
||||
```
|
||||
|
||||
**CLIでの使用:**
|
||||
```
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
9Routerは成功するまで各モデルを順番に自動的に試します。
|
||||
|
||||
---
|
||||
|
||||
## なぜコンボを使うのか?
|
||||
|
||||
### 1. サブスクリプション価値を最大化
|
||||
```
|
||||
cc/claude-opus → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
→ サブスクリプション優先、低価格バックアップ、無料緊急時
|
||||
→ すでに支払っているサブスクリプションから完全な価値を得る
|
||||
```
|
||||
|
||||
### 2. コストを最小化
|
||||
```
|
||||
glm/glm-4.7 → minimax/MiniMax-M2.1 → if/kimi-k2-thinking
|
||||
|
||||
→ 最安の有料オプションから開始 (100万あたり$0.60)
|
||||
→ さらに安いものへフォールバック (100万あたり$0.20)
|
||||
→ 緊急時の無料階層
|
||||
→ 総コスト: 月$5〜10 vs ChatGPT APIの$2000
|
||||
```
|
||||
|
||||
### 3. 24時間可用性を確保
|
||||
```
|
||||
cc/claude-opus → cx/gpt-5.2-codex → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
→ 最後に常に無料階層を含める
|
||||
→ クォータ切れにならない
|
||||
→ いつでもどこでもコーディング
|
||||
```
|
||||
|
||||
### 4. 品質に最適化
|
||||
```
|
||||
cc/claude-opus-4-5 → cx/gpt-5.2-codex → gc/gemini-3-pro
|
||||
|
||||
→ 最高のモデルが最初
|
||||
→ 他のプレミアムモデルへフォールバック
|
||||
→ フォールバックチェーン全体で高品質を維持
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## コンボの作成方法
|
||||
|
||||
### ステップ1: ダッシュボードを開く
|
||||
|
||||
```
|
||||
http://localhost:20128
|
||||
→ パスワードでログイン
|
||||
```
|
||||
|
||||
### ステップ2: コンボへ移動
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New Combo
|
||||
```
|
||||
|
||||
### ステップ3: コンボを設定
|
||||
|
||||
**コンボ名:**
|
||||
```
|
||||
premium-coding
|
||||
```
|
||||
|
||||
**説明(任意):**
|
||||
```
|
||||
サブスクリプション優先、低価格バックアップ、無料緊急時
|
||||
```
|
||||
|
||||
**モデルを選択:**
|
||||
```
|
||||
1. cc/claude-opus-4-5-20251101
|
||||
2. glm/glm-4.7
|
||||
3. minimax/MiniMax-M2.1
|
||||
```
|
||||
|
||||
**ドラッグで並べ替え** - 上から下へ優先順位。
|
||||
|
||||
### ステップ4: 保存
|
||||
|
||||
```
|
||||
「Save Combo」をクリック
|
||||
→ コンボがモデルリストに表示
|
||||
```
|
||||
|
||||
### ステップ5: CLIで使用
|
||||
|
||||
```
|
||||
Cursor/Cline/任意のツール:
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## コンボの例
|
||||
|
||||
### 例1: プレミアムコーディング (サブスク → 低価格 → 無料)
|
||||
|
||||
**目標**: サブスクリプション価値を最大化、追加コストを最小化。
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
**使用法:**
|
||||
```
|
||||
Cursor IDE:
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
**動作:**
|
||||
```
|
||||
朝 (新鮮なクォータ):
|
||||
Request → cc/claude-opus-4-5 ✅
|
||||
|
||||
午後 (Claudeクォータ切れ):
|
||||
Request → glm/glm-4.7 ✅ (自動切替)
|
||||
|
||||
夕方 (GLMクォータ切れ):
|
||||
Request → minimax/MiniMax-M2.1 ✅ (自動切替)
|
||||
```
|
||||
|
||||
**月コスト (1億トークン):**
|
||||
```
|
||||
Claude Code経由で8000万: $0 (サブスクリプション)
|
||||
GLM経由で1500万: $9
|
||||
MiniMax経由で500万: $1
|
||||
合計: $10 + サブスクリプション
|
||||
```
|
||||
|
||||
**節約**: ChatGPT API ($2000) に対して約99%。
|
||||
|
||||
---
|
||||
|
||||
### 例2: バジェットコンボ (低価格 → 無料)
|
||||
|
||||
**目標**: コストを最小化、バックアップに無料階層を使用。
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: budget-combo
|
||||
Models:
|
||||
1. glm/glm-4.7
|
||||
2. minimax/MiniMax-M2.1
|
||||
3. if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
**使用法:**
|
||||
```
|
||||
Cline:
|
||||
Provider: OpenAI Compatible
|
||||
Base URL: http://localhost:20128/v1
|
||||
Model: budget-combo
|
||||
```
|
||||
|
||||
**動作:**
|
||||
```
|
||||
Request → glm/glm-4.7
|
||||
✅ 日次クォータ利用可 → GLMを使用 (100万あたり$0.60)
|
||||
❌ クォータ消費 → MiniMaxを試行 (100万あたり$0.20)
|
||||
❌ MiniMaxクォータ切れ → iFlowを使用 (無料)
|
||||
```
|
||||
|
||||
**月コスト (1億トークン):**
|
||||
```
|
||||
GLM経由で7000万: $42
|
||||
MiniMax経由で2000万: $4
|
||||
iFlow経由で1000万: $0
|
||||
合計: $46 vs ChatGPT APIの$2000
|
||||
```
|
||||
|
||||
**節約**: 97%。
|
||||
|
||||
---
|
||||
|
||||
### 例3: フリーコンボ (ゼロコスト)
|
||||
|
||||
**目標**: 100%無料、コストはゼロ。
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: free-combo
|
||||
Models:
|
||||
1. if/kimi-k2-thinking
|
||||
2. qw/qwen3-coder-plus
|
||||
3. kr/claude-sonnet-4.5
|
||||
```
|
||||
|
||||
**使用法:**
|
||||
```
|
||||
Claude Desktop:
|
||||
Model: free-combo
|
||||
```
|
||||
|
||||
**動作:**
|
||||
```
|
||||
Request → if/kimi-k2-thinking
|
||||
✅ 利用可 → iFlowを使用
|
||||
❌ エラー → Qwenを試行
|
||||
❌ エラー → Kiroを試行
|
||||
```
|
||||
|
||||
**月コスト:**
|
||||
```
|
||||
無料プロバイダー経由で1億トークン: $0
|
||||
合計: 永久に$0
|
||||
```
|
||||
|
||||
**ユースケース**: 個人プロジェクト、学習、実験。
|
||||
|
||||
---
|
||||
|
||||
### 例4: 品質優先 (プレミアムモデルのみ)
|
||||
|
||||
**目標**: 最高の品質、低価格フォールバックなし。
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
**使用法:**
|
||||
```
|
||||
Codex CLI:
|
||||
export OPENAI_BASE_URL="http://localhost:20128"
|
||||
Model: quality-first
|
||||
```
|
||||
|
||||
**動作:**
|
||||
```
|
||||
Request → cc/claude-opus-4-5
|
||||
❌ クォータ切れ → cx/gpt-5.2-codex
|
||||
❌ クォータ切れ → gc/gemini-3-pro-preview
|
||||
❌ すべて切れ → エラーを返す (低価格フォールバックなし)
|
||||
```
|
||||
|
||||
**ユースケース**: クリティカルな本番コード、複雑なリファクタリング。
|
||||
|
||||
---
|
||||
|
||||
### 例5: マルチサブスクリプション (すべてを最大化)
|
||||
|
||||
**目標**: 追加料金前にすべてのサブスクリプションを利用。
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: multi-sub
|
||||
Models:
|
||||
1. gc/gemini-3-flash-preview (月18万無料)
|
||||
2. cc/claude-opus-4-5-20251101 (Proサブスクリプション)
|
||||
3. cx/gpt-5.2-codex (Plusサブスクリプション)
|
||||
4. gh/gpt-5 (Copilotサブスクリプション)
|
||||
5. glm/glm-4.7 (低価格バックアップ)
|
||||
6. if/kimi-k2-thinking (無料緊急時)
|
||||
```
|
||||
|
||||
**月コスト (2億トークン):**
|
||||
```
|
||||
Gemini CLI経由で5000万: $0 (無料プラン)
|
||||
Claude Code経由で8000万: $0 (サブスクリプション)
|
||||
Codex経由で4000万: $0 (サブスクリプション)
|
||||
Copilot経由で2000万: $0 (サブスクリプション)
|
||||
GLM経由で800万: $4.80
|
||||
iFlow経由で200万: $0
|
||||
合計: $4.80 + 既存サブスクリプション
|
||||
```
|
||||
|
||||
**結果**: サブスクリプションから1.9億トークン使用、わずか$4.80の追加料金。
|
||||
|
||||
---
|
||||
|
||||
### 例6: クォータリセット最適化
|
||||
|
||||
**目標**: リセット時間に基づいて使用量を分散。
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: reset-optimized
|
||||
Models:
|
||||
1. cc/claude-opus-4-5 (5時間リセット、朝に使用)
|
||||
2. gc/gemini-3-flash (1K/日、午後に使用)
|
||||
3. glm/glm-4.7 (毎日午前10時リセット、夕方に使用)
|
||||
4. minimax/MiniMax-M2.1 (5時間ローリング、夜に使用)
|
||||
5. if/kimi-k2-thinking (無制限、緊急時)
|
||||
```
|
||||
|
||||
**日課:**
|
||||
```
|
||||
08:00 - 13:00: Claude Code (新鮮な5時間クォータ)
|
||||
13:00 - 18:00: Gemini CLI (1K/日クォータ)
|
||||
18:00 - 22:00: GLM (翌朝10時リセット)
|
||||
22:00 - 08:00: MiniMax (5時間ローリング) または iFlow
|
||||
```
|
||||
|
||||
**結果**: 最小コストで24時間コーディング。
|
||||
|
||||
---
|
||||
|
||||
## CLIツールでコンボを使用
|
||||
|
||||
### Cursor IDE
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [ダッシュボードから取得]
|
||||
Model: premium-coding
|
||||
```
|
||||
|
||||
### Claude Desktop
|
||||
|
||||
`~/.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: [ダッシュボードから取得]
|
||||
Model: free-combo
|
||||
```
|
||||
|
||||
### APIリクエスト
|
||||
|
||||
```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
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ベストプラクティス
|
||||
|
||||
### 1. 常に無料階層を含める
|
||||
|
||||
```
|
||||
✅ 良い:
|
||||
cc/claude-opus → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
❌ 悪い:
|
||||
cc/claude-opus → glm/glm-4.7
|
||||
(無料フォールバックなし、クォータ切れの可能性)
|
||||
```
|
||||
|
||||
**理由**: 24時間可用性を確保、クォータでブロックされない。
|
||||
|
||||
### 2. コスト順に並べる (安価→高価)
|
||||
|
||||
```
|
||||
✅ 良い:
|
||||
glm/glm-4.7 → minimax/MiniMax-M2.1 → cc/claude-opus
|
||||
|
||||
❌ 悪い:
|
||||
cc/claude-opus → glm/glm-4.7
|
||||
(シンプルなタスクにサブスクリプションクォータを浪費)
|
||||
```
|
||||
|
||||
**例外**: サブスクリプション価値を最大化したい場合は、サブスクリプションを最初に。
|
||||
|
||||
### 3. 品質要件に合わせる
|
||||
|
||||
```
|
||||
本番コードの場合:
|
||||
cc/claude-opus → cx/gpt-5.2-codex → glm/glm-4.7
|
||||
|
||||
クイックタスクの場合:
|
||||
glm/glm-4.7 → if/kimi-k2-thinking
|
||||
|
||||
実験用:
|
||||
if/kimi-k2-thinking → qw/qwen3-coder-plus
|
||||
```
|
||||
|
||||
### 4. クォータリセット時間を考慮
|
||||
|
||||
```
|
||||
朝のコンボ (新鮮なクォータ):
|
||||
cc/claude-opus → cx/gpt-5.2-codex
|
||||
|
||||
夕方のコンボ (クォータが消費されている可能性):
|
||||
glm/glm-4.7 → minimax/MiniMax-M2.1 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### 5. 異なるユースケース用に複数のコンボを作成
|
||||
|
||||
```
|
||||
premium-coding: 複雑なタスク用
|
||||
budget-combo: シンプルなタスク用
|
||||
free-combo: 実験用
|
||||
quality-first: 本番コード用
|
||||
```
|
||||
|
||||
**タスク要件に基づいてコンボを切り替え**ます。
|
||||
|
||||
### 6. コンボパフォーマンスをモニター
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Combo Usage:
|
||||
premium-coding:
|
||||
80% cc/claude-opus経由 (良好、サブスクリプション使用)
|
||||
15% glm/glm-4.7経由 (許容バックアップ)
|
||||
5% minimax経由 (まれなフォールバック)
|
||||
```
|
||||
|
||||
**最適化**: フォールバック使用が多すぎる場合、プライマリクォータを増やすかモデルを並べ替え。
|
||||
|
||||
---
|
||||
|
||||
## 高度な設定
|
||||
|
||||
### コンボごとに予算上限を設定
|
||||
|
||||
```
|
||||
Dashboard → Combos → Edit → Budget:
|
||||
Daily limit: $5
|
||||
Monthly limit: $50
|
||||
```
|
||||
|
||||
上限に達すると、9Routerは有料モデルをスキップして無料階層のみを使用。
|
||||
|
||||
### コンボ内のモデルを有効/無効
|
||||
|
||||
```
|
||||
Dashboard → Combos → Edit → Models:
|
||||
✅ cc/claude-opus-4-5 (有効)
|
||||
❌ glm/glm-4.7 (一時的に無効)
|
||||
✅ if/kimi-k2-thinking (有効)
|
||||
```
|
||||
|
||||
**ユースケース**: コンボを削除せずに高価なモデルを一時的に無効化。
|
||||
|
||||
### 既存のコンボを複製
|
||||
|
||||
```
|
||||
Dashboard → Combos → Clone "premium-coding"
|
||||
→ "-copy" サフィックス付きのコピーを作成
|
||||
→ 変更して新しいコンボとして保存
|
||||
```
|
||||
|
||||
**ユースケース**: 異なるシナリオ用のバリエーションを作成。
|
||||
|
||||
---
|
||||
|
||||
## トラブルシューティング
|
||||
|
||||
**問題: コンボがモデルリストに表示されない**
|
||||
|
||||
**解決策:**
|
||||
1. ダッシュボードを更新
|
||||
2. コンボが保存されていることを確認 (緑のチェック)
|
||||
3. CLIツールを再起動してモデルリストを更新
|
||||
|
||||
**問題: コンボが常に最後のモデル (無料階層) を使用**
|
||||
|
||||
**解決策:**
|
||||
1. プライマリモデルのクォータを確認 (Dashboard → Quota)
|
||||
2. APIキーが有効か確認 (Dashboard → Providers)
|
||||
3. 予算上限を超えていないか確認
|
||||
|
||||
**問題: コンボのコストが予想より高い**
|
||||
|
||||
**解決策:**
|
||||
1. Dashboard → Analytics → コンボ使用量を確認
|
||||
2. プライマリモデルがクォータ切れか確認
|
||||
3. モデルを並べ替え (安価を先に)
|
||||
4. 予算上限を設定
|
||||
|
||||
---
|
||||
|
||||
## 関連
|
||||
|
||||
- [スマートルーティング](./smart-routing.md) - 自動フォールバックの仕組み
|
||||
- [クォータトラッキング](./quota-tracking.md) - 使用量とコストを監視
|
||||
@@ -0,0 +1,687 @@
|
||||
# クォータトラッキングと使用量モニタリング
|
||||
|
||||
リアルタイムのトークン消費を追跡し、クォータ制限を監視し、コストを見積もり、不足前にアラートを取得。サブスクリプションクォータを無駄にしたり、予算上限を超えたりすることはありません。
|
||||
|
||||
---
|
||||
|
||||
## 概要
|
||||
|
||||
9Routerはすべてのプロバイダーに対して包括的なクォータトラッキングを提供:
|
||||
|
||||
- **リアルタイムトークン消費** - リクエストごとの使用トークンを表示
|
||||
- **クォータ上限と残量** - 使用量 vs 上限を追跡
|
||||
- **リセットカウントダウン** - クォータが更新されるタイミング
|
||||
- **コスト見積もり** - 有料階層の支出を計算
|
||||
- **月次レポート** - 使用パターンを分析
|
||||
- **アラートと通知** - 上限前に警告を取得
|
||||
|
||||
---
|
||||
|
||||
## ダッシュボード概要
|
||||
|
||||
### クォータサマリー
|
||||
|
||||
```
|
||||
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) │
|
||||
└─────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## リアルタイムトークン消費
|
||||
|
||||
### リクエストごとのトラッキング
|
||||
|
||||
各リクエストに詳細なトークン使用量が表示されます:
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
### ライブ使用量モニター
|
||||
|
||||
```
|
||||
Dashboard → Live Monitor
|
||||
|
||||
Current request:
|
||||
Model: glm/glm-4.7
|
||||
Tokens streamed: 450 / ~800 estimated
|
||||
Cost so far: $0.0009
|
||||
Duration: 1.8s
|
||||
```
|
||||
|
||||
### モデル別のトークン内訳
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## クォータ上限とリセット時間
|
||||
|
||||
### サブスクリプションプロバイダー
|
||||
|
||||
**Claude Code (Pro/Max)**
|
||||
```
|
||||
クォータタイプ: 時間ベース (5時間ローリング)
|
||||
上限: 5時間の使用
|
||||
リセット: 5時間ローリングウィンドウ + 週次更新
|
||||
追跡: モデルごとの使用時間
|
||||
|
||||
ダッシュボード表示:
|
||||
Opus: 2.5h / 5h 使用
|
||||
Sonnet: 1.2h / 5h 使用
|
||||
Haiku: 0.8h / 5h 使用
|
||||
|
||||
週次リセット: 毎週月曜00:00 UTC
|
||||
```
|
||||
|
||||
**OpenAI Codex (Plus/Pro)**
|
||||
```
|
||||
クォータタイプ: 時間ベース (5時間ローリング)
|
||||
上限: 5時間 (Plus) / 10時間 (Pro)
|
||||
リセット: 5時間ローリングウィンドウ + 週次更新
|
||||
|
||||
ダッシュボード表示:
|
||||
GPT-5.2 Codex: 3.5h / 5h 使用
|
||||
Resets in: 1h 30m
|
||||
```
|
||||
|
||||
**Gemini CLI (無料)**
|
||||
```
|
||||
クォータタイプ: リクエスト数 + 月次トークン
|
||||
日次上限: 1,000 リクエスト
|
||||
月次上限: 180,000 コンプリーション
|
||||
リセット: 日次 00:00 UTC + 月次 1日
|
||||
|
||||
ダッシュボード表示:
|
||||
Today: 450 / 1,000 requests (45%)
|
||||
This month: 45K / 180K completions (25%)
|
||||
Daily reset in: 18h 30m
|
||||
Monthly reset in: 26 days
|
||||
```
|
||||
|
||||
**GitHub Copilot**
|
||||
```
|
||||
クォータタイプ: 月次使用量
|
||||
上限: プランによる
|
||||
リセット: 各月1日
|
||||
|
||||
ダッシュボード表示:
|
||||
Usage: 60% of monthly quota
|
||||
Resets: March 1, 2026 (in 25 days)
|
||||
```
|
||||
|
||||
### 低価格プロバイダー
|
||||
|
||||
**GLM-4.7**
|
||||
```
|
||||
クォータタイプ: 日次トークン上限
|
||||
上限: 10Mトークン/日 (Coding Plan)
|
||||
リセット: 毎日午前10時 北京時間 (UTC+8)
|
||||
|
||||
ダッシュボード表示:
|
||||
Used: 7M / 10M tokens (70%)
|
||||
Remaining: 3M tokens
|
||||
Resets in: 5h 35m
|
||||
Cost today: $4.20
|
||||
```
|
||||
|
||||
**MiniMax M2.1**
|
||||
```
|
||||
クォータタイプ: 5時間ローリングウィンドウ
|
||||
上限: 5時間あたり5Mトークン
|
||||
リセット: 連続ローリングウィンドウ
|
||||
|
||||
ダッシュボード表示:
|
||||
Used (5h): 4M / 5M tokens (80%)
|
||||
Oldest usage expires in: 45m
|
||||
Cost (5h): $0.80
|
||||
```
|
||||
|
||||
**Kimi K2**
|
||||
```
|
||||
クォータタイプ: 月次サブスクリプション
|
||||
上限: 10Mトークン/月 ($9固定)
|
||||
リセット: サブスクリプション日に月次
|
||||
|
||||
ダッシュボード表示:
|
||||
Used: 6M / 10M tokens (60%)
|
||||
Resets: Feb 15, 2026 (in 11 days)
|
||||
Cost: $9/month (prepaid)
|
||||
```
|
||||
|
||||
### 無料プロバイダー
|
||||
|
||||
**iFlow / Qwen / Kiro**
|
||||
```
|
||||
クォータタイプ: 無制限 (レート制限)
|
||||
上限: ハード制限なし
|
||||
リセット: なし
|
||||
|
||||
ダッシュボード表示:
|
||||
Used today: 5M tokens
|
||||
Cost: $0 (free forever)
|
||||
Status: ✅ Available
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## コスト見積もり
|
||||
|
||||
### リアルタイムコストトラッキング
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
### 月次支出レポート
|
||||
|
||||
```
|
||||
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)
|
||||
```
|
||||
|
||||
### コスト予測
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 使用量ダッシュボード
|
||||
|
||||
### 概要統計
|
||||
|
||||
```
|
||||
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%)
|
||||
```
|
||||
|
||||
### モデル別使用量
|
||||
|
||||
```
|
||||
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)
|
||||
```
|
||||
|
||||
### 時間別使用量
|
||||
|
||||
```
|
||||
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)
|
||||
```
|
||||
|
||||
### コンボ別使用量
|
||||
|
||||
```
|
||||
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)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## アラートと通知
|
||||
|
||||
### クォータアラート
|
||||
|
||||
```
|
||||
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)
|
||||
```
|
||||
|
||||
**通知例:**
|
||||
```
|
||||
⚠️ 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)
|
||||
```
|
||||
|
||||
### 予算アラート
|
||||
|
||||
```
|
||||
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)
|
||||
```
|
||||
|
||||
**通知例:**
|
||||
```
|
||||
⚠️ 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
|
||||
```
|
||||
|
||||
### コスト異常検知
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ベストプラクティス
|
||||
|
||||
### 1. クォータを毎日モニター
|
||||
|
||||
```
|
||||
日課:
|
||||
1. ダッシュボードクォータ概要を確認 (30秒)
|
||||
2. リセット時間を確認
|
||||
3. クォータ可用性に合わせて使用量を計画
|
||||
```
|
||||
|
||||
**例:**
|
||||
```
|
||||
朝の確認:
|
||||
✅ Claude Code: 5時間利用可 (新鮮なリセット)
|
||||
✅ Gemini CLI: 1Kリクエスト利用可
|
||||
⚠️ GLM-4.7: 2Mトークン残 (午前10時リセット)
|
||||
|
||||
アクション: 朝の作業にClaude Codeを使用
|
||||
```
|
||||
|
||||
### 2. 予算上限を設定
|
||||
|
||||
```
|
||||
Dashboard → Settings → Budget:
|
||||
Daily: $5 (使いすぎ防止)
|
||||
Monthly: $150 (予算に整合)
|
||||
```
|
||||
|
||||
**結果**: 上限到達時に自動的に無料階層へ切替。
|
||||
|
||||
### 3. コンボ使用を最適化
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Combos:
|
||||
どのモデルが最もよく使われているか確認
|
||||
コストを最小化するためにコンボ順序を調整
|
||||
```
|
||||
|
||||
**例:**
|
||||
```
|
||||
現在: cc/claude-opus → glm/glm-4.7
|
||||
80% Claude経由 (良好)
|
||||
20% GLM経由 ($12/月)
|
||||
|
||||
最適化後: gc/gemini-3-flash → cc/claude-opus → glm/glm-4.7
|
||||
50% Gemini経由 (無料)
|
||||
40% Claude経由 (サブスクリプション)
|
||||
10% GLM経由 ($6/月)
|
||||
|
||||
節約: $6/月
|
||||
```
|
||||
|
||||
### 4. リセット時間を追跡
|
||||
|
||||
```
|
||||
Dashboard → Quota → Reset Schedule:
|
||||
Claude Code: 5時間ローリング + 週次月曜
|
||||
Gemini CLI: 日次 00:00 UTC + 月次 1日
|
||||
GLM-4.7: 毎日午前10時 北京時間
|
||||
MiniMax: 5時間ローリングウィンドウ
|
||||
```
|
||||
|
||||
**戦略**: クォータが新鮮な時にプロバイダーを使用。
|
||||
|
||||
### 5. 月次レポートを確認
|
||||
|
||||
```
|
||||
Dashboard → Analytics → Monthly Report:
|
||||
Total tokens: 1.5B
|
||||
Total cost: $120
|
||||
Savings: 97% vs ChatGPT API
|
||||
|
||||
インサイト:
|
||||
- 60% サブスクリプション経由の使用 ($0)
|
||||
- 30% GLM経由 ($90)
|
||||
- 10% 無料階層経由 ($0)
|
||||
|
||||
最適化:
|
||||
- Gemini CLI使用を増やす (無料)
|
||||
- GLM使用を減らす (高価)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## APIアクセス
|
||||
|
||||
### クォータステータスを取得
|
||||
|
||||
```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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 使用統計を取得
|
||||
|
||||
```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
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## トラブルシューティング
|
||||
|
||||
**問題: クォータが0%を表示するがリクエストが失敗**
|
||||
|
||||
**解決策:**
|
||||
1. プロバイダー接続を確認 (Dashboard → Providers)
|
||||
2. APIキーが有効か確認
|
||||
3. プロバイダーがダウンしているか確認 (ステータスページ)
|
||||
4. OAuthプロバイダーを再接続してみる
|
||||
|
||||
**問題: コスト見積もりが正しくない**
|
||||
|
||||
**解決策:**
|
||||
1. Dashboard → Settings → Pricing
|
||||
2. プロバイダーごとの料金が現在のレートと一致するか確認
|
||||
3. プロバイダーがレートを変更した場合は料金を更新
|
||||
4. 不一致が続く場合はサポートに連絡
|
||||
|
||||
**問題: リセット時間が更新されない**
|
||||
|
||||
**解決策:**
|
||||
1. ダッシュボードを更新 (F5)
|
||||
2. システム時刻が正しいか確認
|
||||
3. タイムゾーン設定を確認
|
||||
4. 問題が続く場合は9Routerを再起動
|
||||
|
||||
**問題: アラートが受信されない**
|
||||
|
||||
**解決策:**
|
||||
1. Dashboard → Settings → Alerts
|
||||
2. メールアドレスが正しいか確認
|
||||
3. スパムフォルダを確認
|
||||
4. 通知をテスト (Send Testボタン)
|
||||
|
||||
---
|
||||
|
||||
## 関連
|
||||
|
||||
- [スマートルーティング](./smart-routing.md) - クォータに基づく自動フォールバック
|
||||
- [コンボ](./combos.md) - カスタムフォールバックチェーンを作成
|
||||
@@ -0,0 +1,407 @@
|
||||
# スマートルーティングと自動フォールバック
|
||||
|
||||
9Routerは3階層フォールバックシステムを使用して、最適な利用可能なプロバイダーへリクエストを自動的にルーティングします。クォータ制限やレート制限でコーディングが止まることはありません。
|
||||
|
||||
---
|
||||
|
||||
## 動作の仕組み
|
||||
|
||||
9Routerは、既存のサブスクリプションを最大化し、コストを最小化し、24時間可用性を確保するため、インテリジェントなルーティングを使用します:
|
||||
|
||||
```
|
||||
Request → 9Router → Tier 1を確認 (サブスクリプション)
|
||||
↓ クォータ消費
|
||||
Tier 2を確認 (低価格)
|
||||
↓ 予算上限
|
||||
Tier 3を確認 (無料)
|
||||
↓
|
||||
Response
|
||||
```
|
||||
|
||||
### 3階層フォールバックシステム
|
||||
|
||||
**Tier 1: サブスクリプション (プライマリ)**
|
||||
- Claude Code (Pro/Max)
|
||||
- OpenAI Codex (Plus/Pro)
|
||||
- Gemini CLI (月18万無料)
|
||||
- GitHub Copilot
|
||||
- Antigravity (Google)
|
||||
|
||||
**目標**: すでに支払っているサブスクリプションから価値を最大化。
|
||||
|
||||
**Tier 2: 低価格 (バックアップ)**
|
||||
- GLM-4.7 (入力100万あたり$0.60)
|
||||
- MiniMax M2.1 (入力100万あたり$0.20)
|
||||
- Kimi K2 (月$9固定)
|
||||
|
||||
**目標**: サブスクリプションクォータ切れ時の超低価格バックアップ (ChatGPT APIより約90%安い)。
|
||||
|
||||
**Tier 3: 無料 (緊急時)**
|
||||
- iFlow (8モデル)
|
||||
- Qwen (3モデル)
|
||||
- Kiro (Claude無料)
|
||||
|
||||
**目標**: 無制限コーディング用のゼロコストフォールバック。
|
||||
|
||||
---
|
||||
|
||||
## 自動切替
|
||||
|
||||
9Routerはクォータをリアルタイムでモニターし、プロバイダーを自動的に切り替えます:
|
||||
|
||||
### シナリオ1: サブスクリプションクォータ消費
|
||||
|
||||
```
|
||||
ユーザーリクエスト → cc/claude-opus-4-5
|
||||
↓ クォータ消費 (5時間制限到達)
|
||||
自動切替 → glm/glm-4.7
|
||||
↓ 日次クォータ消費
|
||||
自動切替 → minimax/MiniMax-M2.1
|
||||
↓ 5時間クォータ消費
|
||||
自動切替 → if/kimi-k2-thinking (無料)
|
||||
↓
|
||||
レスポンス配信 ✅
|
||||
```
|
||||
|
||||
**結果**: ダウンタイムゼロ、シームレスな体験。
|
||||
|
||||
### シナリオ2: レート制限
|
||||
|
||||
```
|
||||
ユーザーリクエスト → cx/gpt-5.2-codex
|
||||
↓ レート制限 (リクエストが多すぎ)
|
||||
自動切替 → glm/glm-4.7
|
||||
↓
|
||||
レスポンス配信 ✅
|
||||
```
|
||||
|
||||
### シナリオ3: プロバイダー利用不可
|
||||
|
||||
```
|
||||
ユーザーリクエスト → cc/claude-opus-4-5
|
||||
↓ プロバイダーエラー (503)
|
||||
自動切替 → 次の利用可能なモデル
|
||||
↓
|
||||
レスポンス配信 ✅
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## モデル選択ロジック
|
||||
|
||||
9Routerは以下に基づいて最適なモデルを選択します:
|
||||
|
||||
1. **クォータ可用性** - プロバイダーに残量があるか確認
|
||||
2. **コスト階層** - サブスクリプション → 低価格 → 無料を優先
|
||||
3. **リセットタイミング** - クォータリセット時を考慮
|
||||
4. **プロバイダー健全性** - エラーのあるプロバイダーをスキップ
|
||||
|
||||
### 優先順位の例
|
||||
|
||||
`cc/claude-opus-4-5` へのリクエストの場合:
|
||||
|
||||
```
|
||||
1. Claude Codeクォータを確認
|
||||
✅ 利用可 → cc/claude-opus-4-5を使用
|
||||
❌ 消費 → ステップ2へ
|
||||
|
||||
2. フォールバック階層を確認 (設定されている場合)
|
||||
✅ GLMクォータ利用可 → glm/glm-4.7を使用
|
||||
❌ 消費 → ステップ3へ
|
||||
|
||||
3. 無料階層を確認
|
||||
✅ iFlow利用可 → if/kimi-k2-thinkingを使用
|
||||
❌ すべて消費 → クォータエラーを返す
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 設定オプション
|
||||
|
||||
### ダッシュボード設定
|
||||
|
||||
**1. 自動フォールバックを有効/無効化**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Smart Routing
|
||||
→ 「Auto Fallback」をオン/オフに切替
|
||||
```
|
||||
|
||||
- **オン** (デフォルト): 自動階層切替
|
||||
- **オフ**: 厳格モード、プライマリモデル利用不可時にエラーを返す
|
||||
|
||||
**2. 予算上限を設定**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Budget Control
|
||||
→ 日次上限: $5
|
||||
→ 月次上限: $50
|
||||
```
|
||||
|
||||
予算到達時、9Routerは自動的に無料階層へ切替。
|
||||
|
||||
**3. フォールバック順序を設定**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Fallback Priority
|
||||
→ 各階層内でプロバイダーをドラッグして並べ替え
|
||||
```
|
||||
|
||||
カスタム順序の例:
|
||||
```
|
||||
Tier 1: Gemini CLI → Claude Code → Codex
|
||||
Tier 2: MiniMax → GLM → Kimi
|
||||
Tier 3: iFlow → Kiro → Qwen
|
||||
```
|
||||
|
||||
**4. クォータリセット通知**
|
||||
|
||||
```
|
||||
Dashboard → Settings → Notifications
|
||||
→ クォータリセット時にメール
|
||||
→ 80%クォータ使用時にアラート
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 例
|
||||
|
||||
### 例1: 基本的な自動フォールバック
|
||||
|
||||
**セットアップ:**
|
||||
```
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
Fallback: 自動 (デフォルト3階層)
|
||||
```
|
||||
|
||||
**動作:**
|
||||
```
|
||||
朝 (新鮮なクォータ):
|
||||
Request → cc/claude-opus-4-5 ✅
|
||||
|
||||
午後 (クォータ消費):
|
||||
Request → glm/glm-4.7 ✅ (自動切替)
|
||||
|
||||
夕方 (GLMクォータ切れ):
|
||||
Request → minimax/MiniMax-M2.1 ✅ (自動切替)
|
||||
|
||||
深夜 (すべての有料クォータ切れ):
|
||||
Request → if/kimi-k2-thinking ✅ (無料階層)
|
||||
```
|
||||
|
||||
**コスト**: 月$5〜10の追加料金 (主にサブスクリプションでカバー)。
|
||||
|
||||
### 例2: 予算意識のルーティング
|
||||
|
||||
**セットアップ:**
|
||||
```
|
||||
Dashboard → Settings:
|
||||
Daily budget: $2
|
||||
Monthly budget: $20
|
||||
Fallback: 有効
|
||||
```
|
||||
|
||||
**動作:**
|
||||
```
|
||||
1〜15日 (予算内):
|
||||
Requests → glm/glm-4.7 (低価格階層)
|
||||
コスト: $1.50/日
|
||||
|
||||
16日 (予算到達):
|
||||
Requests → if/kimi-k2-thinking (無料階層)
|
||||
コスト: $0
|
||||
|
||||
翌月 (予算リセット):
|
||||
Requests → 再びglm/glm-4.7
|
||||
```
|
||||
|
||||
**結果**: 月$20を超えない、常に利用可能。
|
||||
|
||||
### 例3: サブスクリプションのみモード
|
||||
|
||||
**セットアップ:**
|
||||
```
|
||||
Dashboard → Settings:
|
||||
Auto Fallback: オフ
|
||||
Strict mode: オン
|
||||
```
|
||||
|
||||
**動作:**
|
||||
```
|
||||
Request → cc/claude-opus-4-5
|
||||
✅ クォータ利用可 → 成功
|
||||
❌ クォータ消費 → エラーを返す (フォールバックなし)
|
||||
```
|
||||
|
||||
**ユースケース**: 有料サブスクリプションのみを使用したい場合、追加コストなし。
|
||||
|
||||
### 例4: 無料のみモード
|
||||
|
||||
**セットアップ:**
|
||||
```
|
||||
Model: if/kimi-k2-thinking
|
||||
Fallback: qw/qwen3-coder-plus → kr/claude-sonnet-4.5
|
||||
```
|
||||
|
||||
**動作:**
|
||||
```
|
||||
すべてのリクエスト → 無料階層のみ
|
||||
コスト: 永久に$0
|
||||
```
|
||||
|
||||
**ユースケース**: 個人プロジェクト、学習、実験。
|
||||
|
||||
---
|
||||
|
||||
## ベストプラクティス
|
||||
|
||||
### 1. サブスクリプション価値を最大化
|
||||
|
||||
```
|
||||
戦略:
|
||||
- サブスクリプションモデルをTier 1に設定
|
||||
- ダッシュボードでクォータ使用量をモニター
|
||||
- サブスクリプション消費時のみ低価格階層を使用
|
||||
```
|
||||
|
||||
**コンボ例:**
|
||||
```
|
||||
cc/claude-opus-4-5 → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### 2. コストに最適化
|
||||
|
||||
```
|
||||
戦略:
|
||||
- Gemini CLI無料階層を最初に使用 (月18万)
|
||||
- GLM/MiniMaxへフォールバック (超低価格)
|
||||
- 緊急時: iFlow (無料)
|
||||
```
|
||||
|
||||
**コンボ例:**
|
||||
```
|
||||
gc/gemini-3-flash-preview → glm/glm-4.7 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
### 3. 品質に最適化
|
||||
|
||||
```
|
||||
戦略:
|
||||
- 最高のモデルを使用 (Claude Opus、GPT-5.2)
|
||||
- 良質な低価格モデルへフォールバック (GLM-4.7)
|
||||
- 最後の手段: 無料階層
|
||||
```
|
||||
|
||||
**コンボ例:**
|
||||
```
|
||||
cc/claude-opus-4-5 → cx/gpt-5.2-codex → glm/glm-4.7
|
||||
```
|
||||
|
||||
### 4. 24時間可用性
|
||||
|
||||
```
|
||||
戦略:
|
||||
- フォールバックに常に無料階層を含める
|
||||
- クォータリセット時間をモニター
|
||||
- プロバイダー間で使用量を分散
|
||||
```
|
||||
|
||||
**コンボ例:**
|
||||
```
|
||||
cc/claude-opus-4-5 → glm/glm-4.7 → minimax/MiniMax-M2.1 → if/kimi-k2-thinking
|
||||
```
|
||||
|
||||
**結果**: クォータ切れにならない、いつでもコーディング。
|
||||
|
||||
---
|
||||
|
||||
## クォータリセット戦略
|
||||
|
||||
クォータリセット時間に合わせて使用量を計画:
|
||||
|
||||
| プロバイダー | クォータリセット | 戦略 |
|
||||
|----------|-------------|----------|
|
||||
| **Claude Code** | 5時間 + 週次 | 朝、新鮮なクォータを使用 |
|
||||
| **Codex** | 5時間 + 週次 | Claudeクォータ切れ後に使用 |
|
||||
| **Gemini CLI** | 日次 (1K) + 月次 (18万) | 一日中使用 |
|
||||
| **GLM-4.7** | 毎日午前10時 | 夕方使用、翌朝リセット |
|
||||
| **MiniMax M2.1** | 5時間ローリング | いつでも使用、ローリングウィンドウを追跡 |
|
||||
| **iFlow/Qwen/Kiro** | 制限なし | 緊急時バックアップ |
|
||||
|
||||
**日課の例:**
|
||||
```
|
||||
08:00 - 13:00: Claude Code (新鮮な5時間クォータ)
|
||||
13:00 - 18:00: Gemini CLI (1K/日クォータ)
|
||||
18:00 - 22:00: GLM-4.7 (低価格、午前10時リセット)
|
||||
22:00 - 08:00: MiniMaxまたはiFlow (5時間ローリングまたは無料)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## モニタリングとアラート
|
||||
|
||||
### ダッシュボードクォータトラッカー
|
||||
|
||||
```
|
||||
Dashboard → Quota Overview:
|
||||
Claude Code: 2.5h / 5h 残 (50%)
|
||||
Gemini CLI: 今日 450 / 1000 リクエスト
|
||||
GLM-4.7: 5M / 10M トークン (8時間後リセット)
|
||||
MiniMax: 3M / 5M トークン (5時間ローリング)
|
||||
```
|
||||
|
||||
### リアルタイム通知
|
||||
|
||||
```
|
||||
Dashboard → Notifications:
|
||||
⚠️ Claude Codeクォータ80%使用 (1時間残)
|
||||
✅ GLM-4.7クォータリセット (10Mトークン利用可)
|
||||
💰 日次予算50%使用 ($2.50 / $5)
|
||||
```
|
||||
|
||||
### 使用統計
|
||||
|
||||
```
|
||||
Dashboard → Analytics:
|
||||
今日: 5000万トークン
|
||||
- 3000万 Claude Code経由 (サブスクリプション)
|
||||
- 1500万 GLM-4.7経由 ($9)
|
||||
- 500万 iFlow経由 (無料)
|
||||
|
||||
コスト: $9 (vs ChatGPT APIの$1000)
|
||||
節約: 99%
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## トラブルシューティング
|
||||
|
||||
**問題: "All providers quota exhausted"**
|
||||
|
||||
**解決策:**
|
||||
1. ダッシュボードクォータトラッカーを確認
|
||||
2. クォータリセットを待つ (カウントダウン参照)
|
||||
3. フォールバックチェーンに無料階層を追加
|
||||
4. または予算上限を増やす
|
||||
|
||||
**問題: "Too many fallback switches"**
|
||||
|
||||
**解決策:**
|
||||
1. プライマリプロバイダーがダウンしているか確認
|
||||
2. クォータ上限を増やす (サブスクリプションをアップグレード)
|
||||
3. より安いプライマリモデルを使用 (Claudeの代わりにGLM)
|
||||
|
||||
**問題: "Unexpected costs"**
|
||||
|
||||
**解決策:**
|
||||
1. Dashboard → Analytics → 使用量を確認
|
||||
2. 日次/月次予算上限を設定
|
||||
3. クリティカルでないタスクは無料階層へ切替
|
||||
4. 無料フォールバック付きのコンボを使用
|
||||
|
||||
---
|
||||
|
||||
## 関連
|
||||
|
||||
- [コンボ](./combos.md) - カスタムフォールバックチェーンを作成
|
||||
- [クォータトラッキング](./quota-tracking.md) - 使用量とコストをモニター
|
||||
@@ -0,0 +1,478 @@
|
||||
# インストール
|
||||
|
||||
トラブルシューティングのヒント付きの9Router詳細インストールガイド。
|
||||
|
||||
---
|
||||
|
||||
## 要件
|
||||
|
||||
### システム要件
|
||||
|
||||
- **Node.js**: バージョン 20.0.0以上
|
||||
- **npm**: バージョン 10.0.0以上 (Node.jsに付属)
|
||||
- **OS**: macOS、Linux、Windows (WSL推奨)
|
||||
- **ディスク容量**: インストールに約200MB
|
||||
|
||||
### バージョンを確認
|
||||
|
||||
```bash
|
||||
node --version
|
||||
# v20.x.x以上が表示されるはず
|
||||
|
||||
npm --version
|
||||
# 10.x.x以上が表示されるはず
|
||||
```
|
||||
|
||||
**Node.jsがない場合?** [nodejs.org](https://nodejs.org/)からインストール
|
||||
|
||||
---
|
||||
|
||||
## インストール方法
|
||||
|
||||
### 方法1: グローバルインストール (推奨)
|
||||
|
||||
どこからでも使用できるように9Routerをグローバルインストール:
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
**9Routerを起動:**
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
**利点:**
|
||||
- ✅ どのディレクトリからでも実行
|
||||
- ✅ シンプルなコマンド: `9router`
|
||||
- ✅ `npm update -g 9router` で自動更新
|
||||
|
||||
### 方法2: ローカルインストール
|
||||
|
||||
特定のプロジェクトにインストール:
|
||||
|
||||
```bash
|
||||
mkdir my-9router
|
||||
cd my-9router
|
||||
npm install 9router
|
||||
```
|
||||
|
||||
**9Routerを起動:**
|
||||
|
||||
```bash
|
||||
npx 9router
|
||||
```
|
||||
|
||||
**利点:**
|
||||
- ✅ プロジェクトごとに分離
|
||||
- ✅ プロジェクトごとのバージョン管理
|
||||
- ✅ グローバル名前空間の汚染なし
|
||||
|
||||
### 方法3: ソースから (開発)
|
||||
|
||||
GitHubからクローンしてビルド:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/decolua/9router.git
|
||||
cd 9router/app
|
||||
npm install
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
**利点:**
|
||||
- ✅ 最新の開発機能
|
||||
- ✅ 開発に貢献可能
|
||||
- ✅ カスタム変更
|
||||
|
||||
---
|
||||
|
||||
## 初回実行
|
||||
|
||||
### サーバーを起動
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
**何が起こるか:**
|
||||
1. サーバーが `http://localhost:20128` で起動
|
||||
2. ダッシュボードが自動的にブラウザで開く
|
||||
3. `~/.9router` にデータディレクトリが作成される
|
||||
4. APIキーが自動生成される
|
||||
|
||||
### ダッシュボードログイン
|
||||
|
||||
**デフォルト認証情報:**
|
||||
- パスワード: `123456`
|
||||
|
||||
**⚠️ パスワードをすぐに変更:**
|
||||
1. ダッシュボードにログイン
|
||||
2. Settings → Change Password
|
||||
3. 強力なパスワードを使用
|
||||
|
||||
### APIキーを取得
|
||||
|
||||
```
|
||||
Dashboard → Settings → API Keys
|
||||
→ APIキーをコピー
|
||||
→ CLIツールで使用
|
||||
```
|
||||
|
||||
**APIキー形式の例:**
|
||||
```
|
||||
9r_1234567890abcdef1234567890abcdef
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## インストールを確認
|
||||
|
||||
### サーバーステータスを確認
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/health
|
||||
```
|
||||
|
||||
**期待されるレスポンス:**
|
||||
```json
|
||||
{
|
||||
"status": "ok",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
### 利用可能なモデルを一覧表示
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/v1/models \
|
||||
-H "Authorization: Bearer your-api-key"
|
||||
```
|
||||
|
||||
**期待されるレスポンス:**
|
||||
```json
|
||||
{
|
||||
"object": "list",
|
||||
"data": [
|
||||
{
|
||||
"id": "cc/claude-opus-4-5-20251101",
|
||||
"object": "model",
|
||||
"created": 1234567890,
|
||||
"owned_by": "claude-code"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### チャットコンプリーションをテスト
|
||||
|
||||
```bash
|
||||
curl http://localhost:20128/v1/chat/completions \
|
||||
-H "Authorization: Bearer your-api-key" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"model": "cc/claude-opus-4-5-20251101",
|
||||
"messages": [
|
||||
{"role": "user", "content": "Hello!"}
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 設定
|
||||
|
||||
### 環境変数
|
||||
|
||||
`.env` ファイルを作成するか、環境変数を設定:
|
||||
|
||||
```bash
|
||||
# セキュリティ (本番環境では必須)
|
||||
export JWT_SECRET="your-secure-secret-change-this"
|
||||
export INITIAL_PASSWORD="your-password"
|
||||
|
||||
# ストレージ
|
||||
export DATA_DIR="~/.9router"
|
||||
|
||||
# サーバー
|
||||
export PORT="20128"
|
||||
export NODE_ENV="production"
|
||||
|
||||
# ロギング
|
||||
export ENABLE_REQUEST_LOGS="false"
|
||||
```
|
||||
|
||||
### データディレクトリ
|
||||
|
||||
**デフォルトの場所:** `~/.9router`
|
||||
|
||||
**内容:**
|
||||
```
|
||||
~/.9router/
|
||||
├── db.json # データベース (プロバイダー、コンボ、使用量)
|
||||
├── api-keys.json # APIキー
|
||||
└── logs/ # リクエストログ (有効化されている場合)
|
||||
```
|
||||
|
||||
**場所を変更:**
|
||||
|
||||
```bash
|
||||
export DATA_DIR="/custom/path"
|
||||
9router
|
||||
```
|
||||
|
||||
### ポート設定
|
||||
|
||||
**デフォルトポート:** `20128`
|
||||
|
||||
**ポートを変更:**
|
||||
|
||||
```bash
|
||||
export PORT="3000"
|
||||
9router
|
||||
```
|
||||
|
||||
**またはコマンドラインで:**
|
||||
|
||||
```bash
|
||||
9router --port 3000
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## トラブルシューティング
|
||||
|
||||
### ポートがすでに使用されている
|
||||
|
||||
**エラー:**
|
||||
```
|
||||
Error: listen EADDRINUSE: address already in use :::20128
|
||||
```
|
||||
|
||||
**解決策1: 既存のプロセスを終了**
|
||||
|
||||
```bash
|
||||
# ポート20128を使用しているプロセスを検索
|
||||
lsof -i :20128
|
||||
|
||||
# プロセスを終了
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
**解決策2: 別のポートを使用**
|
||||
|
||||
```bash
|
||||
9router --port 3000
|
||||
```
|
||||
|
||||
### Permission Denied
|
||||
|
||||
**エラー:**
|
||||
```
|
||||
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/9router'
|
||||
```
|
||||
|
||||
**解決策: sudoを使用 (非推奨) またはnpm権限を修正**
|
||||
|
||||
```bash
|
||||
# npm権限を修正 (推奨)
|
||||
mkdir ~/.npm-global
|
||||
npm config set prefix '~/.npm-global'
|
||||
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
|
||||
# 再度インストール
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
### Node.jsバージョンが古すぎる
|
||||
|
||||
**エラー:**
|
||||
```
|
||||
Error: The engine "node" is incompatible with this module
|
||||
```
|
||||
|
||||
**解決策: Node.jsを更新**
|
||||
|
||||
```bash
|
||||
# nvmを使用 (推奨)
|
||||
nvm install 20
|
||||
nvm use 20
|
||||
|
||||
# またはnodejs.orgからダウンロード
|
||||
```
|
||||
|
||||
### ダッシュボードが開かない
|
||||
|
||||
**問題:** ダッシュボードが自動的に開かない
|
||||
|
||||
**解決策1: 手動で開く**
|
||||
|
||||
```
|
||||
http://localhost:20128
|
||||
```
|
||||
|
||||
**解決策2: ファイアウォールを確認**
|
||||
|
||||
```bash
|
||||
# macOS: システム環境設定 → セキュリティでNode.jsを許可
|
||||
# Linux: iptablesを確認
|
||||
# Windows: Windowsファイアウォールを確認
|
||||
```
|
||||
|
||||
### プロバイダーに接続できない
|
||||
|
||||
**問題:** OAuthログインが失敗、またはAPIキーが無効
|
||||
|
||||
**解決策1: インターネット接続を確認**
|
||||
|
||||
```bash
|
||||
ping google.com
|
||||
```
|
||||
|
||||
**解決策2: プロバイダーのステータスを確認**
|
||||
|
||||
- Claude Code: [status.anthropic.com](https://status.anthropic.com)
|
||||
- OpenAI: [status.openai.com](https://status.openai.com)
|
||||
- Gemini: [status.cloud.google.com](https://status.cloud.google.com)
|
||||
|
||||
**解決策3: APIキーを再生成**
|
||||
|
||||
```
|
||||
Dashboard → Provider → Disconnect → Reconnect
|
||||
```
|
||||
|
||||
### 高メモリ使用量
|
||||
|
||||
**問題:** 9RouterがRAMを使いすぎている
|
||||
|
||||
**解決策: サーバーを再起動**
|
||||
|
||||
```bash
|
||||
# 停止
|
||||
pkill -f 9router
|
||||
|
||||
# 起動
|
||||
9router
|
||||
```
|
||||
|
||||
**または自動再起動にPM2を使用:**
|
||||
|
||||
```bash
|
||||
npm install -g pm2
|
||||
pm2 start 9router --name 9router
|
||||
pm2 save
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## デプロイメントオプション
|
||||
|
||||
### ローカル開発
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
9router
|
||||
```
|
||||
|
||||
**ユースケース:** 個人コーディング、テスト
|
||||
|
||||
### VPS/クラウドサーバー
|
||||
|
||||
```bash
|
||||
# インストール
|
||||
npm install -g 9router
|
||||
|
||||
# 設定
|
||||
export JWT_SECRET="your-secure-secret"
|
||||
export INITIAL_PASSWORD="your-password"
|
||||
export NODE_ENV="production"
|
||||
|
||||
# PM2で起動
|
||||
npm install -g pm2
|
||||
pm2 start 9router --name 9router
|
||||
pm2 save
|
||||
pm2 startup
|
||||
```
|
||||
|
||||
**ユースケース:** チームアクセス、リモートコーディング
|
||||
|
||||
### Docker
|
||||
|
||||
```bash
|
||||
docker pull 9router/9router:latest
|
||||
|
||||
docker run -d \
|
||||
-p 20128:20128 \
|
||||
-e JWT_SECRET="your-secure-secret" \
|
||||
-e INITIAL_PASSWORD="your-password" \
|
||||
-v 9router-data:/root/.9router \
|
||||
--name 9router \
|
||||
9router/9router:latest
|
||||
```
|
||||
|
||||
**ユースケース:** コンテナデプロイ、Kubernetes
|
||||
|
||||
### リバースプロキシ (Nginx)
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name your-domain.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:20128;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
|
||||
# SSE support for streaming
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**ユースケース:** HTTPS、カスタムドメイン、ロードバランシング
|
||||
|
||||
---
|
||||
|
||||
## アンインストール
|
||||
|
||||
### グローバルインストールを削除
|
||||
|
||||
```bash
|
||||
npm uninstall -g 9router
|
||||
```
|
||||
|
||||
### データディレクトリを削除
|
||||
|
||||
```bash
|
||||
rm -rf ~/.9router
|
||||
```
|
||||
|
||||
### 設定を削除
|
||||
|
||||
```bash
|
||||
# シェル設定から環境変数を削除
|
||||
nano ~/.bashrc # または ~/.zshrc
|
||||
# 9router関連のエクスポートを削除
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 次のステップ
|
||||
|
||||
- [スタートガイド](../getting-started.md) - プロバイダーを接続してコーディング開始
|
||||
- [機能](../features/) - クォータトラッキング、コンボ、デプロイを確認
|
||||
- [トラブルシューティング](../troubleshooting.md) - 一般的な問題の修正
|
||||
|
||||
---
|
||||
|
||||
## ヘルプが必要?
|
||||
|
||||
- **ウェブサイト**: [9router.com](https://9router.com)
|
||||
- **GitHub**: [github.com/decolua/9router](https://github.com/decolua/9router)
|
||||
- **Issues**: [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
@@ -0,0 +1,247 @@
|
||||
# はじめに
|
||||
|
||||
9Routerを5分で起動し、AIリクエストをインテリジェントにルーティングし始めましょう。
|
||||
|
||||
---
|
||||
|
||||
## クイックスタート
|
||||
|
||||
### 1. インストール
|
||||
|
||||
```bash
|
||||
npm install -g 9router
|
||||
```
|
||||
|
||||
**要件:** Node.js 20+ ([インストール詳細](getting-started/installation.md))
|
||||
|
||||
### 2. 起動
|
||||
|
||||
```bash
|
||||
9router
|
||||
```
|
||||
|
||||
🎉 **ダッシュボードが自動的に開きます** (`http://localhost:20128`)
|
||||
|
||||
- デフォルトパスワード: `123456` (ダッシュボードで変更)
|
||||
- APIキーは自動生成
|
||||
- プロバイダー接続の準備完了
|
||||
|
||||
### 3. プロバイダーを接続
|
||||
|
||||
プロバイダーを接続する方法は3つあります:
|
||||
|
||||
#### オプションA: OAuth(サブスクリプションプロバイダー)
|
||||
|
||||
**最適:** Claude Code、Codex、Gemini CLI、GitHub Copilot
|
||||
|
||||
```
|
||||
Dashboard → Providers → Connect [Provider]
|
||||
→ OAuthログイン → トークン自動更新
|
||||
→ クォータトラッキング有効化
|
||||
```
|
||||
|
||||
**例: Claude Code**
|
||||
1. 「Connect Claude Code」をクリック
|
||||
2. Claudeアカウントでログイン
|
||||
3. 9Routerを認可
|
||||
4. ✅ 完了! モデルを使用: `cc/claude-opus-4-5-20251101`
|
||||
|
||||
#### オプションB: APIキー(低価格プロバイダー)
|
||||
|
||||
**最適:** GLM、MiniMax、Kimi、OpenRouter
|
||||
|
||||
```
|
||||
Dashboard → Providers → Add API Key
|
||||
→ プロバイダーを選択
|
||||
→ APIキーを貼り付け
|
||||
→ 保存
|
||||
```
|
||||
|
||||
**例: GLM-4.7**
|
||||
1. [Zhipu AI](https://open.bigmodel.cn/)でサインアップ
|
||||
2. Coding PlanからAPIキーを取得
|
||||
3. Dashboard → Add API Key → Provider: `glm` → キーを貼り付け
|
||||
4. ✅ 完了! モデルを使用: `glm/glm-4.7`
|
||||
|
||||
#### オプションC: 無料プロバイダー(コストなし)
|
||||
|
||||
**最適:** iFlow、Qwen、Kiro
|
||||
|
||||
```
|
||||
Dashboard → Providers → Connect [Free Provider]
|
||||
→ デバイスコードまたはOAuth
|
||||
→ 無制限利用
|
||||
```
|
||||
|
||||
**例: iFlow**
|
||||
1. 「Connect iFlow」をクリック
|
||||
2. iFlowアカウントでログイン
|
||||
3. 認可
|
||||
4. ✅ 完了! 8モデルを使用: `if/kimi-k2-thinking`、`if/qwen3-coder-plus`など
|
||||
|
||||
---
|
||||
|
||||
## 4. CLIツールで使用
|
||||
|
||||
コーディングツールを9Routerに向けます:
|
||||
|
||||
### Cursor IDE
|
||||
|
||||
```
|
||||
Settings → Models → Advanced:
|
||||
OpenAI API Base URL: http://localhost:20128/v1
|
||||
OpenAI API Key: [9routerダッシュボードから取得]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
### Claude Desktop
|
||||
|
||||
`~/.claude/config.json`を編集:
|
||||
|
||||
```json
|
||||
{
|
||||
"anthropic_api_base": "http://localhost:20128/v1",
|
||||
"anthropic_api_key": "your-9router-api-key"
|
||||
}
|
||||
```
|
||||
|
||||
### Cline / Continue / RooCode
|
||||
|
||||
```
|
||||
Provider: OpenAI Compatible
|
||||
Base URL: http://localhost:20128/v1
|
||||
API Key: [ダッシュボードから取得]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
### Codex CLI
|
||||
|
||||
```bash
|
||||
export OPENAI_BASE_URL="http://localhost:20128"
|
||||
export OPENAI_API_KEY="your-9router-api-key"
|
||||
|
||||
codex "your prompt"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. スマートコンボを作成(オプション)
|
||||
|
||||
コンボはモデル間の自動フォールバックを可能にします:
|
||||
|
||||
```
|
||||
Dashboard → Combos → Create New
|
||||
|
||||
Name: premium-coding
|
||||
Models:
|
||||
1. cc/claude-opus-4-5-20251101 (サブスクリプション優先)
|
||||
2. glm/glm-4.7 (低価格バックアップ、100万あたり$0.6)
|
||||
3. if/kimi-k2-thinking (無料フォールバック)
|
||||
|
||||
CLIで使用: premium-coding
|
||||
```
|
||||
|
||||
**動作:**
|
||||
1. 最初にClaude Opusを試行(サブスクリプション)
|
||||
2. クォータ消費時 → GLM-4.7(超低価格)
|
||||
3. 予算上限時 → iFlow(無料)
|
||||
4. ダウンタイムゼロ、自動切替!
|
||||
|
||||
---
|
||||
|
||||
## 利用可能なモデル
|
||||
|
||||
### サブスクリプションモデル(最初に最大化)
|
||||
|
||||
**Claude Code (`cc/`)** - Pro/Maxサブスクリプション:
|
||||
- `cc/claude-opus-4-5-20251101` - Claude 4.5 Opus
|
||||
- `cc/claude-sonnet-4-5-20250929` - Claude 4.5 Sonnet
|
||||
- `cc/claude-haiku-4-5-20251001` - Claude 4.5 Haiku
|
||||
|
||||
**Codex (`cx/`)** - Plus/Proサブスクリプション:
|
||||
- `cx/gpt-5.2-codex` - GPT 5.2 Codex
|
||||
- `cx/gpt-5.1-codex-max` - GPT 5.1 Codex Max
|
||||
|
||||
**Gemini CLI (`gc/`)** - 月18万無料:
|
||||
- `gc/gemini-3-flash-preview` - Gemini 3 Flash Preview
|
||||
- `gc/gemini-2.5-pro` - Gemini 2.5 Pro
|
||||
|
||||
**GitHub Copilot (`gh/`)** - サブスクリプション:
|
||||
- `gh/gpt-5` - GPT-5
|
||||
- `gh/claude-4.5-sonnet` - Claude 4.5 Sonnet
|
||||
|
||||
### 低価格モデル(バックアップ)
|
||||
|
||||
**GLM (`glm/`)** - 100万あたり$0.6/$2.2:
|
||||
- `glm/glm-4.7` - GLM 4.7(毎日午前10時リセット)
|
||||
|
||||
**MiniMax (`minimax/`)** - 100万あたり$0.20/$1.00:
|
||||
- `minimax/MiniMax-M2.1` - MiniMax M2.1(5時間リセット)
|
||||
|
||||
**Kimi (`kimi/`)** - 月$9(1000万トークン):
|
||||
- `kimi/kimi-latest` - Kimi Latest
|
||||
|
||||
### 無料モデル(緊急時)
|
||||
|
||||
**iFlow (`if/`)** - 8モデル無料:
|
||||
- `if/kimi-k2-thinking` - Kimi K2 Thinking
|
||||
- `if/qwen3-coder-plus` - Qwen3 Coder Plus
|
||||
- `if/glm-4.7` - GLM 4.7
|
||||
- `if/deepseek-r1` - DeepSeek R1
|
||||
|
||||
**Qwen (`qw/`)** - 3モデル無料:
|
||||
- `qw/qwen3-coder-plus` - Qwen3 Coder Plus
|
||||
- `qw/qwen3-coder-flash` - Qwen3 Coder Flash
|
||||
|
||||
**Kiro (`kr/`)** - 2モデル無料:
|
||||
- `kr/claude-sonnet-4.5` - Claude Sonnet 4.5
|
||||
- `kr/claude-haiku-4.5` - Claude Haiku 4.5
|
||||
|
||||
---
|
||||
|
||||
## コスト最適化戦略
|
||||
|
||||
### 月予算: $10〜20/月
|
||||
|
||||
```
|
||||
1. クイックタスクにGemini CLI無料プラン(月18万)を使用
|
||||
2. Claude Codeサブスクリプションのクォータを完全利用(すでに支払い済み)
|
||||
3. クォータ切れ時はGLM(100万あたり$0.6)へフォールバック
|
||||
4. 緊急時: MiniMax M2.1(100万あたり$0.20)またはiFlow(無料)
|
||||
|
||||
実例(月1億トークン):
|
||||
Gemini CLI経由で6000万: $0(無料プラン)
|
||||
Claude Code経由で3000万: $0(既存サブスクリプション)
|
||||
GLM経由で800万: $4.80
|
||||
MiniMax経由で200万: $0.40
|
||||
合計: 月$5.20 + 既存サブスクリプション
|
||||
```
|
||||
|
||||
### クォータリセット戦略
|
||||
|
||||
```
|
||||
日課:
|
||||
1. 朝: Claude Codeの新しいクォータ(5時間リセット)
|
||||
2. 午後: Gemini CLIへ切替(1K/日)
|
||||
3. 夕方: GLM日次クォータ(翌朝10時リセット)
|
||||
4. 深夜: MiniMax(5時間ローリング)またはiFlow(無料)
|
||||
|
||||
→ 最小の追加コストで24時間コーディング!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 次のステップ
|
||||
|
||||
- [インストール詳細](getting-started/installation.md) - 要件、トラブルシューティング
|
||||
- [機能](features/) - クォータトラッキング、コンボ、デプロイを確認
|
||||
- [FAQ](faq.md) - よくある質問と回答
|
||||
- [トラブルシューティング](troubleshooting.md) - 一般的な問題の修正
|
||||
|
||||
---
|
||||
|
||||
## ヘルプが必要?
|
||||
|
||||
- **ウェブサイト**: [9router.com](https://9router.com)
|
||||
- **GitHub**: [github.com/decolua/9router](https://github.com/decolua/9router)
|
||||
- **Issues**: [github.com/decolua/9router/issues](https://github.com/decolua/9router/issues)
|
||||
@@ -0,0 +1,164 @@
|
||||
# 9Routerへようこそ
|
||||
|
||||
**Claude、Codex、Geminiを無料で利用 • 100万トークンあたり$0.20からの超低価格な代替手段**
|
||||
|
||||
9Routerは、インテリジェントなルーティングと自動フォールバックを通じて、サブスクリプションの価値を最大化し、コストを最小限に抑えるAIモデルルーターです。
|
||||
|
||||
---
|
||||
|
||||
## 9Routerとは?
|
||||
|
||||
9Routerは、コーディングツール(Cursor、Cline、Claude Desktop)とAIプロバイダーの間に位置するスマートプロキシです。クォータ、コスト、可用性に基づいて、リクエストを最適なモデルへ自動的にルーティングします。
|
||||
|
||||
**お金を無駄にしないために:**
|
||||
- ❌ サブスクリプションのクォータが毎月未使用のまま失効
|
||||
- ❌ レート制限でコーディングが中断
|
||||
- ❌ 高額なAPI(プロバイダーあたり月$20〜50)
|
||||
- ❌ プロバイダー間の手動切り替え
|
||||
|
||||
**価値を最大化するために:**
|
||||
- ✅ **サブスクリプションを最大限活用** - Claude Code、Codex、Geminiのクォータを余すことなく追跡・利用
|
||||
- ✅ **無料で利用可能** - CLI経由でiFlow、Qwen、Kiroモデルにアクセス
|
||||
- ✅ **超低価格バックアップ** - GLM(100万あたり$0.6)、MiniMax M2.1(100万あたり$0.20)
|
||||
- ✅ **スマートフォールバック** - サブスクリプション → 低価格 → 無料へ自動切替
|
||||
|
||||
---
|
||||
|
||||
## 主な機能
|
||||
|
||||
### 🔄 スマート3階層フォールバック
|
||||
|
||||
```
|
||||
一度セットアップすれば、コーディングが止まらない:
|
||||
|
||||
Tier 1 (サブスクリプション): Claude Code → Codex → Gemini
|
||||
↓ クォータ消費
|
||||
Tier 2 (低価格): GLM-4.7 → MiniMax M2.1 → Kimi
|
||||
↓ 予算上限
|
||||
Tier 3 (無料): iFlow → Qwen → Kiro
|
||||
|
||||
→ 自動切替、ダウンタイムゼロ!
|
||||
```
|
||||
|
||||
### 📊 クォータトラッキング
|
||||
|
||||
- プロバイダーごとのリアルタイムトークン消費
|
||||
- リセットカウントダウン(5時間、毎日、毎週、毎月)
|
||||
- 有料プランのコスト見積もり
|
||||
- 月次支出レポート
|
||||
|
||||
### 🎯 ユニバーサルCLIサポート
|
||||
|
||||
カスタムOpenAIエンドポイントをサポートするあらゆるツールで動作:
|
||||
|
||||
✅ **Cursor** • **Cline** • **Claude Desktop** • **Codex** • **RooCode** • **Continue** • **OpenAI互換ツール全般**
|
||||
|
||||
### 💰 コスト最適化
|
||||
|
||||
**実例(月1億トークン):**
|
||||
```
|
||||
Gemini CLI経由で6000万: $0(無料プラン)
|
||||
Claude Code経由で3000万: $0(既存サブスクリプション)
|
||||
GLM経由で800万: $4.80
|
||||
MiniMax経由で200万: $0.40
|
||||
合計: 月$5.20 vs ChatGPT APIの$2000!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## なぜ9Routerを選ぶのか?
|
||||
|
||||
### サブスクリプションを最大化
|
||||
|
||||
すでにClaude Code(月$20〜100)やCodex(月$20〜200)に支払っていますか? 完全な価値を引き出しましょう:
|
||||
|
||||
- クォータ使用量をリアルタイムで追跡
|
||||
- クォータリセット(5時間、週次)時に自動切替
|
||||
- 失効前にすべてのトークンを使い切る
|
||||
- Gemini CLI: 月18万コンプリーション**無料**
|
||||
|
||||
### 超低価格バックアップ
|
||||
|
||||
サブスクリプションのクォータが切れたら、わずかな金額で:
|
||||
|
||||
| プロバイダー | 100万トークンあたりのコスト | リセット |
|
||||
|----------|-------------------|-------|
|
||||
| **GLM-4.7** | 入力$0.60 / 出力$2.20 | 毎日午前10時 |
|
||||
| **MiniMax M2.1** | 入力$0.20 / 出力$1.00 | 5時間ローリング |
|
||||
| **Kimi K2** | 月$9(1000万トークン) | 月次 |
|
||||
|
||||
**ChatGPT API(100万あたり$20)より約90%安い!**
|
||||
|
||||
### 永久無料フォールバック
|
||||
|
||||
他がすべてクォータ制限に達した時の緊急バックアップ:
|
||||
|
||||
- **iFlow**: 8モデル(Kimi K2、Qwen3 Coder Plus、GLM 4.7、MiniMax M2)
|
||||
- **Qwen**: 3モデル(Qwen3 Coder Plus/Flash、Vision)
|
||||
- **Kiro**: Claude Sonnet 4.5、Haiku 4.5(AWS Builder ID)
|
||||
|
||||
---
|
||||
|
||||
## クイックスタート
|
||||
|
||||
2分で始められます:
|
||||
|
||||
```bash
|
||||
# グローバルインストール
|
||||
npm install -g 9router
|
||||
|
||||
# 起動(ダッシュボードが自動で開きます)
|
||||
9router
|
||||
```
|
||||
|
||||
🎉 **ダッシュボードが開く** → プロバイダーを接続 → コーディング開始!
|
||||
|
||||
**CLIツールで使う:**
|
||||
|
||||
```
|
||||
Endpoint: http://localhost:20128/v1
|
||||
API Key: [ダッシュボードから取得]
|
||||
Model: cc/claude-opus-4-5-20251101
|
||||
```
|
||||
|
||||
[→ 完全なスタートガイド](getting-started.md)
|
||||
|
||||
---
|
||||
|
||||
## ユースケース
|
||||
|
||||
### 個人開発者向け
|
||||
|
||||
- Claude Code/Codexサブスクリプションを最大限活用
|
||||
- Gemini CLI無料プラン(月18万)を活用
|
||||
- 超低価格モデル(100万あたり$0.20)へフォールバック
|
||||
- レート制限なしで24時間コーディング
|
||||
|
||||
### チーム向け
|
||||
|
||||
- VPS/クラウドにデプロイして共有アクセス
|
||||
- チームの支出をリアルタイムで追跡
|
||||
- 階層ごとに予算上限を設定
|
||||
- 集中型のプロバイダー管理
|
||||
|
||||
### モバイル/リモートコーディング向け
|
||||
|
||||
- クラウドデプロイ(https://9router.com)を使用
|
||||
- iPad、スマホ、どこからでもアクセス
|
||||
- localhost制限なし
|
||||
- Cloudflareエッジネットワーク(300以上のロケーション)
|
||||
|
||||
---
|
||||
|
||||
## 次は?
|
||||
|
||||
- [スタートガイド](getting-started.md) - 5分でインストールと設定
|
||||
- [インストールガイド](getting-started/installation.md) - 詳細なセットアップ手順
|
||||
- [機能](features/) - すべての機能を確認
|
||||
- [FAQ](faq.md) - よくある質問
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<sub>AIの価値を最大化する開発者のために ❤️ で構築</sub>
|
||||
</div>
|
||||
@@ -0,0 +1,109 @@
|
||||
# Claude Code統合
|
||||
|
||||
9RouterをClaude Code CLIと統合し、AnthropicのAPIリクエストを9Routerのインテリジェントルーティングシステム経由でルーティングします。
|
||||
|
||||
## 前提条件
|
||||
|
||||
- Claude Code CLIがインストール済み
|
||||
- 9Routerがローカルで動作中、またはクラウドエンドポイントが設定済み
|
||||
- 9RouterダッシュボードからのAPIキー
|
||||
|
||||
## セットアップ
|
||||
|
||||
### 1. 環境変数を設定
|
||||
|
||||
シェル設定ファイル (`~/.bashrc`、`~/.zshrc`、または `~/.bash_profile`) で以下の環境変数を設定:
|
||||
|
||||
```bash
|
||||
# 9Router用Base URL
|
||||
export ANTHROPIC_BASE_URL="http://localhost:20128/v1"
|
||||
|
||||
# オプション: エイリアス用のデフォルトモデルを設定
|
||||
export ANTHROPIC_DEFAULT_OPUS_MODEL="cc/claude-opus-4-5-20251101"
|
||||
export ANTHROPIC_DEFAULT_SONNET_MODEL="cc/claude-sonnet-4-5-20250929"
|
||||
export ANTHROPIC_DEFAULT_HAIKU_MODEL="cc/claude-haiku-4-5-20251001"
|
||||
```
|
||||
|
||||
### 2. シェル設定をリロード
|
||||
|
||||
```bash
|
||||
source ~/.zshrc # または ~/.bashrc
|
||||
```
|
||||
|
||||
### 3. 設定を確認
|
||||
|
||||
環境変数が正しく設定されているか確認:
|
||||
|
||||
```bash
|
||||
echo $ANTHROPIC_BASE_URL
|
||||
```
|
||||
|
||||
## モデルエイリアス
|
||||
|
||||
Claude Codeは9Routerモデルにマッピングされる以下のモデルエイリアスをサポート:
|
||||
|
||||
| エイリアス | モデル | 環境変数 |
|
||||
|-------|-------|---------------------|
|
||||
| `opus` | Claude Opus 4.5 | `ANTHROPIC_DEFAULT_OPUS_MODEL` |
|
||||
| `sonnet` | Claude Sonnet 4.5 | `ANTHROPIC_DEFAULT_SONNET_MODEL` |
|
||||
| `haiku` | Claude Haiku 4.5 | `ANTHROPIC_DEFAULT_HAIKU_MODEL` |
|
||||
|
||||
## 使用例
|
||||
|
||||
### モデルエイリアスを使用
|
||||
|
||||
```bash
|
||||
# Opusモデルを使用
|
||||
claude --model opus "Explain quantum computing"
|
||||
|
||||
# Sonnetモデルを使用
|
||||
claude --model sonnet "Write a Python function"
|
||||
|
||||
# Haikuモデルを使用
|
||||
claude --model haiku "Quick code review"
|
||||
```
|
||||
|
||||
### フルモデル名を使用
|
||||
|
||||
```bash
|
||||
claude --model cc/claude-opus-4-5-20251101 "Your prompt here"
|
||||
```
|
||||
|
||||
## 設定ファイル
|
||||
|
||||
Claude Codeは設定を `~/.claude/settings.json` に保存します。必要に応じてこのファイルを手動で編集できます:
|
||||
|
||||
```json
|
||||
{
|
||||
"baseUrl": "http://localhost:20128/v1",
|
||||
"defaultModel": "sonnet"
|
||||
}
|
||||
```
|
||||
|
||||
## トラブルシューティング
|
||||
|
||||
### 接続の問題
|
||||
|
||||
接続エラーが発生した場合:
|
||||
|
||||
1. 9Routerが動作中か確認: `curl http://localhost:20128/health`
|
||||
2. 環境変数が正しく設定されているか確認
|
||||
3. ファイアウォールがポート20128をブロックしていないか確認
|
||||
|
||||
### モデルが見つからない
|
||||
|
||||
「model not found」エラーが発生した場合:
|
||||
|
||||
1. モデル名が9Routerの設定と一致しているか確認
|
||||
2. 9Routerダッシュボードでプロバイダー接続がアクティブか確認
|
||||
3. 接続されたプロバイダーでモデルが利用可能か確認
|
||||
|
||||
## クラウドエンドポイント
|
||||
|
||||
localhostの代わりに9Routerクラウドエンドポイントを使用するには:
|
||||
|
||||
```bash
|
||||
export ANTHROPIC_BASE_URL="https://9router.com"
|
||||
```
|
||||
|
||||
9RouterクラウドダッシュボードでAPIキーが設定されていることを確認してください。
|
||||
Loaded 50 of 124 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user