Multimodal Support - Mem0

Multimodal support

Multimodal support lets Mem0 extract facts from images alongside regular text. Add screenshots, receipts, or product photos and Mem0 will store the insights as searchable memories so agents can recall them later.

You’ll use this when…

Mem0 passes images straight to your configured vision model, so per-image size and resolution limits come from that provider (for example, OpenAI caps images at 20 MB). Compress or resize large files to stay within your provider’s limits and keep processing fast.


Feature anatomy

Supported formats

Format Used for Notes
JPEG / JPG Photos and screenshots Default option for camera captures.
PNG Images with transparency Keeps sharp text and UI elements crisp.
WebP Web-optimized images Smaller payloads for faster uploads.
GIF Static or animated graphics Works for simple graphics and short loops.

Configure it

You must set enable_vision: True in your LLM config for image content to be processed. Without it, image turns are silently dropped and no vision memories are created. Example:

config = {"llm": {"provider": "openai", "config": {"enable_vision": True, "vision_details": "auto"}}}
client = Memory.from_config(config)

vision_details maps to the vision model’s image detail setting and accepts "auto" (the default), "low", or "high". Use "high" for dense images like receipts or documents; "low" is faster and cheaper for simple photos.

Add image messages from URLs

Python

from mem0 import Memory

client = Memory()

messages = [\
    {\
        "role": "user", "content": "Hi, my name is Alice."},\
    {\
        "role": "user",\
        "content": {\
            "type": "image_url",\
            "image_url": {\
                "url": "https://example.com/menu.jpg"\
            }\
        }\
    }\
]

client.add(messages, user_id="alice")

TypeScript

import { Memory } from "mem0ai/oss";

const client = new Memory();

const messages = [\
  { role: "user", content: "Hi, my name is Alice." },\
  {\
    role: "user",\
    content: {\
      type: "image_url",\
      image_url: { url: "https://example.com/menu.jpg" }\
    }\
  }\
];

await client.add(messages, { userId: "alice" });

Inspect the response payload: the memories list should include entries extracted from the menu image as well as the text turns.

Upload local images as base64

Python

import base64
from mem0 import Memory

def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")

client = Memory()
base64_image = encode_image("path/to/your/image.jpg")

messages = [\
    {\
        "role": "user",\
        "content": [\
            {"type": "text", "text": "What's in this image?"},\
            {\
                "type": "image_url",\
                "image_url": {\
                    "url": f"data:image/jpeg;base64,{base64_image}"\
                }\
            }\
        ]\
    }\
]

client.add(messages, user_id="alice")

TypeScript

import fs from "fs";
import { Memory } from "mem0ai/oss";

function encodeImage(imagePath: string) {
  const buffer = fs.readFileSync(imagePath);
  return buffer.toString("base64");
}

const client = new Memory();
const base64Image = encodeImage("path/to/your/image.jpg");

const messages = [\
  {\
    role: "user",\
    content: [\
      { type: "text", text: "What's in this image?" },\
      {\
        type: "image_url",\
        image_url: {\
          url: `data:image/jpeg;base64,${base64Image}`\
        }\
      }\
    ]\
  }\
];

await client.add(messages, { userId: "alice" });

Smaller images upload and process faster. Compress or resize before encoding to base64, and check your vision provider’s per-image size limit for large files.


See it in action

Restaurant menu memory

from mem0 import Memory

client = Memory()

messages = [\
    {\
        "role": "user",\
        "content": "Help me remember which dishes I liked."\
    },\
    {\
        "role": "user",\
        "content": {\
            "type": "image_url",\
            "image_url": {\
                "url": "https://example.com/restaurant-menu.jpg"\
            }\
        }\
    },\
    {\
        "role": "user",\
        "content": "I’m allergic to peanuts and prefer vegetarian meals."\
    }\
]

result = client.add(messages, user_id="user123")
print(result)

Document capture

messages = [\
    {\
        "role": "user",\
        "content": "Store this receipt information for expenses."\
    },\
    {\
        "role": "user",\
        "content": {\
            "type": "image_url",\
            "image_url": {\
                "url": "https://example.com/receipt.jpg"\
            }\
        }\
    }\
]

client.add(messages, user_id="user123")

Error handling

Python

from mem0 import Memory

client = Memory()

try:
    messages = [{\
        "role": "user",\
        "content": {\
            "type": "image_url",\
            "image_url": {"url": "https://example.com/image.jpg"}\
        }\
    }]

client.add(messages, user_id="user123")
    print("Image processed successfully")

except ValueError as exc:
    print(f"Invalid image message: {exc}")
except Exception as exc:
    print(f"Could not process image: {exc}")

TypeScript

import { Memory } from "mem0ai/oss";

const client = new Memory();

try {
  const messages = [{\
    role: "user",\
    content: {\
      type: "image_url",\
      image_url: { url: "https://example.com/image.jpg" }\
    }\
  }];

await client.add(messages, { userId: "user123" });
  console.log("Image processed successfully");
} catch (error: any) {
  console.log(`Could not process image: ${error.message}`);
}

Verify the feature is working


Best practices

  1. Ask for intent: Prompt users to explain why they sent an image so the memory includes the right context.
  2. Keep images readable: Encourage clear photos without heavy filters or shadows for better extraction.
  3. Split bulk uploads: Send multiple images as separate add calls to isolate failures and improve reliability.
  4. Watch privacy: Avoid uploading sensitive documents unless your environment is secured for that data.
  5. Validate file size early: Check file size before encoding to save bandwidth and time.

Troubleshooting

Issue Cause Fix
Upload rejected Image exceeds your vision provider’s size limit Compress or resize before sending.
Memory missing image data Low-quality or blurry image Retake the photo with better lighting.
Invalid format error Unsupported file type Convert to JPEG or PNG first.
Slow processing High-resolution images Downscale or compress to under 5 MB.
Base64 errors Incorrect prefix or encoding Ensure data:image/<type>;base64, is present and the string is valid.