Skip to main content

Python SDK for Recall by VecLabs - cryptographic memory layer for AI agents

Project description

recall-sdk-python

Python SDK for VecLabs Recall — decentralized vector memory for AI agents.

PyPI Version Tests License: MIT Python


Install

pip install solvec --pre

Quick Start

from solvec import SolVec

sv = SolVec(api_key="your-api-key")
collection = sv.collection("agent-memory", dimensions=1536)

# Upsert vectors
collection.upsert([{
    "id": "mem_001",
    "values": [...],
    "metadata": {"text": "User prefers dark mode"}
}])

# Query
results = collection.query(vector=[...], top_k=5)

# Verify collection integrity against on-chain Merkle root
proof = collection.verify()
print(proof.solana_explorer_url)

Authentication

Get an API key at app.veclabs.xyz.

import os
from solvec import SolVec

sv = SolVec(api_key=os.environ["RECALL_API_KEY"])

Self-hosted with Shadow Drive (bring your own Solana wallet):

sv = SolVec(
    network="devnet",
    wallet="~/.config/solana/id.json",
    shadow_drive=True
)

API Reference

SolVec(api_key?, network?, wallet?, shadow_drive?)

Creates a client. Use api_key for hosted mode or wallet + shadow_drive=True for self-hosted.

sv.collection(name, dimensions?)

Returns a collection handle. Creates the collection on first write. dimensions required on first write, inferred after.

collection = sv.collection("my-collection", dimensions=1536)

collection.upsert(vectors)

Insert or update vectors. Each vector requires id and values. metadata is optional.

collection.upsert([
    {"id": "v1", "values": [...], "metadata": {"source": "gpt-4"}},
    {"id": "v2", "values": [...]}
])

After every upsert, a SHA-256 Merkle root of all vector IDs is posted to the Solana Anchor program on-chain.

collection.query(vector, top_k?, metric?)

Nearest-neighbor search. Returns top-k results with scores and metadata.

results = collection.query(
    vector=[...],
    top_k=10,              # default: 10
    metric="cosine"        # cosine (default), euclidean, dot
)

for match in results.matches:
    print(match.id, match.score, match.metadata)

collection.delete(ids)

Delete vectors by ID.

collection.delete(["v1", "v2"])

collection.verify()

Fetches the on-chain Merkle root from Solana and verifies it against the current collection state.

proof = collection.verify()
print(proof.valid)               # bool
print(proof.on_chain_root)       # str
print(proof.computed_root)       # str
print(proof.solana_explorer_url) # str

collection.stats()

Returns collection statistics.

stats = collection.stats()
print(stats.vector_count)   # int
print(stats.dimensions)     # int
print(stats.merkle_root)    # str

Migrating from Pinecone

The API is intentionally shaped to match Pinecone's client. Migration is three line changes:

# Before
from pinecone import Pinecone
pc = Pinecone(api_key="YOUR_KEY")
index = pc.Index("my-index")

# After
from solvec import SolVec
sv = SolVec(api_key="YOUR_KEY")
index = sv.collection("my-index")

# Everything below stays identical
index.upsert(vectors=[...])
index.query(vector=[...], top_k=10)
index.verify()  # new — Pinecone has no equivalent

Usage with LangChain

from langchain.vectorstores import VecLabsRecall
from langchain.embeddings import OpenAIEmbeddings

vectorstore = VecLabsRecall(
    api_key="your-api-key",
    collection="langchain-memory",
    embedding=OpenAIEmbeddings()
)

vectorstore.add_texts(["User prefers dark mode", "Meeting at 3pm"])
docs = vectorstore.similarity_search("user preferences", k=5)

LangChain integration is in progress. Star the repo to follow along.


Development

git clone https://github.com/veclabs/recall-sdk-python
cd recall-sdk-python

pip install hatch
hatch build
pytest tests/ -v   # 48 tests

Status

Feature Status
Hosted API (api key mode) ✅ Live
Shadow Drive (self-host) ✅ Available — shadow_drive=True
Merkle verification ✅ Complete
TypeScript parity ✅ 48/48 tests — full parity
LangChain integration 📋 In progress
LlamaIndex integration 📋 Planned
AutoGen integration 📋 Planned

Related


Contributing

See CONTRIBUTING.md.

Priority: LangChain integration, LlamaIndex integration, AutoGen integration.


License

MIT. See LICENSE.


veclabs.xyz · @veclabs · Discord

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solvec-0.1.0a10.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solvec-0.1.0a10-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file solvec-0.1.0a10.tar.gz.

File metadata

  • Download URL: solvec-0.1.0a10.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for solvec-0.1.0a10.tar.gz
Algorithm Hash digest
SHA256 418ee8e5f505812c309ac003ed464dd74409c4291e3001a0e5059c1cf23e49a0
MD5 16d990ca61833322d924cc3a41027290
BLAKE2b-256 e80cddad67cf1bbc88134472244f2179e7e9a7466ebe7045fbde38a8ef4daef9

See more details on using hashes here.

File details

Details for the file solvec-0.1.0a10-py3-none-any.whl.

File metadata

  • Download URL: solvec-0.1.0a10-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for solvec-0.1.0a10-py3-none-any.whl
Algorithm Hash digest
SHA256 b04a88e31800d8c0be51cdf31ead62c9073192af590310369590bb36ac16a618
MD5 3d97bc06f8cb4aaa9ab9d51dd3502201
BLAKE2b-256 eeb37df7a10c21ca1cc22cfdfc91cf56ea89a53f269dbb8d3466d4e68499f05c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page