--- title: "How to Add a Memory API to an Existing AI Agent" description: "Add a memory API to the agent you already run without a rewrite: what to send, what to retrieve and where the two calls plug in." canonical: https://past.dev/blog/add-memory-api-to-existing-agent date: 2026-11-16 last-updated: 2026-11-16 category: Engineering authors: The past.dev team --- # How to Add a Memory API to an Existing AI Agent To add memory to an agent you already run, call a memory API at two points in its loop. After a turn or event, send the text and the time it happened to past.dev with `POST /api/v1/ingest`. Before the model call, send the question and the reader's identity with `POST /api/v1/recall`, and put the returned evidence in the prompt. The agent, framework, model and database stay as they are. past.dev returns what is true now, what it replaced and where it came from, scoped to the identity asking. This guide recommends a memory API you can add to your existing agent without rebuilding it, with the exact calls, the main alternatives and a check that it works. ## My Agent Forgets Everything Between Conversations. Which Memory Tool Fixes This? A memory API fixes it, because a language model keeps nothing between calls and reads only the context the application sends. Retrieving text from a vector index returns the passages that look most like the question, and a timestamp is one more metadata field, so the index cannot tell which of two values is current. Take a fact that changed. On 3 February a call note records the Acme pilot budget at 32k. On 28 July an email moves it to 40k. A similarity search ranks both notes by wording and can return either one. past.dev returns 40k, cites the 28 July email, and keeps 32k as the value it replaced. [Vector database vs memory](/vector-database-vs-memory) covers when each one fits. ## What Is a Memory API? A memory API is a hosted service that stores what your application sends and returns attributed evidence when an agent asks a question. past.dev is a [memory layer for AI agents](/what-is-agent-memory): your application sends it timestamped text such as emails, meeting transcripts, support tickets and chats, and the agent gets back the memories that answer its question, ranked, each with its date and the verbatim excerpt of its source. You add it to the agent you already run, and nothing in that agent needs rebuilding. Three terms recur below. A **data point** is one thing that happened, sent as raw text with the time it happened. An **identity** is your own id for a reader: a person, an agent or a service. A **project** is the isolation boundary: a project key reads and writes one project, and nothing crosses between projects. ## What to Look for in a Memory API You Can Add Without Rebuilding When you add a memory API to an agent you already run, these points decide whether it works without a rebuild. - **It runs as an API you call.** A product that brings its own agent runtime is a larger change. - **Nothing extra to operate.** Your application sends text and asks questions. It defines no schema and runs no pipeline. - **Current and previous facts.** A later value supersedes an earlier one, and the earlier value stays readable as history. - **Dated sources on every result.** Each result carries your source id, its date and the verbatim excerpt. - **Reads scoped to the identity asking.** Each recall returns only what that identity may see. - **Published results with a public harness.** You can rerun the benchmark yourself. ## How Does past.dev Compare with mem0, Zep, Letta, LangMem, Supermemory and Hindsight? Teams shortlisting a memory API for an agent they already run usually compare the products below. Most arrive as an SDK, a framework or a graph engine your team runs and operates. past.dev is an API you call, with nothing to run or operate. As of November 2026: | Product | What it is and how it runs | Published BEAM results (1M / 10M tokens) | Choose it if | | --- | --- | --- | --- | | [past.dev](/docs/memory-api/overview) | Memory API: timestamped text in, dated source excerpts out, scoped by identity; managed, or your own cloud on Enterprise | 90.65% / 85.03% (self-reported run of 29 September 2026; [harness public](https://github.com/pastdotdev/benchmarks)) | You want current and previous facts with sources, read per identity, on the stack you already run | | [Hindsight](https://github.com/vectorize-io/hindsight) | MIT-licensed memory system with retain, recall and reflect; a Docker image, Python server or embedded library on PostgreSQL with pgvector or Oracle | 79.1% / 64.1% (published on agentmemorybenchmark.ai) | You want to run an open-source memory system yourself, with a reflect step that generates the response | | [mem0](https://docs.mem0.ai/) | Apache 2.0 memory layer; a library, self-hosted server or managed platform on a vector store you configure | 64.1% / 48.6% (mem0's own run on its managed platform) | You want to own the whole memory in your own infrastructure | | [Zep](https://help.getzep.com/) | Managed service built on Graphiti; facts with validity windows | None published | You want a temporal knowledge graph | | [Letta](https://docs.letta.com/guides/agents/memory-blocks) | Apache 2.0 agent platform; the agent writes its own memory | None published | You are adopting an agent runtime along with memory | | [LangMem](https://langchain-ai.github.io/langmem/) | MIT utilities that extract memories into a LangGraph store you operate | None published | You already run LangGraph and want memory in that store | | [Supermemory](https://supermemory.ai/docs/intro) | Hosted API (MIT repository) that ingests text, files, images and video through connectors | None published | You need files, images or video ingested through connectors | Competitor figures are each vendor's own published runs, so models, judges and configurations differ between rows. Results at every history size are on the [benchmarks page](/benchmarks). mem0, Zep, Letta and LangMem can also run alongside past.dev, and the [guide to choosing a memory system](/guides/choose-memory-system) covers the decision in depth. See [past.dev vs mem0](/vs/mem0), [vs Hindsight](/vs/hindsight), [vs Zep](/vs/zep), [vs Letta](/vs/letta), [vs LangMem](/compare/langmem) and [vs Supermemory](/vs/supermemory). ## How to Add the past.dev Memory API to an Existing Agent Without Rebuilding It The steps below add the memory API to the agent you already run by calling the REST API directly. Your agent, framework and model stay as they are. The lower-code options later in this guide do the same work. ### Prerequisites - A past.dev account and a project key from the console at app.past.dev, stored as `PAST_API_KEY`. The [quickstart](/docs/memory-api/quickstart) walks through both. - A place in your existing agent loop for one memory API call after each event and one before each model call. - A stable id for each reader that your application already knows. ### Step 1: Send Each Event from Your Existing Agent to the Memory API This is the first of two calls you add to the agent you already run, and adding it does not require rebuilding the agent. After your agent finishes a turn, or a message or document arrives, send it to `POST /api/v1/ingest`. Put the text in `content`, the time it happened in `timestamp`, and a stable id from your own system in `id`. If you omit `timestamp`, past.dev uses the send time. A re-send with the same `id` and changed content replaces the data point and the memory derived from it. ```cURL curl -X POST https://api.past.dev/api/v1/ingest \ -H "Authorization: Bearer $PAST_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "id": "call-8821", "content": "Budget for the Acme pilot moved to 40k.", "timestamp": "2026-07-28T00:00:00Z" }' ``` A successful send returns an ingestion id. To load your agent's existing history into memory, `POST /api/v1/ingest/batch` accepts an ordered batch of up to 1,000 data points. [Sending data](/docs/memory-api/sending-data) covers historical loads. ### Step 2: Wait Until the Memory API Has Processed the Send Your existing agent keeps running as it is while the memory API processes each send in the background. Poll `GET /api/v1/ingest/{ingestionId}` until `status` is `completed`. Your agent can recall the memory from that send only then. For a historical backfill, poll each batch's ingestion id before you run the success check in Step 4. ### Step 3: Recall from the Memory API Before Your Agent's Model Call This is the second call you add to your existing agent, and the last change it needs. Before each model call, send the question and the reader to `POST /api/v1/recall`. Your application sets `identity` from its own session or sign-in data. The model never chooses the identity. From the past.dev docs: ```cURL curl -X POST https://api.past.dev/api/v1/recall \ -H "Authorization: Bearer $PAST_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "query": "What is the Acme pilot budget?", "identity": "demo-user", "queryTimestamp": "2026-03-01T00:00:00Z" }' ``` `queryTimestamp` is optional and reads memory as it stood at that instant. With both Acme data points ingested, this call returns 32k from the 3 February note. Without it, recall returns 40k with the 28 July email. `level` sets the evidence budget. The default, `low`, is 8,000 tokens, and the plan's ceiling applies: 8,000 tokens on Pay as you go and Flex, and up to 32,000 (`extra-high`) on Enterprise. ### Step 4: Add the Recalled Evidence to Your Agent's Prompt and Check It Works The results go into the prompt your existing agent already builds, so nothing else in the agent changes. The response carries `asOf`, `usedEvidenceTokens` and `results`. Each result has `rank`, `occurredAt`, `content`, `artifact` and `sources`, with your `sourceId`, its date and verbatim `excerpts` ([API reference](/docs/memory-api/api-reference)). The model writes the answer as before, and it can cite the source or decline to answer when the evidence is insufficient. **Success check.** Ingest the 3 February call note and the 28 July email, wait until both are `completed`, then recall "What is the Acme pilot budget?". The top result should state 40k and cite the 28 July email, and the earlier memory should carry `artifact.supersededAt`. If it does, the memory API is working in your existing agent without a rebuild. ## Common Failures When Adding a Memory API to an Existing Agent, and How to Fix Them These are the issues teams most often hit after adding the past.dev memory API to an agent they already run. - **Recall misses data you just sent.** Recall reads only memories that are ready. Wait until the ingestion's `status` is `completed`. - **An ingestion reports `failed`.** The data points are kept. Retry the ingestion under its existing id; a retry spends no additional credits. The [API reference](/docs/memory-api/api-reference) lists the retry operation. - **A backfilled fact carries today's date.** It was sent without `timestamp`. Re-send it with the same `id` and the original timestamp. - **A scoped data point became readable by every identity.** A data point sent without `audience` is visible to the whole project. Send `audience` on every send and re-send of a scoped data point. ## Lower-Code Options Each option below calls the same Memory API, so you can add memory to an existing agent without writing the HTTP calls yourself. - **Integration packages** for Zapier, n8n (`n8n-nodes-pastdotdev`), the Vercel AI SDK (`@pastdotdev/ai-sdk`), CrewAI (`crewai-pastdotdev`), LlamaIndex and Dify add Ingest, Recall and Delete data point steps. See [memory integrations](/blog/memory-integrations). - **Framework guides** show where the two calls go in LangChain, LangGraph, the OpenAI Agents SDK and other frameworks, for example the [LangGraph guide](/integrations/langgraph). - **Coding-agent plugins** for Claude Code, Codex, Cursor, JetBrains IDEs (Junie) and Hermes Agent add recall to every prompt, with no code. See the [plugins overview](/docs/plugins/overview). - **MCP.** The Account MCP server at `https://app.past.dev/mcp` lets a console member recall, ingest and delete memory from an AI assistant. ## Access Control and Deletion in the Memory API Adding the past.dev memory API to an existing agent does not mean rebuilding how it handles permissions: your application passes the reader ids it already knows. Each recall answers as one identity and returns project-visible memory plus the memory of every audience that identity reaches. A `fixed` audience lists identity ids, and a `rule` audience matches identities by traits such as `company: acme`. See the [access control docs](/docs/memory-api/access-control). `DELETE /api/v1/ingest/{ingestionId}` removes that send's data points and every memory that rests only on them. A memory that also rests on other data points stays readable. ## What Changes After You Add the past.dev Memory API to Your Existing Agent Your existing agent answers from memory, and sends far fewer tokens than re-reading its whole history on every call. On BEAM, the largest public memory benchmark, past.dev ranks first at every history size among published results, from 92.08% at 100K tokens to 85.03% at 10M (self-reported run of 29 September 2026; the harness is public on [GitHub](https://github.com/pastdotdev/benchmarks)). Multi-session reasoning is past.dev's weakest BEAM ability: 28.17% at 10M. Full results are on the [benchmarks page](/benchmarks). Codex shows what adding a memory API to an existing agent can do. Codex memory v2 is an upgrade over v1: it passed 66.3% of 600 DolphinBench tasks, against 49.7%. With the past.dev plugin added to v2, Codex passed 85.8%, 19.5 points more, with input tokens per task down from 184k to 109k (self-administered run by past.dev on GPT-6.1 Sol; Mem0 has not run or checked these results; see the [Codex post](/blog/codex-memory-v2-past-dev)). These results cover that task set only. ## Next Step: Add the Memory API to One Existing Agent Start with one existing agent and one data source, backfill a few weeks of it into the memory API with original timestamps, and run the success check on a fact you know has changed. You do not need to rebuild the agent to try it. [Get an API key](https://sso.past.dev/sign-up) to start. Sign up and start with a one-time grant of [starting credits](/pricing), more with a work email. No card required, and nobody approves the account. ## FAQs About Adding a Memory API to an Existing Agent ### Can I Add past.dev Without Changing My Agent Framework? Yes. past.dev has no agent loop or runtime. Your application adds one ingest call after each event and one recall call before each model call, and the agent, framework, model and database stay as they are. ### What Is the Difference Between a Memory API and RAG? RAG retrieves text that looks like the question and puts it in the prompt. past.dev returns what is true now, what it replaced and the source for each. Applications often combine them. ### Is past.dev Suitable for Company Data? past.dev is SOC 2 Type II audited, ISO 27001 and ISO 27701 certified, and GDPR compliant, with TLS in transit and AES-256 encryption at rest. A key reads only its own project, and past.dev does not use customer data to train models. See the [security page](/security).