Skip to main content

TryAii

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

from tryaii import DREClient, Router

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

print(result.best_model)     # e.g. "anthropic/claude-opus-5.5"
print(result.best_reasoning) # "q'=0.98 (4 real of 5) | imputed: 1/5 | cost 0.2066 ($12.00/M) | ..."

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

Install

pip install tryaii

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

Optional extras for provider integrations:

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

Quick Start

from tryaii 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(),
)

Model catalog

The package ships a starter catalog: 45 well-known models from OpenAI, Anthropic, Google, DeepSeek, xAI and Mistral, scored on 16 benchmarks. It works offline with no account. Log in (free, with your tryaii.com Google account) to route on the full catalog of 322 models:

tryaii login     # device sign-in: open the printed URL in any browser and approve the code
tryaii whoami    # the signed-in account and the downloaded catalog release
tryaii logout    # remove the credentials and the downloaded catalog

After login the full catalog downloads automatically, is refreshed at most once a day, cached under ~/.tryaii/catalog/ (or TRYAII_DRE_DATA_DIR), and used only after its Ed25519 signature checks out. In code:

Router()                    # catalog="auto": full when logged in, else starter
Router(catalog="starter")   # always the packaged catalog, no network
Router(catalog="full")      # raises LoginRequiredError when not logged in

CLI

Installing the package adds a tryaii 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 route "Write a Python function to merge sorted arrays" --quality=5 --cost=1
tryaii eval prompts.json --output results/my-run --quality=5 --cost=1 --speed=1
tryaii models --provider anthropic        # add --json for machine-readable output
tryaii benchmarks --json
tryaii setup                               # download the embedding model + warm centroids
tryaii cachelint request.json              # pre-flight prompt-cache analysis (warn-only)
tryaii login                               # free: unlock the full model catalog
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
cachelint <input.json | -> --json, raw-text mode via --provider <name> + --model <name>; exact OpenAI/xAI counts need pip install tryaii[cachelint]

The cachelint engine also runs inside the clients: pass cache_lint="warn" to DREClient/AsyncDREClient/OpenRouterIntegration (or set TRYAII_CACHE_LINT=warn) to lint every outgoing chat request and verify cache predictions against the response usage — warn-only and fail-open.

| models | --provider <name>, --json | | benchmarks | --json | | setup / regenerate | --model <name> | | login / logout | none | | whoami | --json |

Global flags: --no-banner (or TRYAII_NO_BANNER=1), NO_COLOR=1, -v/--verbose, -V/--version. All flags work in any position and match the npm CLI.

Eval over a dataset

# Balanced run into a named folder
tryaii 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 eval prompts.json --output results/budget --max-price=0.10 --output-tokens=2000
tryaii 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 import Router
from tryaii.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 import Router
from tryaii.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[openai]

License

Apache 2.0

Metadata

Release files for tryaii 0.7.1

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

Source distribution (sdist)

Source distribution for tryaii 0.7.1
File Size Uploaded
tryaii-0.7.1.tar.gz 482.9 kB Details

Built distribution (wheel)

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

Total release size: 857.6 kB

Release files / tryaii-0.7.1.tar.gz

Download URL tryaii-0.7.1.tar.gz
Size 482.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a780b26adbdb1580ee163345a9d63cd18c5603d8f377aae07a415ca364e7ec02
BLAKE2b-256 checksum
How to use checksums
3e2b987528f7f96075d1c6b407313f03bd6497334ae672cb9af183d78fadf362
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / tryaii-0.7.1-py3-none-any.whl

Download URL tryaii-0.7.1-py3-none-any.whl
Size 374.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5db5cb2fad8ef9600e063006d4f8efbf46de223c5122bf6fac0e2b7fb501466
BLAKE2b-256 checksum
How to use checksums
3a280cf2995b7e33172d5b0d6cd2733aa09b2c8d240d8227d3d1d264b6d0b3f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

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