Skip to main content
Learn by building. These examples show you how to use Memvid in production scenarios.

Quick Examples

Semantic Search in 10 Lines

import { use } from '@memvid/sdk';

// Open or create memory
const mem = await use('basic', 'knowledge.mv2', { mode: 'auto' });

// Add some knowledge
await mem.put({ title: 'AI Basics', label: 'docs', text: 'Artificial intelligence is...' });
await mem.put({ title: 'ML Guide', label: 'docs', text: 'Machine learning enables...' });

// Search semantically
const results = await mem.find('how do computers learn?', { k: 5 });
results.hits.forEach(hit => console.log(`${hit.title}: ${hit.snippet}`));

LangChain RAG Pipeline

from memvid_sdk import use
from langchain_openai import ChatOpenAI
from langchain.chains import RetrievalQA

# Initialize with LangChain adapter
mem = use('langchain', 'knowledge.mv2')

# Create RAG chain
qa = RetrievalQA.from_chain_type(
    llm=ChatOpenAI(model="gpt-4o"),
    retriever=mem.as_retriever(k=5),
    return_source_documents=True
)

# Ask questions
result = qa.invoke("What are the main features?")
print(result['result'])

Next.js API Route with Streaming

// app/api/chat/route.ts
import { use } from '@memvid/sdk';
import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';

const mem = await use('vercel-ai', 'knowledge.mv2');

export async function POST(req: Request) {
  const { messages } = await req.json();

  const result = await streamText({
    model: openai('gpt-4o'),
    system: 'You are a helpful assistant. Use the tools to search the knowledge base.',
    tools: mem.tools,
    messages,
    maxSteps: 5,
  });

  return result.toDataStreamResponse();
}

Multi-Agent Research Team

from memvid_sdk import use
from autogen import AssistantAgent, UserProxyAgent

mem = use('autogen', 'research-papers.mv2')

# Create researcher agent with Memvid tools
researcher = AssistantAgent(
    name="researcher",
    llm_config={"tools": mem.tools},
    system_message="You research topics using the knowledge base."
)

# Create writer agent
writer = AssistantAgent(
    name="writer",
    system_message="You write summaries based on research findings."
)

# Create user proxy
user = UserProxyAgent(name="user", human_input_mode="NEVER")

# Start research task
user.initiate_chat(
    researcher,
    message="Research the latest advances in transformer architectures"
)

Example Categories

By Use Case

By Framework

FrameworkIntegration Guide
LangChainLangChain Integration
LlamaIndexLlamaIndex Integration
Vercel AIVercel AI Integration
OpenAIOpenAI Integration
Google ADKGoogle ADK Integration

Starter Templates

Get started quickly with our templates:

Community Examples

Explore what others have built:

Awesome Memvid

Community-curated list of Memvid projects, tutorials, and resources
ProjectDescriptionAuthor
DocuChatChat with your documents@developer1
ResearchGPTAcademic paper assistant@developer2
CodeSearchSemantic code search@developer3

Submit Your Example

Built something cool? Share it with the community!

Submit Example

Submit your example for inclusion in the docs