InferRoute Technical Docs
🐙 GitHub Playground

Academic Research & Mathematical Foundations

InferRoute is built upon robust theoretical frameworks for cost-performance trade-offs and multi-tier cascading inference.

🔄 FrugalGPT: LLM Cascades & Prompt Adaptation

Derived from the paper "FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance" (Chen et al., Stanford University, 2023), InferRoute implements three key cost-saving mechanics:

1. Prompt Adaptation

Prunes long prompt histories or few-shot example prefixes down to at most 1 context example when querying cheap local models (Ollama/vLLM), restoring full complexity only when cascading to commercial endpoints.

2. LLM Approximation (Redis Cache)

Uses standard Redis completion caches. Matches queries in under 10ms, avoiding upstream model fees completely for exact duplicate concurrent prompts.

3. Sequential LLM Cascade

Sequentially routes queries through a chain of backends (Ollama ➔ vLLM ➔ Gemini ➔ OpenAI). A Reliability Judge assesses output quality at each tier, escalating to the next tier if the quality score falls below \(\tau\).

4. Streaming Cascade Buffer Heuristics

Buffers SSE stream chunks server-side to detect infinite loops or gibberish outputs. Speculatively cancels degraded local streams and escalates to premium cloud nodes mid-stream to avoid client-facing disruptions.

📄

Theoretical Framework: Model Cascading & Optimization

The FrugalGPT framework models cost-performance optimization as a decision sequence under cost bounds. By arranging models in ascending order of cost and capabilities (e.g., \(M_1, M_2, \dots, M_k\)), the system routes the query sequentially. For each model \(M_j\), the response is validated by a specialized quality assessor (Reliability Judge). If the response quality satisfies the threshold (\(Q(M_j, x) \ge \tau\)), the generation stops, avoiding subsequent cloud execution fees. Otherwise, the request escalates to the next model tier, guaranteeing response quality while keeping average costs minimal.

🎛️ Interactive Cascade Simulator

Adjust the sliding acceptance threshold \(\tau\) and click Simulate to trace the sequential escalation path.

Acceptance Threshold (\(\tau\)): 0.60
1
OLLAMA (Tier 1 - Cheap Local) Pending
Waiting to run...
2
vLLM (Tier 2 - Mid Local) Pending
Waiting to run...
3
OPENAI (Tier 3 - Premium Cloud) Pending
Waiting to run...
System ready. Click "Simulate Cascade" to start.

🧠 RouterBench: Mathematical Optimization

Based on the paper "RouterBench: A Benchmark for Multi-LLM Routing System" (Li et al., Martian, 2024), InferRoute structures content-aware models using standard cost-quality constraints.

1. The Utility Score Formula

The routing engine maximizes target utility for prompt \(x\) by selecting backend \(m\):

\[\text{Score}(m, x) = \lambda \cdot \text{Quality}_{\text{pred}}(m, x) - \text{Cost}(m)\]

Here, \(\lambda\) is the cost-quality trade-off parameter (willingness-to-pay), \(\text{Quality}_{\text{pred}}\) is the predicted model quality score (0.0 to 1.0), and \(\text{Cost}(m)\) represents model API execution fees.

2. Routing Curve Metric (AIQ)

To evaluate a routing policy globally across budgets, we calculate the **AIQ (Area under the cost-quality curve)** using the Trapezoidal Rule:

\[\text{AIQ} = \int_{c_{\min}}^{c_{\max}} Q(c) \, dc \approx \sum_{i=0}^{n-1} \frac{q_i + q_{i+1}}{2} \cdot (c_{i+1} - c_i)\]

3. Supported Routing Policies

InferRoute implements six distinct routing strategies matching the RouterBench & FrugalGPT frameworks:

🎲 Zero Router Baseline (zero): Non-content-aware routing. Randomly routes requests to Cloud vs. Local backends based on a target mixture ratio \(p \in [0, 1]\) to form the baseline cost-quality curve.
📋 Rule-Based Router (rule): Content-aware heuristics. Evaluates prompt keywords (e.g., routing math tasks to GPT/Gemini, coding tasks to local vLLM, simple greetings to Ollama).
🧠 KNN-Based Router (knn): Jaccard nearest-neighbor lookup on historical runs. Finds the \(K\) most similar prompts, averages their quality, and maximizes the score equation.
🕸️ MLP-Based Router (mlp): A fast logistic regression classifier extracting features (length, code, math, JSON) to predict model success rates and select the highest-scoring backend.
🔮 Oracle Router (oracle): Theoretical optimal offline reference that has perfect knowledge of outcomes and chooses the cheapest backend that achieves a quality score \(\ge 0.8\).
🔄 Cascade Router (cascade): FrugalGPT-style sequential escalation. Triggers cascading hops across model tiers if the reliability judge output score falls below threshold \(\tau\).
📄

Theoretical Framework: Cost-Quality Optimization Frontier

The RouterBench framework models LLM selection as a multi-objective optimization problem. By defining the parameter \(\lambda\) (cost-quality trade-off coefficient), the scoring equation evaluates the economic utility of selecting a model \(m\) for a prompt \(x\). The parameter \(\lambda\) represents a user's willingness-to-pay: setting a higher \(\lambda\) prioritizes response quality, while a lower \(\lambda\) emphasizes cost savings. The Area under the cost-quality curve (AIQ) measures the cumulative routing performance across all budget constraints, serving as a unified metric for evaluating routing efficiency.

📚 Original Research Papers & Reference Hub

Read and preview the full research publications associated with this routing engine directly in your browser:

📄 FrugalGPT Paper How to Use Large Language Models While Reducing Cost and Improving Performance (Stanford, 2023) Read / Preview PDF
查看学术综述 (Paper Summary)
🔍 研究背景

商业大模型单次调用费用昂贵,而开源/小尺寸模型(如 Llama、GPT-3.5)极其便宜但准确率参差不齐。本论文提出通过调度低成本模型并搭配判定机制,以在保留高准确率的同时大幅削减总费用。

📐 数学建模与公式

级联模型 (Cascade Decision): 设定模型序列 \((M_1, M_2, \dots, M_k)\) 以及质量评估器 \(J: \text{Response} \to [0, 1]\)。

对于请求 \(x\),系统依次生成 \(y_i = M_i(x)\),若 \(J(y_i) \ge \tau\)(接受度阈值),则立刻终止级联返回,否则 escalation 到下一级。

📊 实验结论

相比直接调用 GPT-4,FrugalGPT 可降低高达 90% 的总账单,并指出小模型无法有效吸收冗长上下文,提示词裁剪至关重要。

⚙️ Codebase 集成落地

级联选路运行在 main.py 的级联流中,裁剪在 prompt_adapter.py,评分判定运行在 validator.py

📄 RouterBench Paper A Benchmark for Multi-LLM Routing System (Martian, 2024) Read / Preview PDF
查看学术综述 (Paper Summary)
🔍 研究背景

大模型路由逐步多样化,但缺乏标准化的评估基准和数学框架来对比不同路由器在性价比上的优劣。

📐 数学建模与公式

效用评分公式: \(S(m, x) = \lambda \cdot Q_{\text{pred}}(m, x) - C(m)\),其中 \(\lambda\) 代表用户的支付意愿系数,\(Q\) 代表模型的质量预测,\(C\) 代表计费成本。

AIQ 曲线下面积积分: \(\text{AIQ} = \int_{c_{\min}}^{c_{\max}} Q(c) \, dc\),衡量在各种预算曲线下的全局选路表现。

📊 实验结论

引入预测型 MLP 路由器相比静态概率分配(Zero Router)可提升整体 AIQ 达 15% 以上。Oracle 决策上限揭示了路由组合的潜能。

⚙️ Codebase 集成落地

效用评分与路由在 router.py 中的 KNN/MLP 选路策略中运行,帕累托分析和 AIQ 计算在 plot_results.py

📄 Hybrid LLM Routing Paper Hybrid LLM: Cost-Efficient and Quality-Aware Query Routing (IBM / Tsinghua, 2024) Read / Preview PDF
查看学术综述 (Paper Summary)
🔍 研究背景

解决企业在拥有高并发免费本地小模型群(Edge)与计费的云端强模型(Cloud)时,如何实现高可用混合选路,减少多级判定带来的 TTFT 耗时。

📐 数学建模与公式

难度分类器 (Difficulty Estimator): \(D(x) = \text{Classifier}(x) \in \{0, 1\}\),直接判定请求难易度并直达目标模型,强调一击即中。

📊 实验结论

中等体量分类器能以 85% 以上精度区分复杂度。能够降低多达 40% 的平均网络往返延迟,节约超 60% 费用。

⚙️ Codebase 集成落地

learned_router.py 中实现了提取 prompt 任务特质(数学、代码等)的特征估计和直达策略分流。

📄 RouteLLM Paper Learning to Route LLMs with Preference Data (LMSYS / Berkeley, ICLR 2025) Read / Preview PDF
查看学术综述 (Paper Summary)
🔍 研究背景

针对写作、创意、日常对话等缺乏唯一标准解的任务,探讨如何利用大模型竞技场(Chatbot Arena)产生的人类真实偏好对战数据训练二分类器。

📐 数学建模与公式

偏好对战概率 (Bradley-Terry Extension): \(P(M_{\text{strong}} \succ M_{\text{cheap}} \mid x) = \sigma(f(x))\),通过交叉熵损失优化预测。概率大于阈值 \(\theta\) 时上报强模型,否则分流至便宜模型。

📊 实验结论

在 Arena 上能在维持 GPT-4 95% 满意度的同时,缩减 50% API 费用,并验证了轻量级分类网络的优越性。

⚙️ Codebase 集成落地

概率选路决策与阈值判定借鉴了该设计(router.py),拟在后续工作中引入专门的偏好二分类预测器 `preference_router.py`。

📄 EquiRouter Paper When Routing Collapses: On Degenerate Convergence (Lai & Ye, 2026) Read / Preview PDF
查看学术综述 (Paper Summary)
🔍 研究背景

指出当存在 3 个以上候选模型池时,传统的 MSE 回归训练机制会导致在高预算(大 \(\lambda\))时决策权坍缩,强制全选最昂贵模型。

📐 数学建模与公式

决策感知排序损失 (Decision-Aware Ranking Loss):

\(\mathcal{L}_{\text{rank}} = -\sum_{i \ne j} \log \sigma \Big( \big(\text{Utility}(M_i, x) - \text{Utility}(M_j, x)\big) \cdot \mathbb{I}(M_i \succ M_j) \Big)\),强调学习两模型效用之差,维持边界决策概率。

📊 实验结论

EquiRouter 成功解决回归多分类塌陷问题,在同等质量下,高预算区间多降低 17% 开销。

⚙️ Codebase 集成落地

网关对效用归一化进行了放塌陷微调。未来将在 `benchmarks/train_router.py` 中直接换用此排名损失函数进行优化。

📄 R2-Router Paper R2-Router: A New Paradigm for LLM Routing with Reasoning (ICML 2026) Read / Preview PDF
查看学术综述 (Paper Summary)
🔍 研究背景

大模型调用费用大多由生成字数决定。若不设防生成字数,大模型输出的冗长答复会极大地蚕食路由的成本红利。

📐 数学建模与公式

联合寻优公式: \(\max_{m, L} \left[ \text{Quality}(m, x, L) - \lambda \cdot \text{Cost}(m, L) \right]\),其中 \(L\) 代表限制最大输出 token 字数。

📊 实验结论

常识问答和提取任务在缩短字数后质量维持原样,这为输出开销带来了 4-5 倍的缩减,显著加快了端到端流式接收。

⚙️ Codebase 集成落地

prompt_adapter.py 中实现了动态提示词注入与长度自适应,根据模型档次调整 payload `max_tokens` 参数。

📄 Router-R1 Paper Multi-Round Routing and Aggregation via Reinforcement Learning (2025) Read / Preview PDF
查看学术综述 (Paper Summary)
🔍 研究背景

单次单轮分类分流遇到超复杂的多步推理或代码排错任务基本失灵。复杂任务需要多轮拆解、反复求证与多次升级路由。

📐 数学建模与公式

RL 奖励机制: \(\mathcal{R} = \mathcal{R}_{\text{accuracy}}(y) + \mathcal{R}_{\text{format}}(\text{think\_blocks}) - \beta \cdot \text{Cost}_{\text{inference}}\),用强化学习调教 local 选路 agent。Agent 生成带有 `<think>` 思维链的逻辑步骤,拆分调度子请求并汇总。

📊 实验结论

训练过的 8B 代理学会了在思考链中调度预算,仅耗费 GPT-4 35% 的成本就达到了等同程度的数学解答水准。

⚙️ Codebase 集成落地

对应了网关在 main.py 级联检验模块中配置的失败回退重试与条件流阻断。

📄 LLMRouterBench Paper A Massive Benchmark and Unified Framework for LLM Routing (2026) Read / Preview PDF
查看学术综述 (Paper Summary)
🔍 研究背景

解决路由领域实验设计混乱、微调偏好漂移等数据漂移(Data Drift)带来的评测不稳定性,亟需大规模科学对照评测基准。

📊 实验结论

构建了 400K 级多任务标准测试集,证实路由存在 Scaling Laws(缩放定律):决策模型并非越大越好,1B 以下的特征分类器往往性能/能耗性价比最高。

⚙️ Codebase 集成落地

网关所采用的 Reproducible Evaluation Harness 脚本提供了基础实验测试设计方法与任务配置格式(workload.json)。

📄 Routing Survey Paper A Survey on Routing Strategies for Resource Optimisation (2025) Read / Preview PDF
查看学术综述 (Paper Summary)
🔍 研究背景

为大模型服务架构及硬件开销分摊在资源优化垂直领域的科学分类(Taxonomy)建立体系。

📊 总结机制

从路由特征空间(Embedding/Text/Agent)、选路时间节点(Pre-generation/In-generation/Post-generation)与基础设施成本(本地 GPU 折旧 vs 云 API 计费)对比了各种架构的吞吐量、响应延时等折中机制。

⚙️ Codebase 集成落地

确定了 InferRoute 数据平面与控制平面分离、网关多指标 Prometheus 监控的设计方针。

📚 Academic Bibliography & References

Formal scientific citations for the core research papers referenced during the design and optimization of the InferRoute gateway:

1. FrugalGPT (Stanford University)

Chen, L., Zaharia, M., & Zou, J. (2023). FrugalGPT: How to use large language models while reducing cost and improving performance. arXiv preprint arXiv:2305.05196.

Show BibTeX Citation
@article{chen2023frugalgpt,
  title={FrugalGPT: How to use large language models while reducing cost and improving performance},
  author={Chen, Lingjiao and Zaharia, Matei and Zou, James},
  journal={arXiv preprint arXiv:2305.05196},
  year={2023}
}

2. RouterBench (Martian)

Li, T., Martian Team, et al. (2024). RouterBench: A Benchmark for Multi-LLM Routing System. arXiv preprint arXiv:2403.11164.

Show BibTeX Citation
@article{li2024routerbench,
  title={RouterBench: A Benchmark for Multi-LLM Routing System},
  author={Li, Teh-Hsien and others},
  journal={arXiv preprint arXiv:2403.11164},
  year={2024}
}

3. Hybrid LLM Routing (IBM / Tsinghua)

Ding, J., et al. (2024). Hybrid LLM: Cost-Efficient and Quality-Aware Query Routing. arXiv preprint arXiv:2404.14944.

Show BibTeX Citation
@article{ding2024hybrid,
  title={Hybrid LLM: Cost-Efficient and Quality-Aware Query Routing},
  author={Ding, Jiayi and others},
  journal={arXiv preprint arXiv:2404.14944},
  year={2024}
}

4. RouteLLM (LMSYS / UC Berkeley)

Ong, I., Almahairi, A., Wu, V., Chiang, W. L., Wu, T., Gonzalez, J. E., Kadous, M. W., & Stoica, I. (2025). RouteLLM: Learning to Route LLMs with Preference Data. Proceedings of the Thirteenth International Conference on Learning Representations (ICLR).

Show BibTeX Citation
@inproceedings{ong2025routellm,
  title={RouteLLM: Learning to Route LLMs with Preference Data},
  author={Ong, Isaac and Almahairi, Amjad and Wu, Vincent and Chiang, Wei-Lin and Wu, Tianhao and Gonzalez, Joseph E. and Kadous, M. Waleed and Stoica, Ion},
  booktitle={The Thirteenth International Conference on Learning Representations},
  year={2025}
}

5. EquiRouter (Routing Collapse Mitigation)

Lai, G., & Ye, H. J. (2026). When Routing Collapses: On the Degenerate Convergence of LLM Routers. arXiv preprint arXiv:2602.03478.

Show BibTeX Citation
@article{lai2026when,
  title={When Routing Collapses: On the Degenerate Convergence of LLM Routers},
  author={Lai, Guannan and Ye, Han-Jia},
  journal={arXiv preprint arXiv:2602.03478},
  year={2026}
}

6. R2-Router (Output-Length-Constrained Routing)

Anonymous (2026). R2-Router: A New Paradigm for LLM Routing with Reasoning. arXiv preprint arXiv:2602.02823.

Show BibTeX Citation
@article{r2router2026,
  title={R2-Router: A New Paradigm for LLM Routing with Reasoning},
  journal={arXiv preprint arXiv:2602.02823},
  year={2026}
}

7. Router-R1 (Reinforcement Learned Multi-Round Router)

Anonymous (2025). Router-R1: Teaching LLMs Multi-Round Routing and Aggregation via Reinforcement Learning. arXiv preprint arXiv:2506.09033.

Show BibTeX Citation
@article{routerr12025,
  title={Router-R1: Teaching LLMs Multi-Round Routing and Aggregation via Reinforcement Learning},
  journal={arXiv preprint arXiv:2506.09033},
  year={2025}
}

8. LLMRouterBench (Large-Scale Benchmarking Framework)

Anonymous (2026). LLMRouterBench: A Massive Benchmark and Unified Framework for LLM Routing. arXiv preprint arXiv:2601.07206.

Show BibTeX Citation
@article{llmrouterbench2026,
  title={LLMRouterBench: A Massive Benchmark and Unified Framework for LLM Routing},
  journal={arXiv preprint arXiv:2601.07206},
  year={2026}
}

9. Resource-Optimized LLM Routing Survey

Anonymous (2025). Doing More with Less: A Survey on Routing Strategies for Resource Optimisation in Large Language Model-Based Systems. arXiv preprint arXiv:2502.00409.

Show BibTeX Citation
@article{resource_routing_survey_2025,
  title={Doing More with Less: A Survey on Routing Strategies for Resource Optimisation in Large Language Model-Based Systems},
  journal={arXiv preprint arXiv:2502.00409},
  year={2025}
}

🏗 InferRoute Gateway Request Lifecycle

The sequence details how the gateway interceptor resolves client requests, manages cache, allocates concurrency slots, and executes cascades:

sequenceDiagram autonumber actor Client as Client App / SDK participant GW as InferRoute Gateway participant Auth as Auth & Credit Gate participant Cache as Cache Layer (Redis) participant Limiter as Vegas Limiter participant Router as Routing Engine participant Model as LLM Upstream participant Audit as DB Audit & Billing Client->>GW: POST /v1/chat/completions (Stream) GW->>Auth: verify_api_key & check_balance alt Balance <= $0.00 Auth-->>Client: 402 Payment Required else Balance OK Auth-->>GW: Tenant ID Resolved GW->>Cache: try_acquire_dedup_lock alt Cache Hit Cache-->>Client: Stream Cached chunks directly else Cache Miss GW->>Cache: match_longest_prefix Cache-->>GW: Return Cache-Affinity Weight GW->>Limiter: acquire_slot alt Concurrency Exceeded Limiter-->>Client: 429 Too Many Requests else Slot Acquired GW->>Router: choose_backend (Scoring weights) Router-->>GW: Selected Backend (e.g. Ollama) GW->>Model: Invoke Model Stream Model-->>GW: Yield Stream Chunks GW->>Client: Forward Stream Chunks alt Loop/Repetitive Garbage Detected GW->>Model: Cancel speculative stream GW->>Router: Trigger Fallback Cascade Router->>Model: Invoke Cloud Backend (OpenAI) Model-->>Client: Stream Cloud response end GW->>Limiter: release_slot GW->>Audit: db_log_request & debit wallet end end end
1

Authentication & Credit check

Resolves client headers to tenant ID and asserts balance balance \(> \$0.00\). Applies a resilient fail-open policy if the database is unreachable.

2

Exact & Prefix Cache Match

Performs a Redis exact completion lookup. If missing, checks the Radix Trie prefix index to score warm KV-cache affinity on self-hosted model backends.

3

Vegas Concurrency Control

Queries concurrency limits to dynamically protect local GPU memory allocations, rejecting or cascading requests to cloud buffers if limits are breached.

4

Model Selection & Cascade Stream

Routes prompts to the chosen backend. For cascades, it buffers output stream tokens, runs heuristics, and transparently initiates speculative escalations upon validation failures.

5

Audit Ledger logging

Logs latency telemetry and final aggregated token costs asynchronously to PostgreSQL database ledgers, decrementing tenant credit limits.

🎨 Observability Control Center & Interactive Playground

InferRoute features an interactive client playground dashboard (served at the root / path) allowing developers to monitor and simulate gateway functions in real-time:

1. Live Telemetry Cost Dashboard

Displays financial metrics including cumulative API dollars saved, tokens processed, Redis cache hit rates, average Time-to-First-Token (TTFT), and system uptime in real-time.

2. Interceptor Pipeline Visualizer

Renders a live vertical step visualizer tracking individual requests. Watch prompts flow through Cache lookup ➔ Concurrency limit verification ➔ Primary model execution ➔ speculative loops cancellation ➔ Cascade trigger.

3. Wallet & Credit Controller

Simulates tenant wallet balances and limits. Allows manual top-up adjustments (e.g., refilling $10.00 trial credits) to inspect rate-limiting triggers and HTTP 402 payment requirements.

4. Chaos Engineering Panel

Allows manual injection of failures (latency spikes, HTTP 500 crashes, network dropouts) into specific backend nodes to observe gateway self-healing, automatic failovers, and circuit-breaker status changes in real-time.

📊 RouterBench Policy Sweep Outcomes

Below are evaluation statistics sweeping mixture ratios (\(p\)), trade-off factors (\(\lambda\)), and cascade thresholds (\(\tau\)) over workload dataset prompts:

Routing Strategy Cost per Request ($ USD) Avg Quality Score (0 - 1.0) Avg Latency (ms) SLO Compliance Fallback Hops
Oracle Router Optimal $0.000022 0.78 258ms 100.0% 0.0%
KNN Router (\(\lambda = 1.00\)) $0.000019 0.75 266ms 100.0% 0.0%
MLP Router (\(\lambda = 0.50\)) $0.000023 0.75 258ms 100.0% 0.0%
Cascade Router (\(\tau = 0.60\)) $0.000017 0.62 239ms 100.0% 66.7%
Always OpenAI Cloud $0.000044 0.75 250ms 100.0% 0.0%
Always Ollama Local $0.000000 0.31 190ms 100.0% 8.3%

📈 Trade-off Visualization Curves

These curves show the actual measured performance frontier across swept cost levels:

Cost-Quality Pareto Frontier

Cost-Quality Frontier

Pareto sweeps comparing KNN, MLP, FrugalGPT Cascades, and the Zero Router baseline. Note the efficient frontier pushed to the top-left by the learned routers.

Latency Comparison

Latency Comparison

Comparison of processing latency and time-to-first-token (TTFT) metrics across different routing scenarios.

📈 Executive Experiment Summary

98% API Cost Saved

Through exact stream deduplication via Redis Pub/Sub, multiple concurrent burst requests calling duplicate system prompts are coalesced into a single upstream model invocation.

80% TTFT Reduction

Prefix-affinity routing identifies Warm KV-caches on GPU nodes using a Radix Trie, routing prompts to nodes with active context caches to eliminate prefill latency.

📊 Reproducible Evaluation Sweep Harness

InferRoute provides a built-in evaluation framework to verify the cost-quality trade-offs of all routing algorithms under realistic workload datasets. The system sweeps ratios and willingness-to-pay parameters to export Pareto curves:

1. Run the Evaluation Sweep Orchestrator

This script iterates across dataset prompts, simulating requests against mock or real endpoints and logging cost, latency, quality, and routing outputs:

python benchmarks/run_router_eval.py

2. Compile Metrics & Generate Pareto Curves

This script reads the raw evaluation outcomes, fits the cost-quality points using the Trapezoidal Rule to calculate Area Under the Curve (AIQ), and exports standard PNG curves:

python benchmarks/plot_results.py

⚙️ Sweeping Parameters Summary

The evaluation sweeps the target cloud mixture ratio \(p \in [0, 1]\) for the Zero Router baseline, and sweeping trade-off thresholds \(\lambda \in [0, 1]\) or \(\tau \in [0, 1]\) for KNN, MLP, and Cascade routing algorithms to systematically construct the Pareto frontier.

🛡️ Vegas Adaptive Limiting & Circuit Breakers

InferRoute maintains system resilience through autonomous closed-loop feedback controllers.

1. Vegas Congestion Limiter

Inspired by TCP Vegas congestion control, the gateway dynamically scales concurrent request slots based on measured latency queue sizes. It auto-throttles requests during model spikes to prevent local GPU OOMs.

2. Self-Healing Circuit Breaker

Monitors consecutive timeouts and error codes. Transitions from CLOSED to OPEN upon 5 consecutive failures, bypassing degraded local nodes to fallback cloud targets instantly, recovering automatically via HALF-OPEN testing.

🎮 Interactive Gateway Sandbox (Client-Side Simulator)

Play with all 9 academic routing policies directly in your browser. This sandbox simulates prefix cache check, Vegas limiter slots, RouteLLM Bradley-Terry勝率 matching, R2-Router word restraints, and Router-R1 agentic draft correction.

Sandbox Panel
System initialized. Select any of the 9 academic routing policies from the dropdown above and send a message. The gateway pipeline visualizer and metrics will update in real-time.
Trial Wallet Balance:
$5.00
Estimated Savings $0.00
Tokens Saved 0
Last TTFT 0 ms
Cache Hit Rate 0%

🚀 Gateway Pipeline Visualizer IDLE

1. Exact & Prefix Cache Check
Checking Redis caches (Radix Trie check)
2. Vegas Concurrency Limiter
Validating slot queue depth
3. Routing Decision Engine
Evaluating policy formula
4. Verification & Output Judge
Running syntactic & loop validation