Skip to main content

🐍 VantaDB Python SDK

Status: active (core-promise surface until 1.0 — the Python SDK is the ICP-03 entry).

Official Python bindings for VantaDB, an embedded, native-Rust database engine designed for persistent memory, hybrid retrieval and graph queries in local-first AI applications.

Why VantaDB instead of a plain vector store?

Most embedded vector databases (e.g. ChromaDB) index vectors and stop there. VantaDB ships the missing pieces agents actually need:

  • Hybrid search with RRF fusion — dense vector ANN (HNSW) and lexical BM25 run together and fuse via Reciprocal Rank Fusion, so semantic misses get caught by keyword matches (and vice versa). One call (search), one ranked result set.
  • Graph and memory in one engine — namespace-scoped memory records live next to a property graph with typed edges: BFS/DFS traversals, PageRank, cycle detection and topological sort, all queryable through IQL (query / query_structured).
  • Explicit memory lifecycle — per-record TTL expiry (purge_expired) and atomic fact replacement (supersede) without delete/reinsert races.
  • Built-in migration paths — bulk_import / bulk_import_bytes for fast ingestion, export_namespace / export_all for backup, and reindex_hnsw_from_text to rebuild indexes from stored payloads after schema or index changes.

📦 Installation

pip install vantadb-py

Note: The distribution name is vantadb-py and the canonical import is import vantadb (same as the Rust crate and the npm package). import vantadb_py remains available and is not broken.

Naming (ADR-041 anti-stutter): the canonical client name is Client (VantaDB was removed — use Client); canonical type names are Record, SearchHit/Hit, ListResult, Vector. Memory methods live under db.memory (get / list / search / delete); the flat Client keeps shared names (put / search / count / ...) that delegate to the same operations — db.search(...) ≡ db.memory.search(...).

From TestPyPI (Pre-release testing)

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ vantadb-py

From Source (Development)

Requires Rust and Maturin.

# Clone the repository
git clone https://github.com/ness-e/Vantadb.git
cd Vantadb/vantadb-python

# Compile and install into the active virtual environment
pip install maturin
maturin develop --release

🚀 Quickstart

import vantadb

# 1. Open or create an embedded database
db = vantadb.Client("./my_agent_memory", memory_limit_bytes=128 * 1024 * 1024)

# 2. Store persistent memory (payload + vector + metadata)
db.put(
    namespace="agent/session_1",
    key="fact_001",
    payload="The user prefers direct, technical answers.",
    metadata={"source": "chat", "priority": "high"},
    vector=[0.1, 0.2, 0.3, 0.4]  # Dense vector (e.g. embedding from a local model)
)

# 3. Retrieve the exact record
record = db.memory.get("agent/session_1", "fact_001")
print(record["payload"])

# 4. Hybrid search (vector + lexical)
# Note: The query vector must match the dimensionality of the stored vectors
query_vector = [0.15, 0.25, 0.35, 0.45]
results = db.search(
    namespace="agent/session_1",
    query_vector=query_vector,
    text_query="user preferences",
    top_k=5
)

for hit in results:
    print(f"Key: {hit.key}, Score: {hit.score:.4f}")

# 5. Resource monitoring (critical for local agents)
stats = db.operational_metrics()
print(f"Logical usage: {stats['hnsw_logical_bytes'] / 1024:.2f} KB")
print(f"Physical RSS: {stats['process_rss_bytes'] / 1024:.2f} KB")

# 6. Clean shutdown
db.close()

🔢 Real Embeddings

The vectors above are toy examples. VantaDB stores and searches any dense vector but does not generate embeddings — bring your own client (local Ollama or the OpenAI API):

import json, urllib.request

def embed(text: str) -> list[float]:
    req = urllib.request.Request(
        "http://localhost:11434/api/embed",
        data=json.dumps({"model": "nomic-embed-text", "input": text}).encode(),
        headers={"Content-Type": "application/json"},
    )
    return json.load(urllib.request.urlopen(req))["embeddings"][0]

db.put(
    namespace="agent/session_1",
    key="fact_002",
    payload="The user prefers direct, technical answers.",
    metadata={"source": "chat"},
    vector=embed("user tone preferences"),
)

Use one embedding model per namespace — stored and query vectors must share the same dimensionality. Full walkthrough: QUICKSTART → Real Embeddings.

Cross-SDK Search Parity

VantaDB exposes the same search capabilities across bindings, but the search() name carries different semantics per SDK. Read this before porting code between Python and TypeScript. The canonical method→domain map lives in docs/api/BINDINGS_NAMESPACES.md.

Capability Python SDK TypeScript SDK
search() meaning Hybrid memory search (vector + text, namespace-scoped) → returns SearchHit[] Hybrid search (vector + text) → returns SearchHit[]
Pure vector ANN search_vector(vector, top_k=10) searchVector(vector, topK?)
Hybrid (vector + text) search(namespace, query_vector, text_query=...) search({ namespace, query_vector, text_query })
Namespace scoping search(namespace=...) (search_vector() is global over nodes) search({ namespace })
Filters search(filters=...) search({ filters })
top_k search(top_k=) search({ top_k }) / searchVector(v, topK)
distance_metric search(distance_metric="cosine"/"euclidean") search({ distance_metric: "Cosine"/"Euclidean" })
text_query search(text_query=...) search({ text_query })
Explain search(explain=True) + explain_memory_search() search({ explain }) + explainSearch()
Batch search search_batch(vectors) / search_batch_requests(requests) — Python-only —
Hybrid method / profile override search(method=...) — Python-only —

Porting hazard: search() in Python is namespace-scoped hybrid memory search, while search() in TypeScript takes an options object — read the table rows before porting. To get hybrid search in Python use search() / memory.search(); to get pure vector ANN in Python use search_vector() (in TypeScript use searchVector()).

🤖 Use Case: Memory for AI Agents

VantaDB is optimized to act as long-term memory for local autonomous agents (Claude, Gemini, LLaMA, etc.):

  • Zero-Copy Persistence: Data survives agent restarts with no serialization overhead.
  • Hybrid RRF search: Combines semantic similarity (vectors) with lexical matching (BM25) for precise context retrieval.
  • Explicit Memory Control: memory_limit_bytes prevents the agent from collapsing the host device's RAM.
  • Embedded: No external servers, no Docker, no network latency. Ideal for edge and offline devices.

🛠️ Development and Testing

# Run the SDK test suite
pytest tests/test_sdk.py -v

# Format Python code
black tests/ vantadb_python/

📜 License

Distributed under the VantaDB main project license. See the LICENSE at the repository root.

Metadata

Release files for vantadb-py 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for vantadb-py 0.9.0
File Actions
vantadb_py-0.9.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for vantadb_py-0.9.0-cp311-abi3-win_amd64.whl
vantadb_py-0.9.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details for vantadb_py-0.9.0-cp311-abi3-manylinux_2_28_x86_64.whl
vantadb_py-0.9.0-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details for vantadb_py-0.9.0-cp311-abi3-manylinux_2_28_aarch64.whl
vantadb_py-0.9.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for vantadb_py-0.9.0-cp311-abi3-macosx_11_0_arm64.whl

Total release size: 10.3 MB

Release files / vantadb_py-0.9.0-cp311-abi3-win_amd64.whl

Download URL vantadb_py-0.9.0-cp311-abi3-win_amd64.whl
Size 2.5 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3ae3caa91cfa63c847e5e7a2e851708bec5bfa85a7924263210d2ae221a3f101
BLAKE2b-256 checksum
How to use checksums
2defa667f0d1e4ceeecc0bf47cd03ab681ffba6fa9de0eea1a1cad7cf04faa68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / vantadb_py-0.9.0-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL vantadb_py-0.9.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 2.7 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
a75785898b889d3941ca152cf44a552deeed7d6b7eb777b8cee441f21708a0f4
BLAKE2b-256 checksum
How to use checksums
1faba7bb3e72673bc0ca837a8e0c8a32ab80325bceafb09df6de3d8a1a42f370
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / vantadb_py-0.9.0-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL vantadb_py-0.9.0-cp311-abi3-manylinux_2_28_aarch64.whl
Size 2.6 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
2757a825a31f2687821025669f18357fad996c39b162e1d9d919a476839d7fd6
BLAKE2b-256 checksum
How to use checksums
e5fd3717358bf9a3c22a9efe4bdecf7f9486121e247d922f121ecd12de74f0ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / vantadb_py-0.9.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL vantadb_py-0.9.0-cp311-abi3-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
10a4450a43d1d378c77aa939739c537ca649b01344e8e82dea5b35cadfabf5d7
BLAKE2b-256 checksum
How to use checksums
d1dd3bff49317de8223161f4e1810918131b5672f8ac20674ee60aa39c5240f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for vantadb-py 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page