# LLMRouter: A Unified Open-Source Library for LLM Routing with 16+ Router Strategies

> LLMRouter is a Python library from the UIUC ULab research group that routes each query to the optimal large language model based on task complexity, cost, and performance requirements. It provides 16+ routing strategies organized into five categories, a unified command-line interface, a Gradio-based chat interface, and the xRouteBench benchmark for evaluation.

**ulab-uiuc/LLMRouter** — LLMRouter: An Open-Source Library for LLM Routing

- Repository: https://github.com/ulab-uiuc/LLMRouter
- Website: https://ulab-uiuc.github.io/LLMRouter/
- Stars: 2,987 · Forks: 310
- Language: Python
- License: MIT
- Published: 2026-09-10 · Updated: 2026-09-10 · Language: en
- Canonical page: https://hysenlabs.com/projects/ulab-uiuc-llmrouter

## What LLM Routing Solves and Who Needs It

LLM routing is the practice of sending each query to a different model based on what that query needs, rather than routing everything to a single model. A simple factual lookup does not need the compute and cost of a large frontier model; a complex multi-step reasoning task may produce poor results on a smaller model. A router sits in front of the model pool and decides, per query, which model to call.

LLMRouter formulates routing as a unified sequential decision process that covers single-turn queries, multi-turn conversation histories, personalized routing (where the preferred model is user-specific), and multimodal inputs. The README states that experiments show learned routers outperform the strongest fixed-model baseline by 14.6% relatively, and that lightweight and user-conditioned routers provide strong advantages under tight cost budgets.

The library targets machine learning engineers and researchers who want to implement, compare, or extend LLM routing strategies in a single codebase. The five router categories (single-round, multi-round, multimodal, agentic, and personalized) reflect a range of deployment scenarios.

## The Five Router Categories and 16-Plus Strategies

Single-round routers handle one-turn queries. The library includes KNN (k-nearest neighbors), SVM (support vector machine), MLP (multi-layer perceptron), RACERRouter (robust adaptive cost-efficient routing), Matrix Factorization, Elo-based routing, a graph-based router (GraphRouter), a BERT-based router, a hybrid probabilistic router, and a transformed-score router, among others. Each is listed in the README with training and inference support status.

Multi-round routers handle conversation histories where the routing decision should account for the full dialog context. Multimodal routers handle inputs that combine text with images, video, or time-series data. The TSRouter variant, released in July 2026, routes time-series queries to the best (modality, model) pair via a four-partite heterogeneous graph over task, query, modality, and model nodes.

Personalized routers condition the routing decision on a specific user's interaction history. The RouteProfile framework, released in May 2026 alongside a companion paper, enables structured profile construction from heterogeneous interaction histories using flat, embedding-based, text-GNN, and trainable GNN profile types.

## Installing LLMRouter and Using the CLI

The library is available on PyPI and requires Python 3.10 or higher:

```bash
pip install llmrouter-lib
```

The pyproject.toml registers a command-line entry point named llmrouter, providing a unified CLI for training, inference, and interactive chat. Key dependencies include torch 2.0+, transformers 4.40+, scikit-learn 1.2+, torch-geometric 2.3+, and gradio 4.0+. The RouterR1 variant additionally requires vLLM 0.6.3 and torch 2.4.0, which are declared as an optional dependency group in pyproject.toml. For local development, clone the repository and install from source. The ComfyUI visual interface, which provides a drag-and-drop node editor for constructing routing pipelines, is in the ComfyUI/ directory and has its own setup steps separate from the core library.

## The xRouteBench Benchmark

LLMRouter introduces xRouteBench, a benchmark dataset hosted on HuggingFace at ulab-ai/xRouteBench, designed for evaluating routing strategies across multiple task types. The benchmark covers generic LLM routing, memory-augmented routing, vision routing, time-series routing, and personalized routing.

The data generation pipeline in the benchmark_pipeline/ directory produces training data from 11 benchmark datasets with automatic API calling and evaluation. This pipeline is the mechanism by which teams can generate supervision data for training a router on their own model pool, rather than relying on public benchmark data.

xRouteBench evaluates both response quality and inference cost jointly, which is a more realistic measure than quality alone. The README notes that experiments show learned routers outperform fixed-model baselines while lightweight routers offer advantages specifically under tight cost budgets.

## ComfyUI Interface and OpenClaw Integration

LLMRouter provides a visual interface built on ComfyUI, released in February 2026. It allows users to construct data generation and routing pipelines by dragging and dropping nodes, train routers visually, and monitor routing performance in real time. The ComfyUI/ directory in the repository contains the interface files.

The OpenClaw Router integration, also released in February 2026, wraps LLMRouter as an OpenAI-compatible server. This means applications that already call the OpenAI API can point at the OpenClaw Router endpoint without changing client code, and the router will select which underlying model to use for each request. The README states that it supports Slack, Discord, and other messaging platform integrations, multimodal understanding (image, audio, video), retrieval-augmented routing memory, and streaming.

The version number at the time of the last push is 0.4.0, as recorded in pyproject.toml.

## Limitations: Training Data Requirements and Deep Learning Dependencies

The routers in LLMRouter are learned models, not rule-based heuristics. This means that using most of them requires a training dataset of queries paired with model performance labels. The data generation pipeline helps automate this, but it requires calling multiple LLMs through APIs to collect the supervision data, which incurs API costs before any routing savings are realized.

The dependency stack is heavy for a routing library: torch, transformers, torch-geometric, scikit-learn, gradio, and litellm are all direct dependencies. Teams deploying routing in a latency-sensitive production service need to account for model load time and the overhead of the router itself. A lightweight router (KNN or SVM) adds much less overhead than a BERT-based or GNN-based one.

The classification-style single-round routers assume that routing can be decided on the query alone. Multi-turn conversations require the multi-round router variants, and personalized scenarios require the profile-based variants. Using the wrong router category for a use case will give worse results than a fixed model.

## LLMRouter vs. RouteLLM

RouteLLM, from LMSYS, is another open-source LLM routing library that focuses on binary routing decisions between a strong and a weak model pair. Its approach is simpler: it classifies each query as requiring either the strong model or the weak model. LLMRouter covers a broader range of strategies and supports multi-model pools, multimodal inputs, and personalized routing, which RouteLLM does not address.

The trade-off is complexity. RouteLLM is easier to deploy for the specific case of routing between two models (for example, GPT-4 and GPT-3.5-Turbo or a local model and a frontier model). LLMRouter is more appropriate when the routing space includes more than two models, when the input modality varies, or when personalization is a requirement. For teams that need the simpler binary case, RouteLLM has a smaller dependency footprint.

## Conclusion

LLMRouter is a practical starting point for teams building cost-aware or capability-aware LLM routing systems, with the breadth of 16+ implemented strategies and a benchmark suite included. The main cost of adoption is the data pipeline step: the routers need training data, which requires running queries against multiple models to collect supervision signals. Teams with straightforward single-model deployments will not benefit from routing. Before adopting it, verify that Python 3.10+ and the required deep learning dependencies (torch, transformers, torch-geometric) fit your deployment environment.

## FAQ

### What is an LLM router?

An LLM router is a system that dynamically selects which language model to use for each query, rather than sending all queries to a single model. It balances cost, quality, and task requirements. LLMRouter is an open-source library that implements 16+ routing strategies for this purpose.

### What is an AI model router?

An AI model router routes each input query to the model best suited to answer it, considering task complexity, cost per token, and expected output quality. LLMRouter implements this as a trained classifier that covers single-turn, multi-turn, multimodal, agentic, and personalized routing scenarios.

### What is the best LLM router?

The README reports that learned routers in LLMRouter outperform the strongest fixed-model baseline by 14.6% relatively in response quality while enabling cost savings. The best strategy depends on use case: the README notes that lightweight and user-conditioned routers have strong advantages under tight cost budgets and personalized settings respectively.

## Sources

- [Issues](https://github.com/ulab-uiuc/LLMRouter/issues)
- [License: MIT](https://github.com/ulab-uiuc/LLMRouter/blob/main/LICENSE)
- [Project website](https://ulab-uiuc.github.io/LLMRouter/)
- [README](https://github.com/ulab-uiuc/LLMRouter/blob/main/README.md)
- [ulab-uiuc/LLMRouter on GitHub](https://github.com/ulab-uiuc/LLMRouter)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/ulab-uiuc-llmrouter
