Skip to main content
Once you have an API key (from the Quickstart), you can see Synap’s memory in action in a few lines. This page ingests a single message, shows what Synap pulls out of it, and retrieves it back.
This is a B2C example: one user, identified by user_id alone. On a B2B instance you also pass a customer_id. See Identifiers & Scopes.

1. Ingest one message

You hand Synap raw text; it runs the ingestion pipeline and stores structured memory. The call returns immediately with an ingestion_id you can wait on.
first_memory.py
import asyncio
from maximem_synap import MaximemSynapSDK

async def main():
    sdk = MaximemSynapSDK()          # reads SYNAP_API_KEY from the environment
    await sdk.initialize()
    try:
        result = await sdk.memories.create(
            document=(
                "User: I'm Alex, I run a small coffee roastery in Portland. "
                "I always prefer email over phone, and I'm planning to expand to a "
                "second location next spring."
            ),
            document_type="ai-chat-conversation",
            user_id="user_alex",
        )

        # Block until the pipeline finishes (good for scripts and tests).
        await sdk.memories.wait_for_completion(result.ingestion_id)
        print("Ingested:", result.ingestion_id)
    finally:
        await sdk.shutdown()

asyncio.run(main())

2. See what Synap extracted

From that one message, Synap extracts structured memory types, not just a blob of text:
TypeWhat it found
FactAlex runs a coffee roastery in Portland.
PreferencePrefers email over phone.
Temporal eventPlanning a second location next spring.
EntitiesAlex, Portland, coffee roastery (resolved and linked in the graph).
You did not tag any of this by hand. Extraction and entity resolution happen automatically.

3. Read it back

On the next turn, fetch context for the same scope you ingested at, before you call your LLM:
context = await sdk.user.context.fetch(
    user_id="user_alex",
    search_query=["communication preferences", "business"],
)

for fact in context.facts:
    print("fact:", fact.content)
for pref in context.preferences:
    print("preference:", pref.content)
Inject context.facts and context.preferences into your system prompt, and your agent now “remembers” Alex on every future conversation.

Where to go next

Quickstart

The full setup: create a Client, an Instance, and an API key, then run the loop.

Memory Model Cheat Sheet

The 5 identifiers, 2 write paths, and 4 fetch interfaces on one page.

Playground

Try it in the browser, no install or API key needed.

First Integration

Wire Synap into a real FastAPI + LLM app, end to end.