Upstash Vector - Mem0

Documentation Index

Fetch the complete documentation index at: /llms.txt

Use this file to discover all available pages before exploring further.

Upstash Vector is a serverless vector database with built-in embedding models.

Usage with Upstash embeddings

You can enable the built-in embedding models by setting enable_embeddings to True. This allows you to use Upstash’s embedding models for vectorization.

Server-side Upstash embeddings (enable_embeddings) are available in the Python SDK only. The TypeScript SDK always embeds text with your configured embedder before writing to Upstash, so use the external embedding provider setup below.

import os
from mem0 import Memory

os.environ["UPSTASH_VECTOR_REST_URL"] = "..."
os.environ["UPSTASH_VECTOR_REST_TOKEN"] = "..."

config = {
    "vector_store": {
        "provider": "upstash_vector",
        "config": {
            "enable_embeddings": True,
        }
    }
}

m = Memory.from_config(config)
m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})

Setting enable_embeddings to True will bypass any external embedding provider you have configured.

Usage with external embedding providers

Python

import os
from mem0 import Memory

os.environ["OPENAI_API_KEY"] = "..."
os.environ["UPSTASH_VECTOR_REST_URL"] = "..."
os.environ["UPSTASH_VECTOR_REST_TOKEN"] = "..."

config = {
    "vector_store": {
        "provider": "upstash_vector",
    },
    "embedder": {
        "provider": "openai",
        "config": {
            "model": "text-embedding-3-large"
        },
    }
}

m = Memory.from_config(config)
m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})

TypeScript

import { Memory } from "mem0ai/oss";

// Set OPENAI_API_KEY, UPSTASH_VECTOR_REST_URL, and UPSTASH_VECTOR_REST_TOKEN in your environment.
const config = {
  embedder: {
    provider: "openai",
    config: {
      apiKey: process.env.OPENAI_API_KEY,
      model: "text-embedding-3-large",
    },
  },
  vectorStore: {
    provider: "upstash_vector",
    config: {
      collectionName: "memories",
      url: process.env.UPSTASH_VECTOR_REST_URL,
      token: process.env.UPSTASH_VECTOR_REST_TOKEN,
    },
  },
};

const memory = new Memory(config);
await memory.add("Likes to play cricket on weekends", {
  userId: "alice",
  metadata: { category: "hobbies" },
});

Config

Here are the parameters available for configuring Upstash Vector:

Parameter Description Default Value
url URL for the Upstash Vector index None
token Token for the Upstash Vector index None
client An upstash_vector.Index instance None
collection_name The default namespace used ""
enable_embeddings Whether to use Upstash embeddings False

When url and token are not provided, the UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN environment variables are used.

The TypeScript SDK uses camelCase config keys (collectionName, url, token), where collectionName is required. Pass url and token (or a preconfigured client) explicitly, since the TypeScript SDK does not read them from environment variables. enable_embeddings is not supported in TypeScript.