DocsReferenceRAGVector Store

Mastra Vector Store Configuration

mastra.config.ts

Vector stores are referenced in the vectorProvider array in mastra.config.ts.

The vector store configuration is defined in agent-chatbot/mastra/vector-configs/pinecone.json. This file specifies your Pinecone vector indexes and their configurations. Here’s a runnable example: pinecone.json

Required Fields

  • name: Unique name for your Pinecone index
  • metric: Similarity metric (typically “cosine”)
  • dimension: Vector dimension (1536 for OpenAI embeddings)
  • host: Your Pinecone index endpoint
  • namespaces: Array of namespaces within the index

Annotated Example Configuration

[
  {
    "name": "github-repos", // Name of your Pinecone index
    "metric": "cosine", // Similarity metric (usually "cosine")
    "dimension": 1536, // Vector dimension (1536 for OpenAI embeddings)
    "host": "github-repos-xyz123.svc.us-east-1.pinecone.io", // Your Pinecone index endpoint
    "namespaces": [
      // Array of namespaces in this index
      "reposListForUser"
    ],
    "spec": {
      "serverless": {
        "region": "us-east-1", // AWS region for serverless deployment
        "cloud": "aws" // Cloud provider
      }
    }
  }
]

Notes

  1. Each index must have a unique name
  2. The dimension should match your embedding model
  3. Namespaces help organize different types of data within an index
  4. The host URL is provided by Pinecone when you create an index

This configuration file is automatically read by Mastra to set up your vector store connections.

Creating a new vector store

You can create a new vector store by filling out the form in your admin UI at localhost:3456/rag/create.

Create a new vector store

Giving an agent access to a vector store

To give your agent access to a vector store, you need to add the vector store’s name to the vectorProvider field in an agent object in mastra.config.ts.

Runnable example: agent-chatbot/mastra.config.ts#L69

API Signature

Parameters

vector_provider:

string
Name of the vector database provider (e.g. 'PINECONE')

indexName:

string
The name of the index to query

content:

string
The content to find similar matches for

entityType:

string
Namespace/entity type to query within

topK?:

number
Number of top results to return (defaults to 1)

filter?:

Record<string, any>
Filter criteria for the query

Returns an array

id:

string
The ID of the search result.

store:

number

metadata?:

Record<string, any>