Memory
The platform includes semantic memory powered by Mem0, allowing conversations to remember information across sessions. Memories are per-user and can be searched, managed, and automatically injected into conversation context.
How Memory Works
Memories are facts, preferences, and context extracted from conversations and stored in a vector database. When a new message is sent, relevant memories can be retrieved and included in the LLM's context, giving the AI long-term recall.
Searching Memories
Search across a user's memories using natural language. Results are ranked by semantic similarity.
curl -X POST https://api.yocaso.dev/api/v1/llm/gateway/search-memories \
-H "X-API-Key: sk_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"query": "dietary preferences"
}'
Response:
{
"memories": [
{
"id": "mem_abc123",
"memory": "User is vegetarian and avoids gluten",
"score": 0.92,
"created_at": "2025-02-15T10:00:00Z",
"updated_at": "2025-02-15T10:00:00Z"
},
{
"id": "mem_def456",
"memory": "User prefers meals under 500 calories",
"score": 0.85,
"created_at": "2025-02-20T14:30:00Z",
"updated_at": "2025-02-20T14:30:00Z"
}
]
}
Listing Memories
List all memories for the authenticated user (paginated):
curl -X POST https://api.yocaso.dev/api/v1/llm/gateway/list-memories \
-H "X-API-Key: sk_your_key_here" \
-H "Content-Type: application/json" \
-d '{}'
Getting a Specific Memory
curl -X POST https://api.yocaso.dev/api/v1/llm/gateway/get-memory \
-H "X-API-Key: sk_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"memory_id": "mem_abc123"
}'
Updating a Memory
Correct or refine an existing memory:
curl -X POST https://api.yocaso.dev/api/v1/llm/gateway/update-memory \
-H "X-API-Key: sk_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"memory_id": "mem_abc123",
"memory": "User is vegetarian, avoids gluten, and prefers organic produce"
}'
Deleting Memories
Delete a Single Memory
curl -X POST https://api.yocaso.dev/api/v1/llm/gateway/delete-memory \
-H "X-API-Key: sk_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"memory_id": "mem_abc123"
}'
Delete All Memories
This permanently deletes all memories for the user. This action cannot be undone.
curl -X POST https://api.yocaso.dev/api/v1/llm/gateway/delete-all-memories \
-H "X-API-Key: sk_your_key_here" \
-H "Content-Type: application/json" \
-d '{}'
Memory Timestamp Injection
When memories are injected into conversation context, each memory can include a timestamp annotation showing when it was remembered (and optionally when it was last updated). This helps the LLM understand the recency and relevance of each memory.
Example context block:
[Relevant memories about this user:]
- User is vegetarian and avoids gluten (remembered: Feb 15, 2025 at 10:00 AM UTC)
- User prefers meals under 500 calories (remembered: Feb 20, 2025 at 2:30 PM UTC, updated: Mar 1, 2025 at 9:00 AM UTC)
Timestamp injection is enabled by default. To disable it, set inject_memory_timestamps to false in the Mem0 configuration:
{
"mem0_config": {
"enabled": true,
"inject_memory_timestamps": false
}
}
| Field | Type | Default | Description |
|---|---|---|---|
inject_memory_timestamps | bool | true | Include (remembered: <date>) annotations on injected memories. Adds (updated: <date>) if the memory was modified after creation. |
Memory and Conversations
Memories integrate with conversations in two ways:
-
Automatic retrieval — When a message is sent, the platform can search for relevant memories and include them in the LLM's context, giving it awareness of past interactions.
-
MCP tool access — Memory operations are exposed as MCP tools, allowing the LLM to search, create, and update memories during a conversation.
User Impersonation
When using API keys with the users:impersonate scope, memory operations act on the impersonated user's memories:
curl -X POST https://api.yocaso.dev/api/v1/llm/gateway/search-memories \
-H "X-API-Key: sk_your_key_here" \
-H "X-On-Behalf-Of: user_123" \
-H "Content-Type: application/json" \
-d '{
"query": "exercise habits"
}'
Related
- Conversations Guide — How memories integrate with conversations
- MCP Tools Guide — Memory as MCP tools
- LLM Gateway API Reference — Full endpoint reference