Skip to main content
Neptune Analytics is a memory-optimized graph database engine for analytics. With Neptune Analytics, you can get insights and find trends by processing large amounts of graph data in seconds, including vector search.

Installation

The Neptune Analytics provider needs the AWS Neptune Graph client. Install it alongside mem0ai:
pip install mem0ai[vector-stores]
npm install @aws-sdk/client-neptune-graph

Usage

Configure AWS credentials in your environment (environment variables, shared config file, an IAM role, or an instance profile). Both SDKs pick them up automatically through the standard AWS credential chain.
from mem0 import Memory

config = {
    "vector_store": {
        "provider": "neptune",
        "config": {
            "collection_name": "mem0",
            "endpoint": "neptune-graph://g-abc123xyz0",
        },
    },
}

m = Memory.from_config(config)
messages = [
    {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
    {"role": "assistant", "content": "How about a thriller movie? They can be quite engaging."},
    {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
    {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
]
m.add(messages, user_id="alice", metadata={"category": "movies"})
import { Memory } from 'mem0ai/oss';

const config = {
  vectorStore: {
    provider: 'neptune',
    config: {
      collectionName: 'mem0',
      graphIdentifier: 'g-abc123xyz0',
      // Any other key here (region, credentials, maxAttempts, ...) is
      // forwarded to the underlying NeptuneGraphClient constructor.
      region: 'us-east-1',
    },
  },
};

const memory = new Memory(config);
const messages = [
  { role: "user", content: "I'm planning to watch a movie tonight. Any recommendations?" },
  { role: "assistant", content: "How about a thriller movie? They can be quite engaging." },
  { role: "user", content: "I'm not a big fan of thriller movies but I love sci-fi movies." },
  { role: "assistant", content: "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future." },
];
await memory.add(messages, { userId: "alice", metadata: { category: "movies" } });

Config

ParameterDescriptionDefault Value
collection_nameThe name of the collection to store the vectorsmem0
endpointConnection URL for the Neptune Analytics service, must be neptune-graph://<graph-id>Required
Both SDKs store vectors on graph nodes labeled MEM0_VECTOR_<collection_name>. Point them at the same graph with the same collection_name — the defaults differ, mem0 in Python and memories in TypeScript — and get(), list(), and delete() interoperate across SDKs.
search() is not currently cross-SDK compatible. The TypeScript provider filters on Neptune’s reserved ~label metafield, while the Python provider filters on a synthetic label property that only Python’s own insert() writes. Python’s search() therefore cannot see nodes written by the TypeScript provider.

IAM Permissions

Your AWS identity (user or role) needs a policy that allows the ExecuteQuery actions used for reads, writes, and deletes:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "neptune-graph:ReadDataViaQuery",
        "neptune-graph:WriteDataViaQuery",
        "neptune-graph:DeleteDataViaQuery"
      ],
      "Resource": "*"
    }
  ]
}
For production, scope the resource ARN down to your specific graph.