Skip to main content

Nordlys

Smart LLM model routing with a checkpoint-based runtime.

Install

uv pip install -e .

Quick Start

from nordlys import Dataset, Trainer, Router, ModelConfig

# 1. Define models
models = [
    ModelConfig(id="openai/gpt-4", cost_input=30.0, cost_output=60.0),
    ModelConfig(id="openai/gpt-4o-mini", cost_input=0.15, cost_output=0.6),
]

# 2. Build training dataset with binary targets per model
dataset = Dataset.from_list([
    {
        "id": "1",
        "input": "Design a database schema for this app",
        "targets": {"openai/gpt-4": 1, "openai/gpt-4o-mini": 0},
    },
    {
        "id": "2",
        "input": "Summarize this short changelog",
        "targets": {"openai/gpt-4": 0, "openai/gpt-4o-mini": 1},
    },
])

# 3. Train checkpoint, then create runtime router
checkpoint = Trainer(models=models).fit(dataset)
router = Router(checkpoint=checkpoint)

result = router.route("Implement this parser")
print(result.model_id)

How It Works

  1. Clusters similar prompts together
  2. Learns which model performs best per cluster
  3. Routes new prompts to the optimal model

Runtime API

  • router.route(prompt, models=None) routes one prompt.
  • router.route_batch(prompts, models=None) routes a list of prompts.
  • Optional models filter restricts candidates to specific model IDs.

Checkpoint I/O

checkpoint.to_json_file("router.json")
loaded = Router(checkpoint="router.json")

Links

Citation

This project is inspired by the Universal Router approach:

@article{universalrouter2025,
  title={Universal Router: Foundation Model Routing for Arbitrary Tasks},
  author={},
  journal={arXiv preprint arXiv:2502.08773},
  year={2025},
  url={https://arxiv.org/pdf/2502.08773}
}

Paper: Universal Router: Foundation Model Routing for Arbitrary Tasks

Metadata

Release files for nordlys 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nordlys 0.8.0
File Size Uploaded Provenance Actions
nordlys-0.8.0.tar.gz 207.2 kB Without provenance Details for nordlys-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nordlys 0.8.0
File Interpreter ABI Platform Actions
nordlys-0.8.0-py3-none-any.whl Python 3 none any Details for nordlys-0.8.0-py3-none-any.whl

Total release size: 289.0 kB

Release files / nordlys-0.8.0.tar.gz

Download URL nordlys-0.8.0.tar.gz
Size 207.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6bc729ceeda776392befe4b997b4684c9cbf9384ff98a728a8f2f4954567404f
BLAKE2b-256 checksum
How to use checksums
ea925a0a3d31639cdbcfe653f70bb2ae8090fbdffedf9a4557a2644eaf12ab3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / nordlys-0.8.0-py3-none-any.whl

Download URL nordlys-0.8.0-py3-none-any.whl
Size 81.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f77401bf318b94d895522e0370081bcffd75bdaf059ded15f199712e86000b9
BLAKE2b-256 checksum
How to use checksums
2da0a5867416497b7ad6409b315109cd14a14e6e6f905e9b164a793274864da2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for nordlys 0.8.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.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page