velesdb (Python)
Embedded vector + graph database for Python: local-first semantic search and explainable agent memory.
Licensed under the VelesDB Core License 1.0 (source-available). The compiled wheel embeds the VelesDB engine and is governed by the same license.
Objective
Vector search usually means running a server: a container, a port, a network hop on every query, and an ops story you did not ask for. VelesDB's Python SDK removes all of it — the engine is compiled into the wheel and runs inside your process, against a directory on disk. You get microsecond-scale similarity search, hybrid dense + sparse retrieval, graphs and VelesQL without a daemon, and — when you are building an agent — a memory layer that can explain why it returned what it returned.
If you already run a managed vector service and are happy with it, you do not have this problem and can stop here.
Use cases
- A RAG prototype on a laptop that must survive
pip installand nothing else — no Docker, no cloud account. - An AI agent that has to remember decisions across process restarts and justify them later (
why()). - A desktop or CLI application shipping semantic search inside the app, with the index living next to the user's data.
- A batch job that embeds a corpus once, writes a portable index directory, and searches it in-process.
- An offline or air-gapped environment where sending embeddings to a hosted API is not an option.
Prerequisites
| Requirement | Minimum version | Note |
|---|---|---|
| Python | 3.9 | requires-python = ">=3.9"; a single cp39-abi3 wheel covers 3.9+ |
| pip | any recent | prebuilt wheels, no compilation |
| NumPy | 1.20 | hard runtime dependency, installed automatically |
| Rust | 1.90 | only when building from the sdist / source checkout |
| Embedding model | — | not included: VelesDB stores and searches vectors, it does not generate them |
Installation
pip install velesdb
Optional extras (all independent, install only what you use):
pip install "velesdb[embed-sentence-transformers]" # local embedding adapter
pip install "velesdb[embed-openai]" # OpenAI-compatible adapter
pip install "velesdb[pandas]" # DataFrame ingestion
pip install "velesdb[polars]" # Polars ingestion
Building from a source checkout of this repository instead:
pip install maturin
cd crates/velesdb-python
maturin develop
First success in 60 seconds
# pip install velesdb
import velesdb
db = velesdb.Database("./hello_velesdb_data") # created if missing
docs = db.get_or_create_collection("docs", metric="cosine") # dimension auto-detected
# 4-D vectors whose axes stand for four made-up topics: [tech, food, music, sport]
docs.upsert([
{"id": 1, "vector": [1.0, 0.0, 0.0, 0.0], "payload": {"title": "Rust release notes"}},
{"id": 2, "vector": [0.0, 1.0, 0.0, 0.0], "payload": {"title": "Best ramen in Tokyo"}},
{"id": 3, "vector": [0.6, 0.0, 0.8, 0.0], "payload": {"title": "AI-generated jazz"}},
])
results = docs.search_request(velesdb.SearchOptions(vector=[1.0, 0.0, 0.0, 0.0], top_k=2))
for r in results:
print(f"score={r['score']:.3f} {r['payload']['title']}")
Expected output — the exact-match document scores 1.000, the partly-tech one 0.600:
score=1.000 Rust release notes
score=0.600 AI-generated jazz
Anything else is a failure: an empty output means the upsert did not land (check
that ./hello_velesdb_data is writable), and a ModuleNotFoundError means the
wheel is not installed in the interpreter you are running. The longer version of
this script is
examples/python/hello_velesdb.py.
Next step, the agent-memory wedge — the same package, no extra install:
from velesdb import MemoryService # offline, deterministic, no API key
mem = MemoryService("./agent_memory") # on-disk store; survives restarts
reason = mem.remember("Robert is recovering from knee surgery")
mem.remember("Booked the aisle seat on Robert's flight", links=[(reason, "because")])
mem.why("why the aisle seat on Robert's flight?") # walks booking → reason
why() returns the best-matching memory plus the connected subgraph reached
through typed links — context that shares no words with the question, which a
plain vector recall cannot find. See
PYTHON_AGENT_MEMORY.md.
Configuration
Database(path, config=...) accepts a typed VelesConfigOptions covering every
engine section of the core VelesConfig. Build it in code or load it from a
velesdb.toml (engine-only semantics: a shell-owned [server] / [logging]
table in a shared file is ignored).
| Section | Type | Controls |
|---|---|---|
limits |
LimitsOptions |
collection and resource ceilings |
search |
SearchConfigOptions |
default search mode, max results |
hnsw |
HnswConfigOptions |
index build/search parameters |
storage |
StorageOptions |
on-disk storage behaviour |
quantization |
QuantizationOptions |
compression settings |
from velesdb import Database, VelesConfigOptions, LimitsOptions, SearchConfigOptions
cfg = VelesConfigOptions(
limits=LimitsOptions(max_collections=50),
search=SearchConfigOptions(default_mode="accurate", max_results=100),
)
db = Database("./tenant1", config=cfg)
# Or from TOML (fail-fast: invalid TOML/values raise ValueError,
# a missing file raises FileNotFoundError):
cfg = VelesConfigOptions.from_toml_path("./velesdb.toml")
db = Database("./tenant1", config=cfg)
wal_batch is intentionally not exposed — the concurrent WAL writer is a
VelesDB Enterprise feature (see
WRITE_CONCURRENCY.md).
Examples
Runnable scripts, not snippets: examples/python/
(hello_velesdb.py, hybrid_queries.py, fusion_strategies.py,
graph_traversal.py, graphrag_langchain.py, graphrag_llamaindex.py,
multimodel_notebook.py) and the agent-memory demos in
examples/agent_memory/.
API / commands
Signatures and docstrings ship inside the wheel as a typed stub
(python/velesdb/__init__.pyi, with py.typed),
so your IDE and mypy/pyright are the reference. Task-oriented guides:
| Guide | What it covers |
|---|---|
| PYTHON_API_REFERENCE.md | Database / Collection, sparse + hybrid search, fusion strategies, distance metrics, storage modes, bulk loading, streaming ingestion |
| PYTHON_AGENT_MEMORY.md | MemoryService (remember / recall / why / feedback) and the semantic / episodic / procedural SDK |
| PYTHON_CONTEXT_COMPILER.md | compile_context, provenance handles, working contexts, LangChain and LlamaIndex wiring |
| PYTHON_GRAPH.md | persistent graph collections, MATCH queries, in-memory GraphStore |
| PYTHON_VELESQL.md | VelesQL.parse() / ParsedStatement introspection |
| PYTHON_RAG_PIPELINE.md | text → embeddings → results, built-in embedding adapters |
| PYTHON_PERFORMANCE.md | throughput tuning (numpy f32, upsert_bulk_numpy, batching) |
| PYTHON_ENGINE_BENCHMARKS.md | measured engine latency and recall figures |
| PYTHON_REMOTE_SERVER.md | talking to a running velesdb-server over HTTP |
Known limits
- No embedding generation. VelesDB stores and searches vectors; you bring the model (or use the optional adapters).
- Embedded only. There is no Python client class for a remote server — use HTTP against
velesdb-server. - One process per database directory. A second process opening the same path fails with
DatabaseLockedError([VELES-031]). wal_batch/ concurrent WAL writing is not exposed — Enterprise feature.- No GPU in the published wheels. The
gpuCargo feature exists but is not enabled by[tool.maturin]; it requires building from source. Collection.search(...)is deprecated since v1.15 (emitsDeprecationWarning); usesearch_request(SearchOptions(...)).Collection.get_graph_store()returns a standalone in-memory graph that is not connected to the collection; useDatabase.create_graph_collection()for persistence.
Compatibility
Prebuilt wheels published to PyPI (single cp39-abi3 wheel per platform, so one
wheel covers Python 3.9 and later):
| Platform | Status | Note |
|---|---|---|
| Linux x86_64 (glibc) | Prebuilt wheel | manylinux2014 — glibc 2.17+ |
| Linux aarch64 (glibc) | Prebuilt wheel | manylinux2014 |
| Linux x86_64 (musl) | Prebuilt wheel | musllinux_1_2 — Alpine images |
| Linux aarch64 (musl) | Prebuilt wheel | musllinux_1_2 |
| macOS arm64 + x86_64 | Prebuilt wheel | single universal2 wheel |
| Windows x64 | Prebuilt wheel | MSVC |
| Windows arm64 | Prebuilt wheel | aarch64-pc-windows-msvc |
| Anything else (PyPy, exotic arches, older glibc) | Source build | sdist fallback, needs Rust 1.90 |
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
ModuleNotFoundError: No module named 'velesdb' |
the compiled extension is not installed in the active interpreter (a source checkout is not importable as-is) | pip install velesdb, or maturin develop inside crates/velesdb-python |
DimensionMismatchError: ... expected 768 ... 512 |
the vector length differs from the collection's dimension | re-embed with the model that matches the collection, or create the collection with dimension=None to auto-detect on first upsert |
DatabaseLockedError: [VELES-031] Database is already opened by another process |
another process (or a still-open handle, e.g. a notebook kernel) holds that directory | close the other handle, or give the second process its own directory |
RuntimeError on collection.stream_insert([...]) |
streaming ingestion was never enabled | call collection.enable_streaming(...) first |
FileNotFoundError from VelesConfigOptions.from_toml_path(...) |
config loading is fail-fast by design | check the path; malformed TOML or invalid values raise ValueError instead |
All typed exceptions (DimensionMismatchError, CollectionNotFoundError,
CollectionExistsError, EdgeExistsError, DatabaseLockedError,
VelesQLSyntaxError, VelesQLParameterError) derive from velesdb.VelesDBError,
so except velesdb.VelesDBError is a safe catch-all.
velesdb-python v4.1.0 · Last updated: 2026-07-25 · Applies to: velesdb-core 4.2.0 · Report a docs error
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file velesdb-4.2.0.tar.gz.
File metadata
- Download URL: velesdb-4.2.0.tar.gz
- Upload date:
- Size: 3.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2cd05f644adad576a008999da6b0136b7b75e10233f1e9a81a8bf5f2d825ee2
|
|
| MD5 |
1a5426a0f7823e433b19ef14de634ae6
|
|
| BLAKE2b-256 |
d9b9c7a5c62864c6a403ce9bd8451359f0914ee9abd0ee9d995e271883adfdb8
|
File details
Details for the file velesdb-4.2.0-cp39-abi3-win_arm64.whl.
File metadata
- Download URL: velesdb-4.2.0-cp39-abi3-win_arm64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.9+, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e699e4bdc2847d623aaaab220ac6243607afb7cc80cd69ece4428f64b42f6311
|
|
| MD5 |
03e50ba6977c5684efacd0c34486bfc8
|
|
| BLAKE2b-256 |
20d6bc53a246538352624e7ac4aa8afe3e8e27031cd56a933bc7031a9674b3df
|
File details
Details for the file velesdb-4.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: velesdb-4.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bb52143c1eed7b5d62676765e2b3294236100c05ed382de0b13621e4a1780f4
|
|
| MD5 |
a0dd8566a014b1d752f3271cc60aa3ee
|
|
| BLAKE2b-256 |
f302710d7472c599c1aea416779e96f3110f0766949aa00633d2ffe332e805d1
|
File details
Details for the file velesdb-4.2.0-cp39-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: velesdb-4.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
470b39af449df5202fe16cf9dd5e1b73998cf86e3ffa5830ed58bb76a6bd2145
|
|
| MD5 |
0ed109e94a9ce379b0346f7c9e846469
|
|
| BLAKE2b-256 |
0196965df7c32453ade92c3bb9ff80061f5bc9851a2ff17febbd57fd47e7d8f3
|
File details
Details for the file velesdb-4.2.0-cp39-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: velesdb-4.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 3.4 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62da67442176a62c0b267167d6fcea4b8625cf3986691d6a869adcddf3a7d19f
|
|
| MD5 |
3d7b29a188b03fc0b73d819d785db8b6
|
|
| BLAKE2b-256 |
f41d5f97e617f4a3f62d052c006aee5af1580a77ffcf188dc34d486e625f9b07
|
File details
Details for the file velesdb-4.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: velesdb-4.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.5 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc226fa059cd6efe487e795b7581104b63e3e54993c9743533c84537a5f5124f
|
|
| MD5 |
a3c739de30d571f1a2449a1cc317888b
|
|
| BLAKE2b-256 |
19bf48a45f1549e4d6d93ceb58179a67878f9775e71a4d0c3030bd696c796135
|
File details
Details for the file velesdb-4.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: velesdb-4.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea93c1a091aa1fecc9777191854a20ea82e2d026d03a7e94cb57ed2af1c77548
|
|
| MD5 |
1c0034ebf26a7fb27c0237854a21ab95
|
|
| BLAKE2b-256 |
7ae44bb4c87eee74ab045996ea8dd910c9884ec56de057743b9841089082b902
|
File details
Details for the file velesdb-4.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: velesdb-4.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 6.4 MB
- Tags: CPython 3.9+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c2ebfcf0fe1b3720f3ce5764bc6b41f4560f769724c41da52dbbddcbd5238b2
|
|
| MD5 |
5b194aa25166756d1965c43e8f846b77
|
|
| BLAKE2b-256 |
78d26a5a234b8423ed8dc3ae143181efeb8216b35841d9ce95f42f7e0cd3892f
|