This topic introduces Alibaba Cloud RDS Long-Term Memory, an enterprise-grade solution that provides AI applications with cross-session, personalized memory capabilities. It explains how to quickly integrate the service using the Alibaba Cloud RDS mem0ai SDK and includes a complete API reference for core operations such as creating, searching, and deleting memories.
Background
In the era of large language model (LLM)-driven AI applications, memory capability (AI Memory) is becoming a core factor in user experience and application value. Traditional AI applications are often stateless—each interaction is independent—and the model cannot remember user preferences, conversation history, or personalized needs. This approach leads to three key problems:
Lost context: Users must repeat their background and needs in every conversation.
Lack of personalization: AI cannot tailor responses based on long-term user behavior patterns.
High cost: To preserve context, applications must pass large volumes of historical dialogue, causing token consumption to surge.
Alibaba Cloud RDS Long-Term Memory is an enterprise-grade AI memory enhancement solution built on the open source project Mem0. It uses intelligent memory management to help AI applications retain context across sessions, adaptively learn over time, and intelligently store and retrieve relevant information—enabling you to build next-generation personalized AI applications with long-term memory.
Key Features
Benefits | Description |
Unified hybrid storage architecture | Deeply integrates with Alibaba Cloud RDS for PostgreSQL and leverages its rich extension ecosystem to enable unified “three-in-one” storage of vector, graph, and relational data. All memory data is managed within a single database instance, greatly simplifying the backend architecture of AI applications. |
Enterprise-grade vector search engine | Built-in high-performance pgvector extension delivers enterprise-grade vector storage and retrieval. Supports multiple indexing algorithms such as HNSW and IVFFlat, and distance metrics including cosine similarity and Euclidean distance. Enables seamless combination of vector search with SQL-based filtering for flexible, efficient hybrid queries. |
Native graph database capability | Integrates the Apache AGE (A Graph Extension) extension to give RDS for PostgreSQL full graph database functionality. Supports the Neo4j-compatible Cypher query language, automatically extracts entities and relationships from conversations to build knowledge graphs, and enables deeper memory association and inference—all with ACID transaction guarantees. |
Open source compatible, seamless integration | Built on the widely adopted open source AI memory layer project Mem0, this solution is fully compatible with its APIs and SDKs. Use simple interfaces to quickly add memory capabilities to existing applications or smoothly migrate your on-premises Mem0 applications to the cloud. |
Scenarios
Leveraging its powerful long-term memory and relationship reasoning capabilities, RDS Long-Term Memory is ideal for the following scenarios:
Personalized AI assistants: Remember user details (such as name and job), preferences (such as “likes spicy food”), and past instructions to deliver more thoughtful, intuitive interactions.
Multi-turn customer support: Maintain full context and historical solutions across long, cross-session support conversations—eliminating repetitive explanations and improving resolution efficiency.
Knowledge-intensive AI applications: In fields such as education, research, and legal consulting, help AI build and accumulate domain-specific knowledge graphs to enable intelligent, knowledge-based Q&A and inference.
Complex relationship analysis: In team collaboration and project management, record relationships between people and tasks (such as “Li Si is Zhang San’s mentor”) to support better decision-making.
Billing
The Long-Term Memory service itself currently has no compute resource fees. You only pay for:
Underlying resource fees: RDS for PostgreSQL instance fees.
Model invocation fees: Pay-as-you-go charges for calling the built-in LLM and embedding model APIs.
Its official billing start date will be announced separately.
Quick Start
Step 1: Create a Long-Term Memory instance
Log on to the RDS console and click Long-Term Memory in the navigation pane on the left.
On the instance list page, click Create Project.
Follow the on-screen prompts to select the Long-Term Memory type and complete the configuration.

After purchase, return to the console and wait until the instance status changes to Running.
Step 2: Get the endpoint and API key
Get the endpoint: On the Long-term memory list page, click the Project ID of your target instance to go to its product page. On the Basic Information tab, view the Outside the network connection address.
Endpoint: Use the Mem0 SDK or the official API endpoint to manage long-term memory.
Mem0 SDK Host: http://<public endpoint>/memory/.
Example: http://<public endpoint>/memory/v1/memories/.
Get API Key: On the Long-term memory list page, click the Project ID of your target instance to go to its product page. In the upper-right corner of the Basic Information tab, click Get API Key to obtain your ServiceKey.

Step 3: Network configuration
To ensure your service can be called properly, complete the following network settings.
Allow the instance to access the Internet
Go to the Basic Information page of your instance.
Click Network Information > Attach EIP.
Configure the whitelist
In the Basic Information section of the instance product page, find White list information .
Click Create Whitelist and add your client or test server IP address to the whitelist.
Step 4: Integrate the RDS Long-Term Memory SDK
Install the official SDK
pip3 install mem0aiSet environment variables
export MEM0_HOST="http://<YOUR-HOST>:80/memory" # Service endpoint
export MEM0_API_KEY="<your-api-key>" # API keyComplete SDK usage example
Vector-only storage (no graph)
Python example
Hybrid vector + graph storage (with graph)
Appendix: API Reference
API Index
Operation | Method | Endpoint |
Get all | POST |
|
Search | POST |
|
Add | POST |
|
Get single | GET |
|
Update | PUT |
|
Delete single | DELETE |
|
Delete all | DELETE |
|
Request headers
All API requests must include the following authentication header: Authorization: Token <your-api-key>.
Request examples
The following shows sample API calls.
Add memory
Store new memories. The service automatically analyzes the messages content to generate conversation summaries and semantic memories.
curl -X POST "http://<host>/memory/v1/memories/" \
-H "Authorization: Token <api-key>" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "My name is Zhang San. I work at Alibaba."}
],
"user_id": "user_001",
"agent_id": "my_agent",
"enable_graph": false
}'Search memories
Search for the most relevant memories based on a query string.
curl -X POST "http://<host>/memory/v2/memories/search/" \
-H "Authorization: Token <api-key>" \
-H "Content-Type: application/json" \
-d '{"query": "search content", "user_id": "user_001"}'Get all memories
Retrieve all raw memories within a specified scope.
curl -X POST "http://<host>/memory/v2/memories/" \
-H "Authorization: Token <api-key>" \
-H "Content-Type: application/json" \
-d '{"user_id": "user_001"}'Delete a single memory
Delete a specific memory by its ID.
curl -X DELETE "http://<host>/memory/v1/memories/<memory-id>/" \
-H "Authorization: Token <api-key>"
Get a single memory
curl -X GET "http://<host>/memory/v1/memories/<Memory_Id>/" \
-H "Authorization: Token <api-key>"Graph search (enable_graph=true)
curl -X POST "http://<host>/memory/v2/memories/search/" \
-H "Content-Type: application/json" \
-H "Authorization: Token <api-key>" \
-d '{
"query": "Zhang San's job",
"user_id": "user_001",
"enable_graph": true,
"limit": 10
}'Standard search (enable_graph=false or omitted)
curl -X POST "http://<host>/memory/v2/memories/search/" \
-H "Content-Type: application/json" \
-H "Authorization: Token <api-key>" \
-d '{
"query": "Where does Zhang San work?",
"user_id": "user_001",
"enable_graph": false,
"limit": 10
}'Get all memories (with graph)
curl -X POST "http://<host>/memory/v2/memories/" \
-H "Content-Type: application/json" \
-H "Authorization: Token <api-key>" \
-d '{
"user_id": "user_001",
"enable_graph": true
}'