AI gateway and inference service
Architecture of enzimos-ai-gateway, enzimos-inference-service, enzimos-streaming-speech, enzimos-dictation and enzimos-agent-harness.
On-device AI in enzimOS is handled by per-user Rust services communicating over private mode-0600 Unix sockets. App capability consent stays completely separate in MCP Center.
| Service | Binary / Unit | Responsibility |
|---|---|---|
| Agent Harness | enzimos-agent-harness | Conversation sessions, workspace file tools, Bubblewrap-sandboxed commands, skills and MCP client. |
| AI Gateway | enzimos-ai-gateway | Explicit routing between the local inference socket and configured OpenAI-compatible HTTPS endpoints. Owns remote credentials. |
| Inference Service | enzimos-inference | Supervises pinned llama.cpp, whisper.cpp and sherpa-onnx runtimes, verified model registry, CPU/memory limits, calibration and idle unload. |
| Streaming Speech | enzimos-streaming-speech.service | Local low-latency streaming English recognition from PipeWire audio in memory for Voice Typing. |
| Dictation | enzimos-dictation | Handles Super + H hold/tap takes, microphone consent, streaming speech or gateway transcription and enzui_text_commit_v1 insertion. |
Assistant / Writing Tools / Apps
-> enzimos-ai-gateway (per-user Unix socket)
-> enzimos-inference -> llama.cpp worker (for the installed text model)
-> serial speech worker (whisper-cli / sherpa-onnx-offline)
-> explicitly configured OpenAI-compatible HTTPS provider (opt-in, no fallback)
Voice Typing (Super + H) -> enzimos-dictation
-> enzimos-streaming-speech (local in-memory English stream)
-> fallback: enzimos-ai-gateway -> enzimos-inference (Whisper base / Parakeet TDT / Moonshine)
-> compositor enzui_text_commit_v1 (or clipboard fallback)llama.cpp is never exposed on a TCP port. All local IPC uses user-owned mode-0700 runtime directories.
The no-fallback rule
enzimos-ai-gateway never falls back from local to a cloud provider. If a local request fails or times out, the caller receives an error and the prompt never leaves the machine.
Model catalog and registry
A standard installation fetches local models on demand from the signed catalog at ai.enzim.dev.
Download text or speech models from Settings › Agents or choose a local text model from the Assistant model selector.
The local registry tracks downloaded models so they are available after a reboot. Image input for LFM3-VL-2B needs a separate vision projector.
Manage and inspect local models from the CLI:
enzimos-inference-models list
enzimos-inference-models catalog
enzimos-inference-models fetch parakeet-tdt-0.6b-v3 --default
enzimos-inference-models add ~/Downloads/model.gguf
enzimos-inference-models default whisper-base
enzimos-inference-models remove IDCatalog downloads are checked against the signed catalog metadata before the model is registered.
Gateway endpoints and providers
enzimos-ai-gateway --config ~/.config/enzimos/ai-providers.json \
--preferences ~/.local/state/enzimos-ai-gateway/preferences.json \
--socket "$XDG_RUNTIME_DIR/enzimos-ai-gateway/service.sock"| Endpoint | Behaviour |
|---|---|
GET /health | Ready status and active default_provider |
GET /v1/providers | Configured providers, kinds, enabled state and capabilities |
GET /v1/models[?provider=NAME] | Models offered by the selected or named provider |
GET/POST /v1/preferences | Revision-checked default_provider updates |
POST /v1/chat/completions | Streamed or non-streamed chat completions |
POST /v1/responses | OpenAI Responses API (explicit remote providers) |
POST /v1/audio/transcriptions | Local PCM WAV transcription routed to inference service |
Supported provider kinds are local, openai-compatible (HTTPS required except loopback, bearer token from a mode-0600 file), and an experimental chatgpt-login PKCE/Responses adapter (tested against loopback fixtures; real-account access is not claimed as supported).
Inference endpoints, admission and limits
| Endpoint | Behaviour |
|---|---|
GET /health, /status, /v1/models | Never load a model; /status reports up to four installed_runtimes |
POST /v1/chat/completions | Native chat and tool schema; 512-token output cap; enable_thinking=false default |
POST /completion, /tokenize | Raw completion and context-budget tokenization |
POST /v1/audio/transcriptions | Local JSON {model, wav_base64, language?} (16 kHz mono 16-bit PCM WAV, up to 60 s) |
Resource policy:
- One active native worker per user, at most two admitted jobs (one running, one waiting).
- Default context 4,608 tokens (4,096 input + 512 output headroom), batch 256 / ubatch 128, in-memory prefix reuse per
conversation_id, no disk prompt cache. - Default memory budget 1,900 MiB; systemd user unit enforces
MemoryHigh=2400M,MemoryMax=2688M,MemorySwapMax=0,CPUQuota=200%,CPUWeight=20,Nice=15,TasksMax=64,RestrictAddressFamilies=AF_UNIX. - Workers run on at most two CPU threads at nice 15 with no core dumps and
no-new-privileges. - Automatic GPU selection (
vulkan,sycl,cuda) is used only when an exact hardware/model/runtime calibration receipt exists; unmeasured hardware conservatively uses CPU.
Run CPU calibration explicitly with enzimos-inference-calibrate:
enzimos-inference-calibrate --run --config /private/inference.json \
--model lfm3-vl-2b --receipt /private/calibration.json \
--output-config /private/inference-calibrated.jsonBuilding and testing
# enzimos-inference-service
cargo build --release --locked
cargo build --example fake_engine --locked
cargo test --locked
# enzimos-ai-gateway
cargo test --locked
# enzimos-agent-harness
cargo build --example fake_mcp --locked
cargo test --locked
# enzimos-dictation
cargo test --lockedAll four repositories require Linux and Rust 1.95 or newer and run their test suites offline against private sockets and fixture runtimes.