Use this file to discover all available pages before exploring further.
Integrate Memvid with the Vercel AI SDK to build AI-powered web applications. The vercel-ai adapter provides tools formatted for use with generateText, streamText, and other AI SDK functions.
import { use } from '@memvid/sdk';// Open with Vercel AI adapterconst mem = await use('vercel-ai', 'knowledge.mv2');// Access Vercel AI toolsconst tools = mem.tools; // Object with tool definitions
import { use } from '@memvid/sdk';import { generateText } from 'ai';import { openai } from '@ai-sdk/openai';// Get Memvid toolsconst mem = await use('vercel-ai', 'knowledge.mv2');// Use with generateTextconst result = await generateText({ model: openai('gpt-4o-mini'), tools: mem.tools, maxSteps: 5, // Allow multiple tool calls system: 'You are a helpful assistant with access to a knowledge base.', prompt: 'Search for information about authentication and summarize it.',});// Access the resultconsole.log(result.text);// View tool calls madefor (const step of result.steps) { if (step.toolCalls) { for (const call of step.toolCalls) { console.log(`Tool: ${call.toolName}, Args: ${JSON.stringify(call.args)}`); } }}
import { use } from '@memvid/sdk';import { streamText } from 'ai';import { openai } from '@ai-sdk/openai';// Get Memvid toolsconst mem = await use('vercel-ai', 'knowledge.mv2');// Stream response with tool useconst result = await streamText({ model: openai('gpt-4o-mini'), tools: mem.tools, maxSteps: 3, system: 'You are a helpful assistant with access to a knowledge base.', prompt: 'What features does the product have?',});// Stream the text outputfor await (const chunk of result.textStream) { process.stdout.write(chunk);}
You can also call tools directly without using an LLM:
import { use } from '@memvid/sdk';const mem = await use('vercel-ai', 'knowledge.mv2');const tools = mem.tools;// Store a documentconst putResult = await tools.memvid_put.execute({ title: 'API Documentation', label: 'docs', text: 'The API supports REST and GraphQL endpoints...',});console.log(putResult); // "Document stored with frame_id: 2"// Search for documentsconst findResult = await tools.memvid_find.execute({ query: 'API endpoints', top_k: 5,});console.log(findResult);// Ask a questionconst askResult = await tools.memvid_ask.execute({ question: 'How do I authenticate with the API?', mode: 'auto',});console.log(askResult);