Vektor is a purely file-based, embedded Vector Database written in native PHP. It is designed for "Zero-RAM Overhead" operation, meaning it doesn't load the entire dataset into memory. Instead, it relies on strict binary file layouts and disk-based seeking to perform approximate nearest neighbor searches using the HNSW (Hierarchical Navigable Small World) algorithm.
Vektor supports optional Bearer Token authentication.
- Create a
.envfile in the project root:cp .env.example .env
- Set your secret token:
VEKTOR_API_TOKEN=your-super-secret-token
- If
VEKTOR_API_TOKENis set, all endpoints (except/up) require the header:Authorization: Bearer <token>. - If
VEKTOR_API_TOKENis not set, the API is open (public).
The system exposes a simple REST API.
Inserts a new vector into the database.
- Payload:
{"id": "doc-1", "vector": [0.1, ...]}
Searches for the nearest neighbors of a given vector.
- Payload:
{"vector": [0.1, ...], "k": 5} - Response:
{ "results": [ { "id": "doc-1", "distance": 0.98 }, { "id": "doc-4", "distance": 0.85 } ] }
Deletes a vector from the database.
- Payload:
{"id": "doc-1"}
Vacuum deleted vectors and rebalance the HNSW graph. This operation locks the database.
- Payload: None
- Response:
{"status": "success", "message": "..."}
Returns DB statistics.
- Response:
{ "storage": { "vector_file_bytes": ... }, "records": { "vectors_total": ... }, "config": { "dimension": 1536, ... } }
Returns simple status for monitoring. Public endpoint.
- Response:
{"status": "up"}
Requires PHP 8.2+ and Composer.
composer install --no-dev
chmod -R 777 data/Point your web server's document root to the public/ directory, using the provided .htaccess (Apache) or nginx.conf.example (Nginx).
MIT