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.8.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.8.0
File
vantadb_py-0.8.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
vantadb_py-0.8.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
vantadb_py-0.8.0-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
vantadb_py-0.8.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details

Total release size: 9.4 MB

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

Download URL vantadb_py-0.8.0-cp311-abi3-win_amd64.whl
Size 2.3 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
fe4ccd0b157f220701c860b590e88aed8554311ed5b655d9ceb7db336622a8f6
BLAKE2b-256 checksum
How to use checksums
f41b40794cf062f8f14ec8d4fba49cdee9fdaf0a5fb6e075f66411b86b9444cf
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 Oct 2, 2026.

Transparency log

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

Download URL vantadb_py-0.8.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 2.5 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
d6ed17b3c26a0f5ba9ddd5cb39c2de57d8a15a4152b546d32859cebd7e2bfa42
BLAKE2b-256 checksum
How to use checksums
55a34124cc7351453ad100b5d16bee77d74048e824f51214282c5d469bf96bb8
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 Oct 2, 2026.

Transparency log

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

Download URL vantadb_py-0.8.0-cp311-abi3-manylinux_2_28_aarch64.whl
Size 2.4 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
45bb093c4332b89b8894577867db0792abc28b2712b32703082ab3173c8f92ba
BLAKE2b-256 checksum
How to use checksums
2366324e54bb2422c15a0b38d9d9c84f11f4af47124fc4b83f12fbd07f4d8dca
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 Oct 2, 2026.

Transparency log

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

Download URL vantadb_py-0.8.0-cp311-abi3-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
18b608c4cbc0f768f045598be9a6510879d98e346af58feb240ff53ea2eb0671
BLAKE2b-256 checksum
How to use checksums
500c62902013b9824796a3164a237f94ed4396ba24f4a04acf79f17f5d285069
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 Oct 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.8.0 This release

4 release files

0.7.0

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