docs/components/vectordbs/dbs/neptune_analytics.mdx
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.
The Neptune Analytics provider needs the AWS Neptune Graph client. Install it alongside mem0ai:
npm install @aws-sdk/client-neptune-graph
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.
<CodeGroup> ```python Python from mem0 import Memoryconfig = { "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"})
```typescript TypeScript
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" } });
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.
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.