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

NameTypeDescription
urlstringREST URL of the Qdrant instance. Eg. https://xyz-example.eu-central.aws.cloud.qdrant.io:6333
apiKeystringOptional Qdrant API key
httpsbooleanWhether to use TLS when setting up the connection. Recommended.

Methods

createIndex()

NameTypeDescriptionDefault Value
indexNamestringName of the index to create
dimensionnumberVector dimension size
metricstringDistance metric for similarity searchcosine

upsert()

NameTypeDescriptionDefault Value
vectorsnumber[][]Array of embedding vectors
metadataRecord<string, any>[]Metadata for each vector (optional)
namespacestringOptional namespace for organization

query()

NameTypeDescriptionDefault Value
vectornumber[]Query vector to find similar vectors
topKnumberNumber of results to return (optional)10
filterRecord<string, any>Metadata filters for the query (optional)

listIndexes()

Returns an array of index names as strings.

describeIndex()

NameTypeDescription
indexNamestringName of the index to describe

Returns

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

deleteIndex()

NameTypeDescription
indexNamestringName 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

Was this page useful?

Thank you for your feedback! 🙏

We are sorry to hear that. 😔 You can edit this page on GitHub, or create a GitHub issue.