Open-Source Smart Routing Gateway — One Line, 94% Token Savings
TokenHub is a fully open-source smart routing gateway for AI coding agents. It strips timestamps/UUIDs to stabilize cache prefixes, folds conversation history, constrains output format — then routes across 20+ vendors by cost, latency and availability.
| Capability | Impact |
|---|---|
| normalize_request | Cross-session cache hit: 99%+ — strips TS/UUID/seed/path so cache keys match across sessions |
| state_folding | Input reduction: 15–39% — folds cold history, keeps semantics, drops redundancy |
| constrained_output | Output reduction: 21–66% — forces JSON shape, cuts verbosity |
| Smart Routing | 20+ vendors unified behind one OpenAI-compatible endpoint, cost-optimal + auto failover |
# One-liner: download and run
curl -LO https://github.com/VBK-AI-Agent-Gateway/Token-Carpool/releases/latest/download/TokenHubAgent.exe
.\TokenHubAgent.exePoint your AI client to http://127.0.0.1:8899 — done.
git clone https://github.com/VBK-AI-Agent-Gateway/Token-Carpool.git
cd Token-Carpool
docker compose up -d
# Gateway: http://localhost:8080/v1# Only one line changes: base_url
client = OpenAI(
api_key="sk-...",
base_url="https://api.tokenhub.work/v1" # ← this is all
)Request → normalize_request → Cache Lookup → Route Decision → Vendor
│ │ │
strip TS/UUID 99% hit cost · latency
fold history cache-first auto failover
Set API Base URL → http://127.0.0.1:8899
In ~/.continue/config.yaml:
apiBase: http://127.0.0.1:8899aider --api-base http://127.0.0.1:8899Set API Endpoint → http://127.0.0.1:8899
| Call | Direct OpenAI | Via TokenHub |
|---|---|---|
| Session 1 (cold) | 1,800ms | 3,118ms |
| Session 2 | 791ms miss cached=0 | 992ms hit -68% |
| Session 3 | 989ms miss cached=0 | 593ms hit -81% |
Direct OpenAI: 0/3 cache hits. TokenHub: 2/2 hits after cold start.
pip install -r requirements.txt
python build.py
# Output: dist/TokenHubAgent.exe├── main.py # Local agent (126 lines)
├── build.py # PyInstaller build script
├── build.bat # Windows one-click build
├── requirements.txt # Python dependencies
├── README.md
└── LICENSE (MIT)
- Gateway API:
https://api.tokenhub.work/v1 - Landing: http://5.189.129.216
- Website: http://www.agentgwapi.online:8888
- GitHub: https://github.com/VBK-AI-Agent-Gateway/Token-Carpool
TokenHub 是一个完全开源的智能路由网关,专门为 AI 编程智能体设计。通过一行代码修改 base_url,即可享受 94% Token 节省:自动剥离时间戳/UUID 稳定缓存前缀、折叠历史对话、约束输出格式,并在 20+ 厂商之间智能路由(成本最优 + 自动故障转移)。支持 Docker 自托管,MIT 开源,可审计、可 Fork、可私有部署。