Note: Theopenai
provider is set as default. Consider usingMEM0_API_KEY
andOPENAI_API_KEY
as environment variables for security.
Note: Themem0Config
is optional. It is used to set the global config for the Mem0 Client (eg.user_id
,agent_id
,app_id
,run_id
,org_id
,project_id
etc).
For standalone features, such asaddMemories
,retrieveMemories
, andgetMemories
, you must either setMEM0_API_KEY
as an environment variable or pass it directly in the function call.
getMemories
will return raw memories in the form of an array of objects, whileretrieveMemories
will return a response in string format with a system prompt ingested with the retrieved memories.
getMemories
is an object with two keys:results
andrelations
ifenable_graph
is enabled. Otherwise, it will return an array of objects.
streamText
as well.
enable_graph
to true
in the mem0Config
object.
enable_graph
in the standalone functions. This includes getMemories
, retrieveMemories
, and addMemories
.
getMemories
function will return an object with two keys: results
and relations
, if enable_graph
is set to true
. Otherwise, it will return an array of objects.
Provider | Configuration Value |
---|---|
OpenAI | openai |
Anthropic | anthropic |
Gemini | gemini |
Mistral | mistral |
Groq | groq |
Note: You can use@ai-sdk/google
package.
createMem0()
: Initializes a new Mem0 provider instance.retrieveMemories()
: Retrieves memory context for prompts.getMemories()
: Get memories from your profile in array format.addMemories()
: Adds user memories to enhance contextual responses.user_id
for consistent memory retrieval.
Note: We also have support foragent_id
,app_id
, andrun_id
. Refer Docs.