Blog·Learning

How to Use Supermemory with AI SDK

By Shardul Mane·8 min read

Blog cover banner reading "How to Use Supermemory with AI SDK" with a 3D white Lego brick stacked on a blue Supermemory one

Every session your AI SDK agent handles starts from zero. No memory of what users asked last week, what they prefer, or what's still unresolved. You can bolt on a vector database, but chunk retrieval isn't the same as understanding context; it hands your agent similar text, not actual knowledge of who it's talking to.

Supermemory slots a full memory layer beneath your existing AI SDK stack without touching your model calls or provider setup. A memory graph that tracks relationships across sessions, user profiles built automatically from behavior, and sub-300ms retrieval that won't stall your streams. This post walks through what that integration actually looks like, what the benchmarks say, and how to get it up and running in under 5 minutes.

TLDR:

  • AI SDK handles requests well, but remembers nothing between sessions by design
  • Supermemory adds memory graph, user profiles, and sub-300ms retrieval below your agent loop
  • Scores 76.7% multi-session accuracy vs 57.9% competitors on LongMemEval-S benchmark
  • Install with npm i supermemory and inject tools directly into generateText or ToolLoopAgent
  • Supermemory gives AI SDK a memory API with graph-based intelligence and retrieval under 300ms

What It Means to Use Supermemory with AI SDK

AI SDK handles tool calls, model output, and streaming responses well. What it doesn't do is remember anything every request your agent gets starts cold, with no knowledge of what your users said last week, what they prefer, or what they're still waiting on. Most teams patch this with a quick vector database setup, but retrieval alone won't cut it: it returns text chunks, not actual understanding of who your user is. Fortunately, using Supermemory with AI SDK gives your agent a real memory layer without ripping out your existing stack.

How Supermemory Fits Into a AI SDK Stack

AI SDK's ToolLoopAgent is good at one thing: managing the conversation loop. It maintains a message array, decides what the model sees at each step, and handles tool call orchestration. But when the session ends, that message array is gone. No built-in persistence, no extraction, no retrieval. You manage all of that yourself.

The challenge with designing effective agent tools is balancing granularity with context overhead: too many small tools slow the loop, too few broad tools reduce precision.

So where does Supermemory slot in? Think of it as the layer sitting just below your agent loop.

What Supermemory replaces

  • Session storage you'd otherwise build manually from scratch
  • A separate vector database for semantic retrieval
  • Document extraction pipelines for PDFs, audio, and web pages
  • Custom user profile logic spread across your codebase

What it augments

  • The conversation loop itself, by injecting relevant memory context before each model call
  • generateText and streamText calls, by supplying a richer system prompt built from the user's memory graph

You pull context from Supermemory before generating, then write new memories back after. That's the full integration pattern. It works with any provider AI SDK supports since there's no coupling to a specific model.

Memory Capabilities That Matter for AI SDK Builders

AI SDK gives excellent primitives for model interaction. What it doesn't give you is memory. Here's what Supermemory actually adds for teams building serious agent workflows.

Memory Graph for Multi-Step Tool Loops

Stateless serverless handlers are a real problem for multi-step tool loops. Each invocation starts cold. The memory graph tracks relationships between memories using ontology-aware edges, handling knowledge updates, contradictions, and inferences automatically. Your agent doesn't need to know what happened three tool calls ago because the graph does.

User Profiles for Personalized Agent Responses

Every ToolLoopAgent call that manually stuffs user preferences into a system prompt is tech debt waiting to compound. Supermemory builds user profiles automatically from behavior, combining static facts with real-time episodic context from recent sessions. Inject the profile, skip the boilerplate.

Hybrid Retrieval Under 300ms

Hybrid retrieval combines vector and keyword search with context-aware reranking. Sub-300ms latency fits cleanly inside a streamText call without stalling the stream.

Multi-Modal Extraction Built In

Native extraction handles PDFs, audio, and web pages automatically. Audio gets transcribed via Gemini 2.5 Flash, chunked, and indexed. Connectors handle Slack, Notion, Drive, and Gmail.

Capability

AI SDK Challenge Solved

Outcome

Memory Graph

Stateless handlers lose context between tool calls

Agents remember relationships across multi-step loops

User Profiles

Manual context injection per request

Auto-built personalization without config overhead

Sub-300ms Retrieval

Latency breaks streaming responses

Memory lookup invisible to end users

Connectors

Manual data pipeline integration

One-line sync from Slack, Notion, Drive, Gmail

Performance Benchmarks in a AI SDK Context

Numbers matter when you're deciding what to ship in production. Here's what the benchmarks actually say and what they mean for AI SDK workloads.

On LongMemEval-S, Supermemory scores 76.7% on multi-session accuracy versus 57.9% for competing providers. For ToolLoopAgent workflows spanning multiple sessions, that gap is the difference between an agent that feels coherent and one that keeps forgetting. Temporal reasoning hits 82.0% against 62.4%, which matters when agents reason across conversation threads with time-sensitive context.

On the LoCoMo benchmark, P@1 is 59.7% versus 34.4% from a major provider. Recall@10 reaches 83.5% versus 69.3%. When your agent executes tool calls and writes results back to memory, poor retrieval precision means wrong context fed into future steps.

The latency story is straightforward: sub-300ms recall across 100B+ tokens processed monthly. A streamText call won't stall waiting on memory. That's the engineering risk these numbers remove entirely.

Enterprise Readiness for Teams Shipping on AI SDK

Shipping memory as critical infrastructure means your compliance and deployment story has to hold up under scrutiny. Supermemory is SOC 2 Type 2, HIPAA, and GDPR compliant, with all data encrypted in transit and at rest.

For teams with data residency requirements, full self-hosting via Docker gives you complete control over where customer conversations live. Cloud, self-hosted, VPC, and hybrid deployments are all supported. Enterprise tier includes a forward-deployed engineer for teams who need hands-on integration support.

The vendor lock-in concern is real when memory becomes load-bearing infrastructure. Supermemory's pluggable vector backend support lets you keep your existing Pinecone, Weaviate, or Qdrant setup and add Supermemory's intelligence layer on top. No forced migration, no ripping out current infrastructure. You get the memory graph, user profiles, and retrieval quality without abandoning what you've already built.

Pricing and Scale Considerations for AI SDK Products

Supermemory uses usage-based billing. Each plan includes a monthly credit balance, which is consumed as you ingest content, retrieve context, and run other operations. Usage beyond the included balance is charged at the published rates.

Plan Monthly price Included monthly credits
Free $0 $5
Pro $19 $20
Max $100 $130
Scale $399 $600
Enterprise Custom Custom

Ingestion is metered in SM tokens: unique content actually ingested. Repeated or unchanged content is not billed again. Ingestion rates differ between Memory and SuperRAG, and between plain text and rich content.

See the current plans and rate card for prices, included credits, and feature availability.

Getting Started: Supermemory + AI SDK

Start with npm i supermemory. Get your API key from console.supermemory.ai. Setup takes under five minutes.

The native AI SDK integration lives in @supermemory/tools/ai-sdk. Import supermemoryTools and pass them directly into your ToolLoopAgent or any custom generateText loop. The tools handle saving and retrieving memories automatically through semantic search, which means you're not writing retrieval logic by hand.

import { supermemoryTools } from "@supermemory/tools/ai-sdk";

const result = await generateText({
  model,
  tools: supermemoryTools({ apiKey: process.env.SUPERMEMORY_API_KEY }),
  messages,
});

The AI SDK memory docs walk through the ToolLoopAgent pattern in full.

FAQ

What's the best way to add memory to a AI SDK agent?

Use Supermemory's native AI SDK integration (@supermemory/tools/ai-sdk). Import supermemoryTools and pass them into your ToolLoopAgent or generateText loop, the tools handle saving and retrieving memories through semantic search automatically, so you skip writing retrieval logic by hand.

AI SDK memory graph vs vector database?

A vector database gives you lookup, not memory. It returns similar chunks but doesn't track relationships, handle contradictions, or understand how user goals shift over time. Supermemory's memory graph uses ontology-aware edges to manage knowledge updates, inferences, and temporal context, so your agent remembers what actually matters across sessions instead of just fetching text.

How do I use Supermemory with AI SDK?

Install with npm i supermemory, grab your API key from console.supermemory.ai, and import supermemoryTools from @supermemory/tools/ai-sdk. Pass the tools directly into your generateText or ToolLoopAgent calls, the tools handle saving and retrieving memories through semantic search automatically. Setup takes under five minutes and works with any model provider AI SDK supports.

Can stateless serverless handlers maintain context across tool calls?

Yes, if you use a memory layer. Supermemory's memory graph tracks relationships between memories automatically, so each cold invocation can pull relevant context from previous tool calls without manual session storage. Your agent doesn't need to remember what happened three steps ago because the graph does.

What does sub-300ms retrieval mean for streaming responses?

Memory lookup completes fast enough that your streamText call never stalls waiting on context. At 100B+ tokens processed monthly, Supermemory maintains sub-300ms latency so users don't see lag when your agent pulls personalized context mid-stream.

  1. An update to supermemoryWe've discontinued the supermemory company brain and Nova. Everyone who was charged has been refunded, our MCP and plugins continue to run, and we're going all in on the memory engine.
  2. SMFS: making agentic retrieval 55% cheaper AND more accurateWe launched SMFS.ai (Supermemory Filesystem) a few weeks ago, with a simple bet: We can redesign the filesystem specifically for agents, with special files, structures, and commands that it can use for it's tasks. Today, SMFS is used by hundreds of companies to power their agents.
  3. Introducing Dynamic Dreaming: supermemory now connects the dots, for you.Dreaming is magical. TLDR: We're launching Dynamic Dreaming in supermemory today, which automatically works if you're using supermemory in any way - API, OpenClaw, Hermes agent, etc.
  4. Dear reader, we just made supermemory insanely cheap... the Context CloudWhen I first started building supermemory, I had one goal: To build the best memory system for AI. I would talk to customers, and find out that memory was not the only thing they needed - They were all setting up 7-8 different vendors at the same time.
  5. Introducing @supermemory/tools v2.0.0Today we're releasing v2.0.0. This release unifies the API across all agents sdk integrations from AI SDK to Mastra, makes conversation identity a first-class concept, and ships with memory saving on by default.
  6. supermemory will make your Hermes-agent crazy powerfulToday, we are launching supermemory support to your Hermes agent TLDR: you can use supermemory now in your Hermes agent, it totally free to get started - https://supermemory.ai/docs/integrations/hermes In case you missed it: Hermes Agent is a self-improving AI agent from Nous Research.
  7. Solving the Precision-Recall Tradeoff: Search Result AggregationWhen you're building memory for AI, search is your foundational layer. The way search generally works is straightforward: the user defines a query, and then sets a limit (top-K) on how many search results they want returned. Usually, this is set to 10 or 20.
  8. Infinitely running stateful coding agentsWe built a plugin for Claude Code and OpenCode that gives your coding agent persistent memory. It remembers your preferences, learns your codebase, and never loses context mid-conversation. The result is an agent you can run for months without starting over.
  9. Why everyone is complaining about OpenClaw's memory (it sucks) - and why supermemory fixes it.TLDR: Today, we are releasing a new version of our openclaw plugin - https://github.com/supermemoryai/openclaw-supermemory. This post is going to be a bit technical, so bear with me (or bookmark for later!) In this post, I will talk about what we do about OpenClaw memory, and how we fix it.
  10. We added supermemory to Claude Code. It's INSANELY powerful now...Today, we are launching the Supermemory plugin for Claude Code! TLDR: You can use supermemory in claude code now. - https://github.com/supermemoryai/claude-supermemory Claude code has genuinely changed how I work. But there's this one thing that drives me crazy...
  11. Clawd / Molt bot's memory SUCKS. We gave it supermemory.I'm the founder of supermemory. Clawd/Molt bot is blowing up right now, with many, many use cases. I set it up, too, and have been using it through telegram. TLDR: just go to https://supermemory.ai/docs/integrations/clawdbot to set up supermemory for your clawd bot.
  12. Catch up with our UNFORGETTABLE Launch WeekOver the last year, one belief has guided almost everything we’ve built at Supermemory AI becomes meaningfully useful only when it remembers. Memory shouldn’t be something developers rebuild from scratch. It shouldn’t be fragile, expensive, or trapped inside a single tool.
  13. Empowering the Next Generation of Founders: Supermemory Startup ProgramIf there’s one thing we’ve learned while building Supermemory, it’s that most startups don’t fail because they didn't build features; they fail when infrastructure slows them down, or they built too slow.
  14. Building code-chunk: AST Aware Code ChunkingAt Supermemory, we're building context engineering infrastructure for AI. A huge part of that is dealing with code: ingesting repos, understanding structure, and making it searchable. The problem is that most code chunking solutions are terrible. We built code-chunk to fix this.
  15. Supermemory raises $3 million with the best memory engine for LLMsToday, I am excited to announce our first funding round to accelerate our mission of building an interoperable, scalable and reliable memory for LLMs and agents. Memory is one of the hardest challenges in AI right now.
  16. Unified Memory That Works Where You Work: Your Second Brain With SupermemoryHi everyone, I’m Dhravya, the founder of Supermemory. I want to start with a little story behind why this product means so much to me. You can also skip straight to what it is and how it works below.
  17. Supermemory just got faster on PlanetScaleWhat is Supermemory? Supermemory completes the missing part of the LLM puzzle: memory. Just as memory is crucial for human intelligence, it's essential for truly intelligent AI systems.
  18. Faster, smarter, reliable infinite chat: Supermemory IS context engineering.People are obsessed with prompts and prompt engineering. Sure, what you say is important, but what the model knows when you say it is the difference between a stateless text generator and an intelligent AI system. In short, context is the most crucial component.
  19. We solved AI API interoperabilityOne API to rule them all, One spec to find them, One library to bring them all and in the TypeScript, bind them. When we were building the the Infinite Chat API, initially, we only supported the OpenAI format. This was fine, until a lot of our customers started asking, asking for more.
  20. The UX and technicalities of awesome MCPsLast month, we launched the Supermemory MCP, mostly to test our own infrastructure and get some initial traction. It blew up. To my absolute surprise, the initial launch itself got half a million impressions (!!!). Then, we launched and got #2 on ProductHunt too.
  21. Architecting a memory engine inspired by the human brainLanguage is at the heart of intelligence, but what truly powers meaningful interaction is memory — the ability to accumulate, recall, and contextualize information over time. Large Language Models (LLMs) have mastered language, but memory remains their Achilles’ heel.