Skip to main content

maximem-vity-sdk

Vity by Maximem AI — a lightweight Python SDK for cross-session semantic memory. Store facts and preferences, recall relevant context for a prompt, run semantic search, and capture whole conversation turns — all over the Maximem REST API.

from maximem_vity import VityClient

client = VityClient(api_key="mx_...")

# Recall context ready to inject into a system prompt
context = client.recall(current_prompt="What color theme does the user like?")

# Store an explicit fact
client.store("User prefers dark mode", memory_type="preference")

# Semantic search
hits = client.search("editor preferences", top_k=5)

Installation

pip install maximem-vity-sdk

Requires Python ≥ 3.9. The only runtime dependency is httpx.

Authentication

Every request is authenticated with a Maximem API key (it starts with mx_). The API key owns the memory spaceVityClient takes no channel or user ID. Use a separate API key whenever memories must be isolated between users or accounts.

Get your key at maximem.ai/dashboard.

import os
from maximem_vity import VityClient

client = VityClient(api_key=os.environ["MAXIMEM_API_KEY"])
export MAXIMEM_API_KEY="mx_..."

API

recall(current_prompt, recent_messages=None, max_tokens=1000, strategy="hybrid") -> str

Returns a plain-text context block for the current prompt, ready to inject into a system prompt (empty string if nothing relevant). strategy is one of "semantic", "recency", or "hybrid".

context = client.recall(
    current_prompt="Remind me what we decided about the API.",
    recent_messages=[{"role": "user", "content": "Let's revisit the API."}],
    max_tokens=800,
)

store(content, memory_type="fact", category="", importance="medium") -> dict

Stores a single explicit memory. memory_type accepts the high-level aliases fact, preference, emotion, episode, knowledge, profile (mapped to Maximem categories automatically), or pass category directly to override. importance is "low", "medium", or "high". Returns {"id": ..., "stored": True}.

client.store("User's timezone is IST", memory_type="fact", importance="high")

search(query, top_k=10, limit=0, category="", min_score=0.0) -> list[dict]

Semantic search. Returns a list of dicts shaped as {"content", "type", "score", "id", "created_at"}. top_k is the convenience limit (capped at 20 by the API); limit overrides it when set.

for hit in client.search("favourite languages", top_k=5, min_score=0.3):
    print(hit["score"], hit["content"])

capture(messages, agent_id="hermes", session_key="") -> dict

Captures a full conversation turn into long-term memory. messages is a list of {"role", "content", "timestamp"} dicts (timestamps are filled in if omitted). Returns {"captured": N, "deduplicated": M}.

client.capture([
    {"role": "user", "content": "I hate comic sans"},
    {"role": "assistant", "content": "Noted — I'll avoid it."},
])

forget(query="", dry_run=True) -> dict

Deletes memories matching a query. Defaults to a dry run — pass dry_run=False to actually delete. Returns {"count": N, "ids": [...]}.

preview = client.forget(query="old project notes")          # safe preview
client.forget(query="old project notes", dry_run=False)     # actually delete

Convenience shims

  • ingest(messages, session_id="") — alias for capture().
  • get_profile() — a broad search returning the user's stored memories.

Lifecycle

VityClient holds a pooled HTTP connection. Close it explicitly or use it as a context manager:

with VityClient(api_key="mx_...") as client:
    client.store("User prefers tabs over spaces")
# connection closed automatically

Error handling

All errors derive from VityError:

Exception Raised when
VityAuthError API key missing or invalid (HTTP 401)
VityRateLimitError Rate limit exceeded (HTTP 429) — back off and retry
VityUnavailableError Network error, timeout, or service error (HTTP 5xx)
VityError Any other API error
from maximem_vity import VityClient, VityError

try:
    client.store("...")
except VityError as e:
    logger.warning("Memory write failed: %s", e)

Configuration

Option Default Description
api_key Required. Maximem API key (mx_...).
endpoint https://agenticrouter-prod.maximem.ai Override for staging.
timeout 30.0 Per-request timeout in seconds.

Development

pip install -e ".[dev]"
pytest                      # run the test suite
python -m build             # build the wheel + sdist into dist/

License

MIT © Maximem AI

Download files

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

Source Distribution

maximem_vity_sdk-0.2.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

maximem_vity_sdk-0.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file maximem_vity_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: maximem_vity_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for maximem_vity_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7934f71f59fc11fb88b4c13bb11a8d5e68c7302d05e1a99e92798ab3dd6c6e59
MD5 8f67db7c76dfe15833d441345c406be8
BLAKE2b-256 95eb180457971644cfedf34d85a9e9bf3598d7d7aec4cd2bc251ae505685714e

See more details on using hashes here.

File details

Details for the file maximem_vity_sdk-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for maximem_vity_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef135401d3f0912e81a162a9b5f73f74b7d38cdedc5f6bbe3e815dd40948fa42
MD5 eee1d51dfb61452cc3170ffa63775a0b
BLAKE2b-256 350128a28dbd48d79c4d3bc51465cce7114a333063fd7c38ff5ae8e59c90722c

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