Cost-aware, latency-optimized routing for multiple LLM API providers
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_routewise-0.2.0-py3-none-any.whl.
File metadata
- Download URL: llm_routewise-0.2.0-py3-none-any.whl
- Upload date:
- Size: 53.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac67243b4a137214bf71152e5ab5432dc895dba221b6faa6673f20a47ad1f51d
|
|
| MD5 |
fac9bdb1e8111706adf678e116d8d563
|
|
| BLAKE2b-256 |
00775058b48e48e368d10f44ec34e97d877e7c81d532961f74daf6761f6aa529
|
Provenance
The following attestation bundles were made for llm_routewise-0.2.0-py3-none-any.whl:
Publisher:
release.yml on HarvardMadSys/RouteWise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_routewise-0.2.0-py3-none-any.whl -
Subject digest:
ac67243b4a137214bf71152e5ab5432dc895dba221b6faa6673f20a47ad1f51d - Sigstore transparency entry: 2210738485
- Sigstore integration time:
-
Permalink:
HarvardMadSys/RouteWise@21e483cde76013a18334c3a5e27cecd62312a2a9 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/HarvardMadSys
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@21e483cde76013a18334c3a5e27cecd62312a2a9 -
Trigger Event:
release
-
Statement type: