@caleblawson/upstash
v0.11.1-alpha.0
Published
Upstash provider for Mastra - includes both vector and db storage capabilities
Readme
@mastra/upstash
Upstash provider for Mastra that includes both vector store and database storage capabilities.
Installation
npm install @mastra/upstashVector Store Usage
import { UpstashVector } from '@mastra/upstash';
// In upstash they refer to the store as an index
const vectorStore = new UpstashVector({
url: process.env.UPSTASH_VECTOR_REST_URL,
token: process.env.UPSTASH_VECTOR_TOKEN
});
// Add vectors
const vectors = [[0.1, 0.2, ...], [0.3, 0.4, ...]];
const metadata = [{ text: 'doc1' }, { text: 'doc2' }];
const ids = await vectorStore.upsert({
indexName: 'my-namespace',
vectors,
metadata
});
// There is no store.createIndex call here, Upstash creates indexes (known as namespaces in Upstash) automatically
// when you upsert if that namespace does not exist yet.
// Query vectors
const results = await vectorStore.query({
indexName: 'my-namespace',
queryVector: [0.1, 0.2, ...],
topK: 10,
filter: { text: { $eq: 'doc1' } },
includeVector: false
});Vector Store Configuration
The Upstash vector store requires the following configuration:
UPSTASH_VECTOR_REST_URL: Your Upstash Vector REST URLUPSTASH_VECTOR_TOKEN: Your Upstash Vector REST tokenUPSTASH_INDEX: Name of the index to use
Database Storage Usage
import { UpstashStore } from '@mastra/upstash';
const store = new UpstashStore({
url: process.env.UPSTASH_REDIS_REST_URL,
token: process.env.UPSTASH_REDIS_REST_TOKEN,
});Database Storage Configuration
The Upstash store requires the following configuration:
UPSTASH_REDIS_REST_URL: Your Upstash Redis REST URLUPSTASH_REDIS_REST_TOKEN: Your Upstash Redis REST token
Features
- Serverless vector database and key-value store
- Pay-per-use pricing
- Low latency global access
- REST API interface
- Built-in vector similarity search
- Durable storage for chat history and agent memory
