Keystone
A free, virtual AI Key and AI Port for UniFi Protect.
Website · Dashboard demo · Install · Turn on features · Hardware · FAQ
UniFi Protect's best AI features — plain-English search, detailed event descriptions, face and license plate recognition, and smart detections on third-party cameras — normally require Ubiquiti's AI Key ($799) and AI Port ($199 for up to three HD cameras). Keystone is free software that takes their place: run it on a computer you already own, and open models do the same jobs on your own network.
Protect adopts Keystone in UniFi Protect → UniFi Devices as a virtual AI Key (and optionally a virtual AI Port), just like real Ubiquiti hardware. No database hacks, no patched Protect files, and no cloud subscriptions.
Works with both UniFi and third-party cameras. UniFi cameras with smart detections (G4 and newer) get plain-English search and event descriptions, and G4/G5 cameras also get face and license plate recognition. Third-party ONVIF cameras (Reolink, Amcrest, or Nest through Scrypted) and older UniFi cameras without smart detections pair with the optional virtual AI Port to get all of that plus Protect's smart detections.
Unofficial community project; not affiliated with or endorsed by Ubiquiti Inc. No vendor firmware, proprietary binaries, or vendor model weights are included. Tested on UniFi Protect 7.3.74 and 7.4.112.
!UniFi Protect showing Keystone adopted as a virtual AI Key and AI Port
What you get
- Plain-English & photo search (Find Anything) — on by default
- Event descriptions — needs a vision model (Ollama or API)
- Smart detections on third-party cameras (virtual AI Port) — off by default
- Face recognition & Enhance Face — off by default
- License plate recognition — off by default
config.yaml so captions say "Alice's sedan pulls into the driveway."
- Speech transcripts & smart audio — off by default
- Native Protect filters, alarms & Home Assistant
tesla, ups, dog, backpack, red, …) so Protect filters and automations work out of the box. Optional webhooks and MQTT send descriptions to Home Assistant or ntfy.
Quick start
Pick the install method that matches your setup. Every method sets up both Keystone and the local search database Protect 7.3+ uses for Find Anything.
Docker Compose
On a Linux host with Docker Compose and Python 3 (no repository clone needed):
mkdir keystone && cd keystone
curl -fsSLO https://raw.githubusercontent.com/seeARMS/keystone/main/docker-compose.yml
curl -fsSLO https://raw.githubusercontent.com/seeARMS/keystone/main/scripts/setup-compose.py
python3 setup-compose.py
docker compose up -d
During setup, enter your UniFi Protect controller's IP address. If you want event descriptions, enter your Ollama or AI server URL; press Enter to skip descriptions for now (Find Anything search still works right away).
Updating, shared Docker hosts (OMV / TrueNAS / Synology), and why host networking?
- Updating: Run
docker compose pull && docker compose up -d. If a release updatesdocker-compose.ymlor setup options, re-downloaddocker-compose.ymlandsetup-compose.pyand rerunpython3 setup-compose.pyfirst — it keeps your existing settings and database password. - Pinning versions or building locally:
latesttracks the newest release. SetKEYSTONE_IMAGE_TAGin.envto pin a version (for exampleKEYSTONE_IMAGE_TAG=0.1.1) or followmainwithedge. To build from a cloned checkout instead of pulling from GHCR, rundocker compose -f docker-compose.yml -f docker-compose.build.yml up -d --build. - Why host networking? Both containers use
network_mode: hostso Protect can discover Keystone on your LAN and reach the exact ports it expects. PostgreSQL restricts its admin account to127.0.0.1and Protect's account strictly to your controller's IP over TLS; Keystone runs as a non-root user with onlyNET_BIND_SERVICEonpython3. - Shared Docker hosts (OMV, TrueNAS, Synology, Portainer): Host networking can collide with existing services on ports
443,5432,8080, or10001/udp. Run the all-in-one image (ghcr.io/seearms/keystone-aio) on its own LAN IP with Dockermacvlan, setKEYSTONE_CONTROLLER_HOSTto Protect's IP, and mount persistent storage at/data. See dedicated-IP deployments.
Proxmox LXC, Debian, or Ubuntu
On a Proxmox host (creates a Debian 13 LXC with 2 cores, 4 GB RAM, and a 16 GB disk):
bash -c "$(curl -fsSL https://raw.githubusercontent.com/seeARMS/keystone/main/scripts/proxmox-lxc.sh)"
Inside an existing Debian 13+ or Ubuntu 24.04+ container or VM (run as root):
bash -c "$(curl -fsSL https://raw.githubusercontent.com/seeARMS/keystone/main/scripts/install.sh)"
Enter your Protect controller's IP and an optional vision server URL (leave it blank to start with Find Anything search only). The first start downloads about 1.6 GB of models.
VLANs, static IPs, and updating Proxmox / Linux installs
- The Proxmox script uses
vmbr0with DHCP by default. SetKEYSTONE_VLAN, orKEYSTONE_IPandKEYSTONE_GATEWAY, before running it for a VLAN or static IP (other options are listed at the top of scripts/proxmox-lxc.sh). Give the container a fixed address (DHCP reservation or static IP) so Protect keeps finding it. - Config lives at
/etc/keystone/config.yaml. Apply edits withsystemctl restart keystone. - To update, run the
install.shone-liner again inside the container or VM — it keeps your config, database, and state.
Unraid
Add the template from the Unraid terminal (until it's in Community Applications):
wget -O /boot/config/plugins/dockerMan/templates-user/my-Keystone.xml \
https://raw.githubusercontent.com/seeARMS/keystone/main/unraid/keystone.xml
Then go to Docker → Add Container and choose Keystone. Set Network Type to br0 with a fixed IP, enter your Protect controller's IP (and optionally a vision provider/URL for descriptions), and apply. Everything is stored in /mnt/user/appdata/keystone; template fields override the matching settings in config.yaml.
Manual install (Python 3.12+ / systemd without Docker)
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
keystone init --controller 192.0.2.10 --ollama http://192.0.2.20:11434 --model qwen3.5:9b
keystone trust -c config.yaml --pin
keystone run -c config.yaml
For Find Anything search on Protect 7.3+ without Docker Compose, install PostgreSQL 16+ with pgvector, enable TLS (ssl = on), run docker/init-protect-db.sql, and set device.sync_postgres_password: true in config.yaml.
Status dashboard: Keystone runs a local status page on 127.0.0.1:8088 (no login). On a headless host, tunnel it with ssh -L 8088:127.0.0.1:8088 [email protected] and open http://127.0.0.1:8088 — or set web.bind_host: 0.0.0.0 in config.yaml on a trusted LAN.
After adopting in Protect
Open UniFi Protect → UniFi Devices and adopt the discovered AI Key. Initial credentials are ubnt / ubnt and Protect rotates them automatically on adoption.
What works out of the box: Only Find Anything search is turned on by default. Event descriptions require a vision server (Ollama or an API), and optional features — speech transcripts, faces, license plates, Enhance Face, third-party camera detections, and backfilling older footage — start off in config.yaml so Keystone doesn't unexpectedly download extra models, use extra RAM, or enable biometric/audio features without you opting in.
| Feature | Default | Turn on in config.yaml | Turn on in UniFi Protect |
| --- | --- | --- | --- |
| Find Anything search | On | Already enabled (embeddings.enabled: true) | Settings → Intelligence → Basic Object Recognition, plus Smart Detections on each camera |
| Event descriptions | Needs vision model (off if URL left blank) | Set vision.provider, vision.base_url, and vision.model | Settings → Intelligence → AI Summary |
| Speech-to-Text (event transcripts) | Off | stt.enabled: true | Settings → Intelligence → Speech-to-Text, plus Speech audio detection on cameras with a mic |
| Face recognition | Off | faces.enabled: true | G4/G5 cameras: Legacy Camera Enhancement → Face Recognition
Paired ONVIF cameras: Face smart detection |
| License plates | Off | lpr.enabled: true | G4/G5 cameras: Legacy Camera Enhancement → License Plate Recognition
Paired ONVIF cameras: License Plate smart detection |
| Enhance Face | Off | enhance.enabled: true | Enhance button on face crops in Protect |
| Third-party cameras (AI Port) | Off | aiport.enabled: true | Adopt AI Port in UniFi Devices, pair ONVIF cameras, enable smart detections |
| Backfill older events | Off | embeddings.retroactive_processing: true | Starts automatically once enabled |
After editing config.yaml, restart Keystone (docker compose restart, systemctl restart keystone, or restart the Unraid container). Protect picks up newly enabled features automatically — no re-adoption needed.
Tip: Not seeing descriptions or transcripts? Open the Keystone dashboard (:8088). Every service card shows whether it's Ready, Off / Disabled (with the config key to turn it on), or reporting an error. Note also that Speech-to-Text transcribes spoken audio from camera microphones into text — Keystone does not generate spoken audio narration of descriptions.
Setting up optional features
Event descriptions (Ollama, LM Studio, oMLX, OpenAI, Anthropic)
To turn on event descriptions, point vision in config.yaml at a vision-capable model, then turn on AI Summary under Protect → Settings → Intelligence.
- Ollama (default provider): keep
vision.provider: ollamaand setvision.base_url(for examplehttp://192.0.2.20:11434) andvision.model(defaultqwen3.5:9b, orqwen3.5:4bfor smaller GPUs). - LM Studio, oMLX, llama.cpp, or vLLM: set
provider: openai-compatible, use the server's/v1base URL, and setmodelto the exact model ID it serves:
vision:
provider: openai-compatible
base_url: http://192.0.2.20:1234/v1
model: your-vision-model
# api_key: set-if-required
- Hosted OpenAI or Anthropic: set
providertoopenaioranthropic,base_urltohttps://api.openai.com/v1orhttps://api.anthropic.com/v1, plusmodelandapi_key. - Skip descriptions: set
vision.provider: disabled. Find Anything search and detections still work with no vision server.
Extra vision options (single-image models, camera layout hints)
- OpenAI-compatible servers must accept image inputs and JSON mode (
response_format: {"type": "json_object"}) on/v1/chat/completions. - If your model only accepts one image per request (or you want faster descriptions), set
vision.frame_layout: stripto combine the 3 frames into one image, orhybridfor a motion strip plus one full-res keyframe. Loweringvision.max_image_sideto640also speeds up prompt evaluation. - You can add optional per-camera layout hints under
cameras:in config.example.yaml so descriptions know which way is entering vs. exiting or which road is the public street.
Third-party cameras (virtual AI Port & Nest)
Turn on the virtual AI Port in config.yaml:
aiport:
enabled: true
Restart Keystone, adopt the discovered AI Port in UniFi Protect → UniFi Devices, pair your ONVIF cameras (or older UniFi cameras without smart detections) to it (up to 10 HD cameras), and enable the smart detections you want on each camera. Package detection and all 9 Protect Smart Audio alarms load automatically only when you enable them in Protect.
Nest and other cloud cameras: Protect only adds third-party cameras that speak ONVIF. Use Scrypted (with its Google Device Access and ONVIF plugins) to expose each Nest camera to Protect as an ONVIF camera, then pair it with Keystone's AI Port like any other third-party camera. UniFi and ONVIF cameras don't need Scrypted.
Speech-to-Text (event transcripts)
Off by default. Turn it on in config.yaml:
stt:
enabled: true
backend: onnx # local Whisper on CPU (or "openai" for a remote Whisper server)
model: whisper-base # whisper-tiny | whisper-base | whisper-small
Restart Keystone, then enable Speech-to-Text under Protect → Settings → Intelligence (and Speech audio detection on audio-capable cameras). Runs locally on CPU with no extra packages; cameras without a microphone return an empty transcript instead of stalling.
License plate recognition
Off by default. Turn it on in config.yaml:
lpr:
enabled: true
Optional: name known vehicles in event descriptions
vehicles:
ABC1234: "Alice's white sedan"
Restart Keystone, then enable Legacy Camera Enhancement → License Plate Recognition on G4/G5 cameras (or License Plate smart detection on cameras paired to the AI Port). Plates appear under Known Vehicles in Protect.
Face recognition & Enhance Face
Both are off by default. Turn on whichever you want in config.yaml:
faces:
enabled: true # feeds Protect's Faces (no photo folder required)
enhance:
enabled: true # answers Protect's "Enhance" button on face crops
backend: gfpgan # or "pillow" for a zero-download, low-RAM fallback
Restart Keystone, then enable Legacy Camera Enhancement → Face Recognition on G4/G5 cameras (or Face smart detection on AI Port cameras). You can name people directly inside Protect's Faces tab without creating a photo folder. If you also want household names used inside written event descriptions, add a local photo gallery (see below).
Model license notice: Face recognition downloads pretrained InsightFace weights at runtime (verified by SHA-256). InsightFace licenses these weights for non-commercial research only. For other uses, including routine household monitoring, obtain appropriate rights before enabling faces.enabled: true. See InsightFace's licensing terms. Keystone does not bundle or redistribute them.
> Biometric & privacy notice: When faces.enabled: true, Keystone computes a temporary face embedding for every clear face detected in person events (not only people in your gallery). You are responsible for complying with applicable local biometric and privacy laws — such as Illinois BIPA or GDPR — especially where cameras cover public or shared spaces.
Local face gallery (names in captions), CLI tools, and G6 merge tip
To use household names inside event descriptions ("Alex walks up to the front door"), put 5–10 clear, varied photos of each person in (one clear face per photo; lock down with chmod 700). Keystone syncs the folder automatically when files change.
Useful commands:
keystone faces list -c config.yaml # people, photo counts, look-alike check
keystone faces sync -c config.yaml --force # re-embed the whole gallery
keystone faces test -c config.yaml frame.jpg clip.mp4 # test matches and scores
- Conservative by default: Blurry, distant (
min_face_px: 40), or side-profile faces are skipped, and a person is only named when their match clearsmin_similarity(0.45) and beats the runner-up bymin_margin(0.10). The vision model is never allowed to guess a name. - Cross-camera carryover: When a person is clearly recognized on one camera, Keystone can carry their name to nearby cameras within 90 seconds if the appearance or companion object (car, dog, package) matches with high confidence and no conflicting face is visible.
- G6 cameras: Keystone's face clusters start separate from G6 cameras' built-in clusters in Protect. Merge the same person's groups once in Protect → Faces and later sightings follow automatically.
- Enhance Face (
enhance.enabled: true): Uses GFPGAN v1.4 (Apache-2.0, ~340 MB download, ~1 s per face on 2 CPU threads) and automatically unloads from RAM after 5 idle minutes (idle_unload_seconds: 300). Falls back topillowif the model can't load.
Backfilling older events (retroactive Find Anything search)
Off by default so existing installs don't kick off a multi-hour backfill unexpectedly. On Protect 7.3.74+, set embeddings.retroactive_processing: true (or KEYSTONE_EMBEDDINGS_RETROACTIVE=true) and restart Keystone.
- Protect sends historical events in batches and marks each done as Keystone indexes it.
- Live events always come first: Backfill uses its own separate queue and pauses whenever live camera events are waiting.
- Low-power hosts: Set
embeddings.retroactive_batch_delay_ms: 200(or500) on a Raspberry Pi or N100 mini PC to leave CPU headroom during long backfills. - Track progress on the dashboard's Find Anything card or in
/api/status.
Hardware & sizing
What computer do I need?
- RAM & CPU:
embeddings.quantization: int8).
- 4 GB RAM, 2–4 CPU cores (typical): comfortable for Find Anything search and up to ~7 HD third-party cameras on CPU.
- 8 GB RAM: recommended if you turn on faces, license plates, speech transcripts, and Enhance Face all at once.
- Do I need a GPU?
qwen3.5:9b (or qwen3.5:4b on 6–8 GB cards). An integrated GPU works too, at about 20–25 seconds per description. Without a GPU, you can use a hosted OpenAI or Anthropic API or disable descriptions.
- Google Coral: Not supported. Keystone uses ONNX models that don't fit in Coral's ~8 MB memory, and regular CPUs handle motion-gated detection easily (~6% CPU for seven 1080p cameras on an Intel Core Ultra 5).
Memory & speed at a glance
| Feature | Memory | Typical speed | Notes |
| --- | --- | --- | --- |
| Base (Find Anything + AI Port detections) | ~3.5–4.5 GB RAM (~2 GB with int8) | Instant search; ~6% CPU for 7× 1080p cameras | Runs on CPU |
| Event descriptions (vision model) | 6–12 GB VRAM on your Ollama host (or cloud API) | 2–5 s (discrete GPU) / ~24 s (iGPU) | Optional; runs on separate box or cloud |
| Face recognition (optional) | +0.3–0.5 GB RAM | ~0.1–0.3 s per frame | CPU |
| Speech transcripts (optional) | +0.3 GB RAM (whisper-base) | < 1 s for a 30 s clip | CPU (whisper-small uses ~1 GB) |
| License plates (optional) | +0.15 GB RAM | ~50 ms per frame | CPU; shared across AI Key & AI Port |
| Package detection (AI Port) | ~11 MB model (loads only if used) | ~60–100 ms per scan | CPU; loads when enabled in Protect |
Tuning for 2–4 GB hosts (Raspberry Pi, N100, small LXCs) & faster descriptions
| Profile | Settings | CLIP RAM (measured)¹ | Est. Keystone total² |
| --- | --- | --- | --- |
| Full (default) | quantization: fp32, lazy_text_model: true, analyze_max_width: 960 | ~1.6 GB idle, ~2.3 GB after first text search | ~3.5–4.5 GB |
| Balanced | quantization: int8 | ~0.42 GB idle, ~0.55–0.8 GB after first text search | ~2–3 GB |
| Lite | int8, text_model_idle_unload_seconds: 300, analyze_max_width: 640, detector_variant: yolox_tiny, embeddings.threads: 2 | ~0.42–0.8 GB | ~1.5–2 GB |
embeddings.quantization: int8(KEYSTONE_EMBEDDINGS_QUANTIZATION) is the biggest RAM saver (~65–74% less RAM thanfp32). On ARM CPUs, search quality matchesfp32closely (cosine ≥ 0.986); on x86 AVX2 CPUs there is a slight drop in ranking precision, so keepfp32if you have ≥ 4–6 GB RAM. Avoidfp16on CPU (slower and uses more RAM; GPU only) andq4(about 4× slower on CPU).embeddings.lazy_text_model: true(default) only loads the search text encoder on your first Find Anything query. Setembeddings.text_model_idle_unload_seconds: 300to free it again when idle.aiport.analyze_max_width: 640(default960, min320) lowers decode CPU on paired ONVIF cameras without affecting detection zone accuracy.- Faster descriptions: Set
vision.frame_layout: hybridorstripto cut vision latency roughly in half, or lowervision.max_image_sideto640.
onnxruntime CPU provider, 4 threads, per-process RSS. ² Whole-process estimate; actual usage depends on camera count and enabled features.
Optional Intel GPU / NPU acceleration (OpenVINO & VA-API)
Keystone defaults to CPU and software video decode so it works everywhere with no drivers. On Intel Core Ultra, Arc, or N100 hosts, you can offload ONNX models to OpenVINO and AI Port video decode to VA-API:
pip install -e ".[openvino]"
acceleration:
provider: auto # auto | cpu | openvino
openvino_device: "AUTO:GPU,CPU" # GPU | NPU | CPU | AUTO:GPU,CPU | AUTO:NPU,GPU,CPU
ffmpeg_hwaccel: auto # none | auto | vaapi (AI Port decode only)
If OpenVINO or VA-API fails to initialize, Keystone logs a warning and falls back to CPU automatically. Active providers show up on the status dashboard and in /api/status.
Troubleshooting Intel GPU resets (Linux xe driver) & OpenVINO cache
- Compiled OpenVINO blobs are cached in
across restarts (/ov_cache acceleration.openvino_cache_dir). Precision defaults toopenvino_precision: FP16(GPU/NPU only) and VA-API defaults toffmpeg_device: /dev/dri/renderD128. - GPU resets on Intel Linux
xedrivers (Xe2/Xe3): OpenVINO's GPU plugin can hit a CCS page fault /Engine memory CAT errorwhen Intel compute-runtime (NEO) packs pooled OpenCL USM buffers against an unmapped 16 MiB boundary. Keystone setsGPU_ENABLE_LARGE_ALLOCATIONS=YESby default on GPU sessions (acceleration.openvino_gpu_large_allocations: true) to bypass that pool. Withonnxruntime-openvino 1.24/ OpenVINO 2025.4, setopenvino_device: GPUdirectly so OpenVINO'sAUTOplugin doesn't strip the property. - Automatic recovery: If a GPU reset still drops the OpenCL context (
CL_OUT_OF_RESOURCES), after 3 device-lost errors within 2 minutes Keystone logs the cause and exits with code75so systemd or Docker restarts it with a fresh context. If that happens 3 times within 30 minutes, Keystone starts on CPU instead to prevent a restart loop, and the dashboard flags the GPU as suspended. A manual restart (systemctl restart keystone/docker compose restart) clears that history and retries the GPU. Tune or disable withacceleration.restart_on_gpu_loss,gpu_loss_max_restarts, andgpu_loss_window_minutes(setrestart_on_gpu_loss: falseif running without a process supervisor).
Under the hood (Technical details)
Architecture & protocol compatibility
- AI Key (
UP-AI-KEY,0xa5f0): Advertises via Ubiquiti UDP10001discovery, serves/api/info,/api/adopt, and/api/readoptover HTTPS (:8080), authenticates to Protect via mTLS with pinned controller SHA-256 certificates, handles UCP4 control commands (:7442), and syncs rotated passwords to PostgreSQL (unifi-protectrole) for Protect 7.3+isSearchHostvector search. - Vision pipeline: Samples 3 chronological frames (
±1.0saround each event'skeyMoment, widened to±2.0son clips≥ 15s, at960px) for motion-aware VLM captions and maps outputs plus class-filtered attributes onto Protect's 5,375-tagramTagsvocabulary. Optionally injects per-camera spatial hints (cameras:inconfig.yaml) and multi-view, episode-chained chronological cross-camera sightings (vision.cross_camera_context_seconds, default90s, strong similarity0.62, cross-view floor0.35, up to3sightings) so distant, rear, indoor, or IR angles benefit from earlier clearer cameras across vehicles, people, animals, and deliveries. Interactive on-demand summaries (RequestAI→:7968/on_demand_inference) narrow long exports to a 4-second window and run a fast 1-frame640pxpass to stay inside Protect's UI timeout. - Find Anything (
:7443): Runs local CLIP ViT-L/14 (768-dim ONNX) for object crop indexing,NL_PARSEtext queries (with relative time-window parsing),IMAGE_SEARCH, and optional CLIP reverification. Protect 7.4's release notes say detection confidence verification has been removed, so expect reverification jobs only from Protect 7.3. - Speech-to-Text (
speechToText, featureFlagssupportTts&supportStt): Fetches Protect's audio-only MP4 export (skipVideo=true, retrying transient404s), decodes 16 kHz mono audio with FFmpeg, transcribes with Whisper (log-mel + timestamp-constrained greedy decoding on onnxruntime, with no-speech and leading-silence gating), and POSTs{camera, event, stt: [{startMs, endMs, text}]}to/internal/aiprocessors/speech-to-text. Segment timestamps use Unix epoch milliseconds for synchronized event playback; queued/active jobs are reported to Protect asUI_AUTO_STT. - Built-in AI Port (
UP AI PORT X,0xa5f5): Uses Protect's higher-capacity0xa5f5profile (3.0capacity points, vs.1.0on a standardUP-AI-Port) so a single Keystone instance can pair up to 10x 1080p ONVIF cameras (in Protect's UI it appears asUP AI PORT X). Relays video to Protect'sms(:7550/:7551) using zero-video-transcodeextendedFlvwith AVC sequence-header normalization and automatic silent-audio fallback, runs motion-gated Apache-2.0 YOLOX ONNX detection, and evaluates Protect's configured polygonzonesandexcludeZones, line-crossing tripwires (lines, A2B/B2A/both with per-object counts) and loitering zones (loiterZones, per-object dwell times; tracks dwelling in a loiter zone are exempt from parked-object suppression until they trigger). - AI Port package detection (
package/packageMaincam): Keystone advertises bothpackage(smartDetectTypes) andpackageMaincam(hasPackageZoneSupportForPrimaryLens) infeatures.smartDetectwhenaiport.package_enabled: true(default). The Apache-2.0 D-FINE Small Objects365 ONNX model (class21,Storage box) loads lazily on the first scan for a camera where Protect enabledpackage, runs throttled everyaiport.package_scan_interval_secondsduring motion or person/vehicle presence plus+3sand+8sfollow-up scans after a person leaves, filters by Protect's configured package zones andexcludeZones, optionally checks each 15%-padded candidate crop via zero-shot CLIP cosine margin against parcel vs. porch false-positive prompts (falling back to a stricter D-FINE score floor if CLIP is unavailable), and suppresses already-reported stationary boxes by IoU (1800s TTL, cleared after 3 consecutive absent scans) so each delivered box emits one crispEventSmartDetectarrival event with crop snapshot. - AI Port Smart Audio detection (all 9
alrmclasses): For paired cameras with audio, Keystone advertises all 9 ProtectAUDIO_TYPES(alrmSpeak,alrmBark,alrmBabyCry,alrmSmoke,alrmCmonx,alrmSiren,alrmBurglar,alrmCarHorn,alrmGlassBreak) infeatures.smartDetect(Protect derivessmartDetectAudioTypesfrom it) and reportsisAudioEventReady. When Protect enables anyenableAlrmflags viaChangeAudioEventsSettings, Keystone starts one shared audio-only FFmpeg decoder (16 kHz mono PCM) for that camera. Silero VAD (MIT, shared ONNX session, per-camera RNN state) loads lazily only ifalrmSpeakis enabled; Google YAMNet (Apache-2.0, shared ONNX session, 0.975 s sliding window / 0.48 s hop) loads lazily only if any of the other 8 audio alarms is enabled. Both feed a per-camera multi-alarm tracker (AudioEventTracker) that handles overlapping alarms cleanly and emits full 9-keyEventSmartAudioenter/moving/leavepayloads. Nothing runs while Protect has all audio detections off. Cameras that list an audio track but send no audio back off quietly (30s, then 60s), and FLV ingest retries audio on later reconnects after a transient startup timeout (aiport.flv_audio_header_timeout, default15s). Tune withaiport.audio_vad_andaiport.audio_alarms_, or disable either withaudio_vad_enabled: false/audio_alarms_enabled: false. - Native Face Recognition (
supportFaceRecognition/ AI Portface): On the AI Key (G4/G5 cameras), each person event'srecognize-anythingupload carries afacepart: one track per distinct face (same-event duplicates collapse at cosine ≥ 0.55, keeping the sharpest frame), a 512-dim ArcFace embedding, a square head-and-shoulders crop, and a link to Protect's person tracker. On the AI Port (paired ONVIF/Nest cameras), Keystone scans head-and-shoulders regions while a person is visible (at most every 1.5 s per camera, stopping once a sharp frontal face is held) and emitsobjectType: "face"tracks inEventSmartDetect, linked to the person. Cross-camera identity propagation carries recognized names withinpropagation_secondswhen no conflicting local face is visible (unknown_quality_faces == 0) via direct multi-view person CLIP matching (≥ 0.85fail-safe default) or companion-object/episode continuity with VLM visual corroboration. Webhook/MQTT payloads includeidentitiesandpeople. - License plate recognition (
supportLicensePlateRecognition/ AI PortlicensePlate): On the AI Key,recognizeKeyFramesjobs withramType: "videoWithRecognition"(orvehicleMeta) are scanned on up tolpr.max_framesvehicle frames decoded at up to 2560px. Keystone adds anlprJSON part (Protect 7.4lprInferenceSchema) plus one JPEG per plate crop to the samerecognize-anythingmultipart POST asram. Plate crops use tracker IDs from920000up, andlprAttrscarries both the plate tracker (objectType: "licensePlate") and Protect's own vehicle tracker (matchedName, string-onlynamesTopK,topKCandidate), so Protect'sVehicleRecognizerfiles the car undervehicle_LPR-. On the AI Port,licensePlateis advertised infeatures.smartDetect. When Protect enables it inChangeSmartDetectSettings, vehicle tracks are read (at most every 1.5 s per camera while moving, locked at ≥ 0.88) and theleaveevent carriessmartDetectSnapshotNameandtrackerIDAttrMap[vehicle].matchedName. The YOLOv9 plate detectors from open-image-models are deliberately not used, because they derive from GPL-3.0 YOLOv9 code. - Retroactive processing (
supportRetroactiveProcessing): Whenembeddings.retroactive_processing: true, Protect sends batches ofrecognizeKeyFrames(ramType: multipleImages) with stored detection thumbnails.getTaskQueueInfoshapesUI_TASK_NUMso Protect's batch budget (50 - UI_TASK_NUM) matches free retroactive queue slots (retroactive_max_queued, default32) and pauses whenever live jobs are queued;UI_AUTO_RAMalways reports the true backlog. Missing/corrupt thumbnails (404/410) are skipped individually, valid thumbnails run in one batched CLIP forward pass, and the callback always completes so Protect never loops on pruned events.
Security defaults
- Dashboard: Binds to
127.0.0.1:8088by default so captions and metadata are not exposed unauthenticated on the LAN. Setweb.bind_host: 0.0.0.0(orKEYSTONE_WEB_BIND_HOST) only on a trusted management network or behind an authenticating reverse proxy. The page is fully self-contained (no CDN or remote fonts) and is served with a hash-pinned Content-Security-Policy that only allows its own scripts and same-origin API calls. - TLS pinning: Controller control/media (
:7442/:7444), search (:7443), and encrypted FLV relays enforce exact leaf SHA-256 pins (TOFU by default, or pre-verified viakeystone trust --pin --control-fingerprint ...). - Enrollment credentials: Setting a custom
device.passwordoraiport.passworddisables factoryubnt/uifallbacks. Once adopted, Protect rotates credentials automatically, factory credentials are rejected permanently, adoption/management endpoints accept requests only fromcontroller.host, and password verification runs off the event loop with per-IP backoff.
Required network ports (for segmented VLANs)
| Direction | Port | Purpose |
| --- | --- | --- |
| Keystone → Protect | TCP 7442 | UCP4 control WebSocket (ds) & AI Port avclient WSS |
| Keystone → Protect | TCP 7443 | Find Anything NL Search WebSocket |
| Keystone → Protect | TCP 7444 | Media export downloads & RAM callbacks |
| Keystone → Protect | TCP 7550 / 7551 | AI Port extendedFlv video ingest (ms, when AI Port enabled) |
| Keystone → Protect | TCP 7447 | RTSP restream of UniFi cameras paired with the AI Port |
| Protect → Keystone | TCP 8080 | AI Key adoption management HTTPS (/api/info, /api/adopt, /api/readopt) |
| Protect → Keystone | TCP 443 | AI Port adoption management HTTPS (/api/1.2/login, /api/1.2/manage, when AI Port enabled) |
| Protect → Keystone | TCP 5432 | PostgreSQL + pgvector over TLS for Protect 7.3+ Find Anything (isSearchHost) |
| Protect ↔ Keystone | UDP 10001 | Ubiquiti v1 LAN discovery (optional if adopted by IP) |
Kubernetes & dedicated-IP deployments
Networking requirements for Kubernetes, macvlan, and LoadBalancer setups
- Use one IP for adoption and search. Protect expects TCP
8080(AI Key),5432(PostgreSQL), and443(when AI Port is enabled) on the same IP. Giveghcr.io/seearms/keystone-aioa dedicated LAN IP with Dockermacvlanor a Multus network attachment. On Kubernetes, you can also expose one Pod through aLoadBalancerService, using the all-in-one image or separate Keystone and PostgreSQL containers in that Pod. With MetalLB or Cilium BGP, setexternalTrafficPolicy: Localso PostgreSQL sees Protect's real source IP. - Advertise the IP Protect can reach. Without
hostNetwork: true, setdevice.advertise_ip(KEYSTONE_DEVICE_ADVERTISE_IP) to the external IP, such as the LoadBalancer IP or the dedicated LAN IP. This keeps Keystone from advertising an internal pod IP. - Give discovery a path to the LAN. UDP
10001broadcast discovery needs Layer 2 reachability to Protect. UsehostNetwork, Multus, or Dockermacvlanon Protect's LAN for automatic discovery. If you only have routed access, adopt by IP and allow the required connections in the table above.
Development
ruff check src tests
pytest -v
Status dashboard architecture, history storage, and frontend build
The status dashboard (:8088) is a React + shadcn/ui app in web/ (Vite, Tailwind CSS v4, TypeScript). It compiles to a single self-contained HTML file, src/keystone/ui/index.html, which is committed so pip install and Docker builds don't need Node. Keystone embeds a status snapshot in the page and polls for updates while the dashboard is live.
Keystone keeps 30 days of activity in . Only the 20 most recent entries can retain thumbnail images. Keep the state directory across upgrades and restarts (Docker Compose already mounts it). History starts with the first run of a version that supports it. Events discarded by an older version are unavailable.
Use the Activity time selector to browse the last hour, 24 hours, 7 days, or 30 days. Timestamps use your browser's local time and show when Keystone recorded each item. Search and category filters cover the selected period, including older pages. The Cameras table uses the same period for its Events column, which counts AI Port smart detection and audio messages. One detection can produce several messages as it starts, updates, and ends. Frames are counted since startup.
If the database becomes unavailable, the dashboard shows recent activity and camera counts from the current session. Keystone retries buffered writes when storage recovers and marks known gaps in the archive. Restarting while the database is still unwritable loses entries held only in memory.
cd web
npm ci
KEYSTONE_URL=http://<keystone-host>:8088 npm run dev # hot reload, proxies /api to a running Keystone
npm test # derivation/formatting tests (vitest)
npm run build # rewrites src/keystone/ui/index.html; commit it
CI fails if the committed bundle doesn't match a fresh build. To refresh the README screenshots (docs/images/dashboard.png dark, dashboard-light.png light; full page at 1280px, resized to 1600px wide), render the sanitized demo snapshot and open it in a browser:
python scripts/render_demo_dashboard.py -o /tmp/keystone-demo.html --json web/src/test/fixtures/demo.json
License & Acknowledgments
Licensed under the Apache License 2.0 (see LICENSE and NOTICE).
- Portions of Keystone's Protect UCP4 AI Key control, adoption/management, TLS pinning, worker/CLIP reverification, and AI Port adoption code are adapted from Olli0103/unifi-protect-local-ai (Apache-2.0) and modified for Keystone; see NOTICE.
- Find Anything embeddings use MIT-licensed OpenAI CLIP ViT-L/14 ONNX weights via Xenova/clip-vit-large-patch14 (pinned to an immutable commit and SHA-256 verified on download).
- AI Port Smart Audio uses the MIT-licensed Silero VAD v6.3 ONNX model (
alrmSpeak, pinned to commit63d4a2a) and Apache-2.0 Google YAMNet ONNX via audiomagic/yamnet-onnx (all other 8 Protect audio alarms, pinned to commitf25b741, AudioSet ontology CC-BY-4.0); both are SHA-256 verified on download and load. - Optional speech-to-text uses MIT-licensed OpenAI Whisper ONNX exports from onnx-community (pinned to immutable commits and SHA-256 verified on download).
- Optional face recognition uses InsightFace SCRFD and ArcFace (WebFace600K) ONNX weights, downloaded at runtime and SHA-256 verified; the weights are licensed by InsightFace for non-commercial research purposes only.
- Optional Face Image Enhancement uses Apache-2.0 GFPGAN v1.4 ONNX weights via neurobytemind/GFPGANv1.4.onnx (pinned to an immutable commit and SHA-256 verified on download).
- Optional license plate recognition uses an Apache-2.0 YOLOX plate detector, either faisalthaheem/open-lpr-models
plate_yolox_tiny_640.onnx(default) or autolane/yolox-s-alpryolox_plates_s.onnx, plus MIT-licensed fast-plate-ocrcct_*_v2_globalOCR. Weights are pinned and SHA-256 verified on download and load; see NOTICE. - Optional ONVIF object detection uses Apache-2.0 YOLOX ONNX weights (SHA-256 verified on download).
- AI Port package detection uses Apache-2.0 D-FINE Small Objects365 ONNX weights via onnx-community/dfine_s_obj365-ONNX (pinned to an immutable commit and SHA-256 verified on download and load; see NOTICE).
Built by Colin Armstrong