A hardened black box around [Ollama + model] — authenticated, encrypted, audited inference over a tiny, stable contract. Local, on the LAN, or over the web.
Raw Ollama has no auth and no TLS. KQAI is the missing layer: it turns an open port into a guarded, auditable one — and never lets the AI make the call.
KAILib can already point an app's model call at an Ollama anywhere — localhost, a LAN box, a machine on the web — by config alone. But Ollama's native API has no authentication and no TLS, and it exposes model management next to inference. Reaching a remote Ollama directly means plaintext prompts on the wire, an open door for anyone who finds the port, and no record that anything happened.
KQAI sits in front of [Ollama + model] and makes that hop secure, narrow, authenticated, encrypted, and auditable — without the calling app changing a single line.
Anything not on this list is not reachable — no model pull/delete, no config passthrough, no arbitrary Ollama API. That narrowness is the security property. The shapes mirror KAILib's own types, so the client maps 1:1.
One-shot completion. Returns a KAILib-shaped Completion: text, model, token counts.
Token-by-token streaming. Not cached, not retried mid-flight — a half-emitted stream can't be replayed.
Cheap and pollable — reachability, model, breaker state, load. What a router hits to pick a box.
The only port on the network is KQAI's TLS listener. Ollama is bound to loopback — nothing reaches the model except KQAI itself. And because the KAILib-side connector is just another LLMProvider, moving from a local Ollama to a fleet of KQAIs is zero app-code change.
max_tokens cap. Appliances OOM on courtesy.infer event (identity, model, token counts, latency — not the prompt by default). Optional emit to PORTAGE for an offline-verifiable receipt.Same KAILib surface throughout — client.ask(...) never changes. What changes is the box behind it.
Stand a KQAI up in front of your own Ollama with one token. On the app side, point an AIBBProvider at it and call it like any model.
from kqai.config import KQAIConfig, Identity from kqai.server import KQAIServer cfg = KQAIConfig( tls_cert="cert.pem", tls_key="key.pem", # TLS is not optional model="llama3.1", # the one model this box serves tokens={"workshop-secret": Identity("workshop-app", models=["llama3.1"])}, ) KQAIServer(cfg).serve() # https://127.0.0.1:8443 — audited, on kai_lib
from kai_lib import LLMClient from kai_lib.llm import AIBBProvider client = LLMClient(AIBBProvider( "https://127.0.0.1:8443", token="workshop-secret", pin="sha256/…", # pin the box's cert — no MITM model="llama3.1")) print(client.ask("What's the torque spec for the caliper bolt?")) # → "42 Nm" — over TLS, authenticated, and logged on the box
Give each caller a client certificate and its own model allowlist + cap. Then compose several KQAIs behind one RouterProvider that prefers local → LAN → web and routes around a dead box on its circuit breaker.
cfg = KQAIConfig( tls_cert="box.pem", tls_key="box.key", model="llama3.1", ollama_host="http://127.0.0.1:11434", # boxed — loopback only max_tokens=1024, # server-enforced ceiling tokens={ "svc-dispatch": Identity("dispatch", models=["llama3.1"], max_tokens=512), "svc-report": Identity("reporting", models=["llama3.1"]), }, )
from kai_lib import KAIApp, LLMClient from kai_lib.llm import RouterProvider, AIBBProvider def box(url): return AIBBProvider(url, client_cert="client.pem", ca="ca.pem", pin="sha256/…") # mutual TLS router = RouterProvider([ box("https://127.0.0.1:8443"), # local sidecar box("https://ai-box.lan:8443"), # LAN appliance box("https://infer.koperwas.com"), # web endpoint ], strategy="prefer_local") # local → LAN → web app = KAIApp(llm=LLMClient(router)) print(app.llm.ask("hello")) # pull the local box's plug → the LAN box answers. No app code changed.
AIBBProvider carries its own circuit breaker, so a tripped box drops out of the rotation and the router moves on — failover from machinery KAILib already has, not new code.The same secured channel, upgraded to a WebSocket for live tokens — the transport a voice/eyes-free client wants.
for tok in client.stream("Walk me through the failover procedure."): speak(tok) # WSS /v1/stream — not cached, not retried mid-flight
Once the inference hop is authenticated, encrypted, and audited, whole classes of deployment that were “don't put that on the wire” become ordinary.
SYNTHEKOS's own to-do list says: “encrypt the hop to a separate Ollama box.” That's precisely KQAI. Point the sovereign grounded-AI appliance at a KQAI and its model can live on another, hardened box — while grounding and abstention stay entirely SYNTHEKOS's.
closes a written SYNTHEKOS gapEvery infer event can emit to PORTAGE for a hash-chained, offline-verifiable receipt — who queried which model, when, and with what result. KQAI records; PORTAGE notarizes. The compliance artifact a regulated buyer actually wants.
Sensors, dashboards, and test harnesses get an authenticated key and a stable three-verb contract — grounded, capped, audited answers — without ever touching a raw model port.
EUser-style machine identityPer-token identity, allowlist, and quota let a single boxed model serve several apps or teams, each seeing only its own models and each held to its own cap — on hardware that never leaves the building.
policy at the edgeBehind a real cert or a tunnel with Access in front, the same box becomes a private web endpoint — authenticated and audited — with the model still boxed on loopback. Sovereign doesn't have to mean “only on this desk.”
local · LAN · web — same codeBecause a KQAI is just another LLMProvider, upgrading a model, moving it to a beefier box, or splitting traffic across a fleet is a config change. The application never learns the difference.
generate + health and WSS token stream, over TLS, with token auth, model allowlist, max_tokens cap, cert pinning, and audit — are built and tested on KAILib (proven end-to-end on localhost with a fake provider; a real-Ollama run is still pending). Mutual-TLS + per-identity authz (Phase 3) and the RouterProvider fleet (Phase 4) are designed and on the roadmap. The badges above say which is which — a system whose whole claim is “it tells you the truth” starts with the page doing the same.