Skip to main content

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_tokens is too small before choosing a backend.
  • The native mode load-balances requests that fit both deployments.
  • The deterministic mode uses LiteLLM deployment order to 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 /health
  • GET /v1/models
  • POST /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.jsonl
  • logs/native-instance_B_256k.jsonl
  • logs/deterministic-instance_A_65k.jsonl
  • logs/deterministic-instance_B_256k.jsonl
  • logs/instance_A_65k.log
  • logs/instance_B_256k.log
  • logs/litellm.log
  • logs/test-results-native.json
  • logs/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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litellm_routing_testbed-0.1.0.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litellm_routing_testbed-0.1.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file litellm_routing_testbed-0.1.0.tar.gz.

File metadata

  • Download URL: litellm_routing_testbed-0.1.0.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.12

File hashes

Hashes for litellm_routing_testbed-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c36ff8935c7a49a985901072138be15982ef86da819659d817f1cb4de6aa3f06
MD5 3299faa33b31d6362282a4196f9bad7e
BLAKE2b-256 3c90903f18538fa3230c3bec763e7e214c4e3a43d4c8110a6476c45822dd5f82

See more details on using hashes here.

File details

Details for the file litellm_routing_testbed-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for litellm_routing_testbed-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96cf20d84f0394d6e13a195971d1f89466aca9a9904e838591347b9fa2acde7a
MD5 83776dc90e6b602e138a75f723f7adbe
BLAKE2b-256 6bf86357af8761ccc5f8e202a2fcee5065055d565f824dbf1397d99d8e9bd5f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page