About Vercel AI SDK
The @moss-tools/vercel-sdk package exposes Moss operations as standard AI SDK tools. Language models can search indexes, create indexes, and manage documents as part of agentic workflows using generateText() or streamText(). Mutating tools set needsApproval: true for user confirmation.
Why Use Moss with Vercel AI SDK
01
Standard AI SDK tool() definitions
mossSearchTool, mossAddDocsTool, mossCreateIndexTool, and more
02
Prebind tools to a specific index
Simpler schemas, or let the LLM choose dynamically
03
Mutating tools set needsApproval: true
Safety for addDocs, createIndex, deleteDocs
04
Works with any AI SDK provider
OpenAI, Anthropic, Google, and more
05
TypeScript-native with typed input/output schemas
via Zod
Quick Start
import { MossClient } from "@moss-js/moss";
import {
mossSearchTool,
mossAddDocsTool,
mossDeleteDocsTool,
mossCreateIndexTool,
mossListIndexesTool,
} from "@moss-tools/vercel-sdk";
import { generateText, stepCountIs } from "ai";
import { openai } from "@ai-sdk/openai";
const client = new MossClient(
process.env.MOSS_PROJECT_ID!,
process.env.MOSS_PROJECT_KEY!,
);
// Prebind tools to a specific index for simpler schemas
const tools = {
search: mossSearchTool({ client, indexName: "docs" }),
addDocs: mossAddDocsTool({ client, indexName: "docs" }),
deleteDocs: mossDeleteDocsTool({ client, indexName: "docs" }),
createIndex: mossCreateIndexTool({ client }),
listIndexes: mossListIndexesTool({ client }),
};
const result = await generateText({
model: openai("gpt-4o"),
tools,
stopWhen: stepCountIs(5),
prompt: "Search the docs index for return policy info and summarize it.",
});Get Started in 3 Steps
01
Install the packages
Run npm install @moss-tools/vercel-sdk @moss-js/moss ai zod to add Moss tools to your project.
02
Initialize tools
Create a MossClient and pass it to the tool factories. Optionally prebind an indexName for simpler LLM schemas.
03
Use with generateText or streamText
Pass the tools object to generateText() or streamText(). The LLM can now search your knowledge base, create indexes, and manage documents autonomously.
Frequently asked questions
Ready to ship faster AI products?
Moss gives you production-ready semantic retrieval without infrastructure complexity.