Mem0 Vercel AI SDK Skill for ClaudeSAFE
The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Overview
From the repository's own README, as read at the audited commit. Badges and raw HTML are left out.
Add persistent memory to any Vercel AI SDK application using @mem0/vercel-ai-provider.
What This Skill Does
When installed, Claude can:
- Set up `@mem0/vercel-ai-provider` in your TypeScript or Next.js project
- Generate working code using the wrapped model (
createMem0) or standalone utilities (retrieveMemories,addMemories, etc.) - Configure multi-provider setups (OpenAI, Anthropic, Google, Groq, Cohere)
- Integrate memory into streaming responses, structured output, and API routes
Installation
CLI (Claude Code, OpenCode, OpenClaw, or any tool that supports skills)
npx skills add https://github.com/mem0ai/mem0 --skill mem0-vercel-ai-sdk
Claude.ai
- Download this
skills/mem0-vercel-ai-sdkfolder as a ZIP - Go to Settings > Capabilities > Skills
- Click Upload skill and select the ZIP
Claude API (Skills API)
curl -X POST https://api.anthropic.com/v1/skills \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "mem0-vercel-ai-sdk", "source": "https://github.com/mem0ai/mem0/tree/main/skills/mem0-vercel-ai-sdk"}'Prerequisites
- Node.js 18+
- Vercel AI SDK v6 (
aipackage version 6.x) - A Mem0 Platform API key (Get one here)
- An LLM provider API key (OpenAI, Anthropic, Google, Groq, or Cohere)
- Set environment variables:
export MEM0_API_KEY="m0-xxx" export OPENAI_API_KEY="sk-xxx" # or your chosen provider's key
Quick Start
After installing, just ask Claude:
- "Add memory to my Vercel AI SDK app"
- "Set up mem0 with streamText in my Next.js API route"
- "Use retrieveMemories with Anthropic instead of the wrapped model"
- "Show me how to read the Mem0 source from generateText with the Vercel AI provider"
- "
5501ce56093eOBSERVED · 2026-10-22Install
Commands as the repository documents them. They are shown, not run.
npx skills add https://github.com/mem0ai/mem0 --skill mem0-vercel-ai-sdk
npm install @mem0/vercel-ai-provider ai@^6
Host compatibility
What the documentation claims. We have not run a compatibility test.
| Host | Status | Notes |
|---|---|---|
| claude-code | mentioned | |
| openclaw | mentioned |
What it tells the agent
The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.
---
name: mem0-vercel-ai-sdk
description: >
Mem0 provider for Vercel AI SDK (@mem0/vercel-ai-provider).
TRIGGER when: user mentions "vercel ai sdk", "@mem0/vercel-ai-provider",
"createMem0", "retrieveMemories", "addMemories", "getMemories",
"searchMemories", "mem0 vercel", "AI SDK provider", "AI SDK memory",
or is using generateText/streamText with mem0. Also triggers for Next.js
apps needing memory-augmented AI.
DO NOT TRIGGER when: user asks about direct Python/TS SDK calls without Vercel
(use mem0 skill), or CLI terminal commands (use mem0-cli skill).
license: Apache-2.0
metadata:
author: mem0ai
version: "2.0.0"
category: ai-memory
tags: "vercel, ai-sdk, memory, nextjs, typescript, provider"
mem0_tested_versions: "@mem0/vercel-ai-provider (npm) >=3.0.0,<4.0.0; ai (npm) >=6.0.0,<7.0.0; mem0ai (npm) >=3.0.0,<4.0.0"
compatibility: Node.js 18+, npm install @mem0/vercel-ai-provider, Vercel AI SDK v6 (ai package ^6), MEM0_API_KEY + LLM provider API key
---
# Mem0 Vercel AI SDK Provider
Memory-enhanced AI provider for Vercel AI SDK. Automatically retrieves and stores memories during LLM calls.
## Step 1: Install
```bash
npm install @mem0/vercel-ai-provider ai@^6
```
`ai` and the `@ai-sdk/*` provider packages ship as regular dependencies of `@mem0/vercel-ai-provider`, so nothing else needs installing. The only peer dependency is `zod` (optional, `^3.0.0`).
## Step 2: Set up environment variables
```bash
export MEM0_API_KEY="m0-xxx"
export OPENAI_API_KEY="sk-xxx" # or ANTHROPIC_API_KEY, GOOGLE_API_KEY, etc.
```
Get a Mem0 API key at: https://app.mem0.ai/dashboard/api-keys?utm_source=oss&utm_medium=skill-mem0-vercel-ai-sdk
## Pattern 1: Wrapped Model
The wrapped model approach is the simplest. `createMem0` returns a provider that wraps any supported LLM with automatic memory retrieval and storage.
```typescript
import { generateText } from "ai";
import { createMem0 } from "@mem0/vercel-ai-provider";
const mem0 = createMem0();
const { text } = await generateText({
model: mem0("gpt-5-mini", { user_id: "alice" }),
prompt: "Recommend a restaurant",
});
```
What happens under the hood:
1. The prompt is stored to Mem0 (`POST /v3/memories/add/`), awaited before the LLM call (a failed write is logged and ignored)
2. The prompt is sent to Mem0 search (`POST /v3/memories/search/`) to retrieve relevant memories
3. If any memories are found, they are injected as a system message at the start of the prompt
4. The underlying LLM (e.g., OpenAI gpt-5-mini) generates a response using the enriched prompt
For `generateText`, the retrieved memories are also attached to the result as a source:
```typescript
const { text, sources } = await generateText({
model: mem0("gpt-5-mini", { user_id: "alice" }),
prompt: "Recommend a restaurant",
});
console.log(sources.find((s) => s.title === "Mem0 Memories")?.providerMetadata?.mem0);
```
The source has `title: "Mem0 Memories"` and `providerMetadata.mem0` holds `memories` (array of memory objects) and `memoriesText`. It is only present when at least one memory was retrieved.
## Pattern 2: Standalone Utilities
Use standalone utilities when you want full control over the memory retrieve/store cycle, or you want to use a provider that is already configured separately.
```typescript
import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";
import { retrieveMemories, addMemories } from "@mem0/vercel-ai-provider";
const prompt = "Recommend a restaurant";
// Retrieve memories -- returns a formatted system prompt string
const memories = await retrieveMemories(prompt, {
user_id: "alice",
mem0ApiKey: "m0-xxx",
});
// Generate using any provider with injected memories
const { text } = await generateText({
model: openai("gpt-5-mini"),
prompt,
system: memories,
});
// Optionally store the conversation back
await addMemories(
[
{ role: "user", content: [{ type: "text", text: prompt }] },
{ role: "assistant", content: [{ type: "text", text }] },
],
{ user_id: "alice", mem0ApiKey: "m0-xxx" }
);
```
## Pattern 3: Streaming
Use `streamText` for streaming responses with memory augmentation:
```typescript
import { streamText } from "ai";
import { createMem0 } from "@mem0/vercel-ai-provider";
const mem0 = createMem0();
const result = streamText({
model: mem0("gpt-5-mini", { user_id: "alice" }),
prompt: "What should I cook for dinner?",
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}
```
The wrapped model stores the conversation and retrieves memories before streaming begins.
## Supported Providers
| Provider | Config value | Required env var |
|----------|-------------|------------------|
| OpenAI (default) | `"openai"` | `OPENAI_API_KEY` |
| Anthropic | `"anthropic"` | `ANTHROPIC_API_KEY` |
| Google | `"google"` (alias `"gemini"`) | `GOOGLE_GENERATIVE_AI_API_KEY` |
| Groq | `"groq"` | `GROQ_API_KEY` |
| Cohere | `"cohere"` | `COHERE_API_KEY` |
Select a provider when creating the Mem0 instance:
```typescript
const mem0 = createMem0({ provider: "anthropic" });
const { text } = await generateText({
model: mem0("claude-sonnet-4-20250514", { user_id: "alice" }),
prompt: "Hello!",
});
```
## How It Works Internally
### Wrapped model flow
```
User prompt
--> processMemories: addMemories (POST /v3/memories/add/, awaited)
--> processMemories: getMemories (POST /v3/memories/search/)
--> memories (if any) injected as system message at start of prompt
--> underlying LLM generates response (doGenerate or doStream)
--> response returned to caller (doGenerate also attaches a "Mem0 Memories" source)
```
### Standalone flow
```
User controls each step:
1. retrieveMemories / getMemories / searchMemories -> fetch memories
2. inject into system prompt manually
3. call generateText / streamText with any provider
4. addMemories -> store new conversation to Mem0
```
## Key Differences Between the 4 Utility Functions
| Function | Returns | UTrust audit
SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.
| Layer | What it checks | Result |
|---|---|---|
| L0 | Provenance & inventory | PASS |
| L1 | Static analysis of the code | NA |
| L2 | Instruction surface (what it tells the agent) | PASS |
| L3 | Class-specific surface | PASS |
| L4 | Behavioural (sandbox) | SKIPPED |
What the source does
- Filesystem
- none-observed
- Network
- none-observed
- Shell
- none-observed
- Dependencies
- pinned
- Secrets in source
- none-found
Findings (5)
.github/CLAUDE.md
CLAUDE.md
cli/node/CLAUDE.md
cli/python/CLAUDE.md
docs/CLAUDE.md
Gates applied: no_behavioural_pass.
5501ce56093efull audit observations/trust-audit/skill/mem0ai__mem0-vercel-ai-sdk.json · Report an issue / request a re-scanAudit history
Every audit this skill has had.
| Date | Source | Verdict | Grade | Score | Change |
|---|---|---|---|---|---|
| 2026-10-22 | 5501ce56093e | SAFE | B | 89 | first audit |
Questions
What does the mem0-vercel-ai-sdk — mem0ai/mem0 skill do?
The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Is mem0-vercel-ai-sdk — mem0ai/mem0 safe to install?
The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.
What can mem0-vercel-ai-sdk — mem0ai/mem0 access on my machine?
The audit observed no filesystem, network or shell use at all in its source.
Which assistants does mem0-vercel-ai-sdk — mem0ai/mem0 work with?
Its documentation mentions claude-code and openclaw. That is what the text claims, not a compatibility test we ran.
How current is this page?
The grade is for one exact copy of the source (5501ce56093e), read on 2026-10-22. The repository is watched, and a new audit runs when it changes — this is the first audit.
Add this badge to your README
Shows this page's audit result and links back to it. It updates when the audit does.
[](https://modelsatlas.com/skills/mem0ai/mem0-vercel-ai-sdk/)
Not your listing, or something out of date? Claim or update your listing.