Start here

The memory API for agents that need to remember

One call writes what happened. One call reads what matters on the next turn. AI Memory keeps durable memory outside the model and outside the prompt, so your agent does not start every session as a stranger.

Updated October 19, 20269 min readAI Memory field guide
A violet API gateway with orbiting memory nodes on a near-black background.

What a memory API does that a vector database does not

A vector database stores embeddings and returns similar chunks. A memory API stores what an agent learned about a person, an account, a project or a decision, then returns the small set of facts that should influence the next response.

That difference matters in production. Documents do not change when a customer upgrades a plan. A memory does. A document does not become wrong when a decision is reversed. A memory should. A document is usually shared by everyone. A memory has an owner, a scope and a retention policy.

AI Memory handles the write path and the read path. On write, it extracts facts, preferences, decisions, constraints and episodes, merges them with what is already known, and compresses the episode down to its signal. On read, it scores semantic similarity, recency, memory kind and the entity graph together, then reranks the result against a token budget.

The five operations behind the API

Most integrations only need add and search. The other operations exist because memory has to be correctable, portable and removable.

OperationWhat it doesWhy it matters
AddAccepts a message array, text or JSON and attaches user, agent, session and tenant scope.You can send the events you already have without rewriting your data model.
SearchReturns ranked memories for a natural-language query with filters and a token budget.The model receives a handful of relevant lines instead of the entire transcript.
UpdateChanges a memory when the newest truth supersedes an older one.A changed plan does not leave two contradictory facts behind.
DeleteRemoves a memory, a scope or a whole user or tenant.Retention, redaction and deletion requests are part of the product, not an afterthought.
ExportReturns the memory graph as JSON.You can move the graph to another deployment or keep a copy outside the service.

The public examples on the AI Memory home page use POST https://api.ai-memory.lol/v1/memories and POST https://api.ai-memory.lol/v1/search. The Python and TypeScript SDKs wrap the same contract.

Scopes are enforced at query time

A memory layer is only safe if one user cannot retrieve another user’s context. AI Memory carries four scopes on every write and filters on them at read time.

ScopeExampleWhat it protects
Useruser:danaPersonal preferences, history and commitments.
Agentagent:support-botWhat one agent learned while doing its job.
Sessionsession:checkout-4821Short-lived context that should not follow the user forever.
Tenanttenant:northwindAccount-level facts and isolation between customers.

Python: add an event, then search it back

The write is deliberately boring. Send the messages you already have, attach the ids you already use, and let the extraction pass decide what deserves to persist.

Pythonpython
from aimemory import Memory

memory = Memory(api_key="aim_live_...")

memory.add(
    messages=[{"role": "user", "content": "we moved to the Scale plan"}],
    user_id="dana",
    agent_id="support-bot",
    metadata={"tenant": "northwind"},
)

context = memory.search(
    "how does Northwind like to be contacted?",
    user_id="dana",
    agent_id="support-bot",
    limit=5,
)

TypeScript: the same contract in the browser-adjacent stack

The TypeScript SDK is useful when the agent runs in a Next.js app, an edge function or a Node service. Keep the API key on the server and pass only the ids your application already trusts.

TypeScripttypescript
import { Memory } from '@aimemory/sdk';

const memory = new Memory({ apiKey: process.env.AI_MEMORY_KEY });

await memory.add({
  messages: [{ role: 'user', content: 'the audit starts in March' }],
  userId: 'dana',
  metadata: { tenant: 'northwind' },
});

const context = await memory.search({
  query: 'what constrains the migration?',
  userId: 'dana',
  rerank: true,
});

Compression is part of the contract

A memory API that only appends is a transcript with a search box. The useful version has to collapse near-duplicates, resolve contradictions and keep the numbers, decisions and constraints that change behavior.

AI Memory keeps superseded facts as versions instead of silently overwriting them, and it preserves verbatim quotes when the exact wording carries the meaning. The result is a smaller prompt, a lower token bill and fewer cases where the model repeats an old truth.

  • Deduplicate and merge updates instead of appending every message.
  • Resolve contradictions to the newest truth while keeping an audit trail.
  • Apply a per-request token budget so retrieval cannot quietly grow without limit.
  • Export the graph as JSON when you need a copy outside the service.

What to check before you adopt any memory API

Memory is more sensitive than a document index because it contains conclusions about people and accounts. Ask hard questions before you send production data.

  • Can the provider filter by user, agent, session and tenant at read time?
  • Can you delete one memory, one user or one tenant without breaking the graph?
  • Can you see the source, scope and timestamp behind a memory?
  • Can you export the graph and replay it somewhere else?
  • Can you self-host or bring your own database if your data residency rules require it?
  • Does the provider use your content for model training? The answer should be no.

Frequently asked questions

Is AI Memory a vector database?

No. Vectors are one part of retrieval. AI Memory also stores memory kind, scope, source, timestamps, versions and entity relationships, then scores and reranks them together.

Does the API work with any model?

Yes. The memory layer sits beside the model rather than inside it. You can use OpenAI, Anthropic, Google, an open model or a mix, and keep the same memory contract.

Do I need to rewrite my application?

No. If you can make an HTTP call, you can add memory. There are SDKs for Python and TypeScript and framework adapters for common agent stacks.

How fast is retrieval?

The reference build on the AI Memory home page reports a p50 retrieval time of 10 ms. Treat that as a reference figure for our own build, not a guarantee for your workload or region.

What happens when a memory is wrong?

Update it, delete it, or let the next event supersede it. Superseded memories are versioned rather than silently dropped, so you can inspect what the agent believed and when.

Can I export everything?

Yes. The memory graph exports as JSON, and the same data can be imported into another deployment or kept as an offline copy.

How is billing measured?

AI Memory plans are published around stored memories: Pro includes 50,000 and Scale includes 500,000. Check the pricing page for the current limits and annual discount.

Can I try it before subscribing?

The home page includes a seeded console that runs entirely in the browser. You can add, search and inspect memories without sending data to a backend, then choose a plan when you are ready to connect your own events.

Give your agent a memory it can keep

Start with the API, connect one real event stream, and measure the difference in recall, tokens and contradictions before you scale it.