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.0.tar.gz (98.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.0-py3-none-any.whl (87.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: enroute-0.3.0.tar.gz
  • Upload date:
  • Size: 98.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.0.tar.gz
Algorithm Hash digest
SHA256 bbb5eecff191a6dbfc2c0d576a5e4b03b6b2e798fe2465d1cf699a5db04c1251
MD5 abb3b762abd0d40a92ed6d862ad73f31
BLAKE2b-256 abc8dcbe2c3a36567c33a8d6f01fa89a6f28ee6b2b469bbc2b6c3acc1bdb9146

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: enroute-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 87.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2abb4e1a7f370ef8fee785ea084474fd0c5d016f87978fa261c2596d0c616c5a
MD5 0a829cf650a539e7775986f3c1cf3477
BLAKE2b-256 798c503aa1803b044241acfde24d06039f578d4f3531c748cab875f594b1ec8a

See more details on using hashes here.

Provenance

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