LiteLLM Routing Testbed
This package proves LiteLLM's context-window-aware routing locally on macOS without starting real vLLM instances. Two FastAPI dummy backends expose the OpenAI Chat Completions API, count every request with LiteLLM's own public token counter, and record one JSON object per received request.
What it proves
- Instance A accepts at most 65,000 input tokens.
- Instance B accepts at most 256,000 input tokens.
- LiteLLM pre-call checks remove deployments whose
max_input_tokensis too small before choosing a backend. - The native mode load-balances requests that fit both deployments.
- The deterministic mode uses LiteLLM deployment
orderto prefer A and uses B only after A is removed by the context check. - A request with 256,001 input tokens is rejected by LiteLLM without reaching either backend.
Requirements
- Apple Silicon macOS
- Python 3.11 or newer
- Free local ports 4000, 4011, and 4012 by default
All services run on loopback and require no external API, database, Redis, container runtime, or model weights. The package forces LiteLLM to use its bundled model-cost map, so startup does not fetch the remote cost-map copy.
Install
cd litellm-routing-testbed
python3 -m venv .venv
.venv/bin/pip install -e .
For development and verification:
.venv/bin/pip install -e '.[dev]'
All direct dependencies are exactly pinned in pyproject.toml.
Run the native proof
The shortest complete run starts all services, executes the required target matrix plus 12 small-request probes, and always shuts down:
.venv/bin/routing-testbed all --mode native
Run lifecycle stages separately when inspecting live services:
.venv/bin/routing-testbed up --mode native
.venv/bin/routing-testbed status --mode native
.venv/bin/routing-testbed test --mode native
.venv/bin/routing-testbed down --mode native
Run deterministic small-first routing
.venv/bin/routing-testbed all --mode deterministic --small-probes 0
This mode adds order: 1 to A and order: 2 to B. The context check still
runs first, so requests through 65k select A and larger valid requests select
B.
Custom ports and target sizes
Every command accepts the same network and runtime options:
.venv/bin/routing-testbed all \
--small-port 5011 \
--large-port 5012 \
--proxy-port 5000 \
--targets 10000,50000,64000,70000,120000,200000,255000,256001
When commands are run separately, repeat the same options so they address the
same state file and endpoints. Use --logs-dir and --run-dir to relocate
runtime artifacts.
Endpoints
The two dummies expose:
GET /healthGET /v1/modelsPOST /v1/chat/completions
LiteLLM listens on http://127.0.0.1:4000 by default. The public test model is
router-model.
Evidence
Runtime evidence remains after down:
logs/native-instance_A_65k.jsonllogs/native-instance_B_256k.jsonllogs/deterministic-instance_A_65k.jsonllogs/deterministic-instance_B_256k.jsonllogs/instance_A_65k.loglogs/instance_B_256k.loglogs/litellm.loglogs/test-results-native.jsonlogs/test-results-deterministic.json
Each backend JSONL row contains the UTC timestamp, instance, target port,
client-reported target tokens, independently counted input tokens,
max_tokens, model, and request ID. The assistant response content also
contains handled_by and input_tokens, which the client uses for its
pass/fail table. Mode-scoped filenames preserve native and deterministic
evidence when the two runs are executed consecutively.
Cleanup
all calls down in a finally block. If a terminal is interrupted during a
separate run, execute:
.venv/bin/routing-testbed down
The process manager checks stored command signatures before signaling PIDs, so a stale state file cannot cause it to terminate an unrelated reused PID.
See ROUTING.md for the verified LiteLLM fields and routing semantics.
Metadata
Release files for litellm-routing-testbed 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| litellm_routing_testbed-0.1.0.tar.gz | 24.5 kB | Without provenance | Details for litellm_routing_testbed-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| litellm_routing_testbed-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for litellm_routing_testbed-0.1.0-py3-none-any.whl |
Total release size: 46.2 kB
Release files / litellm_routing_testbed-0.1.0.tar.gz
| Download URL | litellm_routing_testbed-0.1.0.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c36ff8935c7a49a985901072138be15982ef86da819659d817f1cb4de6aa3f06
|
|
BLAKE2b-256 checksum How to use checksums |
3c90903f18538fa3230c3bec763e7e214c4e3a43d4c8110a6476c45822dd5f82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / litellm_routing_testbed-0.1.0-py3-none-any.whl
| Download URL | litellm_routing_testbed-0.1.0-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96cf20d84f0394d6e13a195971d1f89466aca9a9904e838591347b9fa2acde7a
|
|
BLAKE2b-256 checksum How to use checksums |
6bf86357af8761ccc5f8e202a2fcee5065055d565f824dbf1397d99d8e9bd5f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Security for litellm-routing-testbed 0.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.