Skip to main content

POST /memory/add

Add new memories from a conversation. Mem0 automatically extracts and stores relevant facts from the messages. The API can automatically classify the memory type using LLM-based classification.

Request Body

array
required
Array of message objects representing the conversation.
string
required
Unique identifier for the user. All memories are associated with this user ID.
object
Optional metadata to attach to the memory. You can include custom fields like tags, timestamps, or manually specify memory_type.
boolean
default:"true"
Enable automatic memory type classification. When enabled, the API uses GPT-4.1-nano to classify the memory into one of five types: LONG_TERM, SHORT_TERM, EPISODIC, SEMANTIC, or PROCEDURAL.

Response

boolean
Indicates whether the operation was successful.
object
The result from mem0 containing memory IDs and extracted information.
string
The automatically classified memory type (LONG_TERM, SHORT_TERM, EPISODIC, SEMANTIC, or PROCEDURAL). Only present if auto_classify is enabled.

Example Request

Example Response

Manual Memory Type Override

You can manually specify the memory type by including it in the metadata:

Error Responses

string
Error message describing what went wrong.
500 Internal Server Error

Implementation Details

  • Source: backend/main.py:189
  • Classification Model: GPT-4.1-nano-2025-04-14
  • Default Classification: LONG_TERM (used as fallback on classification errors)
  • Memory Extraction: Powered by mem0, which intelligently extracts facts from conversations