AWS Bedrock - Mem0

Setup

Usage

Python

import os
from mem0 import Memory

os.environ['AWS_REGION'] = 'us-east-1'
os.environ["AWS_ACCESS_KEY_ID"] = "xx"
os.environ["AWS_SECRET_ACCESS_KEY"] = "xx"

config = {
    "llm": {
        "provider": "aws_bedrock",
        "config": {
            "model": "anthropic.claude-sonnet-4-20250514-v1:0",
            "temperature": 0.2,
            "max_tokens": 2000,
        }
    }
}

m = Memory.from_config(config)
m.add([\
    {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},\
    {"role": "assistant", "content": "How about thriller movies? 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."}\
], user_id="alice", metadata={"category": "movies"})

TypeScript

import { Memory } from 'mem0ai/oss';

const config = {
  llm: {
    provider: 'aws_bedrock',
    config: {
      model: 'anthropic.claude-sonnet-4-20250514-v1:0',
      temperature: 0.2,
      maxTokens: 2000,
      // Optional. Omit these to use the default AWS credential chain.
      awsRegion: process.env.AWS_REGION,
      awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
      awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
    },
  },
};

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 thriller movies? 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' } });

@aws-sdk/client-bedrock-runtime is an optional peer dependency of mem0ai, so npm will not install it for you. The TypeScript provider loads it lazily and throws a clear error on the first request if the package is missing.

The TypeScript provider calls the Bedrock Converse API, a single uniform interface across the current Bedrock model families. Streaming and InvokeModel-only models are not supported yet.

Config

All available parameters for the aws_bedrock config are present in Master List of All Params in Config.