Skip to main content Switch to mobile version modelsaar 0.3.0 ModelSaar - intelligent routing for local AI models. One OpenAI-compatible endpoint that picks the most suitable local deployment per request.
pip install modelsaar==0.3.0 Copy PIP instructions
ModelSaar 0.3.0. Install the PyPI package, pull the container, or use the guided installer. The support matrix lists which capabilities have been exercised on real hardware.
Intelligent routing for local AI models. One endpoint. Intelligent model selection.
ModelSaar is a small, local-first, OpenAI-compatible gateway. Your applications (Open WebUI, OpenClaw, OpenCode, Hermes Agent, anything that speaks Chat Completions) connect once and ask for a virtual model such as auto. ModelSaar inspects each request, keeps only the deployments that can actually satisfy it (tools, images, strict JSON schemas, context size, locality, health, capacity), ranks the rest on evidence, routes the request to the winner (the body passes through except documented client-compatibility translations), and records a decision you can inspect.
client ──/v1/chat/completions (model: auto)──▶ ModelSaar ──▶ ollama/qwen3.8:27b │ ollama/gemma4:e4b │ vllm/... └─ X-ModelSaar-Deployment, /admin/explain Validation history. Core routing, streaming, embeddings, probes, CLI, client config generation, evaluation harness and a fault-injection test suite are implemented and tested against controlled backends, and exercised live against a real Ollama server with eight models (discovery, probes, routing, streaming, tool calls, evaluation). Read the verification report before relying on any specific compatibility.
Connect once. Clients can manage their own tools and history. Operators can also enable hosted tools and caller-owned conversations on the Responses API.
Never silently degrade. No truncated history, dropped images, weakened schemas, stripped tools, or hidden cloud fallback. If nothing qualifies you get a structured error with blockers and remedies.
Evidence over marketing. Capabilities are three-state (supported | unsupported | unknown) with provenance (runtime metadata, probe, operator). Quality estimates are labelled measured, prior or uncalibrated. Unknown required capabilities never qualify.
Local and private by default. Loopback bind, generated keys, no prompt logging, cloud-forwarded models excluded unless you opt in, backends only reachable at their configured hosts.
Small. Five runtime dependencies (Starlette, uvicorn, httpx, pydantic, PyYAML). No Docker, Envoy, Redis, Postgres, GPU toolkit or mandatory classifier model.
Release notes cover the new opt-in features, the context and memory changes that can affect existing deployments, and rollback. Install from the tagged source, Python package or container:
# 1. From the tag (always available) git clone https://github.com/gopalasubramanium/modelsaar.git && cd modelsaar && git checkout v0.3.0 python3 -m venv .venv && . .venv/bin/activate && pip install . # 2. From PyPI or the public container registry pip install modelsaar==0.3.0 docker run -v modelsaar-data:/data -v ./config.yaml:/data/config.yaml:ro -p 127.0.0.1:8484:8484 ghcr.io/gopalasubramanium/modelsaar:v0.3.0 The one-line installer on modelsaar.com installs the commit it pins (shown on the site), in its own environment, and upgrades or rolls back an existing installation (installation).
New in 0.2: POST /v1/responses, POST /v1/messages and the opt-in response store (protocols); POST /v1/guardrails, POST /v1/ocr, POST /v1/vote, audio/video input, multimodal embedding items (pipelines); exact token counts and served-context detection per runtime (routing); modelsaar lifecycle (lifecycle); cascades, replica scheduling and modelsaar learn (cascades and learning); modelsaar judge (evaluation). All of it is additive or opt-in: a 0.1 configuration runs unchanged. One table gives the evidence level of every item: docs/roadmap-matrix.md.
Release candidate: decision models (v0.1.0-rc.2; opt-in, experimental — not a stable release)
POST /v1/decisions (typed questions answered by a decision model such as Ollama's nimble, clef or laya through its native /v1/systemone API) and the routing classifier's mode: decision were merged on main at commit 6075cdcf3b0952d4213a7899438f5fe546e95d19 and are available as the GitHub pre-releases v0.1.0-rc.2 (https://github.com/gopalasubramanium/modelsaar/releases/tag/v0.1.0-rc.2 — rc.1 plus the continuation capability probe, modelsaar probe
git clone https://github.com/gopalasubramanium/modelsaar.git modelsaar-preview && cd modelsaar-preview git checkout v0.1.0-rc.2 python3 -m venv .venv && . .venv/bin/activate && pip install -e . export MODELSAAR_HOME=~/.modelsaar-preview # separate config, keys and state modelsaar init --port 8485 # or --endpoint http://host:11434 --type ollama modelsaar discover # a decision model shows role "decision" modelsaar serve Contract and limits: docs/routing.md ("Decisions"); classifier configuration: docs/extending.md; the web page with the tester instructions and the smoke-test record: https://modelsaar.com/preview/decision-models/.
Quickest working setup
Prerequisites: Python 3.10+, and a running local inference server with at least one model (Ollama is the first-class path; any OpenAI-compatible server works with declared models).
# 1. install from the release source git clone --branch v0.3.0 https://github.com/gopalasubramanium/modelsaar.git && cd modelsaar python3 -m venv .venv && . .venv/bin/activate # or: uv venv && . .venv/bin/activate pip install -e . # or: uv pip install -e . # 2. initialise: finds Ollama on 127.0.0.1:11434 (or pass --endpoint), writes config + keys, discovers models modelsaar init # 3. check and verify modelsaar doctor # reachability, context assumptions, unknown capabilities, cloud aliases modelsaar probe --all # live checks: streaming, tools, JSON schema, vision, continuation, latency (uses local compute) # 4. run modelsaar serve # http://127.0.0.1:8484/v1 ; keys in ~/.modelsaar/keys/ # 5. first request (in another shell) modelsaar test # identifies the gateway (GET /healthz), GET /v1/models, one routed completion through `auto` Example request:
curl -s http://127.0.0.1:8484/v1/chat/completions \ -H "Authorization: Bearer $(head -1 ~/.modelsaar/keys/api_keys)" \ -H "Content-Type: application/json" \ -d '{"model":"auto","messages":[{"role":"user","content":"Write a Python function that parses ISO dates"}]}' \ -D - | grep -i x-modelsaar # X-ModelSaar-Deployment tells you what was selected Then connect a client. One command per client (pick yours; these are separate commands, not a pipeline): modelsaar client-config open-webui, modelsaar client-config openclaw, modelsaar client-config opencode (or opencode-v2), modelsaar client-config hermes. Each prints verified configuration; --apply merges file-based configs with a backup. For a GUI field that asks for an API key, print the key in a terminal with head -1 ~/.modelsaar/keys/api_keys and paste the value it prints (a line starting with msk_) — the $(...) form above is shell syntax, not a key. See docs/clients/.
No models yet? modelsaar demo starts a clearly labelled simulated backend so you can try the CLI, the status page and route explanations without downloading anything.
Virtual models (aliases)
Aliases are advertised in GET /v1/models only when at least one usable deployment backs them, with a truthful contract (context_length_min, tools/vision/json_schema = supported/partial/unsupported). Any concrete deployment id (e.g. ollama/qwen3.8:27b) can be requested directly; it still passes the same hard checks.
How a route is chosen
Requirements – structural analysis of the whole request: roles, images/audio, tools and tool_choice, response_format, outstanding tool-call ids, reasoning_content, conservative token accounting (input + output allowance + reasoning budget for thinking models).
Hard filters – role, health, locality policy, capability tri-state, effective context, backend field support, admission feasibility. A score can never override a failed filter.
Classification – deterministic multi-label task signals; an optional local classifier is consulted only for ambiguous cases, under a strict contract with timeout and fallback — either a small chat model answering JSON or, with routing.classifier.mode: decision, a decision model (Ollama /v1/systemone: nimble, clef, laya) answering one choice question with probabilities.
Ranking – transparent score per profile: evidence-based quality (measured > prior > uncalibrated, with uncertainty) minus latency, residency/load and overhead costs, plus a switching penalty for session affinity.
Decision record – request id, config hash, inferred task, requirements, exclusions with reasons, candidate breakdown, chosen deployment, evidence level, overhead. No prompt content.
Inspect: modelsaar explain -m "..." [--tools --image --json-schema], modelsaar decisions, GET /admin/decisions/
Tested support matrix
Legend: F fixture-tested over real HTTP with a controlled fake backend (CI); L executed live against real models (owner's GX10 via Tailscale, 2026-10-11); D documented from primary sources (config keys verified 2026-10-11); NOT RUN needs your hardware/client.
What is a limit of the current code, what is a limit of the runtime, and what is only a limit of the evidence so far. These notes apply to 0.3.0 unless an earlier version is named.
Context length. Ollama does not expose its default context for a model that is not loaded, and that default depends on the machine (4k, 32k or 256k by available VRAM). The gateway assumes the smallest (4096) until it has something better: a Modelfile num_ctx, an operator override, backends[].default_context_length, the value /api/ps reports while the model is loaded, or — opt-in — the last such observation (remember_served_context). A served value below a configured one always wins, so a wrong declaration cannot cause silent truncation. vLLM and llama.cpp report their served context directly. doctor names the source for every deployment.
Token counts. Exact, with the runtime's own chat template, on vLLM (/tokenize) and llama.cpp (/apply-template + /tokenize) — on a real llama.cpp server the counts matched prompt_tokens for English and Chinese prompts (hardware checks, 2026-12-05). Media is never counted by a tokenizer: images and video use a fixed allowance. Ollama documents no tokenizer endpoint, so its counts are a conservative estimate (chars/3, one token per wide character, overheads, +5 %). modelsaar probe --which token_estimate compares that estimate with the runtime's own usage.prompt_tokens on fixed synthetic prompts and raises it per deployment when the runtime counted more; it never lowers it.
Memory budgets. A resident model is counted at what the runtime itself reports (Ollama /api/ps: size for unified-memory pools, size_vram for GPU pools), which includes the context allocation that the 0.2.0 weights-file estimate missed. A model that is not resident is counted at the larger of its estimate and its last observation and is never loaded to be measured; resident models the gateway does not know are counted too. Still a budget, not an out-of-memory guarantee: a never-observed model has only its estimate, an observation is up to one refresh interval old, and nothing reads physical memory (docs/routing.md).
Ollama request fields. Only what Ollama documents, or what was measured on a named version, is forwarded. Refused with a reason rather than altered: tool_choice required/named, logit_bias, n > 1, output audio, remote image URLs. logprobs/top_logprobs are forwarded to Ollama ≥ 0.40.16, where they were measured to work, and refused on older or unknown versions; max_completion_tokens is sent under the documented name max_tokens; neutral values such as n: 1 no longer cause a refusal. For a field Ollama cannot serve, configure a deployment on a runtime that documents it — the gateway does not substitute one silently (table). On llama.cpp, required and named tools and a single-token bias were verified on real requests. Development builds also support multiple choices via backends[].max_chat_choices; two alternatives completed in streaming and non-streaming mode.
Evidence for the 0.2 features. Per feature, not blanket (docs/roadmap-matrix.md). Run on real models on the owner's hardware (2026-12-05, small synthetic inputs, protocol behaviour only): Responses and Messages, stored Responses, a closed-choice vote, a cascade escalation, a feedback policy build, activation and rollback, a judge pass, a small calibration run with isolated code tasks, OCR recognition with a real GLM-OCR model, managed load / leased unload on a real Ollama, llama-swap per-model unload, exact llama.cpp token counts, tool_choice required/named and logit_bias on a real llama.cpp deployment, and least-loaded routing across two physical hosts. On the GX10, a real vLLM deployment identified the first and last colours of a synthetic video. A second deployment returned a 2,048-dimensional embedding for that clip. An external layout detector and GLM-OCR read all four lines of a synthetic two-column page. Granite Guardian passed four user and assistant scoring controls. These checks cover the specified models and inputs. Representative-document accuracy, retrieval quality and performance on user traffic remain unmeasured. Video and embeddings · Layout and recognition.
Code evaluation. The harness executes model-written code inside bubblewrap, Docker or the opt-in macOS sandbox-exec backend. It reports code tasks as skipped when no verified isolation backend is available. In 0.3.0, modelsaar sandbox check checks the current host and prints the activation command when available. Mac isolation test.
Quality numbers. Catalogue priors are hypotheses. modelsaar eval --mode live --save-measurements replaces them with measurements on your hardware, per deployment fingerprint. modelsaar measurements shows, per deployment and task, whether routing is using a measurement (and on how many samples), a prior, or nothing.
Features added in 0.3.0. Image and audio embeddings through Ollama's native API, automatic eviction of idle models, a Conversations API, free-text ensembles (POST /v1/ensemble), a built-in page segmentation for the OCR layout stage (blocks and reading order on clean pages), an optional pinned ONNX detector for labelled OCR regions, explicit frame sampling for inline video, admin-only model downloads from a per-backend allowlist, and cluster placement and recoverable jobs. Fixture-tested; the roadmap matrix says which of them the owner has also run on real models.
Also available in 0.3.0, off by default: hosted tools on the Responses API — a catalogue the operator declares (document search over registered text, fixed HTTP calls on allow-listed hosts, tools of MCP servers on loopback addresses) with per-key allowlists, hard limits and an audit. Live checks cover a real model using all three tool types and a streamed file search through the OpenAI SDK.
Not built, and not planned as such: a code interpreter, a shell, computer use, image generation and open web search. docs/roadmap-expanded.md records what each expanded-roadmap item delivered and what it left out.
Fixed by design (the trust model, not a to-do): the gateway never fetches remote media, never runs model-written code on the host, never executes arbitrary commands, never substitutes a backend silently, never loads, evicts or downloads a model unless the operator has switched that on, and never connects anywhere on a model's request except to a tool endpoint the operator declared for that key.
Installation · Troubleshooting · Privacy & security · Hosted tools
Architecture · Routing · ADR-001 build vs adapt
Model catalogue evidence · Adding a deployment or adapter
Client guides: Open WebUI · OpenClaw · OpenCode · Hermes Agent · SDKs and Responses/Messages clients
Protocols · Pipelines · Lifecycle · Cascades and learning · Acceptance and roadmap matrix
Evaluation · Verification report · Release process · Roadmap
Progress & decision log
Created by Gopala Subramanium. An independent open-source project. Say thanks if ModelSaar has been useful to you.
Apache-2.0 for the gateway code (see LICENSE, NOTICE). Model weights are licensed by their publishers; ModelSaar neither bundles weights nor accepts any model terms on your behalf.
Released: Dec 5, 2026
Author: Gopala Subramanium
Both files in this release have provenance metadata.
View provenance details
Apache Software License (Apache-2.0)
ocr-layout layout-onnx video-frames dev
llm router gateway ollama openai-compatible local-first
Development Status 3 - Alpha
License OSI Approved :: Apache Software License
Programming Language Python :: 3
Topic Internet :: WWW/HTTP :: HTTP Servers
Release files for modelsaar 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 776.0 kB
Release files / modelsaar-0.3.0.tar.gz
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 Dec 5, 2026.
Release files / modelsaar-0.3.0-py3-none-any.whl
Security for modelsaar 0.3.0
Both files in this release have been uploaded with provenance metadata.
With provenance modelsaar-0.3.0.tar.gz Dec 5, 2026
With provenance modelsaar-0.3.0-py3-none-any.whl Dec 5, 2026
Attestation for modelsaar-0.3.0.tar.gz
Attestation for modelsaar-0.3.0-py3-none-any.whl
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
Dec 6, 2026 2 release files Full provenance
Dec 5, 2026 2 release files Full provenance
Dec 4, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from 4d99e05











