Skip to main content

enroute

Unified LLM routing with first-class traces, environments, and benchmarks.

enroute is for builders putting AI into products. Start with an OpenRouter-style multi-provider router. Keep going with the thing OpenRouter does not give you: a single Trace object shared by production traffic and RL-style environments — so you can understand prompts, build datasets, run benchmarks, and eventually autoroute to the best model for your data.

flowchart LR
  App[Your app] --> Client[Enroute]
  Env[Environment] --> Client
  Client --> Trace[Trace]
  Trace --> Dataset[Dataset]
  Dataset --> Bench[Benchmark]

Install

pip install enroute
# optional OpenTelemetry exporter
pip install "enroute[otel]"

Quickstart

Set ENROUTE_API_KEY, then use the client like the OpenAI SDK:

export ENROUTE_API_KEY=enroute-...
from enroute import Enroute, Message

client = Enroute()
response = client.chat(
    model="openai/gpt-4o-mini",
    messages=[Message(role="user", content="Hello from enroute")],
    models=["anthropic/claude-sonnet-4"],  # optional fallbacks
)
print(response.text)
client.close()
# Traces → .enroute/traces.jsonl

Optional BYOK (pass your own upstream keys explicitly):

import os
from enroute import Enroute

client = Enroute(providers={"openai": os.environ["OPENAI_API_KEY"]})

Four pillars

Pillar What you get
Router Sync/async chat + streaming, fallbacks, retries, cost accounting, model catalog
Tracing JSONL / SQLite / OTel sinks, redaction, sampling, late labels, attempt history
Environments Tasks + tools + scorers → scored traces (the RL harness)
Benchmarks Environment × models → markdown/JSON report with win rates

Environments in 30 seconds

from enroute import Environment, TaskData

env = Environment(name="support-triage", version="0.1.0")

@env.tool
def lookup_order(order_id: str) -> dict:
    """Look up an order."""
    return {"status": "shipped"}

@env.scorer(weight=1.0)
def ok(rollout) -> float:
    return 1.0 if "shipped" in (rollout.response.text or "").lower() else 0.0

@env.tasks
def tasks():
    yield TaskData(task_id="1", input="Where is order A?")

rollout = env.rollout(next(env.iter_tasks()), client, model="openai/gpt-4o-mini")
print(rollout.trace.outcome)

Docs

Full documentation: concept pages, guides, and generated API reference.

  • Trace schema stability: schemas/trace.v1.json
  • Routing walkthrough: examples/routing/ (also under docs → Guides)

Development

uv sync --group dev --group docs
uv run pytest -m "not live"
uv run ruff check .
uv run mypy src/enroute
uv run mkdocs build --strict

License

Apache-2.0

Download files

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

Source Distribution

enroute-0.3.4.tar.gz (128.7 kB view details)

Uploaded Source

Built Distribution

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

enroute-0.3.4-py3-none-any.whl (104.0 kB view details)

Uploaded Python 3

File details

Details for the file enroute-0.3.4.tar.gz.

File metadata

  • Download URL: enroute-0.3.4.tar.gz
  • Upload date:
  • Size: 128.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for enroute-0.3.4.tar.gz
Algorithm Hash digest
SHA256 6ab40cb225355264498a3312ce06fe6fcf68f181c55680fa8f2260f91e0b3a63
MD5 13a4db903e6dfe04d460f693b288c60a
BLAKE2b-256 d8f148dd2196a523a6670171f5843daab040a08ddaa98924b1e600b432128197

See more details on using hashes here.

Provenance

The following attestation bundles were made for enroute-0.3.4.tar.gz:

Publisher: publish.yml on taylorlast/enroute

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file enroute-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: enroute-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 104.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for enroute-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 82e9758736fe86e3da356c28c6d6966ca97721bf001df03a0814f5430e749af8
MD5 1a2a6d61aed2ce296f638325b166550c
BLAKE2b-256 1f9ac6be4828420737317594f8a73e1e27bd1aa82ec1268281d175457fca2d95

See more details on using hashes here.

Provenance

The following attestation bundles were made for enroute-0.3.4-py3-none-any.whl:

Publisher: publish.yml on taylorlast/enroute

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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