Skip to main content
Integrate Moss semantic search into Vercel AI SDK agents using the @moss-tools/vercel-sdk package. This setup exposes Moss operations as AI SDK tools, so language models can search, create indexes, and manage documents as part of agentic workflows.
Note: For the full package source and tests, see the vercel-sdk package.

Why use Moss with the Vercel AI SDK?

The Vercel AI SDK’s tool system lets language models call external functions during generation. Moss tools give your agents direct access to a semantic knowledge base with sub-10ms retrieval, enabling RAG workflows and knowledge base operations within a single generateText or streamText call.

Required tools

Integration guide

1

Installation

2

Environment setup

.env.local
3

Create tools and use with an agent

Import the tool factories and initialize them with a Moss client. Each factory returns a standard AI SDK tool with typed input/output schemas.

Available tools

Read-only

Mutating (requires approval)

Mutating tools have needsApproval: true, so the AI SDK prompts for user confirmation before execution.

Configuration

Index binding

Tools accept an optional indexName parameter. When provided, the tool is prebound to that index and the LLM only needs to provide the query or document data. When omitted, the LLM chooses the index name dynamically.

mossSearchTool options