GuidesGuideBuild or buy agent memoryDirectory

Should you build or buy agent memory, and what does hosting it cost?

Updated

Build it if your memory is mostly “keep what users said and find it again”. Postgres with the pgvector extension, an embedding model and one model call to pull facts out of each conversation will do that, and the database is a small, fixed line on the bill. Buy when you need the parts that are hard to get right and keep right: noticing that a new fact replaces an old one, letting unused memories fade, keeping each user’s memories apart, deleting on request.

Either way, the cost that grows with use is the model calls that write memories; storage stays small. That cost depends on how many tokens each write sends, so measure it on your own data before trusting anyone’s figure, ours included. Anthropic’s API returns input_tokens and output_tokens with each response (Anthropic API reference); log them for a day of real writes and multiply by the prices below. If you’ve decided to buy and want to know which system, Which memory layer should I use for my AI agent? answers that.

An AI drafted this page from the sources below and another AI checked it. No person has run these steps, and nothing on this page was built or measured by us: the costs are arithmetic from prices on each vendor’s own pricing page, read 17 November 2026. Counterparts and the directory are ours; Mike LaPeter runs Counterparts.

What you’d build yourself

A working memory has four moving parts, plus the plumbing around them.

PieceWhat it doesModel callsRuns on
Extract

Turns messages into short memories (“prefers aisle seats”)

One per write, often covering several messages

Your model key

Merge

Decides whether a new memory is new, a duplicate, or replaces an old one

Usually folded into the extract call by passing in the closest existing memories; or a later pass

Your model key

Fade

Lowers or drops memories that haven’t come up in a while

None if it’s a rule (age, times recalled); a periodic model pass if you also want old memories summarised

Your database, a scheduled job

Recall

Embeds the question, finds the nearest memories, ranks them and puts the top few in the prompt

One embedding per question; no model call unless you rewrite queries

Your database, an embedding model

Around it

Each user’s memories kept apart, delete and export, a test set to catch regressions

None

Your time

The storage is the easy part. pgvector describes itself as “Open-source vector similarity search for Postgres” that lets you “Store your vectors with the rest of your data”, with exact and approximate nearest-neighbour search (pgvector). Supabase and Neon both document turning it on in their hosted Postgres with one CREATE EXTENSION statement.

What a vector index doesn’t do is know that “moved to Seattle” replaced “lives in Austin”. Both look similar to a question about where someone lives, so both come back. That merge step, and the fade step that keeps old memories from crowding the prompt, are where most of the work goes. Why AI memory goes stale covers how each system handles a changed fact.

Graphiti, the open-source graph framework inside Zep, says plainly what’s left once you have the parts: “you build the service around it: ingestion, tenancy, access control, and operations” (Graphiti README).

What the model calls cost

Every call costs input tokens times the input price plus output tokens times the output price. Prices as of 17 November 2026, per million tokens:

ModelInputOutputSource
Claude Haiku 5.5 (prompts up to 100,000 tokens)

$0.10

$0.50

Anthropic pricing

GPT-6 Luna

$0.10

$0.50

OpenAI pricing

text-embedding-3-small (embeddings)

$0.02

n/a

OpenAI pricing

A worked estimate, not a measurement. Say one extract call reads 8 messages (about 1,400 tokens), your instructions (about 1,500) and the 20 closest existing memories (about 1,000), and writes about 400 tokens back. That’s roughly 4,000 tokens in and 400 out: $0.0004 plus $0.0002, or about $0.60 per 1,000 calls on either model above. The token counts are our assumptions.

Mem0 tested its own pipeline, on LoCoMo, a public benchmark of long conversations, with “about 8 messages” in each add: $3.55 per 1,000 adds on GPT-6 Luna and $4.93 on Claude Haiku 5.5 (Mem0’s model comparison). Mem0 adds that “larger requests cost more”. That’s six to eight times our estimate at the same per-token prices, so Mem0’s calls carry far more context, or there are more of them, than our simple example assumes. A homemade pipeline can be leaner. It can also end up just as heavy once you add the context that makes merging work.

If you build, or use Mem0 with your own key, you choose the model, and two levers move the bill. The model: Mem0’s own table runs from $0.68 per 1,000 adds (Mistral Nemo) to $158.55 (Claude Opus 5.5). And timing: anything that doesn’t have to happen while the user waits, such as a nightly merge-and-fade pass, can go through Anthropic’s Batch API, which takes “a 50 percent discount on both input and output tokens”.

One workload, priced four ways

To compare like with like, take the example Supermemory uses on its own pricing page: 1,000 users who each add 20,000 tokens of conversation a month and run 200 searches. Our assumptions to convert it: about 4 bytes per token (so 80,000 bytes per user), messages averaging 700 bytes (the default in Zep’s own price calculator, so about 114 messages per user), and about 8 messages per Mem0 add (Mem0’s test size, so about 14,300 adds in all). Every total below is our arithmetic from list prices as of 17 November 2026, not a bill anyone received.

RouteWhat you pay forAbout a month
Build: Postgres with pgvector

Hosted Postgres: Supabase Pro is $25 a month with $10 of compute credits (“enough to cover one Micro instance”); Neon’s usage-based Launch plan quotes a “Typical spend” of $15 a month for an intermittent 1 GB database. Extract calls: about $9 at our estimate, or $51 to $70 at Mem0’s tested rates. A nightly merge-and-fade call per user: about $18, or $9 through the Batch API. Embeddings: under $1

$43 to $115, plus the time to build and run it

Mem0, hosted, with your own model key

Mem0 itself: $0 within 50,000 adds and 10,000 retrievals a month. Your model provider: $51 to $70 at Mem0’s tested rates. This workload’s 200,000 searches are over the free 10,000, and the usage-based rate for extra retrievals is “shown when you turn it on”, not published

$51 to $70 or more, plus retrievals at an unpublished rate

Zep, hosted

1 credit per Episode (a message or record) up to 350 bytes and 1 more per extra 350, so about 229,000 credits. Flex is $125 a month with 50,000 credits, then $25 per 10,000; Flex Plus is $375 with 200,000, then $75 per 40,000. Retrieval and storage use no credits, and Zep runs its own model calls

About $450 to $575

Supermemory, hosted

Memory ingestion at $5 per million tokens and searches at $5 per million searches. Supermemory’s own figure for this workload is “about $101 at list rates”, inside the $130 of credits its $100-a-month Max plan includes

About $100

At this size every route costs tens to a few hundred dollars a month, so the hours you’d spend building merge, fade and per-user deletion are likely the larger cost of building. The Mem0 and Zep rows depend on how big each message is. Mem0’s per-add costs come from LoCoMo, whose conversations average 300 turns and 9,000 tokens (LoCoMo paper), about 30 tokens a message by our arithmetic, so adds of eight 700-byte messages are several times larger, and Mem0 says larger requests cost more: read $51 to $70 as a floor. With short chat messages instead, the same 20,000 tokens a user means several times as many Zep Episodes and Mem0 adds. The build row’s range is wide because nobody knows your tokens per write until you measure them.

If your design needs a graph database, the hosting line changes. Graphiti runs on Neo4j, FalkorDB (including an embedded version) or Amazon Neptune. Neo4j’s managed AuraDB Professional starts at $0.09 per GB per hour with a 1 GB minimum, which comes to about $66 for a month left running.

When to build, and when to buy

Building makes sense when:

  • One agent or a handful of users, where plain rows in a table or files you can open are enough, and easier to debug.
  • The memories must stay in your own database next to the rest of your data.
  • You can run the extract model locally. Mem0’s open-source library lists “local LLMs (Ollama)” as a cost option, and Graphiti’s README covers local servers such as Ollama, vLLM and LM Studio.
  • You want to decide what happens when the memory service is down, rather than inherit someone else’s answer.

Buying makes sense when:

  • Many users come back and expect to be remembered, and nobody on the team wants to own a memory pipeline.
  • Facts change often and you need the old version marked as replaced. Mem0’s cloud does this, and its open-source library doesn’t: Mem0’s comparison lists Dream, which “supersedes outdated facts, and merges duplicates per user”, as “Not available” in open source. Check your plan first: Mem0’s Dream docs put the replacing step on every plan, while its pricing page lists Dream under Custom plans.
  • You’d rather pay per message than measure and tune extraction prompts yourself.

Self-hosting a vendor’s open-source version sits in between: their code, your servers and model bill. Check what the cloud has that the code doesn’t. Mem0’s comparison also lists Memory Decay, webhooks, export jobs, batch updates and summaries as not in open source. Supermemory answers “Is supermemory open source?” with “Partly”: its SDKs and plugins are open, but “The memory engine is not open source”. The Mem0, Zep and Supermemory pages in our directory go further.

Which systems make extra model calls

Across the 15 systems in our directory that aren’t an assistant’s own built-in memory (ChatGPT, Claude, Claude Code, Copilot, Gemini and Perplexity are the other six), by our reading of each entry’s cost line (directory data as of 1 November 2026):

  • On every write: Mem0 (an AI call to pull out facts on every add), Zep (“several AI calls per message”), Cognee (when it’s given a model key), Supermemory, and claude-mem (an observer call per tool step, plus a summary each reply).
  • In a separate pass: LangMem (each background run), Letta (its “dreaming” helpers), agent-qa (curation), and Counterparts, which is ours (a daily background write-up run as a short Claude Code session on your subscription).
  • Only if you turn it on: trusty-memory’s merge step.
  • None: Basic Memory, Engram Alpha, Hyperconsciousness, the MCP reference memory server, and Screenpipe for its capture and search.

A small design you can read: Counterparts (ours)

Counterparts isn’t something you can build into an app. It has no SDK or API, and it’s memory for one person’s Claude, not for your users. It’s useful here as a complete memory you can read, with every piece from the table above in one place.

It keeps one SQLite file on your machine, with no database server and no API key. Claude writes the memories itself, in its own words, as it works and at the end of each session, which is the extract step done by the agent instead of a second model. What matters sticks and the rest fades unless it comes up again. Recall matches by keywords and by meaning, using a small model (about 30 MB) that runs on your machine, and weighs each memory by how strong it is. A daily background run writes up any session left unwritten and merges memories (“dreaming”), as a short Claude Code session on your Claude subscription.

The code is open under MIT on GitHub. To watch the design work on your own sessions before you build yours, install it in Claude Code on a Mac, Linux or Windows (new there, through npm), or in Claude Desktop on a Mac.

What people report

From one r/AI_Agents thread asking why developers build their own memory instead of using a service, read from archived copies through the Arctic Shift archive; nobody opened them live on Reddit.

  • “most devs just don’t wanna pay a third party for something they can spin up with chroma and 50 lines of python in an afternoon” (comment)
  • “Memory is the one layer where a bug does not crash your agent, it quietly poisons it, so people want to see exactly what got stored and why.” The same commenter: “The services win when the team is small and speed matters more than ownership.” (comment)
  • “one thing missing from the diy-versus-service comparison is what happens when the memory api is down. does the agent stop, use its last local copy, or carry on without memory?” (comment)

Questions people ask

Do I need a memory product, or will Postgres and pgvector do?

Postgres and pgvector will store memories and find similar ones. You’d still write the extract call, the merge logic that marks a replaced fact, a fade rule, and per-user deletion. If your users’ facts rarely change and you have few users, that’s a small job; if facts change often, it’s most of the work a memory product does.

pgvector or Mem0 for agent memory?

They do different jobs. pgvector is the storage and similarity search; Mem0 adds the extraction call, and in its cloud the step that marks an older fact as replaced (on which plans, Mem0’s docs and pricing page disagree). Mem0’s open-source library can use pgvector as its vector store, so you can run Mem0 on top of Postgres.

Which agent memory provider is cheapest?

It depends on how much you write and search. On one workload (1,000 users, 20,000 tokens of conversation and 200 searches each a month), our arithmetic from list prices as of 17 November 2026 puts building your own at about $43 to $115 plus your time, Mem0 at $51 to $70 or more in model calls plus retrievals at a rate it doesn’t publish, Supermemory at about $100, and Zep at about $450 to $575. On the build and Mem0 routes you pick the model that writes memories, and that choice alone moves the bill several times over.

Why do people build their own instead of using Mem0 or Zep?

The reasons in the r/AI_Agents thread quoted above: a basic version is quick to build, a homemade store is easier to inspect when the agent remembers something wrong, and they’d rather not have their agent’s memory live in someone else’s API. Services win on the parts that take longest to get right, such as merging changed facts.

What do I lose by self-hosting Mem0 instead of using its cloud?

The core calls (add, search, update, delete and the rest) are the same in both. By Mem0’s own comparison, the open-source library doesn’t have Dream (which marks outdated facts and merges duplicates) or Memory Decay (which lets stale memories fade), and has no graph memory, webhooks, export jobs, batch updates or summaries; you provision and pay for the vector store, model and embedder yourself.

How do I build my own agent memory?

Start with the four pieces in the table at the top: an extract call that turns messages into short memories, a merge step that passes in the closest existing memories so a changed fact replaces the old one, a fade rule, and recall by embedding search. Store them in Postgres with pgvector, one row per memory with the user’s id, the text, its embedding and when it was last used. Then add per-user deletion and a small set of test conversations, including a changed fact, before you add users.

Is there a free or cheap memory for an AI app?

Several free tiers cover a prototype, as of 17 November 2026. Mem0 pays the model calls for your first 30 days (10,000 adds and 1,000 retrievals a month), then stays free up to 50,000 adds and 10,000 retrievals with your own model key. Zep starts with 10,000 credits a month, Supermemory with $5 of credits a month, and Letta is free with your own keys for up to 3 agents. To build your own, Supabase (500 MB, paused after a week without activity), Neon (1 GB per project) and Neo4j’s AuraDB each have a free plan.

When do you need a memory layer at all?

When users come back and expect to be remembered, or the history no longer fits in a prompt. Which memory layer should I use for my AI agent? covers that question and the memory tools for agents that keep their own notes, and memory, RAG and the context window covers when a long prompt is enough.

How do I add memory to a bot that uses a model’s API?

Either your code writes memories after each turn (the pieces above, or a service such as Mem0, Zep or Supermemory) and adds the relevant ones to the next prompt, or the model writes its own notes through a memory tool. The memory layer guide compares both designs.

Do I have to run Neo4j for agent memory?

Only for graph-based designs. Graphiti runs on Neo4j, FalkorDB (including an embedded FalkorDB Lite) or Amazon Neptune. Mem0’s open-source library and a plain Postgres-with-pgvector design need no graph database.

Can the memory-writing calls run on a local model?

Yes, for the open-source options. Mem0’s open-source library lists local models through Ollama, and Graphiti’s README covers Ollama, vLLM, llama.cpp and LM Studio. Small models may extract less well: in Mem0’s own tests, accuracy on its benchmark ran from 84.1% (Mistral Nemo, the cheapest) to 93.5% (Claude Opus 5.5, the most expensive).

Is Supermemory open source?

Partly, by its own answer: the main repository and plugins are MIT and the SDKs are Apache 2.0, but “The memory engine is not open source”. Its free local server runs on your machine but isn’t open source.

Can I self-host the memory for my AI companion?

You can keep the store on your own machine with any of the self-hostable options above, and then you hold the file. A memory is notes that the model reads each time; moving the notes moves what it was told, not the model. A different model or setup reading the same notes may answer differently, so test before relying on a move.

Can Counterparts be the memory layer for my app?

No. It has no SDK or API, and it’s built for one person’s Claude. It’s open source under MIT, so you can read how it extracts, fades and recalls, and run it in Claude Code to see the design at work.

Questions? Ask in r/AIMemorySystems.