VelesDB Server
REST API server for VelesDB - a high-performance vector database.
Installation
From crates.io
Docker
# Build from the repository root
From source
Usage
# Start server on default port 8080
# Custom port and data directory
# With logging
RUST_LOG=info
Quick Start Flow
After starting the server, follow this sequence:
- Create a collection —
POST /collections(define dimension and metric) - Insert vectors —
POST /collections/{name}/points(with optional payloads) - Search —
POST /collections/{name}/search(send a query vector, get top-k results) - Add filters — Add metadata conditions to narrow results
- Tune — Adjust
ef_searchor useSearchQuality::Adaptivefor production
The data directory auto-creates if it doesn't exist. Default: ./velesdb_data.
API Reference
Collections
# Create collection (default: full precision, cosine)
Response (201 Created):
# Create collection with quantization (SQ8 = 4x memory reduction)
# Aliases: "sq8" or "int8"
# Create binary collection (Hamming + Binary = 32x compression)
# Aliases: "binary" or "bit"
# List collections
# Get collection info
# Delete collection
Points (Vectors)
# Upsert points
# Get a point by ID
# Delete a point by ID
Search
# Vector similarity search
# Search with explicit search quality mode
# Search with custom ef_search (fine-grained control)
# Search with adaptive ef_search (auto-escalation for hard queries)
The mode parameter accepts the following values:
| Value | Description |
|---|---|
fast |
Low latency (~92% recall) |
balanced |
Default (~99% recall) |
accurate |
High precision (~99.5% recall) |
perfect |
Exhaustive (100% recall) |
autotune |
Auto-computed ef from collection size |
custom:<ef> |
Fixed ef_search (e.g., custom:256) |
adaptive:<min>:<max> |
Two-phase adaptive (e.g., adaptive:32:512) |
Response:
# BM25 full-text search
Response:
# Hybrid search (vector + text)
# Batch search (multiple queries in parallel)
# Multi-query fusion search (MQG for RAG)
# Weighted fusion strategy
# VelesQL query
Response:
# VelesQL with MATCH (full-text)
# Aggregation-only VelesQL endpoint
# Explain query plan
Response:
Graph API
# List edges filtered by label (label is required)
# Add an edge (id, source, target, label are required)
# Remove an edge by ID
# Get total edge count
# List all node IDs
# Get edges for a specific node (direction: in, out, both)
# Get node degree (in + out)
# Store payload on a node
# Get node payload
# Traverse graph from a node (BFS or DFS)
# Parallel multi-source BFS traversal
# Stream graph traversal (SSE)
# Search graph nodes by embedding similarity
MATCH Query API (Cypher-like graph pattern matching)
# Execute a MATCH graph traversal query
# MATCH with vector similarity scoring
Response format:
Index API
# List indexes on a collection
# Create an index
# Delete an index
Health & OpenAPI
# Health check
# OpenAPI spec and Swagger UI (requires --features swagger-ui at build time)
# Open in browser: http://localhost:8080/swagger-ui
Error Responses
All error responses include an error field with a human-readable message. When the
error maps to a structured VelesDB error code, the response also includes a code field:
The code field is optional and omitted when no structured code applies. Use it for
programmatic error handling (e.g., retry on VELES-006, display user hint on VELES-004).
See ERROR_CODES.md for the full list.
Authentication
VelesDB supports optional API key authentication. When no keys are configured, the server runs in local dev mode (all requests are accepted). When one or more keys are configured, every request must include a valid Authorization: Bearer <key> header.
Enabling Authentication
Via environment variable (comma-separated list):
VELESDB_API_KEYS="sk-prod-abc123,sk-prod-def456"
Via velesdb.toml:
[]
= ["sk-prod-abc123", "sk-prod-def456"]
You can configure as many keys as you need. This is useful for rotating keys without downtime: add the new key, deploy, then remove the old key.
Making Authenticated Requests
If authentication is enabled and the header is missing or invalid, the server returns 401 Unauthorized:
Public Endpoints (No Auth Required)
The following endpoints bypass authentication even when API keys are configured:
| Endpoint | Purpose |
|---|---|
GET /health |
Liveness probe |
GET /ready |
Readiness probe |
GET /metrics |
Prometheus metrics (if enabled) |
This allows load balancers and orchestrators to probe the server without credentials.
TLS / HTTPS
VelesDB supports native TLS via rustls (no OpenSSL dependency). When both a certificate and private key are provided, the server binds with HTTPS instead of HTTP.
Generating Self-Signed Certificates (Development)
Configuring TLS
Via environment variables:
VELESDB_TLS_CERT=./cert.pem VELESDB_TLS_KEY=./key.pem
Via CLI flags:
Via velesdb.toml:
[]
= "/etc/velesdb/cert.pem"
= "/etc/velesdb/key.pem"
Both cert and key must be provided together. The server will refuse to start if only one is set or if the files do not exist.
Making Requests Over HTTPS
With a self-signed certificate:
Or skip verification during development (not for production):
Graceful Shutdown
VelesDB performs a clean shutdown when it receives SIGINT (Ctrl+C) or SIGTERM (on Unix). The shutdown sequence:
- Stop accepting new connections -- the listening socket is closed immediately.
- Drain in-flight requests -- the server waits up to
shutdown_timeout_secs(default: 30 seconds) for active connections to complete. - Flush all WALs -- every collection's Write-Ahead Log is flushed to disk, ensuring no acknowledged writes are lost.
- Exit -- the process terminates cleanly.
If the drain timeout expires with connections still active, the server logs a warning and proceeds to the WAL flush.
Configuring the Drain Timeout
Via velesdb.toml:
[]
= 60
The default is 30 seconds, which is sufficient for most workloads.
Health & Readiness Probes
GET /health -- Liveness Probe
Always returns 200 OK as long as the process is running. Use this for container liveness checks.
Response:
GET /ready -- Readiness Probe
Returns 200 OK once the database has finished loading all collections from disk. Returns 503 Service Unavailable while loading.
Response (ready):
Response (not ready):
Kubernetes Example
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 2
periodSeconds: 5
Distance Metrics
| Metric | API Value | Aliases | Use Case |
|---|---|---|---|
| Cosine | cosine |
Text embeddings | |
| Euclidean | euclidean |
Spatial data | |
| Dot Product | dot |
dotproduct, inner, ip |
Pre-normalized vectors |
| Hamming | hamming |
Binary vectors | |
| Jaccard | jaccard |
Set similarity |
Performance
- Cosine similarity: ~33.1 ns per operation (768d)
- Dot product: ~19.8 ns per operation (768d)
- Search latency: 47.0 µs for 10K vectors (768D, Balanced mode)
- Throughput: 38.8 Gelem/s (dot product, 768D)
Configuration Reference
VelesDB loads configuration with the following priority (highest wins):
CLI flags > Environment variables > velesdb.toml file > Built-in defaults
A custom config file path can be specified with --config /path/to/velesdb.toml or VELESDB_CONFIG.
Environment Variables and CLI Flags
| Environment Variable | CLI Flag | Default | Description |
|---|---|---|---|
VELESDB_HOST |
--host |
127.0.0.1 |
Bind address. Use 0.0.0.0 for network access. |
VELESDB_PORT |
--port / -p |
8080 |
Server port. |
VELESDB_DATA_DIR |
--data-dir / -d |
./velesdb_data |
Data directory for persistent storage. |
VELESDB_CONFIG |
--config / -c |
./velesdb.toml |
Path to TOML configuration file (optional). |
VELESDB_API_KEYS |
-- | (empty) | Comma-separated API keys. When set, enables Bearer token auth. |
VELESDB_TLS_CERT |
--tls-cert |
(none) | Path to TLS certificate file (PEM). Requires VELESDB_TLS_KEY. |
VELESDB_TLS_KEY |
--tls-key |
(none) | Path to TLS private key file (PEM). Requires VELESDB_TLS_CERT. |
RUST_LOG |
-- | info |
Log level filter (e.g. warn, info, debug, trace). |
VELESDB_NO_UPDATE_CHECK |
-- | (unset) | Set to 1 to disable startup update check. |
TOML Configuration File
[]
= "0.0.0.0"
= 8080
= "/var/lib/velesdb"
= 30
[]
= ["sk-prod-abc123", "sk-prod-def456"]
[]
= "/etc/velesdb/cert.pem"
= "/etc/velesdb/key.pem"
# Startup update check (enabled by default, no PII collected)
[]
= true # set to false to disable
# timeout_ms = 2000 # network timeout in ms
All sections and fields are optional. Only include what you need to override.
Update Check
On startup, the server performs a non-blocking version check against velesdb.com/api/check. This sends only: version, OS, architecture, and a non-reversible SHA256 instance hash. No personal data is collected.
Disable via environment variable or config:
License
VelesDB Core License 1.0
See LICENSE for details.