Get your API key
Visit memlayer.online and create a free account. Activation is instant and no credit card is required. Once you’re in the dashboard, copy your API key — it looks like
ml_live_xxx. Keep it somewhere safe; you’ll use it in the next step.Install the SDK
Install the MemLayer Python SDK from PyPI using pip.The SDK supports Python 3.10 and above and has no heavy dependencies. It exposes both a synchronous client (
MemLayerClient) and an async client (AsyncMemLayerClient) from the same memlayer package.Initialize the client
Import The client is stateless and thread-safe, so you can create it once at startup and reuse it across your application.
MemLayerClient and create an instance with your API key and the MemLayer base URL. Storing the key in an environment variable is strongly recommended — see the Authentication page for the full pattern.Store a memory
Call The response includes:
client.remember() to store a piece of information about a specific user and agent pairing. Pass a memory_type to tell MemLayer how to classify and score the memory, and an importance float between 0.0 and 1.0 to indicate how significant this memory is relative to others.id— the unique identifier for this memory, which you can use withupdate()orforget()later.is_duplicate—Truewhen MemLayer detected that a near-identical memory already exists, so no new record was written. Use this flag to avoid noisy duplicate storage in high-frequency pipelines.
Retrieve memories
Call Each result exposes
client.recall() with a natural-language query to fetch the memories most relevant to your current context. MemLayer scores candidates using hybrid semantic and importance ranking and returns them in descending order of relevance.content (the original text), score (the combined relevance score), memory_type, and id. Use score to filter out low-confidence memories before injecting them into a prompt.Load session context
Call
client.context() at the start of every session to fetch the highest-scoring memories for a user and agent pairing. The response object exposes a .memories list that you can loop over to build your system prompt.context() ranks and selects the most relevant memories automatically, so you don’t need to filter recall() results yourself when building a prompt. Use recall() directly when you need access to raw scores or other memory metadata.The free plan includes 500 memories and 100 requests per day at no cost. If you hit those limits, upgrade to the Pro plan (50,000 memories, 10,000 requests/day) or Enterprise plan for unlimited usage. View all plan details and manage billing at memlayer.online/billing.
Core Concepts
Understand episodic, semantic, and summary memory types and when to use each one in your agent.
Guides
Explore practical patterns for storing and retrieving memories in real agent pipelines.
