---
title: "Keystone · Local AI, natively in UniFi Protect"
description: "Open-source AI Key and AI Port that adopt natively into UniFi Protect, bringing plain-English Find Anything search, motion-aware event descriptions and smart detections to ONVIF and pre-G6 UniFi cameras, with local models on your own hardware."
url: "https://keystone.armstr.ng/"
---

# Local AI, natively in UniFi Protect

Protect's AI features on the cameras Ubiquiti's AI doesn't cover: third-party ONVIF cameras and UniFi cameras older than G6. Keystone is an open-source AI Key and AI Port that adopts into Protect like Ubiquiti's own hardware, on a box you already own.

Apache-2.0 · Ollama, CLIP & YOLOX · 100% LAN. Source: [GitHub](https://github.com/seeARMS/keystone) (Apache-2.0).

## In Protect

- **Find Anything:** Search every camera in plain English, ONVIF and older UniFi cameras included, from Protect's own search bar.
- **Descriptions:** Descriptions on a G5 Pro: Keystone looks at several moments of each event, so a car pulling in isn't called parked.
- **AI Port:** Pair third-party ONVIF cameras with the built-in AI Port, and they get Protect's native smart detections.

For example, searches like “white tesla”, “person with a backpack” or “delivery” return matching detections from every camera, best match first.

For a vehicle event on a G5 Pro, Keystone looks at several moments of the clip, asks `qwen3.5:9b` what happened, and replaces Protect's “Vehicle detected” with: “White Tesla sedan turns in from the street and drives up the driveway toward the house.” Tags: `white`, `tesla`, `sedan`, `vehicle`, `driving`, `driveway`.

## Everything stays on your network

Keystone is a small service on a box you already run. Protect sends it events; it sends back descriptions, search results and detections over Protect's own protocols. Nothing goes to a cloud unless you point it at one.

### Adopts like real hardware

Advertises over Ubiquiti UDP discovery and connects over Protect's own mTLS and WebSocket protocols (`0xa5f0` and `0xa5f5`). No database hacks or patched Protect files.

### Captions and plain-English search

Looks at several moments of each event so moving cars aren't called parked, maps results onto Protect's 5,375-tag vocabulary, and embeds object crops with local CLIP ViT-L/14.

### Smart detections on ONVIF cameras

The built-in virtual AI Port (`UP AI PORT X`) relays HD streams with zero video transcoding, runs motion-gated YOLOX detections, and evaluates Protect's own polygon zones.

## What you get

The AI features Protect keeps for Ubiquiti's own AI hardware and newest cameras, on every camera you have, in the same places in Protect's own app.

- **Find Anything:** Search every camera in plain English, or with a photo, older UniFi and ONVIF cameras included. A local CLIP model indexes what they see.
- **Event descriptions:** “Vehicle detected” becomes a sentence about what happened, written by a local vision model from several moments of the clip.
- **Smart detections on ONVIF cameras:** Reolink, Amcrest, Nest and other third-party cameras get Protect's own person, vehicle and animal detections, inside the zones you draw in Protect.
- **Protect's own tags and alarms:** Every description maps onto Protect's tag vocabulary, so its filters, notifications and Alarm Manager work as they do with Ubiquiti's hardware.
- **Context across cameras:** When someone walks from the driveway to the door, what one camera saw clearly helps describe what the next one sees.
- **Local by default:** Ollama, CLIP and YOLOX on your own hardware. Point descriptions at an OpenAI-compatible or Anthropic endpoint only if you want to.

## Running in a few minutes

Docker Compose on any Linux box, or Python 3.12+ in an LXC or systemd service.

1. **Start Keystone.** Copy `config.example.yaml`, set `controller.host` and your vision model, and bring it up. Compose includes the TLS `pgvector` database Protect 7.3+ uses for Find Anything.
2. **Adopt it in Protect.** Open UniFi Protect → UniFi Devices and adopt the AI Key. The default credentials, `ubnt` / `ubnt`, rotate automatically on adoption.
3. **Pair ONVIF cameras (optional).** Set `aiport.enabled: true`, adopt the AI Port, pair your cameras, and turn on Basic Object Recognition and AI Summary under Settings → Intelligence.

### Docker Compose

Includes Keystone + the local TLS pgvector database Protect 7.3+ uses for Find Anything.

```bash
git clone https://github.com/seeARMS/keystone.git
cd keystone
cp config.example.yaml config.yaml   # set controller.host & vision.base_url
docker compose up -d --build
```

### Python / LXC

Python 3.12+ with FFmpeg. Add PostgreSQL 16+ with pgvector for Find Anything search.

```bash
git clone https://github.com/seeARMS/keystone.git && cd keystone
python3 -m venv .venv && source .venv/bin/activate && pip install -e .
keystone init --controller 192.168.1.1 --ollama http://192.0.2.20:11434 --model qwen3.5:9b
keystone trust -c config.yaml --pin && keystone run -c config.yaml
```

## Questions

### How is this different from Frigate?

Frigate is a separate NVR, with its own recordings, its own app and its own events. Keystone isn't an NVR and records nothing. It adopts into UniFi Protect as an AI Key and AI Port, so search, descriptions and smart detections show up in Protect itself: the web and mobile apps, push notifications, the timeline and Alarm Manager.

You keep Protect for recording, and everyone in the house keeps the app they already use.

### Do I need Ubiquiti's AI Key, AI Port or G6 cameras?

No. Keystone takes the AI Key's and AI Port's place: it shows up in UniFi Devices as a virtual AI Key, and optionally a virtual AI Port, running on hardware you already own. And it works with the cameras you have, not only Ubiquiti's newest.

### Which cameras does it work with?

Every camera Protect records, including the ones Ubiquiti's AI doesn't cover. UniFi cameras older than G6 get Find Anything and event descriptions. Third-party ONVIF cameras you've added to Protect, such as Reolink, Amcrest or Nest, can also pair with Keystone's AI Port for Protect's own person, vehicle and animal detections, detection and exclude zones, and descriptions.

### What hardware do I need?

Any Linux machine, LXC container or Docker host on the same network as Protect. Search and ONVIF detection run on the CPU in about 4 GiB of RAM.

Descriptions need a vision model through Ollama, on the same machine or on another one with a GPU. A discrete GPU describes an event in a few seconds; an integrated one takes longer.

### Does anything leave my network?

Not unless you choose to send it. Ollama, CLIP and YOLOX all run locally. If you'd rather use a hosted model for descriptions, Keystone can call any OpenAI-compatible or Anthropic endpoint instead.

It pins Protect's certificates, its adoption password rotates when Protect adopts it, and its status dashboard only listens on `127.0.0.1` unless you change that.

### Which models does it use?

Descriptions come from any vision model Ollama serves (`qwen3.5:9b` by default), or from an OpenAI-compatible or Anthropic API. Find Anything uses CLIP ViT-L/14, and ONVIF detection uses YOLOX, both as ONNX models downloaded on first run.

### Which versions of Protect does it support?

Protect 7.3 and later. Find Anything relies on the `pgvector` search database Protect 7.3 introduced, which the Docker Compose setup includes.

### What happens when Protect updates?

Keystone doesn't patch Protect or touch its database, so an update can't overwrite it. It does speak Protect's own device protocols, so a release that changes them may need a Keystone update to match.

### Can I get descriptions in Home Assistant?

Yes. Besides Protect's own notifications, Keystone can send each description to a webhook or over MQTT, for Home Assistant, ntfy or anything else that listens.

### Which ports does it need?

Keystone uses host networking so Protect can discover it. If Keystone and Protect are on different VLANs, allow these:

| Direction | Port | Purpose |
| --- | --- | --- |
| Keystone → Protect | `TCP 7442` | UCP4 control WebSocket and AI Port avclient |
| Keystone → Protect | `TCP 7443` | Find Anything search WebSocket |
| Keystone → Protect | `TCP 7444` | Media export downloads and RAM callbacks |
| Keystone → Protect | `TCP 7550 / 7551` | AI Port `extendedFlv` video ingest |
| Protect → Keystone | `TCP 8080` | AI Key adoption (HTTPS) |
| Protect → Keystone | `TCP 443` | AI Port adoption (HTTPS) |
| Protect → Keystone | `TCP 5432` | PostgreSQL + `pgvector` over TLS for Find Anything |
| Protect ↔ Keystone | `UDP 10001` | Ubiquiti LAN discovery (optional if adopted by IP) |

### Is it affiliated with Ubiquiti?

No. Keystone is an unofficial, open-source community project under the [Apache-2.0 license](https://github.com/seeARMS/keystone/blob/main/LICENSE). It includes no Ubiquiti firmware, binaries or model weights.

## Run it on hardware you already own

Keystone is free and open source. Start it next to Protect, adopt it, and search your cameras tonight.

```bash
git clone https://github.com/seeARMS/keystone.git
```

## Links

- [Source on GitHub](https://github.com/seeARMS/keystone)
- [License (Apache-2.0)](https://github.com/seeARMS/keystone/blob/main/LICENSE)
- [llms.txt](https://keystone.armstr.ng/llms.txt): Keystone in brief, for agents
- [Colin Armstrong](https://armstr.ng/)
