From 9cc690968daee6565d3d789ce16cd2e061aeeb07 Mon Sep 17 00:00:00 2001 From: wehub-resource-sync Date: Mon, 13 Jul 2026 10:10:19 +0000 Subject: [PATCH] docs: make Chinese README the default --- README.md | 1156 ++++++++++++++++++++++++----------------------------- 1 file changed, 514 insertions(+), 642 deletions(-) diff --git a/README.md b/README.md index b6cd76b..a305664 100644 --- a/README.md +++ b/README.md @@ -1,105 +1,108 @@ + +> [!NOTE] +> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。 +> [English](./README.en.md) · [原始项目](https://github.com/decolua/9router) · [上游 README](https://github.com/decolua/9router/blob/HEAD/README.md) +> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。 +
9Router Dashboard - # 9Router - FREE AI Router & Token Saver + # 9Router - 免费 AI 路由器与 Token 节省器 - **Never stop coding. Save 20-40% tokens with RTK + auto-fallback to FREE & cheap AI models.** + **编程永不停歇。使用 RTK + 自动切换到免费/低价 AI 模型,节省 20-40% 的 tokens。** - **Connect All AI Code Tools (Claude Code, Cursor, Antigravity, Copilot, Codex, Gemini, OpenCode, Cline, OpenClaw...) to 40+ AI Providers & 100+ Models.** + **将所有 AI 编程工具(Claude Code、Cursor、Antigravity、Copilot、Codex、Gemini、OpenCode、Cline、OpenClaw...)连接到 40+ AI 提供商和 100+ 模型。** [![npm](https://img.shields.io/npm/v/9router.svg)](https://www.npmjs.com/package/9router) [![Downloads](https://img.shields.io/npm/dm/9router.svg)](https://www.npmjs.com/package/9router) - [![Docker Pulls](https://img.shields.io/docker/pulls/decolua/9router.svg?logo=docker&label=Docker%20pulls)](https://hub.docker.com/r/decolua/9router) - [![GHCR](https://img.shields.io/badge/GHCR-decolua%2F9router-blue?logo=github)](https://github.com/decolua/9router/pkgs/container/9router) [![License](https://img.shields.io/npm/l/9router.svg)](https://github.com/decolua/9router/blob/main/LICENSE) -decolua%2F9router | Trendshift - -[🚀 Quick Start](#-quick-start) • [💡 Features](#-key-features) • [📖 Setup](#-setup-guide) • [🌐 Website](https://9router.com) - -[🇻🇳 Tiếng Việt](./i18n/README.vi.md) • [🇨🇳 中文](./i18n/README.zh-CN.md) • [🇯🇵 日本語](./i18n/README.ja-JP.md) • [🇷🇺 Русский](./i18n/README.ru.md) + decolua%2F9router | Trendshift + + [🚀 快速开始](#-快速开始) • [💡 功能特点](#-主要功能) • [📖 设置指南](#-设置指南) • [🌐 网站](https://9router.com) + [🇻🇳 Tiếng Việt](./i18n/README.vi.md) • [🇨🇳 中文](./i18n/README.zh-CN.md) • [🇯🇵 日本語](./i18n/README.ja-JP.md)
--- -## 🤔 Why 9Router? +## 🤔 为什么选择 9Router? -**Stop wasting money, tokens and hitting limits:** +**告别浪费金钱、tokens 和触碰限制的困扰:** -- ❌ Subscription quota expires unused every month -- ❌ Rate limits stop you mid-coding -- ❌ Tool outputs (git diff, grep, ls...) burn tokens fast -- ❌ Expensive APIs ($20-50/month per provider) -- ❌ Manual switching between providers +- ❌ 订阅配额每月到期却未使用 +- ❌ 速率限制在编程中途打断你 +- ❌ 工具输出(git diff、grep、ls...)快速消耗 tokens +- ❌ 昂贵的 API(每个提供商 $20-50/月) +- ❌ 需要手动在提供商之间切换 -**9Router solves this:** +**9Router 解决这一切:** -- ✅ **RTK Token Saver** - Auto-compress tool_result content, save 20-40% tokens per request -- ✅ **Maximize subscriptions** - Track quota, use every bit before reset -- ✅ **Auto fallback** - Subscription → Cheap → Free, zero downtime -- ✅ **Multi-account** - Round-robin between accounts per provider -- ✅ **Universal** - Works with Claude Code, Codex, Cursor, Cline, any CLI tool +- ✅ **RTK Token 节省器** - 自动压缩 tool_result 内容,每次请求节省 20-40% tokens +- ✅ **充分利用订阅** - 追踪配额,在重置前用尽每一分额度 +- ✅ **自动切换** - 订阅 → 低价 → 免费,零停机时间 +- ✅ **多账户支持** - 按提供商在账户之间轮询 +- ✅ **通用兼容** - 支持 Claude Code、Codex、Cursor、Cline 以及任何 CLI 工具 --- -## 🔄 How It Works +## 🔄 工作原理 ``` ┌─────────────┐ -│ Your CLI │ (Claude Code, Codex, OpenClaw, Cursor, Cline...) -│ Tool │ +│ 你的 CLI │ (Claude Code、Codex、OpenClaw、Cursor、Cline...) +│ 工具 │ └──────┬──────┘ │ http://localhost:20128/v1 ↓ ┌─────────────────────────────────────────────┐ -│ 9Router (Smart Router) │ -│ • RTK Token Saver (cut tool_result tokens) │ -│ • Format translation (OpenAI ↔ Claude) │ -│ • Quota tracking │ -│ • Auto token refresh │ +│ 9Router(智能路由器) │ +│ • RTK Token 节省器(减少 tool_result tokens)│ +│ • 格式转换(OpenAI ↔ Claude) │ +│ • 配额追踪 │ +│ • 自动刷新 token │ └──────┬──────────────────────────────────────┘ │ - ├─→ [Tier 1: SUBSCRIPTION] Claude Code, Codex, GitHub Copilot - │ ↓ quota exhausted - ├─→ [Tier 2: CHEAP] GLM ($0.6/1M), MiniMax ($0.2/1M) - │ ↓ budget limit - └─→ [Tier 3: FREE] Kiro, OpenCode Free, Vertex ($300 credits) + ├─→ [第一层:订阅] Claude Code、Codex、GitHub Copilot + │ ↓ 配额耗尽 + ├─→ [第二层:低价] GLM ($0.6/1M)、MiniMax ($0.2/1M) + │ ↓ 预算超限 + └─→ [第三层:免费] Kiro、OpenCode Free、Vertex ($300 额度) -Result: Never stop coding, minimal cost + 20-40% token savings via RTK +结果:编程永不停歇,最小成本 + 通过 RTK 节省 20-40% tokens ``` --- -## ⚡ Quick Start +## ⚡ 快速开始 -**1. Install globally:** +**1. 全局安装:** ```bash npm install -g 9router 9router ``` -🎉 Dashboard opens at `http://localhost:20128` +🎉 控制面板在 `http://localhost:20128` 打开 -**2. Connect a FREE provider (no signup needed):** +**2. 连接免费提供商(无需注册):** -Dashboard → Providers → Connect **Kiro AI** (free Claude unlimited) or **OpenCode Free** (no auth) → Done! +控制面板 → 提供商 → 连接 **Kiro AI**(免费 Claude 无限量)或 **OpenCode Free**(无需认证)→ 完成! -**3. Use in your CLI tool:** +**3. 在 CLI 工具中使用:** ``` -Claude Code/Codex/OpenClaw/Cursor/Cline Settings: +Claude Code/Codex/OpenClaw/Cursor/Cline 设置: Endpoint: http://localhost:20128/v1 - API Key: [copy from dashboard] + API Key: [从控制面板复制] Model: kr/claude-sonnet-4.5 ``` -**That's it!** Start coding with FREE AI models. +**就这么简单!** 开始使用免费 AI 模型编程。 -**Alternative: run from source (this repository):** +**替代方案:从源码运行(本仓库):** -This repository package is private (`9router-app`), so source/Docker execution is the expected local development path. +本仓库的包是私有的(`9router-app`),所以源码/Docker 执行是预期的本地开发方式。 ```bash cp .env.example .env @@ -107,119 +110,81 @@ npm install PORT=20128 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run dev ``` -Production mode: +生产模式: ```bash npm run build PORT=20128 HOSTNAME=0.0.0.0 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run start ``` -Default URLs: - -- Dashboard: `http://localhost:20128/dashboard` -- OpenAI-compatible API: `http://localhost:20128/v1` +默认 URL: +- 控制面板:`http://localhost:20128/dashboard` +- OpenAI 兼容 API:`http://localhost:20128/v1` --- -## Video Guides +## 视频教程
- - - - - - + + - - - - - - - - - - -
- - Tiết kiệm chi phí LLM với 9Router -
- 🇻🇳 Tiếng Việt
- Tiết kiệm chi phí LLM cho OpenClaw với 9Router
by Mì AI
-
- - 9Router + Claude Code FREE Unlimited Setup -
- 🇵🇰 اردو / हिन्दी
- 9Router + Claude Code FREE Unlimited Setup
by Build AI With Hamid
-
9Router Setup Tutorial
🇺🇸 English
- 9Router + Claude Code FREE Setup
by Build AI With Hamid
+ 9Router + Claude Code 免费设置
by Build AI With Hamid
- - 9Router Setup Tutorial + + + Tiết kiệm chi phí LLM với 9Router
- 🇺🇸 English
- 9Router + Claude Code FREE Setup
by Build AI With Hamid
+ 🇻🇳 Tiếng Việt
+ 使用 9Router 节省 OpenClaw 的 LLM 成本
by Mì AI
Claude Code FREE Forever
🇺🇸 English
- Claude Code FREE Forever — Unlimited Models
by Build AI With Hamid
+ Claude Code 免费永久使用 — 无限模型
by Build AI With Hamid
Claude CLI Free Setup
🇺🇸 English
- Claude CLI Free Setup with 9Router 🚀
by CodeVerse Soban
+ 使用 9Router 免费设置 Claude CLI 🚀
by CodeVerse Soban
+ Cài đặt OpenClaw Free A-Z
🇻🇳 Tiếng Việt
- Cài Đặt OpenClaw Free Từ A-Z + 9Router
by Mai Gia
+ 从零开始安装 OpenClaw 免费版 + 9Router
by Mai Gia
FREE OpenClaw with Claude Opus
🇺🇸 English
- FREE OpenClaw + Claude Opus 4.6
by Build AI With Hamid
-
- - Claude CLI Free Setup -
- 🇮🇩 Indonesia
- Koding 24 Jam Anti Rate Limit! Hemat Token AI 65% | Tutorial Quick Setup 9Router 🚀
by Krisswuh
-
- - Cara Deploy 9Router di Hugging Face GRATIS Non-Stop! | Alternatif VPS RAM 16GB -
- 🇮🇩 Indonesia
- Cara Deploy 9Router di Hugging Face GRATIS Non-Stop! | Alternatif VPS RAM 16GB
by Krisswuh
+ 免费 OpenClaw + Claude Opus 4.6
by Build AI With Hamid
-> 🎬 **Made a video about 9Router?** Submit a [Pull Request](https://github.com/decolua/9router/pulls) adding your video to this section — we'll merge it! +> 🎬 **制作了关于 9Router 的视频?** 提交 [Pull Request](https://github.com/decolua/9router/pulls),将你的视频添加到此部分 — 我们会合并它! --- -## 🛠️ Supported CLI Tools +## 🛠️ 支持的 CLI 工具 -9Router works seamlessly with all major AI coding tools: +9Router 与所有主流 AI 编程工具无缝协作:
@@ -280,9 +245,9 @@ Default URLs: --- -## 🌐 Supported Providers +## 🌐 支持的提供商 -### 🔐 OAuth Providers +### 🔐 OAuth 提供商
@@ -307,15 +272,11 @@ Default URLs: Cursor
Cursor -
- Kimchi
- Kimchi -
-### 🆓 Free Providers +### 🆓 免费提供商
@@ -323,25 +284,25 @@ Default URLs:
Kiro
Kiro AI
- Claude 4.5 + GLM-5 + MiniMax
Unlimited FREE
+ Claude 4.5 + GLM-5 + MiniMax
无限免费
OpenCode Free
OpenCode Free
- No auth • Auto-fetch models
Unlimited FREE
+ 无需认证 • 自动获取模型
无限免费
Vertex AI
Vertex AI
- Gemini 3 Pro + GLM-5 + DeepSeek
$300 credits free
+ Gemini 3 Pro + GLM-5 + DeepSeek
$300 免费额度
-> **Note:** iFlow, Qwen and Gemini CLI free tiers were discontinued in 2026. Use Kiro / OpenCode Free / Vertex instead. +> **注意:** iFlow、Qwen 和 Gemini CLI 的免费等级已于 2026 年停止。请改用 Kiro / OpenCode Free / Vertex。 -### 🔑 API Key Providers (40+) +### 🔑 API Key 提供商(40+)
@@ -424,455 +385,390 @@ Default URLs:
-

...and 20+ more providers including Nebius, Chutes, Hyperbolic, and custom OpenAI/Anthropic compatible endpoints

+

...以及 20+ 更多提供商,包括 Nebius、Chutes、Hyperbolic 和自定义 OpenAI/Anthropic 兼容端点

--- -## 💡 Key Features +## 💡 主要功能 -| Feature | What It Does | Why It Matters | -| --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------- | -| 🚀 **RTK Token Saver** ([RTK](https://github.com/rtk-ai/rtk) ⭐40K) | Compress tool outputs (`git diff`, `grep`, `ls`, `tree`...) before sending to LLM | Save **20-40% input tokens** per request | -| 🧠 **Headroom Token Saver** ([Headroom](https://github.com/chopratejas/headroom)) | Optional external `/v1/compress` proxy before provider routing | Save more context tokens without changing clients | -| 🪨 **Caveman Mode** ([Caveman](https://github.com/JuliusBrussee/caveman) ⭐52K) | Inject caveman-speak prompt → LLM replies terse, technical substance preserved | Save **up to 65% output tokens** | -| 🐴 **Ponytail** ([Ponytail](https://github.com/DietrichGebert/ponytail)) | Inject "lazy senior dev" prompt → LLM writes minimal, YAGNI-first code (Lite/Full/Ultra) | **Fewer output tokens, less refactoring** | -| 🎯 **Smart 3-Tier Fallback** | Auto-route: Subscription → Cheap → Free | Never stop coding, zero downtime | -| 📊 **Real-Time Quota Tracking** | Live token count + reset countdown | Maximize subscription value | -| 🔄 **Format Translation** | OpenAI ↔ Claude ↔ Gemini ↔ Cursor ↔ Kiro ↔ Vertex | Works with any CLI tool | -| 👥 **Multi-Account Support** | Multiple accounts per provider | Load balancing + redundancy | -| 🔄 **Auto Token Refresh** | OAuth tokens refresh automatically | No manual re-login needed | -| 🎨 **Custom Combos** | Create unlimited model combinations | Tailor fallback to your needs | -| 📝 **Request Logging** | Debug mode with full request/response logs | Troubleshoot issues easily | -| 💾 **Cloud Sync** | Sync config across devices | Same setup everywhere | -| 📊 **Usage Analytics** | Track tokens, cost, trends over time | Optimize spending | -| 🌐 **Deploy Anywhere** | Localhost, VPS, Docker, Cloudflare Workers | Flexible deployment options | +| 功能 | 作用 | 为什么重要 | +|---------|--------------|----------------| +| 🚀 **RTK Token 节省器**([RTK](https://github.com/rtk-ai/rtk) ⭐40K) | 压缩工具输出(`git diff`、`grep`、`ls`、`tree`...)后再发送给 LLM | 每次请求节省 **20-40% 输入 tokens** | +| 🪨 **Caveman 模式**([Caveman](https://github.com/JuliusBrussee/caveman) ⭐52K) | 注入 caveman 风格提示词 → LLM 回复简洁,保留技术实质 | 节省 **高达 65% 输出 tokens** | +| 🎯 **智能三层切换** | 自动路由:订阅 → 低价 → 免费 | 编程永不停歇,零停机时间 | +| 📊 **实时配额追踪** | 实时 token 计数 + 重置倒计时 | 充分利用订阅价值 | +| 🔄 **格式转换** | OpenAI ↔ Claude ↔ Gemini ↔ Cursor ↔ Kiro ↔ Vertex | 兼容任何 CLI 工具 | +| 👥 **多账户支持** | 每个提供商支持多个账户 | 负载均衡 + 冗余备份 | +| 🔄 **自动 Token 刷新** | OAuth token 自动刷新 | 无需手动重新登录 | +| 🎨 **自定义组合** | 创建无限模型组合 | 自定义适合你的切换策略 | +| 📝 **请求日志** | 调试模式下的完整请求/响应日志 | 轻松排查问题 | +| 💾 **云同步** | 跨设备同步配置 | 处处相同设置 | +| 📊 **使用分析** | 追踪 tokens、成本、趋势 | 优化开支 | +| 🌐 **任意部署** | 本地、VPS、Docker、Cloudflare Workers | 灵活部署选项 |
-📖 Feature Details +📖 功能详情 -### 🚀 RTK Token Saver +### 🚀 RTK Token 节省器 -Tool outputs (`git diff`, `grep`, `find`, `ls`, `tree`, log dumps...) often eat 30-50% of your prompt budget. RTK detects them and applies smart, lossless compression **before** the request hits the LLM: +工具输出(`git diff`、`grep`、`find`、`ls`、`tree`、日志转储...)通常占用 30-50% 的提示词预算。RTK 在请求到达 LLM 之前检测并应用智能、无损压缩: -- **Filters:** `git-diff`, `git-status`, `grep`, `find`, `ls`, `tree`, `dedup-log`, `smart-truncate`, `read-numbered`, `search-list` -- **Auto-detect:** No config needed — RTK peeks the first 1KB of each `tool_result` and picks the right filter. -- **Safe by design:** If a filter fails, throws, or makes output bigger, RTK silently keeps the original text. Errors never break your request. -- **Universal:** Works across all formats (OpenAI, Claude, Gemini, Cursor, Kiro, OpenAI Responses) because it runs **before** any format translation. -- **Default ON:** Toggle anytime in Dashboard → Endpoint settings. +- **过滤器:** `git-diff`、`git-status`、`grep`、`find`、`ls`、`tree`、`dedup-log`、`smart-truncate`、`read-numbered`、`search-list` +- **自动检测:** 无需配置 — RTK 检查每个 `tool_result` 的前 1KB,选择合适的过滤器。 +- **安全设计:** 如果过滤器失败、抛出异常或使输出变大,RTK 会静默保留原始文本。错误永远不会中断你的请求。 +- **通用兼容:** 适用于所有格式(OpenAI、Claude、Gemini、Cursor、Kiro、OpenAI Responses),因为它在任何格式转换**之前**运行。 +- **默认开启:** 可随时在控制面板 → 端点设置中切换。 ``` -Without RTK: 47K tokens sent to LLM -With RTK: 28K tokens sent to LLM (40% saved · same context · same answer) +不使用 RTK:47K tokens 发送给 LLM +使用 RTK: 28K tokens 发送给 LLM (节省 40% · 相同上下文 · 相同答案) ``` -### 🧠 Headroom Token Saver +### 🎯 智能三层切换 -Headroom is optional and runs separately. 9Router calls Headroom's local `/v1/compress` endpoint, then keeps normal routing, fallback, auth, and usage tracking: +创建具有自动切换功能的组合: ``` -Client → 9Router → Headroom /v1/compress → 9Router → provider +组合:"my-coding-stack" + 1. cc/claude-opus-4-6 (你的订阅) + 2. glm/glm-4.7 (低价备份,$0.6/1M) + 3. if/kimi-k2-thinking (免费备选) + +→ 配额用完或出错时自动切换 ``` -Local setup: +### 📊 实时配额追踪 -```bash -pip install "headroom-ai[proxy]" -headroom proxy --port 8787 -``` +- 每个提供商的 token 消耗 +- 重置倒计时(5小时、每日、每周) +- 付费等级的成本估算 +- 月度支出报告 -Enable in Dashboard → Endpoint → Token Saver → Headroom. Default URL: `http://localhost:8787`. - -Docker examples: - -```bash -# Headroom service in same Docker network -http://headroom:8787 - -# Headroom running on host machine -http://host.docker.internal:8787 -``` - -If Headroom is down or returns an error, 9Router fails open and sends the original request. - -### 🐴 Ponytail (Lazy Senior Dev) - -Ponytail injects a _"lazy senior dev"_ system prompt into every request, biasing the LLM toward minimal, YAGNI-first code — deletion over addition, stdlib over new deps, one-liners over abstractions. Adapted from [DietrichGebert/ponytail](https://github.com/DietrichGebert/ponytail). - -- **Lite** — Build what's asked, name the lazier alternative. -- **Full** — YAGNI ladder enforced: stdlib → native → existing deps → one-liner → minimal code. -- **Ultra** — YAGNI extremist: deletion first, ship the one-liner, challenge the rest of the requirement in the same response. - -``` -Without Ponytail: verbose code, extra abstractions, "just in case" scaffolding -With Ponytail: shortest working diff, no unrequested abstractions, fewer tokens -``` - -Never trades away: input validation, error handling that prevents data loss, security, accessibility, or anything explicitly requested. Enable in Dashboard → Endpoint → Ponytail. Stacks with Caveman (output terseness) and RTK (input compression). - -### 🎯 Smart 3-Tier Fallback - -Create combos with automatic fallback: - -``` -Combo: "my-coding-stack" - 1. cc/claude-opus-4-6 (your subscription) - 2. glm/glm-4.7 (cheap backup, $0.6/1M) - 3. if/kimi-k2-thinking (free fallback) - -→ Auto switches when quota runs out or errors occur -``` - -### 📊 Real-Time Quota Tracking - -- Token consumption per provider -- Reset countdown (5-hour, daily, weekly) -- Cost estimation for paid tiers -- Monthly spending reports - -### 🔄 Format Translation - -Seamless translation between formats: +### 🔄 格式转换 +格式间无缝转换: - **OpenAI** ↔ **Claude** ↔ **Gemini** ↔ **Cursor** ↔ **Kiro** ↔ **Vertex** ↔ **Antigravity** ↔ **Ollama** ↔ **OpenAI Responses** -- Your CLI tool sends OpenAI format → 9Router translates → Provider receives native format -- Works with any tool that supports custom OpenAI endpoints +- 你的 CLI 工具发送 OpenAI 格式 → 9Router 转换 → 提供商接收原生格式 +- 适用于任何支持自定义 OpenAI 端点的工具 -### 👥 Multi-Account Support +### 👥 多账户支持 -- Add multiple accounts per provider -- Auto round-robin or priority-based routing -- Fallback to next account when one hits quota +- 每个提供商添加多个账户 +- 自动轮询或基于优先级的路由 +- 当一个账户达到配额时切换到下一个 -### 🔄 Auto Token Refresh +### 🔄 自动 Token 刷新 -- OAuth tokens automatically refresh before expiration -- No manual re-authentication needed -- Seamless experience across all providers +- OAuth token 在过期前自动刷新 +- 无需手动重新认证 +- 所有提供商的无缝体验 -### 🎨 Custom Combos +### 🎨 自定义组合 -- Create unlimited model combinations -- Mix subscription, cheap, and free tiers -- Name your combos for easy access -- Share combos across devices with Cloud Sync +- 创建无限模型组合 +- 混合订阅、低价和免费等级 +- 为组合命名以便访问 +- 使用云同步跨设备共享组合 -### 📝 Request Logging +### 📝 请求日志 -- Enable debug mode for full request/response logs -- Track API calls, headers, and payloads -- Troubleshoot integration issues -- Export logs for analysis +- 启用调试模式获取完整请求/响应日志 +- 追踪 API 调用、请求头和载荷 +- 排查集成问题 +- 导出日志进行分析 -### 💾 Cloud Sync +### 💾 云同步 -- Sync providers, combos, and settings across devices -- Automatic background sync -- Secure encrypted storage -- Access your setup from anywhere +- 跨设备同步提供商、组合和设置 +- 自动后台同步 +- 安全加密存储 +- 从任何地方访问你的设置 -#### Cloud Runtime Notes +#### 云运行时说明 -- Prefer server-side cloud variables in production: - - `BASE_URL` (internal callback URL used by sync scheduler) - - `CLOUD_URL` (cloud sync endpoint base) -- `NEXT_PUBLIC_BASE_URL` and `NEXT_PUBLIC_CLOUD_URL` are still supported for compatibility/UI, but server runtime now prioritizes `BASE_URL`/`CLOUD_URL`. -- Cloud sync requests now use timeout + fail-fast behavior to avoid UI hanging when cloud DNS/network is unavailable. +- 生产环境中优先使用服务端云变量: + - `BASE_URL`(云同步调度程序使用的内部回调 URL) + - `CLOUD_URL`(云同步端点基础 URL) +- `NEXT_PUBLIC_BASE_URL` 和 `NEXT_PUBLIC_CLOUD_URL` 仍用于兼容性/UI,但服务端运行时现在优先使用 `BASE_URL`/`CLOUD_URL`。 +- 云同步请求现在使用超时 + 快速失败行为,以避免云 DNS/网络不可用时 UI 挂起。 -### 📊 Usage Analytics +### 📊 使用分析 -- Track token usage per provider and model -- Cost estimation and spending trends -- Monthly reports and insights -- Optimize your AI spending +- 追踪每个提供商和模型的 token 使用量 +- 成本估算和支出趋势 +- 月度报告和洞察 +- 优化你的 AI 支出 -> **💡 IMPORTANT - Understanding Dashboard Costs:** -> -> The "cost" displayed in Usage Analytics is **for tracking and comparison purposes only**. -> 9Router itself **never charges** you anything. You only pay providers directly (if using paid services). -> -> **Example:** If your dashboard shows "$290 total cost" while using iFlow models, this represents -> what you would have paid using paid APIs directly. Your actual cost = **$0** (iFlow is free unlimited). -> -> Think of it as a "savings tracker" showing how much you're saving by using free models or -> routing through 9Router! +> **💡 重要 - 了解控制面板成本:** +> +> 使用分析中显示的"成本"**仅用于追踪和比较目的**。 +> 9Router 本身**永远不会向你收费**。你只直接向提供商付款(如果使用付费服务)。 +> +> **示例:** 如果你的控制面板显示使用 iFlow 模型时"总成本 $290",这代表你如果直接使用付费 API 需要支付的金额。你的实际成本 = **$0**(iFlow 免费无限量)。 +> +> 把它想象成一个"节省追踪器",展示你通过使用免费模型或通过 9Router 路由节省了多少钱! -### 🌐 Deploy Anywhere +### 🌐 任意部署 -- 💻 **Localhost** - Default, works offline -- ☁️ **VPS/Cloud** - Share across devices -- 🐳 **Docker** - One-command deployment -- 🚀 **Cloudflare Workers** - Global edge network +- 💻 **本地** - 默认,离线可用 +- ☁️ **VPS/云** - 跨设备共享 +- 🐳 **Docker** - 一键部署 +- 🚀 **Cloudflare Workers** - 全球边缘网络
--- -## 💰 Pricing at a Glance +## 💰 价格一览 -| Tier | Provider | Cost | Quota Reset | Best For | -| ------------------- | --------------------- | ------------ | ---------------- | --------------------------------------- | -| **🚀 TOKEN SAVER** | **RTK (built-in)** | **FREE** | Always on | **Save 20-40% tokens on EVERY request** | -| **💳 SUBSCRIPTION** | Claude Code (Pro/Max) | $20-200/mo | 5h + weekly | Already subscribed | -| | Codex (Plus/Pro) | $20-200/mo | 5h + weekly | OpenAI users | -| | GitHub Copilot | $10-19/mo | Monthly | GitHub users | -| | Cursor IDE | $20/mo | Monthly | Cursor users | -| **💰 CHEAP** | GLM-5.1 / GLM-4.7 | $0.6/1M | Daily 10AM | Budget backup | -| | MiniMax M2.7 | $0.2/1M | 5-hour rolling | Cheapest option | -| | Kimi K2.5 | $9/mo flat | 10M tokens/mo | Predictable cost | -| **🆓 FREE** | Kiro AI | $0 | Unlimited | Claude 4.5 + GLM-5 + MiniMax free | -| | OpenCode Free | $0 | Unlimited | No auth, auto-fetch models | -| | Vertex AI | $300 credits | New GCP accounts | Gemini 3 Pro + DeepSeek + GLM-5 | +| 等级 | 提供商 | 成本 | 配额重置 | 适用场景 | +|------|----------|------|-------------|----------| +| **🚀 TOKEN 节省器** | **RTK(内置)** | **免费** | 始终开启 | **每次请求节省 20-40% tokens** | +| **💳 订阅** | Claude Code (Pro/Max) | $20-200/月 | 5小时 + 每周 | 已有订阅的用户 | +| | Codex (Plus/Pro) | $20-200/月 | 5小时 + 每周 | OpenAI 用户 | +| | GitHub Copilot | $10-19/月 | 每月 | GitHub 用户 | +| | Cursor IDE | $20/月 | 每月 | Cursor 用户 | +| **💰 低价** | GLM-5.1 / GLM-4.7 | $0.6/1M | 每日 10AM | 预算备份 | +| | MiniMax M2.7 | $0.2/1M | 5小时滚动 | 最便宜选项 | +| | Kimi K2.5 | $9/月固定 | 10M tokens/月 | 可预测成本 | +| **🆓 免费** | Kiro AI | $0 | 无限量 | Claude 4.5 + GLM-5 + MiniMax 免费 | +| | OpenCode Free | $0 | 无限量 | 无需认证,自动获取模型 | +| | Vertex AI | $300 额度 | 新 GCP 账户 | Gemini 3 Pro + DeepSeek + GLM-5 | -**💡 Pro Tip:** RTK + Kiro AI + OpenCode Free combo = **$0 cost + 20-40% token savings**! +**💡 专业提示:** RTK + Kiro AI + OpenCode Free 组合 = **$0 成本 + 节省 20-40% tokens**! --- -### 📊 Understanding 9Router Costs & Billing +### 📊 理解 9Router 成本与计费 -**9Router Billing Reality:** +**9Router 计费真相:** -✅ **9Router software = FREE forever** (open source, never charges) -✅ **Dashboard "costs" = Display/tracking only** (not actual bills) -✅ **You pay providers directly** (subscriptions or API fees) -✅ **FREE providers stay FREE** (iFlow, Kiro, Qwen = $0 unlimited) -❌ **9Router never sends invoices** or charges your card +✅ **9Router 软件 = 永久免费**(开源,绝不收费) +✅ **控制面板"成本" = 仅用于显示/追踪**(不是实际账单) +✅ **你直接向提供商付款**(订阅或 API 费用) +✅ **免费提供商保持免费**(iFlow、Kiro、Qwen = $0 无限量) +❌ **9Router 永不发送发票** 或扣款 -**How Cost Display Works:** +**成本显示如何工作:** -The dashboard shows **estimated costs** as if you were using paid APIs directly. This is **not billing** - it's a comparison tool to show your savings. - -**Example Scenario:** +控制面板显示**估算成本**,如同你直接使用付费 API。这**不是计费** — 它是一个比较工具,展示你的节省。 +**示例场景:** ``` -Dashboard Display: -• Total Requests: 1,662 -• Total Tokens: 47M -• Display Cost: $290 +控制面板显示: +• 总请求数:1,662 +• 总 Tokens:47M +• 显示成本:$290 -Reality Check: -• Provider: iFlow (FREE unlimited) -• Actual Payment: $0.00 -• What $290 Means: Amount you SAVED by using free models! +实际检查: +• 提供商:iFlow(免费无限量) +• 实际支付:$0.00 +• $290 意味着什么:通过使用免费模型节省的金额! ``` -**Payment Rules:** - -- **Subscription providers** (Claude Code, Codex): Pay them directly via their websites -- **Cheap providers** (GLM, MiniMax): Pay them directly, 9Router just routes -- **FREE providers** (iFlow, Kiro, Qwen): Genuinely free forever, no hidden charges -- **9Router**: Never charges anything, ever +**付款规则:** +- **订阅提供商**(Claude Code、Codex):通过他们的网站直接付款 +- **低价提供商**(GLM、MiniMax):直接付款,9Router 只做路由 +- **免费提供商**(iFlow、Kiro、Qwen):真正的永久免费,无隐藏费用 +- **9Router**:从不收取任何费用,永远不会 --- -## 🎯 Use Cases +## 🎯 使用场景 -### Case 1: "I have Claude Pro subscription" +### 场景 1:"我有 Claude Pro 订阅" -**Problem:** Quota expires unused, rate limits during heavy coding - -**Solution:** +**问题:** 配额到期未用完,繁忙编码时遇到速率限制 +**解决方案:** ``` -Combo: "maximize-claude" - 1. cc/claude-opus-4-7 (use subscription fully) - 2. glm/glm-5.1 (cheap backup when quota out) - 3. kr/claude-sonnet-4.5 (free emergency fallback) +组合:"maximize-claude" + 1. cc/claude-opus-4-7 (充分利用订阅) + 2. glm/glm-5.1 (配额用完时的低价备份) + 3. kr/claude-sonnet-4.5 (免费紧急备选) -Monthly cost: $20 (subscription) + ~$5 (backup) = $25 total -vs. $20 + hitting limits = frustration +月成本:$20(订阅)+ ~$5(备份)= $25 总计 +对比:$20 + 遇到限制 = 沮丧 ``` -### Case 2: "I want zero cost" +### 场景 2:"我想零成本" -**Problem:** Can't afford subscriptions, need reliable AI coding - -**Solution:** +**问题:** 负担不起订阅,需要可靠的 AI 编码 +**解决方案:** ``` -Combo: "free-forever" - 1. kr/claude-sonnet-4.5 (Claude 4.5 free unlimited) - 2. kr/glm-5 (GLM-5 free via Kiro) - 3. oc/ (OpenCode Free, no auth) +组合:"free-forever" + 1. kr/claude-sonnet-4.5 (Claude 4.5 免费无限量) + 2. kr/glm-5 (通过 Kiro 免费使用 GLM-5) + 3. oc/ (OpenCode Free,无需认证) -Monthly cost: $0 -Quality: Production-ready models + RTK saves 20-40% tokens +月成本:$0 +质量:生产级模型 + RTK 节省 20-40% tokens ``` -### Case 3: "I need 24/7 coding, no interruptions" +### 场景 3:"我需要 24/7 编码,不中断" -**Problem:** Deadlines, can't afford downtime - -**Solution:** +**问题:** 截止日期紧迫,不能承受停机 +**解决方案:** ``` -Combo: "always-on" - 1. cc/claude-opus-4-7 (best quality) - 2. cx/gpt-5.5 (second subscription) - 3. glm/glm-5.1 (cheap, resets daily) - 4. minimax/MiniMax-M2.7 (cheapest, 5h reset) - 5. kr/claude-sonnet-4.5 (free unlimited) +组合:"always-on" + 1. cc/claude-opus-4-7 (最佳质量) + 2. cx/gpt-5.5 (第二个订阅) + 3. glm/glm-5.1 (低价,每日重置) + 4. minimax/MiniMax-M2.7 (最便宜,5小时重置) + 5. kr/claude-sonnet-4.5 (免费无限量) -Result: 5 layers of fallback = zero downtime -Monthly cost: $20-200 (subscriptions) + $10-20 (backup) +结果:5 层切换 = 零停机时间 +月成本:$20-200(订阅)+ $10-20(备份) ``` -### Case 4: "I want FREE AI in OpenClaw" +### 场景 4:"我想在 OpenClaw 中使用免费 AI" -**Problem:** Need AI assistant in messaging apps (WhatsApp, Telegram, Slack...), completely free - -**Solution:** +**问题:** 需要在消息应用(WhatsApp、Telegram、Slack...)中使用 AI 助手,完全免费 +**解决方案:** ``` -Combo: "openclaw-free" - 1. kr/claude-sonnet-4.5 (Claude 4.5 free) - 2. kr/glm-5 (GLM-5 free) - 3. kr/MiniMax-M2.5 (MiniMax free) +组合:"openclaw-free" + 1. kr/claude-sonnet-4.5 (Claude 4.5 免费) + 2. kr/glm-5 (GLM-5 免费) + 3. kr/MiniMax-M2.5 (MiniMax 免费) -Monthly cost: $0 -Access via: WhatsApp, Telegram, Slack, Discord, iMessage, Signal... +月成本:$0 +访问方式:WhatsApp、Telegram、Slack、Discord、iMessage、Signal... ``` --- -## ❓ Frequently Asked Questions +## ❓ 常见问题
-📊 Why does my dashboard show high costs? +📊 为什么我的控制面板显示高成本? -The dashboard tracks your token usage and displays **estimated costs** as if you were using paid APIs directly. This is **not actual billing** - it's a reference to show how much you're saving by using free models or existing subscriptions through 9Router. +控制面板追踪你的 token 使用情况,并显示**估算成本**,如同你直接使用付费 API。这**不是实际计费** — 它是一个参考,展示你通过使用免费模型或通过 9Router 路由现有订阅节省了多少钱。 -**Example:** +**示例:** +- **控制面板显示:** "$290 总成本" +- **实际情况:** 你在使用 iFlow(免费无限量) +- **你的实际成本:** **$0.00** +- **$290 的含义:** 你通过使用免费模型而不是付费 API **节省**的金额! -- **Dashboard shows:** "$290 total cost" -- **Reality:** You're using iFlow (FREE unlimited) -- **Your actual cost:** **$0.00** -- **What $290 means:** Amount you **saved** by using free models instead of paid APIs! - -The cost display is a "savings tracker" to help you understand your usage patterns and optimization opportunities. +成本显示是一个"节省追踪器",帮助你了解使用模式和优化机会。
-💳 Will I be charged by 9Router? +💳 9Router 会扣我的钱吗? -**No.** 9Router is free, open-source software that runs on your own computer. It never charges you anything. +**不会。** 9Router 是在你自己的电脑上运行的开源软件。它永远不会向你收取任何费用。 -**You only pay:** +**你只需支付:** +- ✅ **订阅提供商**(Claude Code $20/月、Codex $20-200/月)→ 在他们的网站上直接付款 +- ✅ **低价提供商**(GLM、MiniMax)→ 直接付款,9Router 只是路由你的请求 +- ❌ **9Router 本身** → **永不收费,永远不会** -- ✅ **Subscription providers** (Claude Code $20/mo, Codex $20-200/mo) → Pay them directly on their websites -- ✅ **Cheap providers** (GLM, MiniMax) → Pay them directly, 9Router just routes your requests -- ❌ **9Router itself** → **Never charges anything, ever** - -9Router is a local proxy/router. It doesn't have your credit card, can't send invoices, and has no billing system. It's completely free software. +9Router 是一个本地代理/路由器。它没有你的信用卡,不能发送发票,也没有计费系统。它是完全免费的软件。
-🆓 Are FREE providers really unlimited? +🆓 免费提供商真的是无限量的吗? -**Yes!** The current FREE providers (Kiro, OpenCode Free, Vertex) are genuinely free with **no hidden charges**. +**是的!** 当前的免费提供商(Kiro、OpenCode Free、Vertex)是真正的免费,**无隐藏费用**。 -These are free services offered by those respective companies: +这些是各公司提供的免费服务: +- **Kiro AI**:通过 AWS Builder ID / Google / GitHub OAuth 免费无限量使用 Claude 4.5 + GLM-5 + MiniMax +- **OpenCode Free**:无认证直连代理,模型从 `opencode.ai/zen/v1/models` 自动获取 +- **Vertex AI**:新 Google Cloud 账户可获得 $300 免费额度(90 天) -- **Kiro AI**: Free unlimited Claude 4.5 + GLM-5 + MiniMax via AWS Builder ID / Google / GitHub OAuth -- **OpenCode Free**: No-auth passthrough proxy, models auto-fetched from `opencode.ai/zen/v1/models` -- **Vertex AI**: $300 free credits for new Google Cloud accounts (90 days) +9Router 只是路由你的请求到它们 — 没有"陷阱"或未来的计费。它们是真正的免费服务,9Router 让它们易于使用并支持切换。 -9Router just routes your requests to them - there's no "catch" or future billing. They're truly free services, and 9Router makes them easy to use with fallback support. - -**Discontinued free tiers (no longer recommended):** - -- ❌ **iFlow**: Was free unlimited, now changed to paid (2026) -- ❌ **Qwen Code**: Free OAuth tier discontinued by Alibaba on 2026-04-15 -- ❌ **Gemini CLI**: Still works, but using it with non-CLI tools (Claude, Codex, Cursor...) may result in account bans — only use if you stick to Gemini CLI itself +**已停止的免费等级(不再推荐):** +- ❌ **iFlow**:曾是免费无限量,现在改为付费(2026) +- ❌ **Qwen Code**:阿里巴巴于 2026-04-15 停止免费 OAuth 等级 +- ❌ **Gemini CLI**:仍可用,但与非 CLI 工具(Claude、Codex、Cursor...)一起使用可能会导致账户被封 — 仅在你坚持使用 Gemini CLI 本身时才使用
-💰 How do I minimize my actual AI costs? +💰 如何最小化我的实际 AI 成本? -**Free-First Strategy:** - -1. **Start with 100% free combo:** +**免费优先策略:** +1. **从 100% 免费组合开始:** ``` - 1. gc/gemini-3-flash (180K/month free from Google) - 2. if/kimi-k2-thinking (unlimited free from iFlow) - 3. qw/qwen3-coder-plus (unlimited free from Qwen) + 1. gc/gemini-3-flash (Google 每月 180K 免费) + 2. if/kimi-k2-thinking (iFlow 无限量免费) + 3. qw/qwen3-coder-plus (Qwen 无限量免费) ``` + **成本:$0/月** - **Cost: $0/month** - -2. **Add cheap backup** only if you need it: - +2. **仅在需要时添加低价备份:** ``` 4. glm/glm-4.7 ($0.6/1M tokens) ``` + **额外成本:只为实际使用的部分付费** - **Additional cost: Only pay for what you actually use** +3. **最后使用订阅提供商:** + - 仅当你已有订阅时 + - 9Router 通过配额追踪帮助最大化其价值 -3. **Use subscription providers last:** - - Only if you already have them - - 9Router helps maximize their value through quota tracking - -**Result:** Most users can operate at $0/month using only free tiers! +**结果:** 大多数用户可以仅使用免费等级以 $0/月运行!
-📈 What if my usage suddenly spikes? +📈 如果我的使用量突然激增怎么办? -9Router's smart fallback prevents surprise charges: +9Router 的智能切换可以防止意外费用: -**Scenario:** You're on a coding sprint and blow through your quotas +**场景:** 你正在进行编码冲刺,用尽了配额 -**Without 9Router:** +**没有 9Router:** +- ❌ 达到速率限制 → 工作停止 → 沮丧 +- ❌ 或者:不慎累积大量 API 账单 -- ❌ Hit rate limit → Work stops → Frustration -- ❌ Or: Accidentally rack up huge API bills +**有 9Router:** +- ✅ 订阅达到限制 → 自动切换到低价等级 +- ✅ 低价等级变得昂贵 → 自动切换到免费等级 +- ✅ 编程永不停歇 → 可预测的成本 -**With 9Router:** - -- ✅ Subscription hits limit → Auto-fallback to cheap tier -- ✅ Cheap tier gets expensive → Auto-fallback to free tier -- ✅ Never stop coding → Predictable costs - -**You're in control:** Set spending limits per provider in dashboard, and 9Router respects them. +**你掌控一切:** 在控制面板中设置每个提供商的支出限制,9Router 会遵守它们。
--- -## 📖 Setup Guide +## 📖 设置指南
-🔐 Subscription Providers (Maximize Value) +🔐 订阅提供商(充分利用价值) ### Claude Code (Pro/Max) ```bash -Dashboard → Providers → Connect Claude Code -→ OAuth login → Auto token refresh -→ 5-hour + weekly quota tracking +控制面板 → 提供商 → 连接 Claude Code +→ OAuth 登录 → 自动 token 刷新 +→ 5小时 + 每周配额追踪 -Models: +模型: cc/claude-opus-4-7 cc/claude-opus-4-6 cc/claude-sonnet-4-6 cc/claude-haiku-4-5-20251001 ``` -**Pro Tip:** Use Opus for complex tasks, Sonnet for speed. 9Router tracks quota per model! +**专业提示:** 复杂任务使用 Opus,追求速度使用 Sonnet。9Router 按模型追踪配额! ### OpenAI Codex (Plus/Pro) ```bash -Dashboard → Providers → Connect Codex -→ OAuth login (port 1455) -→ 5-hour + weekly reset +控制面板 → 提供商 → 连接 Codex +→ OAuth 登录(端口 1455) +→ 5小时 + 每周重置 -Models: +模型: cx/gpt-5.5 cx/gpt-5.4 cx/gpt-5.3-codex @@ -882,11 +778,11 @@ Models: ### GitHub Copilot ```bash -Dashboard → Providers → Connect GitHub -→ OAuth via GitHub -→ Monthly reset (1st of month) +控制面板 → 提供商 → 连接 GitHub +→ 通过 GitHub 进行 OAuth +→ 每月重置(每月 1 日) -Models: +模型: gh/gpt-5.4 gh/claude-opus-4.7 gh/claude-sonnet-4.6 @@ -897,11 +793,11 @@ Models: ### Cursor IDE ```bash -Dashboard → Providers → Connect Cursor -→ OAuth login -→ Monthly subscription +控制面板 → 提供商 → 连接 Cursor +→ OAuth 登录 +→ 每月订阅 -Models: +模型: cu/claude-4.6-opus-max cu/claude-4.5-sonnet-thinking cu/gpt-5.3-codex @@ -910,53 +806,53 @@ Models:
-💰 Cheap Providers (Backup) +💰 低价提供商(备份) -### GLM-5.1 / GLM-4.7 (Daily reset, $0.6/1M) +### GLM-5.1 / GLM-4.7(每日重置,$0.6/1M) -1. Sign up: [Zhipu AI](https://open.bigmodel.cn/) -2. Get API key from Coding Plan -3. Dashboard → Add API Key: - - Provider: `glm` - - API Key: `your-key` +1. 注册:[Zhipu AI](https://open.bigmodel.cn/) +2. 从编程计划获取 API key +3. 控制面板 → 添加 API Key: + - 提供商:`glm` + - API Key:`your-key` -**Use:** `glm/glm-5.1`, `glm/glm-5`, `glm/glm-4.7` +**使用:** `glm/glm-5.1`、`glm/glm-5`、`glm/glm-4.7` -**Pro Tip:** Coding Plan offers 3× quota at 1/7 cost! Reset daily 10:00 AM. +**专业提示:** 编程计划提供 3 倍配额,成本仅为 1/7!每日 10:00 AM 重置。 -### MiniMax M2.7 (5h reset, $0.20/1M) +### MiniMax M2.7(5小时重置,$0.20/1M) -1. Sign up: [MiniMax](https://www.minimax.io/) -2. Get API key -3. Dashboard → Add API Key +1. 注册:[MiniMax](https://www.minimax.io/) +2. 获取 API key +3. 控制面板 → 添加 API Key -**Use:** `minimax/MiniMax-M2.7`, `minimax/MiniMax-M2.5` +**使用:** `minimax/MiniMax-M2.7`、`minimax/MiniMax-M2.5` -**Pro Tip:** Cheapest option for long context (1M tokens)! +**专业提示:** 长上下文(1M tokens)的最便宜选项! -### Kimi K2.5 ($9/month flat) +### Kimi K2.5($9/月固定) -1. Subscribe: [Moonshot AI](https://platform.moonshot.ai/) -2. Get API key -3. Dashboard → Add API Key +1. 订阅:[Moonshot AI](https://platform.moonshot.ai/) +2. 获取 API key +3. 控制面板 → 添加 API Key -**Use:** `kimi/kimi-k2.5`, `kimi/kimi-k2.5-thinking` +**使用:** `kimi/kimi-k2.5`、`kimi/kimi-k2.5-thinking` -**Pro Tip:** Fixed $9/month for 10M tokens = $0.90/1M effective cost! +**专业提示:** 每月 $9 固定费用获得 10M tokens = 实际成本 $0.90/1M!
-🆓 FREE Providers (Recommended) +🆓 免费提供商(推荐) -### Kiro AI (Claude 4.5 + GLM-5 + MiniMax FREE) +### Kiro AI(Claude 4.5 + GLM-5 + MiniMax 免费) ```bash -Dashboard → Connect Kiro -→ AWS Builder ID, AWS IAM Identity Center, Google, or GitHub -→ Unlimited usage +控制面板 → 连接 Kiro +→ AWS Builder ID、AWS IAM Identity Center、Google 或 GitHub +→ 无限量使用 -Models: +模型: kr/claude-sonnet-4.5 kr/claude-haiku-4.5 kr/glm-5 @@ -965,94 +861,94 @@ Models: kr/deepseek-3.2 ``` -**Pro Tip:** Best free option for Claude. No API key, no payment, fully unlimited. +**专业提示:** Claude 最佳免费选项。无需 API key,无需付款,完全无限量。 -### OpenCode Free (No auth, auto-fetch models) +### OpenCode Free(无需认证,自动获取模型) ```bash -Dashboard → Connect OpenCode Free -→ No login required (passthrough proxy) -→ Models auto-fetched from opencode.ai/zen/v1/models +控制面板 → 连接 OpenCode Free +→ 无需登录(直连代理) +→ 模型从 opencode.ai/zen/v1/models 自动获取 ``` -**Pro Tip:** Fastest setup. Just connect and start coding. +**专业提示:** 最快的设置。连接后即可开始编码。 -### Vertex AI ($300 free credits for new GCP accounts) +### Vertex AI(新 GCP 账户 $300 免费额度) ```bash -Dashboard → Connect Vertex AI -→ Upload Google Cloud Service Account JSON -→ Enable Vertex AI API in your GCP project +控制面板 → 连接 Vertex AI +→ 上传 Google Cloud 服务账户 JSON +→ 在你的 GCP 项目中启用 Vertex AI API -Models: +模型: vertex/gemini-3.1-pro-preview vertex/gemini-3-flash-preview vertex/gemini-2.5-flash -Vertex Partner (Anthropic / DeepSeek / GLM / Qwen via Vertex): +Vertex 合作伙伴(通过 Vertex 提供 Anthropic / DeepSeek / GLM / Qwen): vertex-partner/glm-5-maas vertex-partner/deepseek-v3.2-maas vertex-partner/qwen3-next-80b-a3b-thinking-maas ``` -**Pro Tip:** New Google Cloud accounts get $300 credits free for 90 days. Plenty for daily coding. +**专业提示:** 新 Google Cloud 账户可获得 90 天内 $300 免费额度。足够日常编码使用。
-🎨 Create Combos +🎨 创建组合 -### Example 1: Maximize Subscription → Cheap Backup +### 示例 1:充分利用订阅 → 低价备份 ``` -Dashboard → Combos → Create New +控制面板 → 组合 → 创建新组合 -Name: premium-coding -Models: - 1. cc/claude-opus-4-7 (Subscription primary) - 2. glm/glm-5.1 (Cheap backup, $0.6/1M) - 3. minimax/MiniMax-M2.7 (Cheapest fallback, $0.20/1M) +名称:premium-coding +模型: + 1. cc/claude-opus-4-7 (订阅主用) + 2. glm/glm-5.1 (低价备份,$0.6/1M) + 3. minimax/MiniMax-M2.7 (最便宜的备选,$0.20/1M) -Use in CLI: premium-coding +在 CLI 中使用:premium-coding -Monthly cost example (100M tokens): - 80M via Claude (subscription): $0 extra - 15M via GLM: $9 - 5M via MiniMax: $1 - Total: $10 + your subscription +月度成本示例(100M tokens): + 80M 通过 Claude(订阅):$0 额外费用 + 15M 通过 GLM:$9 + 5M 通过 MiniMax:$1 + 总计:$10 + 你的订阅费用 ``` -### Example 2: Free-Only (Zero Cost) +### 示例 2:仅免费(零成本) ``` -Name: free-combo -Models: - 1. kr/claude-sonnet-4.5 (Claude 4.5 free unlimited) - 2. kr/glm-5 (GLM-5 free via Kiro) - 3. vertex/gemini-3.1-pro-preview ($300 free credits) +名称:free-combo +模型: + 1. kr/claude-sonnet-4.5 (Claude 4.5 免费无限量) + 2. kr/glm-5 (通过 Kiro 免费使用 GLM-5) + 3. vertex/gemini-3.1-pro-preview ($300 免费额度) -Cost: $0 forever (+ 20-40% token savings via RTK)! +成本:通过 RTK 永久 $0(+ 节省 20-40% tokens)! ```
-🔧 CLI Integration +🔧 CLI 集成 ### Cursor IDE ``` -Settings → Models → Advanced: - OpenAI API Base URL: http://localhost:20128/v1 - OpenAI API Key: [from 9router dashboard] - Model: cc/claude-opus-4-7 +设置 → 模型 → 高级: + OpenAI API Base URL:http://localhost:20128/v1 + OpenAI API Key:[来自 9router 控制面板] + Model:cc/claude-opus-4-7 ``` -Or use combo: `premium-coding` +或使用组合:`premium-coding` ### Claude Code -Edit `~/.claude/config.json`: +编辑 `~/.claude/config.json`: ```json { @@ -1072,13 +968,13 @@ codex "your prompt" ### OpenClaw -**Option 1 — Dashboard (recommended):** +**选项 1 — 控制面板(推荐):** ``` -Dashboard → CLI Tools → OpenClaw → Select Model → Apply +控制面板 → CLI 工具 → OpenClaw → 选择模型 → 应用 ``` -**Option 2 — Manual:** Edit `~/.openclaw/openclaw.json`: +**选项 2 — 手动:** 编辑 `~/.openclaw/openclaw.json`: ```json { @@ -1107,32 +1003,32 @@ Dashboard → CLI Tools → OpenClaw → Select Model → Apply } ``` -> **Note:** OpenClaw only works with local 9Router. Use `127.0.0.1` instead of `localhost` to avoid IPv6 resolution issues. +> **注意:** OpenClaw 仅适用于本地 9Router。使用 `127.0.0.1` 而不是 `localhost` 以避免 IPv6 解析问题。 ### Cline / Continue / RooCode ``` -Provider: OpenAI Compatible -Base URL: http://localhost:20128/v1 -API Key: [from dashboard] -Model: cc/claude-opus-4-7 +Provider:OpenAI 兼容 +Base URL:http://localhost:20128/v1 +API Key:[来自控制面板] +Model:cc/claude-opus-4-7 ```
-🚀 Deployment +🚀 部署 -### VPS Deployment +### VPS 部署 ```bash -# Clone and install +# 克隆并安装 git clone https://github.com/decolua/9router.git cd 9router npm install npm run build -# Configure +# 配置 export JWT_SECRET="your-secure-secret-change-this" export INITIAL_PASSWORD="your-password" export DATA_DIR="/var/lib/9router" @@ -1144,10 +1040,10 @@ export NEXT_PUBLIC_CLOUD_URL="https://9router.com" export API_KEY_SECRET="endpoint-proxy-api-key-secret" export MACHINE_ID_SALT="endpoint-proxy-salt" -# Start +# 启动 npm run start -# Or use PM2 +# 或使用 PM2 npm install -g pm2 pm2 start npm --name 9router -- start pm2 save @@ -1156,144 +1052,128 @@ pm2 startup ### Docker -Published images (multi-platform `linux/amd64` + `linux/arm64`): +```bash +# 构建镜像(从仓库根目录) +docker build -t 9router . -- Docker Hub: [`decolua/9router`](https://hub.docker.com/r/decolua/9router) -- GHCR: [`ghcr.io/decolua/9router`](https://github.com/decolua/9router/pkgs/container/9router) +# 运行容器(当前设置使用的命令) +docker run -d \ + --name 9router \ + -p 20128:20128 \ + --env-file /root/dev/9router/.env \ + -v 9router-data:/app/data \ + -v 9router-usage:/root/.9router \ + 9router +``` -**Quick start (use published image):** +便携命令(如果你已经在仓库根目录): ```bash docker run -d \ --name 9router \ -p 20128:20128 \ - -v "$HOME/.9router:/app/data" \ - -e DATA_DIR=/app/data \ - decolua/9router:latest + --env-file ./.env \ + -v 9router-data:/app/data \ + -v 9router-usage:/root/.9router \ + 9router ``` -→ Open http://localhost:20128 - -**Build from source (dev):** - -```bash -git clone https://github.com/decolua/9router.git -cd 9router/app -docker build -t 9router . -docker run -d --name 9router -p 20128:20128 \ - -v "$HOME/.9router:/app/data" -e DATA_DIR=/app/data 9router -``` - -**Container defaults:** - +容器默认值: - `PORT=20128` - `HOSTNAME=0.0.0.0` -**Useful commands:** +常用命令: ```bash docker logs -f 9router docker restart 9router docker stop 9router && docker rm 9router -docker pull decolua/9router:latest # update to latest ``` -**Data persistence:** `$HOME/.9router/db/data.sqlite` on host ↔ `/app/data/db/data.sqlite` in container. +### 环境变量 -### Environment Variables +| 变量 | 默认值 | 描述 | +|----------|---------|-------------| +| `JWT_SECRET` | 自动生成(`~/.9router/jwt-secret`) | 用于控制面板 auth cookie 的 JWT 签名密钥(设置可在多实例间共享) | +| `INITIAL_PASSWORD` | `123456` | 当没有保存的哈希时首次登录的密码 | +| `DATA_DIR` | `~/.9router` | 主应用数据库位置(`db.json`) | +| `PORT` | 框架默认值 | 服务端口(示例中为 `20128`) | +| `HOSTNAME` | 框架默认值 | 绑定主机(Docker 默认为 `0.0.0.0`) | +| `NODE_ENV` | 运行时默认值 | 设置 `production` 用于部署 | +| `BASE_URL` | `http://localhost:20128` | 云同步任务使用的服务端内部基础 URL | +| `CLOUD_URL` | `https://9router.com` | 服务端云同步端点基础 URL | +| `NEXT_PUBLIC_BASE_URL` | `http://localhost:3000` | 向后兼容/公开基础 URL(服务端运行时优先使用 `BASE_URL`) | +| `NEXT_PUBLIC_CLOUD_URL` | `https://9router.com` | 向后兼容/公开云 URL(服务端运行时优先使用 `CLOUD_URL`) | +| `API_KEY_SECRET` | `endpoint-proxy-api-key-secret` | 生成 API key 的 HMAC 密钥 | +| `MACHINE_ID_SALT` | `endpoint-proxy-salt` | 稳定机器 ID 哈希的盐值 | +| `ENABLE_REQUEST_LOGS` | `false` | 在 `logs/` 下启用请求/响应日志 | +| `AUTH_COOKIE_SECURE` | `false` | 强制 `Secure` auth cookie(在 HTTPS 反向代理后面设置为 `true`) | +| `REQUIRE_API_KEY` | `false` | 在 `/v1/*` 路由上强制使用 Bearer API key(面向互联网部署时推荐) | +| `HTTP_PROXY`、`HTTPS_PROXY`、`ALL_PROXY`、`NO_PROXY` | 空 | 用于上游提供商调用的可选出站代理 | -| Variable | Default | Description | -| ---------------------------------------------------- | ---------------------------------------- | ----------------------------------------------------------------------------------- | -| `JWT_SECRET` | Auto-generated (`~/.9router/jwt-secret`) | JWT signing secret for dashboard auth cookie (override to share across instances) | -| `INITIAL_PASSWORD` | `123456` | First login password when no saved hash exists | -| `DATA_DIR` | `~/.9router` | Main app data location (SQLite at `$DATA_DIR/db/data.sqlite`) | -| `PORT` | framework default | Service port (`20128` in examples) | -| `HOSTNAME` | framework default | Bind host (Docker defaults to `0.0.0.0`) | -| `NODE_ENV` | runtime default | Set `production` for deploy | -| `BASE_URL` | `http://localhost:20128` | Server-side internal base URL used by cloud sync jobs | -| `CLOUD_URL` | `https://9router.com` | Server-side cloud sync endpoint base URL | -| `NEXT_PUBLIC_BASE_URL` | `http://localhost:3000` | Backward-compatible/public base URL (prefer `BASE_URL` for server runtime) | -| `NEXT_PUBLIC_CLOUD_URL` | `https://9router.com` | Backward-compatible/public cloud URL (prefer `CLOUD_URL` for server runtime) | -| `API_KEY_SECRET` | `endpoint-proxy-api-key-secret` | HMAC secret for generated API keys | -| `MACHINE_ID_SALT` | `endpoint-proxy-salt` | Salt for stable machine ID hashing | -| `ENABLE_REQUEST_LOGS` | `false` | Enables request/response logs under `logs/` | -| `AUTH_COOKIE_SECURE` | `false` | Force `Secure` auth cookie (set `true` behind HTTPS reverse proxy) | -| `REQUIRE_API_KEY` | `false` | Enforce Bearer API key on `/v1/*` routes (recommended for internet-exposed deploys) | -| `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`, `NO_PROXY` | empty | Optional outbound proxy for upstream provider calls | -| `SEARXNG_URL` | `http://localhost:8888/search` | Endpoint for the built-in unauthenticated SearXNG web-search provider | +注意: +- 也支持小写代理变量:`http_proxy`、`https_proxy`、`all_proxy`、`no_proxy`。 +- `.env` 不会打包到 Docker 镜像中(`.dockerignore`);使用 `--env-file` 或 `-e` 注入运行时配置。 +- 在 Windows 上,`APPDATA` 可用于本地存储路径解析。 +- `INSTANCE_NAME` 出现在较旧的文档/环境变量模板中,但当前运行时未使用。 -Notes: +### 运行时文件和存储 -- Lowercase proxy variables are also supported: `http_proxy`, `https_proxy`, `all_proxy`, `no_proxy`. -- `.env` is not baked into Docker image (`.dockerignore`); inject runtime config with `--env-file` or `-e`. -- On Windows, `APPDATA` can be used for local storage path resolution. -- `INSTANCE_NAME` appears in older docs/env templates, but is currently not used at runtime. - -### Runtime Files and Storage - -- Main app state: `${DATA_DIR}/db/data.sqlite` (SQLite — providers, combos, aliases, keys, settings, usage history) -- Auto backups: `${DATA_DIR}/db/backups/` -- Optional request/translator logs: `/logs/...` when `ENABLE_REQUEST_LOGS=true` -- Both `${DATA_DIR}` and `~/.9router` resolve to the same location in a Docker container — the symlink `/root/.9router -> /app/data` is created at build time. +- 主应用状态:`${DATA_DIR}/db.json`(提供商、组合、别名、密钥、设置),由 `src/lib/localDb.js` 管理。 +- 使用历史和日志:`${DATA_DIR}/usage.json` 和 `${DATA_DIR}/log.txt`,由 `src/lib/usageDb.js` 管理。 +- 可选的请求/翻译器日志:`ENABLE_REQUEST_LOGS=true` 时位于 `/logs/...`。 +- `${DATA_DIR}` 和 `~/.9router` 在 Docker 容器中解析到同一位置 — 符号链接 `/root/.9router -> /app/data` 在构建时创建。
--- -## 📊 Available Models +## 📊 可用模型
-View all available models - -**Claude Code (`cc/`)** - Pro/Max: +查看所有可用模型 +**Claude Code(`cc/`)** - Pro/Max: - `cc/claude-opus-4-7` - `cc/claude-opus-4-6` - `cc/claude-sonnet-4-6` - `cc/claude-sonnet-4-5-20250929` - `cc/claude-haiku-4-5-20251001` -**Codex (`cx/`)** - Plus/Pro: - +**Codex(`cx/`)** - Plus/Pro: - `cx/gpt-5.5` - `cx/gpt-5.4` - `cx/gpt-5.3-codex` - `cx/gpt-5.2-codex` - `cx/gpt-5.1-codex-max` -**GitHub Copilot (`gh/`)**: - +**GitHub Copilot(`gh/`)**: - `gh/gpt-5.4` - `gh/claude-opus-4.7` - `gh/claude-sonnet-4.6` - `gh/gemini-3.1-pro-preview` - `gh/grok-code-fast-1` -**Cursor (`cu/`)** - Subscription: - +**Cursor(`cu/`)** - 订阅: - `cu/claude-4.6-opus-max` - `cu/claude-4.5-sonnet-thinking` - `cu/gpt-5.3-codex` - `cu/kimi-k2.5` -**GLM (`glm/`)** - $0.6/1M: - +**GLM(`glm/`)** - $0.6/1M: - `glm/glm-5.1` - `glm/glm-5` - `glm/glm-4.7` -**MiniMax (`minimax/`)** - $0.2/1M: - +**MiniMax(`minimax/`)** - $0.2/1M: - `minimax/MiniMax-M2.7` - `minimax/MiniMax-M2.5` -**Kimi (`kimi/`)** - $9/mo flat: - +**Kimi(`kimi/`)** - $9/月固定: - `kimi/kimi-k2.5` - `kimi/kimi-k2.5-thinking` -**Kiro (`kr/`)** - FREE unlimited: - +**Kiro(`kr/`)** - 免费无限量: - `kr/claude-sonnet-4.5` - `kr/claude-haiku-4.5` - `kr/glm-5` @@ -1301,12 +1181,10 @@ Notes: - `kr/qwen3-coder-next` - `kr/deepseek-3.2` -**OpenCode Free (`oc/`)** - FREE no-auth: - -- Auto-fetched from `opencode.ai/zen/v1/models` - -**Vertex AI (`vertex/`)** - $300 free credits: +**OpenCode Free(`oc/`)** - 免费无需认证: +- 从 `opencode.ai/zen/v1/models` 自动获取 +**Vertex AI(`vertex/`)** - $300 免费额度: - `vertex/gemini-3.1-pro-preview` - `vertex/gemini-3-flash-preview` - `vertex/gemini-2.5-flash` @@ -1317,59 +1195,52 @@ Notes: --- -## 🐛 Troubleshooting +## 🐛 故障排除 -**"Language model did not provide messages"** +**"语言模型未提供消息"** +- 提供商配额耗尽 → 检查控制面板配额追踪器 +- 解决方案:使用组合切换或切换到更便宜的等级 -- Provider quota exhausted → Check dashboard quota tracker -- Solution: Use combo fallback or switch to cheaper tier +**速率限制** +- 订阅配额用完 → 切换到 GLM/MiniMax +- 添加组合:`cc/claude-opus-4-7 → glm/glm-5.1 → kr/claude-sonnet-4.5` -**Rate limiting** +**OAuth token 已过期** +- 9Router 自动刷新 +- 如果问题持续:控制面板 → 提供商 → 重新连接 -- Subscription quota out → Fallback to GLM/MiniMax -- Add combo: `cc/claude-opus-4-7 → glm/glm-5.1 → kr/claude-sonnet-4.5` +**高成本** +- 在控制面板 → 端点设置中启用 RTK(默认开启,节省 20-40% tokens) +- 在控制面板中检查使用统计 +- 将主模型切换到 GLM/MiniMax +- 对于非关键任务使用免费等级(Kiro、OpenCode Free、Vertex) -**OAuth token expired** +**控制面板在错误端口打开** +- 设置 `PORT=20128` 和 `NEXT_PUBLIC_BASE_URL=http://localhost:20128` -- Auto-refreshed by 9Router -- If issues persist: Dashboard → Provider → Reconnect +**首次登录不工作** +- 检查 `.env` 中的 `INITIAL_PASSWORD` +- 如果未设置,回退密码是 `123456` -**High costs** - -- Enable RTK in Dashboard → Endpoint settings (default ON, saves 20-40% tokens) -- Check usage stats in Dashboard -- Switch primary model to GLM/MiniMax -- Use free tier (Kiro, OpenCode Free, Vertex) for non-critical tasks - -**Dashboard opens on wrong port** - -- Set `PORT=20128` and `NEXT_PUBLIC_BASE_URL=http://localhost:20128` - -**First login not working** - -- Check `INITIAL_PASSWORD` in `.env` -- If unset, fallback password is `123456` - -**No request logs under `logs/`** - -- Set `ENABLE_REQUEST_LOGS=true` +**`logs/` 下没有请求日志** +- 设置 `ENABLE_REQUEST_LOGS=true` --- -## 🛠️ Tech Stack +## 🛠️ 技术栈 -- **Runtime**: Node.js 20+ -- **Framework**: Next.js 16 -- **UI**: React 19 + Tailwind CSS 4 -- **Database**: SQLite (better-sqlite3 / node:sqlite / sql.js fallback) -- **Streaming**: Server-Sent Events (SSE) -- **Auth**: OAuth 2.0 (PKCE) + JWT + API Keys +- **运行时**:Node.js 20+ +- **框架**:Next.js 16 +- **UI**:React 19 + Tailwind CSS 4 +- **数据库**:LowDB(基于 JSON 文件) +- **流式传输**:Server-Sent Events (SSE) +- **认证**:OAuth 2.0 (PKCE) + JWT + API Keys --- -## 📝 API Reference +## 📝 API 参考 -### Chat Completions +### 聊天补全 ```bash POST http://localhost:20128/v1/chat/completions @@ -1385,60 +1256,61 @@ Content-Type: application/json } ``` -### List Models +### 列出模型 ```bash GET http://localhost:20128/v1/models Authorization: Bearer your-api-key -→ Returns all models + combos in OpenAI format +→ 以 OpenAI 格式返回所有模型和组合 ``` -## 📧 Support +## 📧 支持 -- **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) +- **网站**:[9router.com](https://9router.com) +- **GitHub**:[github.com/decolua/9router](https://github.com/decolua/9router) +- **问题**:[github.com/decolua/9router/issues](https://github.com/decolua/9router/issues) --- -## 👥 Contributors +## 👥 贡献者 -Thanks to all contributors who helped make 9Router better! +感谢所有帮助改进 9Router 的贡献者! [![Contributors](https://contrib.rocks/image?repo=decolua/9router&max=150&columns=15&anon=1&v=20260309)](https://github.com/decolua/9router/graphs/contributors) --- -## 📊 Star Chart +## 📊 Star 图表 [![Star Chart](https://starchart.cc/decolua/9router.svg?variant=adaptive)](https://starchart.cc/decolua/9router) -## 🔀 Forks -**[OmniRoute](https://github.com/diegosouzapw/OmniRoute)** — A full-featured TypeScript fork of 9Router. Adds 36+ providers, 4-tier auto-fallback, multi-modal APIs (images, embeddings, audio, TTS), circuit breaker, semantic cache, LLM evaluations, and a polished dashboard. 368+ unit tests. Available via npm and Docker. + +## 🔀 分支 + +**[OmniRoute](https://github.com/diegosouzapw/OmniRoute)** — 9Router 的全功能 TypeScript 分支。增加了 36+ 提供商、4 层自动切换、多模态 API(图像、嵌入、音频、TTS)、断路器、语义缓存、LLM 评估和精美的控制面板。368+ 单元测试。可通过 npm 和 Docker 使用。 --- -## 🙏 Acknowledgments +## 🙏 致谢 -Built on the shoulders of giants: +站在巨人的肩膀上构建: -- **[CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI)** — original Go implementation that inspired this JavaScript port. -- **[RTK](https://github.com/rtk-ai/rtk)** ![Stars](https://img.shields.io/github/stars/rtk-ai/rtk?style=flat&color=yellow) — Rust token-saver. 9Router ports its compression pipeline to JS → **−20-40% input tokens** on every request. -- **[Caveman](https://github.com/JuliusBrussee/caveman)** ![Stars](https://img.shields.io/github/stars/JuliusBrussee/caveman?style=flat&color=yellow) by **[@JuliusBrussee](https://github.com/JuliusBrussee)** — viral _"why use many token when few token do trick"_. 9Router adapts its prompt → **−65% output tokens**. -- **[Ponytail](https://github.com/DietrichGebert/ponytail)** ![Stars](https://img.shields.io/github/stars/DietrichGebert/ponytail?style=flat&color=yellow) by **[@DietrichGebert](https://github.com/DietrichGebert)** — _"lazy senior dev"_ skill. 9Router injects its YAGNI-first ladder → **fewer tokens, less code, shorter diffs**. +- **CLIProxyAPI** — 启发了这个 JavaScript 移植的原始 Go 实现。 +- **[RTK](https://github.com/rtk-ai/rtk)** ![Stars](https://img.shields.io/github/stars/rtk-ai/rtk?style=flat&color=yellow) — Rust token 节省器。9Router 将其压缩管道移植到 JS → 每次请求 **减少 20-40% 输入 tokens**。 +- **[Caveman](https://github.com/JuliusBrussee/caveman)** ![Stars](https://img.shields.io/github/stars/JuliusBrussee/caveman?style=flat&color=yellow) by **[@JuliusBrussee](https://github.com/JuliusBrussee)** — 病毒式传播的 *"为什么用很多 token 当少的 token 就能搞定"*。9Router 适配其提示词 → **减少 65% 输出 tokens**。 -Huge thanks to these authors — without their work, 9Router's token-saving features wouldn't exist. ⭐ them on GitHub! +非常感谢这些作者 — 没有他们的工作,9Router 的 token 节省功能就不会存在。在 GitHub 上给他们加星! --- -## 📄 License +## 📄 许可证 -MIT License - see [LICENSE](LICENSE) for details. +MIT 许可证 — 详见 [LICENSE](LICENSE)。 ---
- Built with ❤️ for developers who code 24/7 -
+ 用 ❤️ 为 24/7 编程的开发者构建 + \ No newline at end of file