Quickstart

Up and running
in three steps

Store a memory, recall it semantically, wire it into your agent.

Step 01

Store your first memory

Send any plain-text string to /v1/memory/remember. Memstore embeds it automatically — no embedding code required on your side.

curl -X POST https://memstore.dev/v1/memory/remember \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "The user prefers concise answers and codes in Python."
  }'
import requests

response = requests.post(
    "https://memstore.dev/v1/memory/remember",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={"content": "The user prefers concise answers and codes in Python."}
)
print(response.json())
# {"id": "abc123...", "content": "...", "created_at": "..."}
const res = await fetch("https://memstore.dev/v1/memory/remember", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    content: "The user prefers concise answers and codes in Python.",
  }),
});
const data = await res.json();
console.log(data);
// { id: "abc123...", content: "...", created_at: "..." }
Response
{
  "id":         "fc6eb8f5-b456-42ba-a7f1-e0fc9be8a9a9",
  "content":    "The user prefers concise answers and codes in Python.",
  "session":    null,
  "metadata":   {},
  "created_at": "2026-03-21T18:15:03.715Z"
}

Step 02

Recall it semantically

Query with natural language using /v1/memory/recall?q=. You don't need the exact wording — Memstore finds what's conceptually relevant.

curl "https://memstore.dev/v1/memory/recall?q=what+language+does+this+user+prefer" \
  -H "Authorization: Bearer YOUR_API_KEY"
response = requests.get(
    "https://memstore.dev/v1/memory/recall",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    params={"q": "what language does this user prefer"}
)
memories = response.json()["memories"]
print(memories[0]["content"])
# "The user prefers concise answers and codes in Python."
const res = await fetch(
  "https://memstore.dev/v1/memory/recall?q=what+language+does+this+user+prefer",
  { headers: { "Authorization": "Bearer YOUR_API_KEY" } }
);
const { memories } = await res.json();
console.log(memories[0].content);
// "The user prefers concise answers and codes in Python."
Response
{
  "memories": [
    {
      "id":         "fc6eb8f5-b456-42ba-a7f1-e0fc9be8a9a9",
      "content":    "The user prefers concise answers and codes in Python.",
      "score":      0.87,
      "created_at": "2026-03-21T18:15:03.715Z"
    }
  ],
  "count": 1,
  "query": "what language does this user prefer"
}
Why this works: The query "what language does this user prefer" never appears in the stored text — yet Memstore returns it at 0.87 similarity because the meaning matches. That's semantic search.

Step 03

Wire it into your agent

The pattern is the same regardless of framework: recall context before you call the LLM, store new facts after. Two lines, infinite memory.

Recall relevant context

Before the LLM call, fetch memories related to the current query and inject them into the system prompt.

GET /v1/memory/recall?q={user_message}

Run your LLM with memory injected

Prepend recalled memories to the system prompt as "Relevant context". The LLM reasons over past facts automatically.

Store anything worth keeping

After the LLM responds, decide what's worth remembering — preferences, decisions, facts — and store it.

POST /v1/memory/remember

import requests, openai

API_KEY = "YOUR_API_KEY"
headers = {"Authorization": f"Bearer {API_KEY}"}

def chat(user_message: str) -> str:
    # ① Recall
    mems = requests.get(
        "https://memstore.dev/v1/memory/recall",
        headers=headers, params={"q": user_message, "top_k": 3}
    ).json().get("memories", [])

    context = "\n".join(m["content"] for m in mems)

    # ② Run LLM with memory injected
    reply = openai.chat.completions.create(
        model="gpt-4o",
        messages=[
            {"role": "system", "content": f"Relevant context:\n{context}"},
            {"role": "user",   "content": user_message},
        ]
    ).choices[0].message.content

    # ③ Store new fact if worth keeping
    requests.post(
        "https://memstore.dev/v1/memory/remember",
        headers=headers,
        json={"content": f"User asked: {user_message}. Agent replied: {reply}"}
    )

    return reply
import OpenAI from "openai";

const openai = new OpenAI();
const BASE   = "https://memstore.dev/v1/memory";
const HDRS   = { "Authorization": "Bearer YOUR_API_KEY" };

async function chat(userMessage) {
  // ① Recall
  const { memories = [] } = await fetch(
    `${BASE}/recall?q=${encodeURIComponent(userMessage)}&top_k=3`,
    { headers: HDRS }
  ).then(r => r.json());

  const context = memories.map(m => m.content).join("\n");

  // ② Run LLM with memory injected
  const { choices } = await openai.chat.completions.create({
    model: "gpt-4o",
    messages: [
      { role: "system", content: `Relevant context:\n${context}` },
      { role: "user",   content: userMessage },
    ],
  });
  const reply = choices[0].message.content;

  // ③ Store new fact
  await fetch(`${BASE}/remember`, {
    method: "POST",
    headers: { ...HDRS, "Content-Type": "application/json" },
    body: JSON.stringify({ content: `User: ${userMessage} | Agent: ${reply}` }),
  });

  return reply;
}