Full API walkthrough for the tensory Python library.
Create a store with an embedder for vector search and an LLM function for claim extraction.
from tensory import Tensory, Claim, Context
from tensory.embedder import OpenAIEmbedder
store = await Tensory.create(
"memory.db",
llm=my_llm_fn, # any async (str) -> str
embedder=OpenAIEmbedder(api_key="sk-..."), # or dim=512 for cheaper
)A research context is the lens that shapes what gets extracted. The goal and domain tell the extraction pipeline what matters.
ctx = await store.create_context(
goal="Track DeFi team movements and protocol partnerships",
domain="crypto",
)Two modes for ingesting information.
Pass raw text and a context. The LLM extracts claims, relations, and detects collisions with existing knowledge -- all relative to the context lens.
result = await store.add(
"Google announced partnership with EigenLayer for cloud restaking...",
source="reddit:r/defi",
context=ctx,
)
# result.claims — extracted claims
# result.relations — entity relations
# result.collisions — auto-detected conflictsAlready have structured claims? Skip the LLM entirely.
await store.add_claims([
Claim(text="EigenLayer team grew to 60", entities=["EigenLayer"])
])Hybrid search combines vector similarity, full-text search, and graph traversal. Results are weighted by the active context.
results = await store.search("EigenLayer", context=ctx)Track how facts about an entity evolved over time.
history = await store.timeline("EigenLayer")Same source text, different research goal -- produces different claims. Useful when you revisit raw episodes under a new analytical lens.
tech_ctx = await store.create_context(goal="Track Big Tech AI strategy")
new_claims = await store.reevaluate(episode_id=result.episode_id, context=tech_ctx)Cleanup stale data, inspect store health, profile sources, and consolidate recurring patterns.
await store.cleanup(max_age_days=90)
stats = await store.stats()
source_profile = await store.source_stats("reddit:r/defi")
observations = await store.consolidate(days=7, min_cluster=3)