vercel-ai adapter provides tools formatted for use with generateText, streamText, and other AI SDK functions.
Installation
Quick Start
Available Tools
The Vercel AI adapter provides three tools:| Tool | Description |
|---|---|
memvid_put | Store documents in memory with title, label, and text |
memvid_find | Search for relevant documents by query |
memvid_ask | Ask questions with RAG-style answer synthesis |
Using with generateText
Using with streamText
Direct Tool Usage
You can also call tools directly without using an LLM:Next.js API Route
Next.js with useChat
Tool Parameters
memvid_put
| Parameter | Type | Required | Description |
|---|---|---|---|
title | string | Yes | Title of the document |
label | string | Yes | Category or label |
text | string | Yes | Text content to store |
metadata | object | No | Optional key-value metadata |
memvid_find
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Search query string |
top_k | number | No | Number of results (default: 5) |
memvid_ask
| Parameter | Type | Required | Description |
|---|---|---|---|
question | string | Yes | Question to answer |
mode | string | No | 'auto', 'lex', or 'sem' |
Best Practices
- Set maxSteps to allow the model to make multiple tool calls when needed
- Use streaming for better user experience with
streamText - Handle tool results by checking
result.stepsfor tool call history - Close the memory when done with
mem.seal()
Next Steps
OpenAI SDK
OpenAI function calling
LangChain
LangChain integration