Skip to main content

anansi-memory

Persistent memory for AI apps, backed by a bi-temporal knowledge graph — every fact carries when it was true and when you learned it. Give any LLM app long-term memory in two API calls. MIT-licensed and self-hostable.

pip install anansi-memory

Usage

from anansi_memory import AnansiMemory

memory = AnansiMemory(api_key="ans_...")

# Store a conversation turn
memory.ingest(
    user_id="user_123",
    content="User is building a voice agent. Prefers TypeScript. Team of 4.",
    source_type="conversation",
)

# Before your next LLM call — inject synthesized context into the system prompt
ctx = memory.context(user_id="user_123", q="what is the user building?")
system_prompt = f"You are a helpful assistant.\n\n{ctx.format_for_prompt()}"

context() returns a synthesized profile — static facts and dynamic context that drop straight into a prompt, plus relevant chunks when you pass q. No chunks to dedupe, rank, or trim yourself.

API

AnansiMemory(api_key, base_url=None)

Param Type Description
api_key str Your API key (ans_...)
base_url str Override API base URL (default: https://anansimemory.com)

memory.ingest(user_id, content, source_type=None, source_id=None, metadata=None, embedding=None, session_id=None, agent_id=None)

Store content in a user's memory. Returns IngestResult(id, queued=True).

Param Type Required Description
user_id str ✓ Your internal user ID
content str ✓ Text to remember, max 100 KB
source_type str "conversation", "document", "note", "meeting", "custom"
source_id str Idempotency key — re-ingesting the same ID is a no-op
metadata dict title, author, timestamp, any custom fields

memory.context(user_id, q=None, as_of=None, as_of_knowledge=None)

Retrieve synthesized memory for a user. Returns ContextResult(static, dynamic, relevant, ...). Pass as_of / as_of_knowledge for a bi-temporal point-in-time view (Pro+).

Also available

results  = memory.search(user_id="user_123", query="dark mode", search_mode="hybrid")
chunks   = memory.list_memories("user_123", source_type="conversation")
entities = memory.list_entities("user_123", as_of="2026-05-01", as_of_knowledge="2026-05-01")
memory.delete_user("user_123")  # GDPR hard-delete

# LangChain-compatible retriever (no langchain dependency required)
from anansi_memory.langchain import AnansiRetriever
retriever = AnansiRetriever(api_key="ans_...", user_id="user_123")
docs = retriever.get_relevant_documents("what stack does the user prefer?")

list_entities accepts as_of (the graph as it was valid at an instant) and as_of_knowledge (the graph as we knew it at an instant). The entity graph is a Pro+ feature.

Error handling

from anansi_memory import AnansiMemory, AnansiError

try:
    memory.ingest(user_id=user_id, content=content)
except AnansiError as e:
    print(e.status_code, e.args[0])
    # 401 — invalid API key
    # 402 — monthly quota exceeded
    # 413 — content too large
    # 429 — rate limit (retry after 60s)

Requirements

Python 3.9+. No external dependencies — uses stdlib urllib only.

MIT licensed.

Metadata

Release files for anansi-memory 0.3.0

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

Source distribution (sdist)

Source distribution for anansi-memory 0.3.0
File Size Uploaded Provenance Actions
anansi_memory-0.3.0.tar.gz 6.5 kB With provenance Details for anansi_memory-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for anansi-memory 0.3.0
File Interpreter ABI Platform Actions
anansi_memory-0.3.0-py3-none-any.whl Python 3 none any Details for anansi_memory-0.3.0-py3-none-any.whl

Total release size: 13.8 kB

Release files / anansi_memory-0.3.0.tar.gz

Download URL anansi_memory-0.3.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e9c2a5e56380043167b3312f38a2b014830586915061d2e685f2872bdf60e88c
BLAKE2b-256 checksum
How to use checksums
284b3aa043dd5194530674a43d034af334ba9ddf43ea9e9c51ff08f820fd36d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 9, 2026.

Transparency log

Release files / anansi_memory-0.3.0-py3-none-any.whl

Download URL anansi_memory-0.3.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae0d93a7b49d438bf5972f43e9a05da0e2b7d06680eb29becc76e5a2a2084147
BLAKE2b-256 checksum
How to use checksums
05c74a448e7e97ea6eae6e4bee7156c08ced3108b6645bdacbc0520afc4142ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 9, 2026.

Transparency log

Security for anansi-memory 0.3.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for anansi_memory-0.3.0.tar.gz

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 Jul 9, 2026.

Transparency log

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