Skip to main content

🐍 VantaDB Python SDK

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.

Release files for vantadb-py 0.7.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.7.0
File
vantadb_py-0.7.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
vantadb_py-0.7.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
vantadb_py-0.7.0-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
vantadb_py-0.7.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details

Total release size: 8.9 MB

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

Download URL vantadb_py-0.7.0-cp311-abi3-win_amd64.whl
Size 2.2 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d3fa90333137494942faf71fa8c4b5442ccd20bfa51220b3673a26d179a6839d
BLAKE2b-256 checksum
How to use checksums
6735275e0fe41138c748d8ea9ff95bfd92a3ebaec1acca0758e265e2f84a7038
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

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

Download URL vantadb_py-0.7.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 2.4 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
93775be82e54de90213aa29f3f8b72a5f10366d7e10e776aacffdddc565bffd2
BLAKE2b-256 checksum
How to use checksums
76d05957e4edbeae145baff150834b0df37e921991aed526f9825c287a68cc65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

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

Download URL vantadb_py-0.7.0-cp311-abi3-manylinux_2_28_aarch64.whl
Size 2.3 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
2d4de4d4806242f7e61f173ca79e085eb6e85a39baeb26936336c410a7102b73
BLAKE2b-256 checksum
How to use checksums
e8239134b71d653ae31f9db55f1f83a01c58f863b036eb2d92ef421e8cd9ac90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

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

Download URL vantadb_py-0.7.0-cp311-abi3-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c04846cf7249f7b89418aba44ef06811f0768fe39f24ccb8c6c00082e86226f9
BLAKE2b-256 checksum
How to use checksums
a937941ca857d6c0cd9666765765ef0030064cc349f457a2843df7f6cfe78af9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.0 This release

4 release files

0.6.1

4 release files

0.5.0

3 release files

0.4.0

3 release files

0.2.0

3 release files

0.1.5

3 release files

0.1.4

3 release files

0.1.3

3 release files

0.1.2

3 release files

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