Core Concepts
Memory Fundamentals
A memory is durable context your application can save for an end user and retrieve later by meaning.
What a memory is
Store one useful fact, preference, decision, event, or outcome per memory. MemorySync returns relevant memories when your application asks a related question—even when the wording is different.
What to remember
Good memory
Durable, confirmed context that improves a later task.
- A preference that should apply later.
- A decision or constraint for future work.
- A sourced fact or completed outcome.
Keep elsewhere
Temporary, sensitive, or unverified material needs a different home.
- One-request instructions.
- Passwords, API keys, tokens, or hidden prompts.
- Raw model output or an unselected full transcript.
Add and retrieve
import osfrom memorysync import MemorySyncClientclient = MemorySyncClient(api_key=os.environ["MEMORYSYNC_API_KEY"],base_url="https://api.memorysync.io",project_id=os.environ["MEMORYSYNC_PROJECT_ID"],end_user_id="user-123",)memory = client.add("The user prefers concise answers and dark mode.",source="profile",tags=["preference", "ui"],)
import osfrom memorysync import MemorySyncClientclient = MemorySyncClient(api_key=os.environ["MEMORYSYNC_API_KEY"],base_url="https://api.memorysync.io",project_id=os.environ["MEMORYSYNC_PROJECT_ID"],end_user_id="user-123",)result = client.query("How should I format the answer?",k=5,filters={"tags": ["preference"]},)
Every request has a scope
Use the same project and end-user identifiers when adding and querying memory. These identifiers are access boundaries, not labels.
- Keep API keys on your server.
- Use stable, opaque end-user IDs rather than email addresses.
- Authorize the end user in your own application before calling MemorySync.
Continue
Was this page helpful?