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.1.tar.gz (101.8 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.1-py3-none-any.whl (88.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: enroute-0.3.1.tar.gz
  • Upload date:
  • Size: 101.8 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.1.tar.gz
Algorithm Hash digest
SHA256 096b468b1dd74b014dc8f45b150d08e742b2d5a56a08cdc9ed5280cc3f1a9f59
MD5 e662f49ba6bf74ef9a5147971892a853
BLAKE2b-256 b73f633345fc45740b8f9114682c900f9f32d21494e309fc0a142501f5891ccc

See more details on using hashes here.

Provenance

The following attestation bundles were made for enroute-0.3.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: enroute-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 88.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56e66d219872bf3d5b5bd211c698542cee03a17ca0e309c0818e92f79f6ee85b
MD5 611d762d03b8c34383a9ba171f12dc2c
BLAKE2b-256 1768ca11194a95a3d9dc5ca689936df95c39e7fc2c3d93652ccdf31051a46edb

See more details on using hashes here.

Provenance

The following attestation bundles were made for enroute-0.3.1-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