Skip to main content

TryAii Diff Routing Engine -- Embedding-based AI model router. Understands your prompt semantically and routes to the best model based on benchmarks, cost, speed, and quality.

Project description

TryAii-DRE

Embedding-based AI model router. Understands your prompt semantically and routes to the best model based on benchmarks, cost, speed, and quality.

from tryaii_dre import DREClient, Router

router = Router()
result = router.route("Write a Python function to merge sorted arrays")

print(result.best_model)     # "gpt-5.2"
print(result.best_reasoning) # "Quality: 0.94 on [HumanEval (93%), SWE-bench (87%)]"

client = DREClient(api_key="sk-or-...")
response = client.chat("Write a quicksort implementation")
print(response.content)

Install

pip install tryaii-dre

The base install includes local embeddings via sentence-transformers - no API keys needed.

Optional extras for provider integrations:

pip install tryaii-dre[openrouter]  # Route & call models via OpenRouter (adds httpx)
pip install tryaii-dre[openai]      # Use OpenAI embeddings instead of local (adds openai)
pip install tryaii-dre[redis]       # Redis client for planned distributed cache (not yet implemented)
pip install tryaii-dre[all]         # All optional integrations

Quick Start

from tryaii_dre import Router, Priorities

router = Router()

# Route with default balanced priorities
result = router.route("Explain quantum entanglement simply")
print(result.best_model)

# Quality-first (ignore cost)
result = router.route(
    "Debug this memory leak in my Node.js app",
    priorities=Priorities(quality=5, cost=1, speed=2),
)

# Budget mode
result = router.route(
    "Summarize this email",
    priorities=Priorities.budget(),
)

CLI

Installing the package adds a tryaii-dre command (same surface as the Node SDK). It opens with an animated blue→red banner, then runs your command. The banner prints to stderr and auto-suppresses when output is piped, so --json stays clean.

tryaii-dre route "Write a Python function to merge sorted arrays" --quality=5 --cost=1
tryaii-dre eval prompts.json --output results/my-run --quality=5 --cost=1 --speed=1
tryaii-dre models --provider anthropic        # add --json for machine-readable output
tryaii-dre benchmarks --json
tryaii-dre setup                               # download the embedding model + warm centroids
Command Key options
route "<prompt>" --quality/--cost/--speed <1-5> (default 3), --top-k <n>
eval <input.json> -o/--output <dir>, --max-price <usd>, --output-tokens <n>, --budget-mode strict|fit-output
models --provider <name>, --json
benchmarks --json
setup / regenerate --model <name>

Global flags: --no-banner (or TRYAII_NO_BANNER=1), NO_COLOR=1, -v/--verbose.

Eval over a dataset

# Balanced run into a named folder
tryaii-dre eval prompts.json --output results/my-run --quality=5 --cost=1 --speed=1

# Budget-aware: --max-price is the total budget for the whole dataset
tryaii-dre eval prompts.json --output results/budget --max-price=0.10 --output-tokens=2000
tryaii-dre eval prompts.json --output results/budget-fit --max-price=0.10 --output-tokens=2000 --budget-mode=fit-output

The input can be an array of strings or objects with prompt, optional id, and optional category. In budgeted eval, quality/cost/speed priority flags are ignored: price is the hard constraint, and the optimizer maximizes model quality within that price. --budget-mode=fit-output lowers the fixed output token estimate when the requested length cannot fit the total budget. The command writes results.jsonl, summary.json, and index.html.

OpenRouter Integration

from tryaii_dre import Router
from tryaii_dre.integrations import OpenRouterIntegration

router = Router()
openrouter = OpenRouterIntegration(router, api_key="sk-or-...")

response = openrouter.chat("Write a quicksort implementation")
print(response.model_used)  # Auto-selected best model
print(response.content)     # Actual response

OpenAI Embeddings

from tryaii_dre import Router
from tryaii_dre.embeddings import OpenAIEmbeddingProvider

router = Router(
    embedding_provider=OpenAIEmbeddingProvider(),
)

result = router.route("Summarize this architecture decision")
print(result.best_model)

Install the OpenAI client first:

pip install tryaii-dre[openai]

License

Apache 2.0

Project details


Download files

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

Source Distribution

tryaii_dre-0.2.0.tar.gz (117.3 kB view details)

Uploaded Source

Built Distribution

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

tryaii_dre-0.2.0-py3-none-any.whl (118.0 kB view details)

Uploaded Python 3

File details

Details for the file tryaii_dre-0.2.0.tar.gz.

File metadata

  • Download URL: tryaii_dre-0.2.0.tar.gz
  • Upload date:
  • Size: 117.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for tryaii_dre-0.2.0.tar.gz
Algorithm Hash digest
SHA256 49246d9fe19673f39b1fe86f0e4097d2e0984665a4e6bb32bc8d76cf60583e80
MD5 4887138c3a22cbad32d37b0ee5b3ef2c
BLAKE2b-256 1dada77d74bd0e612b268a868c6f9dec8793e5b438e227e125ede891307b4153

See more details on using hashes here.

File details

Details for the file tryaii_dre-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: tryaii_dre-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 118.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for tryaii_dre-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b062e79a8ba7e17711840df143ba3b5bc1f3a32ce90a71400f6de752e4e2cc0e
MD5 4ff443aa64d321ffec0ae8f3d164c63c
BLAKE2b-256 e32081af916ef2e16cc1fc1035cbc3abdff1aaa02cd99f378ce0ebbc52af4ae9

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 Pingdom Monitoring Sentry Error logging StatusPage Status page