Cookbooks

Cookbooks

End-to-end recipes that wire Memsy into a real app — Next.js, FastAPI, Slack, and tool-calling agents. Each one runs as written.

The guides elsewhere in these docs explain one API at a time. The cookbooks do the opposite: each one is a complete, runnable app built around a single integration point, with the framework's own conventions respected rather than glossed over.

Every recipe uses only what ships in the currently published SDKs — ingest() and search(). No preview APIs, and nothing that needs a version newer than the one Installation gives you.

Which recipe fits your app

Recall happensBest when
Next.js chatOnce per turn, before the LLMChat UIs where every turn benefits from context
FastAPI agentOnce per request, before the LLMRequest/response APIs with a latency budget
Slack botOnce per mentionEvent-driven apps with no request/response shape
Agent toolOnly when the model asksMulti-step agents where most turns need no history

The first three prefetch: they search on every turn and paste the results into the system prompt. That is simpler, and it costs one search per turn whether or not memory was relevant. The fourth makes recall a tool call — cheaper across a long agent run, at the cost of the model sometimes not asking when it should have.

Before you start

Every recipe assumes two environment variables:

export MEMSY_BASE_URL="https://api.memsy.io/v1"
export MEMSY_API_KEY="msy_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Get a key from app.memsy.io → API Keys, or follow the Quickstart first.

Warning

MEMSY_API_KEY is a server-side secret. None of these recipes call Memsy from the browser, and yours shouldn't either — a key shipped to the client can read every memory in your org.

The shape shared by all four

Whatever the framework, the loop is the same three moves:

  1. Recall — search(query, actor_id=...) for memories relevant to what the user just said.
  2. Ground — paste those memories into the system prompt.
  3. Record — ingest([...]) the turn so the next session can recall it.

If a recipe below looks like overkill for your app, that loop in fifteen lines is a legitimate integration. The rest is plumbing for a specific framework's idea of a request.