Skip to main content

ProvizElekto

Smart LLM model router. Picks the best model for each call based on context size, rate limits, and capabilities — and retries automatically on failure.

Your app → pz.call(step, fn)               → CallResult
           pz.call_litellm(step, messages) → CallResult
                    ↕  (automatic)
           select → LLM call → report → retry on failure
                    ↕
              proviz-server (Rust)
          rate-limit state · catalog

Key difference from LiteLLM fallback: LiteLLM retries after failure. ProvizElekto picks the right model before the call — skipping models that are rate-limited or near their quota, can't fit the context, or lack required capabilities — then retries with the next eligible model automatically.

Two roles depending on the path

In the regular flow, the server is a pure router — it picks the model and returns credentials; your code makes the actual LLM call.

In the synchronous /complete flow, the server is the caller — it selects, calls the provider, and reports, all in one round-trip — so your code needs no litellm or provider SDK.

In the batch flow, the server becomes the caller:

# Regular: YOUR code calls the LLM
Your app → POST /select → ModelCandidate → your code → Mistral/OpenAI/...
                                                ↓
                                        POST /report

# Synchronous: the SERVER calls the provider for you
Your app → POST /complete → server selects + calls provider + reports → {text, usage, cost}

# Batch: the SERVER calls Mistral on your behalf
Worker A ──┐
Worker B ──┤ POST /batch/submit → server accumulates over window_secs
Worker C ──┘
                    ↓ server → POST Mistral /v1/batch/jobs (50% discount)
                    ↓ server polls until complete
Worker A ──┐
Worker B ──┤ GET /batch/result/{id} → response
Worker C ──┘

The batch path pools requests from all workers into a single Mistral job — the only way to qualify for Mistral's 50% batch discount. No individual worker can do this on its own, so the server acts as the aggregation point and makes the Mistral call itself.

Deployment note: when using batch, the server process (including Docker) must have the Mistral API key env vars set. In the regular flow, API keys only need to be present in the caller's environment.

Features

  • Context-aware selection - don't waste a 128k model on a 1k prompt
  • Proactive quota tracking - sliding-window counters (RPM/TPM/RPD/TPD) plus atomic in-flight reservations; avoids over-booking before any 429 fires
  • Provider-anchored windows - every successful call forwards x-ratelimit-remaining-* headers back to the server; the window floor is clamped to provider reality so internal estimates can't drift below what the provider actually sees
  • Scored selection - multi-component scoring: fast headroom (RPS/RPM/TPM, 25%), daily budget (RPD/TPD, 20%), quality (20%), cost (15%), latency (10%), traffic balance (10%). Over-quota models stay eligible with lower scores — AllModelsExhausted only fires when every model is in reactive 429 cooldown.
  • Tunable weights - override the cost/latency/quality weights above per request (cost_weight/latency_weight/quality_weight on /select and /complete) or once per group (proviz group set-weights); omitting them reproduces the built-in weights exactly, and no model is ever hard-excluded by a weight the way a hard filter would.
  • Measured per-step quality - POST /catalog/step-quality lets a caller push a real, task-specific quality score (e.g. a benchmark pass-rate) for a (model, step) pair, checked before the model's hand-curated global quality_score.
  • OpenRouter provider routing - when the selected model routes through OpenRouter, the same cost_weight/latency_weight also steers OpenRouter's own upstream-provider choice (provider.sort: "price"|"latency") - the bias applies at both routing levels, not just proviz's own model selection.
  • Aggregator auto-sync - OpenRouter, Requesty, Nous Portal, OrcaRouter and TokenHub each aggregate hundreds of models with drifting pricing; their models.json is machine-generated (once at startup, then hourly). proviz providers sync-<name> --dry-run to review the mapping. OrcaRouter's /v1/models omits capability flags and cache pricing, so each newly-seen model is additionally scraped once from its SEO detail page (PROVIZ_ORCAROUTER_ENRICH_MAX per run, fail-soft); its real per-request cost comes back as usage.cost_usd when /complete sends the X-OrcaRouter-Include-Cost header, and it gets reasoning_effort: "minimal" by default since it has no reasoning-off switch. TokenHub's authenticated /v1/models returns only model ids, so each model's pricing (one-api-style model_ratio × $2/1M), context and capabilities is scraped from its server-rendered detail page; known models are carried forward untouched, proviz providers sync-tokenhub --refresh re-scrapes everything. Its real per-request cost comes back as usage.cost (handled generically, no brand-specific code).
  • Cached-input pricing - providers that keep a warm prompt-cache (DeepSeek, Nous Portal, OpenAI, Anthropic) bill cache-hit input tokens at a steep discount and report the hit count in the response. Model.price_cached_input_per_1m (auto-filled from Nous's pricing.input_cache_read, hand-curated elsewhere) makes cost accounting reflect it; /complete parses usage.prompt_tokens_details.cached_tokens (or DeepSeek's prompt_cache_hit_tokens) and echoes it on the response. None = no distinct rate, cost is byte-identical to before.
  • Prompt-cache stickiness - proviz group set-sticky --slug <g> --enabled makes the selector nudge consecutive calls for that group toward the model that served the last one, so a large repeated prompt prefix stays cache-warm. A bounded bonus that yields to heatroom: it can't keep a rate-limited or headroom-drained model winning, so rotation under load is unaffected. In a sticky group the cost score also blends toward the cached input rate (repeat calls hit the cache), favouring cache-capable models.
  • Traffic shaping - per-brand traffic_weight steers load proportionally across providers in a 5-minute rolling window; under-served brands get a higher score on the traffic component
  • Capability filtering - hard requirements for function calling, JSON mode
  • Language filtering - restrict selection to models declared to support a given language (ISO 639-1), so you never call a model in the wrong language
  • Quality floor - reject models below a quality threshold per step
  • Model groups - define named pools of models (e.g. "fast-chat", "coding-tier1") and restrict selection to that pool
  • Your keys, your models - curated catalog, no vendor proxy
  • Zero-infra - pip install proviz-elekto auto-starts the Rust server as a subprocess
  • Any language - HTTP API, not a library binding
  • Pluggable storage - SQLite (default) or PostgreSQL

Installation

ProvizElekto consists of a Rust server and various clients.

pip install proviz-elekto          # core only
pip install proviz-elekto[litellm] # + built-in LiteLLM integration

The proviz-server binary is bundled in the wheel.

CLI tool (proviz) is also included:

proviz --help

Documentation

Quickstart

from proviz_elekto import ProvizElekto

pz = ProvizElekto(db_path="./proviz.db")
# or PostgreSQL: pz = ProvizElekto(database_url=os.environ["DATABASE_URL"])

result = pz.call_litellm(
    step="verdict",
    messages=[{"role": "user", "content": "Summarize this document..."}],
    estimated_tokens=2500,
    requires_json_mode=True,
)
print(result.provider, result.candidate.model_slug, result.total_tokens)
# → mistral mistral-small-latest 312

call_litellm() selects the best available model, calls it, reports the outcome, and retries with the next eligible model on any failure — automatically.

Without litellm (server-side /complete)

The server calls the provider for you — no litellm or provider SDK in your environment. Best for thin/non-Python callers and minimal dependency footprints.

result = pz.complete(
    step="verdict",
    messages=[{"role": "user", "content": "Summarize this document..."}],
    estimated_tokens=2500,
    response_format={"type": "json_object"},
)
print(result.brand, result.model, result.prompt_tokens, result.completion_tokens, result.cost_usd)
# → mistral mistral-small-latest 2487 312 0.00031

complete() does select + provider call + report in a single round-trip. On provider failure it excludes the model and retries the next-best candidate server-side (up to 4 attempts). Pass tools=/tool_choice= to get un-executed tool_calls back and drive the tool loop yourself. Any OpenAI-compatible provider (groq, mistral, ovh, scaleway, novita, infomaniak, …) works.

Infomaniak embeds an account-specific product_id in its API URL. providers/infomaniak/brand.json stores it as a ${INFOMANIAK_PRODUCT_ID} placeholder in base_url, expanded from the environment at request time — set INFOMANIAK_PRODUCT_ID (from GET https://api.infomaniak.com/1/ai) next to INFOMANIAK_API_KEY wherever the server/Docker container runs. Any base_url in a provider's brand.json/models.json may use ${VAR} this way.

Non-USD pricing. A brand.json may set "price_currency" (e.g. "EUR" for Infomaniak); the model prices in its models.json are then in that currency. The selector converts everything to USD for cost scoring and for the cost_usd / actual_cost_usd figures using live ECB rates (from frankfurter.dev, fetched at most hourly, persisted so last-good values survive restarts). GET /fx/rates shows the current table. USD-only setups are unaffected.

The legacy /select + client-side call + /report flow (below) stays fully supported — use it when you want to own the provider call (streaming, custom SDK).

With a custom LLM caller

import anthropic

client = anthropic.Anthropic()

def my_llm(candidate):
    return client.messages.create(
        model=candidate.model_slug,
        max_tokens=1024,
        messages=[{"role": "user", "content": "Hello"}],
    )

result = pz.call("verdict", my_llm, estimated_tokens=100)
print(result.candidate.brand_slug, result.prompt_tokens)

Pass any callable that accepts a ModelCandidate and returns a response. ProvizElekto wraps it with the same select → report → retry loop.

Low-level API

If you need direct control over selection and reporting:

candidate = pz.select(step="verdict", estimated_tokens=2500)
try:
    response = my_llm_call(candidate)

    # Read provider rate-limit headers (Mistral/OpenAI style; Anthropic style also supported)
    hdrs = getattr(response, "_hidden_params", {}).get("additional_headers") or {}
    rem_req = hdrs.get("x-ratelimit-remaining-requests")
    rem_tok = hdrs.get("x-ratelimit-remaining-tokens")

    pz.report_success(
        candidate.model_id,
        estimated_tokens=candidate.estimated_tokens,  # releases in-flight reservation
        actual_tokens=response.usage.total_tokens,    # improves TPM window accuracy
        remaining_requests=int(rem_req) if rem_req is not None else None,
        remaining_tokens=int(rem_tok)   if rem_tok is not None else None,
    )
    # report_success is fire-and-forget — returns immediately, HTTP call runs in background
except RateLimitError as exc:
    msg = str(exc).lower()
    if "day" in msg or "daily" in msg:
        error_type = "tpd"
    elif "token" in msg:
        error_type = "tpm"
    else:
        error_type = "rpm"
    pz.report_rate_limit(candidate.model_id, error_type)  # synchronous — must complete before retry
except Exception:
    pz.report_error(candidate.model_id, "other")

estimated_tokens in each report call releases the in-flight reservation made at selection time. Omitting it is safe (legacy clients work unchanged) but leaves the in-flight counter inflated until the next selection clears it.

report_success is non-blocking: the HTTP call to proviz runs in a background daemon thread so the caller receives the LLM result without waiting for the round-trip. report_rate_limit and report_error remain synchronous because the model must be blocked in proviz before the retry select() call.

License

Apache-2.0

TypeSafe Jev decisions

Jev is available through POST /complete with categories: ["decision"] and a response_format JSON schema containing a flat object of required enum and boolean properties. Set TYPESAFE_API_KEY in the server's deployment environment. RTFC's Compose files forward this key to proviz; its Kubernetes renderer builds the env-proviz Secret from that configuration. Keep the real key in the deployment's .env, never in committed configuration or on RTFC workers. Jev does not generate free text, queries, summaries or tool calls; it is excluded from ordinary chat selection. The gateway translates finite properties into native TypeSafe Choice/Noul questions and returns JSON in text, plus native decision_probabilities. Boolean decisions use a 0.5 threshold. Choice properties support at most 255 scalar alternatives.

On an existing deployment, seed the new provider with proviz seed --dir ./providers against the intended catalog, then reload it with proviz reload (or restart the server). No group is required for RTFC's default Ricochet routing: it explicitly selects the decision category on the ricochet_decide step. An optional navigation group must contain typesafe/jev-latest. In Ricochet, Jev selects observed page/link IDs and whether to search again or stop. Query generation and the final verdict/summary remain separate text-generating calls; navigation confidence is not verdict confidence. Verify the adapter with cargo test -p proviz-server; its HTTP regression uses a synthetic TypeSafe endpoint and checks routing, usage and ordinary-chat isolation. See the TypeSafe API and model limits/pricing.

Metadata

Release files for proviz-elekto 0.23.5

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

Built distributions (wheels)

Table of built distributions (wheels) for proviz-elekto 0.23.5
File Actions
proviz_elekto-0.23.5-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for proviz_elekto-0.23.5-py3-none-win_amd64.whl
proviz_elekto-0.23.5-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for proviz_elekto-0.23.5-py3-none-musllinux_1_2_x86_64.whl
proviz_elekto-0.23.5-py3-none-manylinux_2_36_x86_64.whl Python 3 none Linux glibc 2.36+ x86-64 Details for proviz_elekto-0.23.5-py3-none-manylinux_2_36_x86_64.whl
proviz_elekto-0.23.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for proviz_elekto-0.23.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
proviz_elekto-0.23.5-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl Python 3 none macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) Details for proviz_elekto-0.23.5-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Total release size: 31.5 MB

Release files / proviz_elekto-0.23.5-py3-none-win_amd64.whl

Download URL proviz_elekto-0.23.5-py3-none-win_amd64.whl
Size 4.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
22df3cf0f47f77901f5951fbb749030214b3c0ce22d4db19c98b5440aae19e1c
BLAKE2b-256 checksum
How to use checksums
60dd5a18963b94861304439e6ef9dedbc96245dfbc757f0af7f2c5e4547ed6cb
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 6, 2026.

Transparency log

Release files / proviz_elekto-0.23.5-py3-none-musllinux_1_2_x86_64.whl

Download URL proviz_elekto-0.23.5-py3-none-musllinux_1_2_x86_64.whl
Size 5.7 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
f980276446d6b6655ceda0e0fd316c3847935a26dcebb34b5552ff8696396140
BLAKE2b-256 checksum
How to use checksums
41ed80fe1d89c26457bfc6fd116d5a47c1c50068fa3b3e64e6ebecc9ae95ca3b
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 6, 2026.

Transparency log

Release files / proviz_elekto-0.23.5-py3-none-manylinux_2_36_x86_64.whl

Download URL proviz_elekto-0.23.5-py3-none-manylinux_2_36_x86_64.whl
Size 5.5 MB
Tags Linux glibc 2.36+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0d887948651fd3358a339321b6bdf0be3572ba82a6555de91762d8636b24242b
BLAKE2b-256 checksum
How to use checksums
c67e00e6d891fe6e242661318d1c2b610591c831be06055ff327fb7e80c0c894
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 6, 2026.

Transparency log

Release files / proviz_elekto-0.23.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL proviz_elekto-0.23.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.4 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
a7540757abd130c719b1c1de9311b2a3e6d1aff5d30f5fcc7d7868fb30303c4d
BLAKE2b-256 checksum
How to use checksums
446f6c3481e4d276af10700f109b5a42daca465e7a13aab265468095b12fc214
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 6, 2026.

Transparency log

Release files / proviz_elekto-0.23.5-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL proviz_elekto-0.23.5-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 10.1 MB
Tags Python 3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5c68055d4e987067e4ebbdf6bab4d32c94265e286a46ecf1bf05a042fbf7b412
BLAKE2b-256 checksum
How to use checksums
23735e7e878860453433bd3662eda7f9786308f84678053997852081778a6785
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 6, 2026.

Transparency log

Security for proviz-elekto 0.23.5

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for proviz_elekto-0.23.5-py3-none-win_amd64.whl

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 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.23.5 This release

5 release files Full provenance

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