Agent skill

Mem0 Provider for Vercel AI SDK

by mem0ai in mem0ai/mem0

Adds persistent memory to Vercel AI SDK apps with the Mem0 provider, using a wrapped model or standalone retrieve and store utilities.

Apache-2.0Auto-check passedAI & LLM Engineering

Install Mem0 Provider for Vercel AI SDK

skills CLI
$ npx skills add mem0ai/mem0 --skill mem0-vercel-ai-sdk -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install mem0ai/mem0 mem0-vercel-ai-sdk --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/mem0ai/mem0.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/mem0-vercel-ai-sdk .claude/skills/mem0-vercel-ai-sdk && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
mem0-vercel-ai-sdk
GitHub stars
67k
Token cost
~2.3k tokens
SKILL.md length
625 words
Files
6 (incl. references)
Skills in repo
26
Repo updated
First seen
Licence
Apache-2.0

At a glance

Adds persistent memory to Vercel AI SDK apps with the Mem0 provider, using a wrapped model or standalone retrieve and store utilities.

  • Works in 2 steps: Install → Set up environment variables
  • Giving a Vercel AI SDK chatbot memory across conversations
  • SKILL.md covers Step 1: Install, Step 2: Set up environment…, Pattern 1: Wrapped Model and Pattern 2: Standalone Utilities, plus 7 more sections
  • Calls npm; reaches api.mem0.ai; needs OPENAI_API_KEY and ANTHROPIC_API_KEY

What it does

The skill shows how to install @mem0/vercel-ai-provider alongside the ai package, set MEM0_API_KEY plus a key for the underlying LLM provider, and then use one of three patterns. The wrapped model, created with createMem0, searches Mem0 for relevant memories, injects them as a system message, calls the underlying LLM and stores the conversation back as a fire-and-forget call. Standalone utilities such as retrieveMemories and addMemories give full control of the cycle, and streamText works with the wrapped model for streaming.

Supported providers are OpenAI (the default), Anthropic, Google, Groq and Cohere, selected when the Mem0 instance is created, each with its own API key variable. Reference files cover the provider API, the memory utilities and usage patterns.

The skill is scoped to Vercel AI SDK use, including Next.js apps. Direct SDK calls and terminal commands belong to other Mem0 skills. The compatibility notes list Node.js 18+ and Vercel AI SDK v5.

When your agent uses it

  • Giving a Vercel AI SDK chatbot memory across conversations
  • Wrapping generateText or streamText calls with automatic memory retrieval
  • Controlling exactly when memories are retrieved and stored
  • Adding memory-augmented AI to a Next.js app

Example prompts

  • “Add Mem0 memory to my Next.js chat route that uses streamText.”
  • “Use retrieveMemories and addMemories so I control when memories are saved for each user.”
  • “Switch the Mem0 provider in this app from OpenAI to Anthropic.”

Requirements

  • Node.js 18 or newer
  • The @mem0/vercel-ai-provider and ai npm packages
  • MEM0_API_KEY and an API key for the LLM provider
  • Compatibility (from SKILL.md): Node.js 18+, npm install @mem0/vercel-ai-provider, Vercel AI SDK v6 (ai package ^6), MEM0_API_KEY + LLM provider API key

Workflow steps

2 steps, taken from the step headings in SKILL.md.

  1. Install
  2. Set up environment variables

What it can do on your machine

Read from SKILL.md and the folder at commit b7ad69a. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • api.mem0.ai

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • OPENAI_API_KEY
    • ANTHROPIC_API_KEY
    • MEM0_API_KEY
    • GOOGLE_GENERATIVE_AI_API_KEY
    • GROQ_API_KEY
    • COHERE_API_KEY
    • GOOGLE_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Node.js 18+, npm install @mem0/vercel-ai-provider, Vercel AI SDK v6 (ai package ^6), MEM0_API_KEY + LLM provider API key

    From compatibility in the SKILL.md frontmatter.

Context cost

Mem0 Provider for Vercel AI SDK loads about 2.3k tokens when it runs, and up to ~10k if it reads all its reference files. Until then it costs about 134 tokens; SKILL.md has 625 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~134
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~10k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from mem0ai/mem0 at commit b7ad69a, republished under its Apache-2.0 licence (© mem0ai). 625 words, ~2,295 tokens.

Download SKILL.mdSave it as .claude/skills/mem0-vercel-ai-sdk/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
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).
compatibility
Node.js 18+, npm install @mem0/vercel-ai-provider, Vercel AI SDK v6 (ai package ^6), MEM0_API_KEY + LLM provider API key
license
Apache-2.0
metadata.author
mem0ai
metadata.version
2.0.0
metadata.category
ai-memory
metadata.tags
vercel, ai-sdk, memory, nextjs, typescript, provider
metadata.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

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

ProviderConfig valueRequired 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

FunctionReturnsUse when
retrieveMemoriesFormatted system prompt stringInjecting directly into system parameter
getMemoriesRaw memory arrayProcessing memories programmatically
searchMemoriesRaw search response (as returned by the API)Need scores and full metadata
addMemoriesAPI responseStoring new messages to Mem0

retrieveMemories, getMemories, and searchMemories accept LanguageModelV3Prompt | string as the first argument; addMemories is typed as LanguageModelV3Prompt (a string also works at runtime). All four take optional Mem0ConfigSettings as the second argument.

Show full SKILL.md (248 more words)Show less

Common Edge Cases and Tips

  • Always provide user_id (or agent_id/app_id/run_id) for consistent memory retrieval. The search endpoint requires at least one entity ID in filters; the provider places these IDs there for you.
  • Standalone utilities require explicit API key: pass mem0ApiKey in the config object, or set the MEM0_API_KEY environment variable.
  • This uses Vercel AI SDK v6 (LanguageModelV3 / ProviderV3 interfaces, @mem0/vercel-ai-provider 3.x). Provider 2.x targeted AI SDK v5. It is not compatible with AI SDK v4 or earlier.
  • processMemories awaits addMemories before searching and calling the LLM, so each wrapped call includes one memory write and one memory search. If either request fails, the error is logged and the LLM call proceeds without memories.
  • "google" and "gemini" are both accepted and map to @ai-sdk/google.
  • Removed in 3.0.0: org_id, project_id, org_name, project_name, output_format, filter_memories, async_mode, enable_graph, version, api_version. Graph memory is now a Mem0 Platform project setting, not a provider option.
  • Default top_k is 10. threshold and rerank are only sent when set (the API default for rerank is false; threshold is a server-side cutoff, not a floor on the returned score).
  • Custom host: set host in the config to point to a different Mem0 API endpoint (default: https://api.mem0.ai).

References

TopicFile
Provider API (createMem0, Mem0Provider, types)local / GitHub
Memory utilities (addMemories, retrieveMemories, etc.)local / GitHub
Usage patterns and exampleslocal / GitHub
SkillWhen to useLink
mem0Python/TypeScript SDK, REST API, framework integrationslocal / GitHub
mem0-cliTerminal commands, scripting, CI/CD, agent tool loopslocal / GitHub

© mem0ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (references) in skills/mem0-vercel-ai-sdk of mem0ai/mem0.

  • SKILL.md
  • LICENSE
  • README.md
  • references/memory-utilities.md
  • references/provider-api.md
  • references/usage-patterns.md

Open the folder on GitHubat commit b7ad69a

Compare with similar skills

Mem0 Provider for Vercel AI SDK next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Mem0 Provider for Vercel AI SDK compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mem0 Provider for Vercel AI SDK this skillmem0ai/mem067k—~2.3kAutomated safety check: PassApache-2.0
Routerbase API Integrationaiskillstore/marketplace433—~964Automated safety check: PassNone
AI SDKvercel-labs/ai-facts16820 repos~1.2kAutomated safety check: PassNone
Claude APIKocoro-lab/Kocoro4147 repos~4.5kAutomated safety check: PassApache-2.0
Genui Integrationopentiny/genui-sdk172—~1.3kAutomated safety check: PassMIT
Talking Avatar Voice Chat Appbuildfastwithai/gen-ai-experiments785—~1.7kAutomated safety check: PassMIT

Similar skills

  • Routerbase API Integration

    aiskillstore/marketplace

    Integrate applications with RouterBase, the OpenAI-compatible model gateway at https://routerbase.com/v1.

    433 GitHub stars~964 tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed
  • AI SDK

    vercel-labs/ai-facts

    Official

    Answer questions about the AI SDK and help build AI-powered features.

    168 GitHub starsUsed in 20 repos~1.2k tokens
    AI & LLM EngineeringAuto-check passed
  • Claude API

    Kocoro-lab/Kocoro

    Build apps with the Claude API or Anthropic SDK. An agent skill from Kocoro-lab/Kocoro.

    414 GitHub starsUsed in 7 repos~4.5k tokens
    AI & LLM EngineeringAuto-check passed
  • Genui Integration

    opentiny/genui-sdk

    genui-sdk 全方位指南:安装、配置、集成、示例。用户提到 genui-sdk、genui-sdk-server,或想构建 AI 聊天界面、动态 UI 组件、Node.js 后端 LLM 代理(OpenAI 兼容 chat/completions API)时使用。涵盖 Vue/Angular 前端(主题、物料、GenuiChat/GenuiRenderer)与 Server…

    172 GitHub stars~1.3k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Talking Avatar Voice Chat App

    buildfastwithai/gen-ai-experiments

    Builds a realtime voice-chat app around a talking character portrait made from your photo or a text description, with mouth sprites driven by the audio.

    785 GitHub stars~1.7k tokensUpdated 18 days ago
    AI & LLM EngineeringAuto-check passed
  • Neon AI Gateway

    neondatabase/agent-skills

    Official

    One API and one credential for frontier and open-source LLMs, built into your Neon branch and powered by Databricks.

    100 GitHub stars~5.1k tokensUpdated 2 days ago
    AI & LLM EngineeringAuto-check: notes

More from mem0ai/mem0

All 26 skills in this repo
  • Adds persistent memory to AI apps with the Mem0 Python and TypeScript SDKs: store, search, update and delete user memories, with framework integrations.

    67k GitHub starsUsed in 1 repo~2.2k tokens
    Auto-check passed
  • Adds, searches, lists, updates and deletes memories on the Mem0 platform from the terminal with the mem0 command, including a JSON mode built for agents.

    67k GitHub stars~2k tokensUpdated yesterday
    Auto-check: notes
  • Finds and deletes specific mem0 memories by search query or ID, always asking for confirmation first, and can undo the most recent memories added this session.

    67k GitHub stars~664 tokensUpdated yesterday
    Auto-check passed
  • Saves a fact, decision or preference the user states into mem0 as written, labeled with a memory type such as decision, convention or user_preference.

    67k GitHub stars~560 tokensUpdated yesterday
    Auto-check passed
  • Shows or changes the default Mem0 memory scope, project, session or global, which decides where memories are saved and searched.

    67k GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed
  • Looks up stored agent memories by keyword or ID and prints compact one-line results instead of full detail.

    67k GitHub stars~502 tokensUpdated yesterday
    Auto-check passed

Questions about Mem0 Provider for Vercel AI SDK

What does Mem0 Provider for Vercel AI SDK do?

Adds persistent memory to Vercel AI SDK apps with the Mem0 provider, using a wrapped model or standalone retrieve and store utilities. The skill shows how to install @mem0/vercel-ai-provider alongside the ai package, set MEM0_API_KEY plus a key for the underlying LLM provider, and then use one of three patterns. The wrapped model, created with createMem0, searches Mem0 for relevant memories, injects them as a system message, calls the underlying LLM and stores the conversation back as a fire-and-forget call.

When should I use Mem0 Provider for Vercel AI SDK?

Mem0 Provider for Vercel AI SDK fits situations like: giving a Vercel AI SDK chatbot memory across conversations; wrapping generateText or streamText calls with automatic memory retrieval; controlling exactly when memories are retrieved and stored; adding memory-augmented AI to a Next.js app.

How do I install Mem0 Provider for Vercel AI SDK in Claude Code?

Run `npx skills add mem0ai/mem0 --skill mem0-vercel-ai-sdk -a claude-code`. Or copy the skill folder (skills/mem0-vercel-ai-sdk in mem0ai/mem0) into .claude/skills/mem0-vercel-ai-sdk in your project. Claude Code loads it when a task matches its description.

How do I install Mem0 Provider for Vercel AI SDK in Codex?

Run `npx skills add mem0ai/mem0 --skill mem0-vercel-ai-sdk -a codex`. Or copy the skill folder (skills/mem0-vercel-ai-sdk in mem0ai/mem0) into .agents/skills/mem0-vercel-ai-sdk in your project. Codex loads it when a task matches its description.

Can I use Mem0 Provider for Vercel AI SDK in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add mem0ai/mem0 --skill mem0-vercel-ai-sdk -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mem0-vercel-ai-sdk, .gemini/skills/mem0-vercel-ai-sdk, .github/skills/mem0-vercel-ai-sdk and .opencode/skills/mem0-vercel-ai-sdk in your project.

What does Mem0 Provider for Vercel AI SDK need to run?

Going by SKILL.md and its folder, Mem0 Provider for Vercel AI SDK needs the command-line tools its instructions call (npm) and credentials named OPENAI_API_KEY, ANTHROPIC_API_KEY, MEM0_API_KEY and GOOGLE_GENERATIVE_AI_API_KEY. Our summary lists: Node.js 18 or newer; The @mem0/vercel-ai-provider and ai npm packages; MEM0_API_KEY and an API key for the LLM provider. Compatibility (from SKILL.md): Node.js 18+, npm install @mem0/vercel-ai-provider, Vercel AI SDK v6 (ai package ^6), MEM0_API_KEY + LLM provider API key.

Does Mem0 Provider for Vercel AI SDK access the network?

SKILL.md names 1 domain. In commands or code: api.mem0.ai; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Mem0 Provider for Vercel AI SDK safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Mem0 Provider for Vercel AI SDK use?

Mem0 Provider for Vercel AI SDK is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Mem0 Provider for Vercel AI SDK use?

About 2.3k tokens (SKILL.md is roughly 9.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 8.1k tokens, read only when the agent opens those files.

What are the alternatives to Mem0 Provider for Vercel AI SDK?

Skills that share tags, products or a category with Mem0 Provider for Vercel AI SDK: Routerbase API Integration (aiskillstore/marketplace, 433 stars), AI SDK (vercel-labs/ai-facts, 168 stars), Claude API (Kocoro-lab/Kocoro, 414 stars) and Genui Integration (opentiny/genui-sdk, 172 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Mem0 Provider for Vercel AI SDK?

mem0ai (a GitHub organization) maintains it in mem0ai/mem0, which has 66,921 GitHub stars. The repository holds 26 skills in this directory. The repository was last updated on October 9, 2026.

Source: mem0ai/mem0 on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.