RouteWise
Latency–Cost Optimization for Multi-Provider LLM Routing
Learn from recent outcomes. Route each request. Hedge selectively.
Developed and maintained by the Harvard MadSys Lab at Harvard SEAS.
English API · 中文 API · Reproducibility
RouteWise is a dependency-free Python library for cost-aware, latency-optimized routing across multiple LLM API providers. Applications supply provider prices, dispatch the returned attempt, and report outcomes so RouteWise can learn from them.
The 0.2.0 distribution is an API-provider-only preview. This repository also
contains the simulator and experiment harnesses used by the paper; those
research packages are not included in the wheel.
Package name: The PyPI project
routewiseis an unaffiliated, incompatible project. Install thellm-routewisedistribution and import thellm_routewisepackage for HarvardMadSys RouteWise.
Installation
RouteWise requires Python 3.10 or later. The published wheel has no runtime dependencies.
python -m pip install llm-routewise==0.2.0
For repository development and paper-artifact workflows:
git clone https://github.com/HarvardMadSys/RouteWise.git
cd RouteWise
uv sync
Quickstart
import llm_routewise as rw
router = rw.Router(
[
rw.Provider("fast", price_in=3.0, price_out=15.0),
rw.Provider("cheap", price_in=0.15, price_out=0.60),
],
alpha=0.25, # Cost budget: 0 = cheapest; 1 = full range for latency optimization.
)
decision = router.route(input_tokens=800)
response = call_your_provider(decision.provider)
decision.completed(
ttft_ms=response.ttft_ms,
output_tokens=response.output_tokens,
)
If your application already predicts completion length, pass that point estimate with the request. Omit it to use RouteWise's internal online estimate.
predicted_tokens = predict_output_tokens(prompt)
decision = router.route(
input_tokens=800,
estimated_output_tokens=predicted_tokens,
)
The estimate affects route and hedge cost calculations only; it is not actual
usage. On completion, report the adopted attempt's actual output_tokens (or
an explicit cost_usd) for billing. Positive actual output tokens also update
RouteWise's internal estimator.
Router computes decisions but performs no network I/O and does not read API
keys. Your application owns provider clients, credentials, and dispatch. Read
the English API reference
or 中文 API 参考
for the full contract.
Repository Development
Run the fast test suite:
uv run pytest -q -m "not slow"
List the paper-facing simulator sections:
uv run python -m routewise_cli.main simulator list
The reproducibility guide covers datasets, live-evaluation credentials, experiment commands, and regression checks.
Documentation
Library Users
Research Artifacts
Maintainers and Advanced Integrators
License
MIT. See the license.
Metadata
Release files for llm-routewise 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_routewise-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / llm_routewise-0.2.0-py3-none-any.whl
| Download URL | llm_routewise-0.2.0-py3-none-any.whl |
|---|---|
| Size | 53.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac67243b4a137214bf71152e5ab5432dc895dba221b6faa6673f20a47ad1f51d
|
|
BLAKE2b-256 checksum How to use checksums |
00775058b48e48e368d10f44ec34e97d877e7c81d532961f74daf6761f6aa529
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency logSecurity for llm-routewise 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 1 file in this release has been uploaded with provenance metadata.
Attestation for llm_routewise-0.2.0-py3-none-any.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.