Skip to main content
A vector store keeps documents, embeddings, and metadata and searches them by similarity. Choose the embedding model and dimensions together with the store. Conversation StorageDriver records and durable task stores serve different purposes. Start with the local example below. It proves indexing/search plumbing without credentials; it does not measure semantic retrieval quality.

VectorStore interface

This selected interface matches the public operations; use vector APIs for complete declarations:

Types

Multimodal parts require an embedding provider that implements that input. Backends persist text, vectors, and metadata; retain media references in metadata when needed. Filter behavior is adapter-specific; do not treat a metadata filter as caller authorization.

Implementations comparison

Call initialize() for a consistent lifecycle even where it is a no-op. Creating an embedding provider can require another optional client, such as openai or @google/genai.

InMemoryVectorStore

Use an ESM TypeScript project ("type": "module" in package.json) on a supported Node version.
Save as retrieve.ts:
Expect delivery. HashEmbedding hashes tokens locally; replace it with a measured semantic embedder before evaluating real retrieval quality. The constructor accepts an optional EmbeddingProvider, not a dimension number.

PgVectorStore

Install pg@8. The PostgreSQL server needs its vector extension available, and initialization requests CREATE EXTENSION IF NOT EXISTS vector. The adapter formats vectors itself; the separate pgvector npm package is not required by its implementation. This host factory returns a store; the caller initializes it, uses it, and closes it after consumers finish:
Collections become sanitized table names. Each collection is created on first upsert with a vector column and HNSW index. The configuration fields are connectionString and optional dimensions; there is no tableName option. Dimension defaults come from the embedder, then 1536 when no embedder is supplied. Existing collections are not automatically migrated when the embedding model changes.

QdrantVectorStore

Install @qdrant/js-client-rest and run or provision a Qdrant service. This is another host factory:
Supported configuration includes url (default http://localhost:6333), apiKey, dimensions, and checkCompatibility. initialize() is a no-op; a missing collection is created on first upsert. Collection names are arguments to store operations, not a collectionName constructor field. Match existing collection dimensions to your embedder.

MongoDBVectorStore

Install mongodb@6. For Atlas vector search, create the named index for the stored embedding field with matching dimensions. This factory configures the client; initialize() connects it:
The v4 constructor accepts uri, optional dbName, and optional indexName. It has no dimensions or collectionName field. Configure Atlas index dimensions on the service and pass collection names to upsert()/search(). The adapter tries Atlas search and can fall back to fetching documents for local similarity on recognized unsupported-search errors. Local fallback has different scaling characteristics; validate the mode used by your deployment instead of assuming every query uses a server-side index.

EmbeddingProvider

With an embedder, a text document/query is embedded automatically. Without one, supply numeric vectors for both documents and queries. This complete local example supplies two-dimensional vectors directly:
A supplied embedding bypasses automatic embedding for that document. A string query still needs an embedder. Keep model, dimensions, document/query formatting, and normalization consistent; re-index a collection when that contract changes.

Connect retrieval to an Agent

Pass the store to KnowledgeBase, add documents, and expose kb.asTool() or explicitly insert retrieved results into the Agent’s context. Merely constructing a knowledge base does not give an Agent access to it. Continue with the retrieval tutorial for the full evidence → answer path and embeddings for model choices.