Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Tools · Class

VectorStoreIndex

VectorStoreIndex creates a searchable vector index from documents. It chunks documents, embeds the chunks with an embedding model, and stores the embeddings in a vector database.

How it works

VectorStoreIndex is imported from the community vectorstores core package and built from documents with fromDocuments. The operation chunks documents, embeds the chunks, and stores the resulting vectors for later similarity retrieval.

Syntax

VectorStoreIndex.fromDocuments(documents, { embedFunc: vercelEmbedding(embeddingModel) })

Parameters

NameTypeDescription
documentsDocument[]Documents to index.
options{ embedFunc: ... }Options containing the embedding function used to embed document chunks.

Returns

A promise resolving to a vector store index.

Key points

  • The index stores document embeddings so content can be searched semantically.
  • Use the static fromDocuments function to construct an index from documents.
  • fromDocuments handles chunking, embedding, and persistence in the vector database.
  • After creation, pair the index with a retriever for similarity-based document lookup.

Common mistakes

  • Define an index before using the vectorstores provider.
  • Provide an embedding model through the embedding function.

Example: Create a vector store index

import { openai } from '@ai-sdk/openai';
import { vercelEmbedding } from '@vectorstores/vercel';
import { VectorStoreIndex } from '@vectorstores/core';

const documents = [
  new Document({ text: 'This is a large document.' }),
];

const index = await VectorStoreIndex.fromDocuments(documents, {
  embedFunc: vercelEmbedding(openai.embedding('text-embedding-3-small')),
});

Creates an index from documents using a Vercel AI SDK embedding model.

When to use it

Semantic document search

Build semantic search over an application's document collection.

RAG retrieval

Prepare indexed context for retrieval-augmented generation.

Agent-accessible knowledge base

Let an AI agent query a vector database through a retriever tool.

  • vectorstores provider
  • VectorStoreIndex.fromDocuments
  • vercelEmbedding
  • retriever
  • vercelTool

Source: Verceltool. Checked 2026-10-15.