Files
landing_page/qdrant-landing/content/documentation/frameworks/mastra.md
T

4.2 KiB

title, short_description, description
title short_description description
Mastra Add Qdrant as the vector store in Mastra TypeScript AI apps to power RAG, agents, workflows, and evaluations on local or serverless deployments. Use Qdrant with the Mastra TypeScript framework as the vector store for RAG, agents, and workflows running locally or in serverless cloud environments.

Mastra

Mastra is a Typescript framework to build AI applications and features quickly. It gives you the set of primitives you need: workflows, agents, RAG, integrations, syncs and evals. You can run Mastra on your local machine, or deploy to a serverless cloud.

Qdrant is available as a vector store in Mastra node to augment application with retrieval capabilities.

Setup

npm install @mastra/core

Usage

import { QdrantVector } from "@mastra/rag";

const qdrant = new QdrantVector({
  url: "https://xyz-example.eu-central.aws.cloud.qdrant.io:6333"
  apiKey: "<YOUR_API_KEY>",
  https: true
});

Constructor Options

Name Type Description
url string REST URL of the Qdrant instance. Eg. https://xyz-example.eu-central.aws.cloud.qdrant.io:6333
apiKey string Optional Qdrant API key
https boolean Whether to use TLS when setting up the connection. Recommended.

Methods

createIndex()

Name Type Description Default Value
indexName string Name of the index to create
dimension number Vector dimension size
metric string Distance metric for similarity search cosine

upsert()

Name Type Description Default Value
vectors number[][] Array of embedding vectors
metadata Record<string, any>[] Metadata for each vector (optional)
namespace string Optional namespace for organization

query()

Name Type Description Default Value
vector number[] Query vector to find similar vectors
topK number Number of results to return (optional) 10
filter Record<string, any> Metadata filters for the query (optional)

listIndexes()

Returns an array of index names as strings.

describeIndex()

Name Type Description
indexName string Name of the index to describe

Returns

interface IndexStats {
  dimension: number;
  count: number;
  metric: "cosine" | "euclidean" | "dotproduct";
}

deleteIndex()

Name Type Description
indexName string Name of the index to delete

Response Types

Query results are returned in this format:

interface QueryResult {
  id: string;
  score: number;
  metadata: Record<string, any>;
}

Further Reading