Guide
Get started with Zentry Platform in minutes
📢 Announcing our research paper: Zentry achieves 26% higher accuracy than OpenAI Memory, 91% lower latency, and 90% token savings! Read the paper to learn how we're revolutionizing AI agent memory.
🎉 Looking for TypeScript support? Zentry has you covered! Check out an example here.
1. Installation
2. API Key Setup
- Sign in to Zentry Platform
- Copy your API Key from the dashboard
3. Instantiate Client
3.1 Instantiate Async Client (Python only)
For asynchronous operations in Python, you can use the AsyncMemoryClient:
4. Memory Operations
Zentry provides a simple and customizable interface for performing CRUD operations on memory.
4.1 Create Memories
Long-term memory for a user
These memory instances persist across multiple sessions. Ideal for maintaining memory over long time spans.
When passing user_id
, memories are primarily created based on user messages, but may be influenced by assistant messages for contextual understanding. For example, in a conversation about food preferences, both the user’s stated preferences and their responses to the assistant’s questions would form user memories. Similarly, when using agent_id
, assistant messages are prioritized, but user messages might influence the agent’s memories based on context. This approach ensures comprehensive memory creation while maintaining appropriate attribution to either users or agents.
Example:
Short-term memory for a user session
These memory instances persist only for the duration of a user session. Ideal for non-repetitive interactions and managing context windows efficiently.
Long-term memory for agents
Add a memory layer for the assistants and agents so that their responses remain consistent across sessions.
The agent_id
retains memories exclusively based on messages generated by the assistant or those explicitly provided as input to the assistant. Messages outside these criteria are not stored as memory.
Long-term memory for both users and agents
When you provide both user_id
and agent_id
, Zentry will store memories for both identifiers separately:
- Memories from messages with
"role": "user"
are automatically tagged with the provideduser_id
- Memories from messages with
"role": "assistant"
are automatically tagged with the providedagent_id
- During retrieval, you can provide either
user_id
oragent_id
to access the respective memories - You can continuously enrich existing memory collections by adding new memories to the same
user_id
oragent_id
in subsequent API calls, either together or separately, allowing for progressive memory building over time - This dual-tagging approach enables personalized experiences for both users and AI agents in your application
Monitor Memories
You can monitor memory operations on the platform dashboard:
4.2 Search Memories
General Memory Search
Pass user messages, interactions, and queries into our search method to retrieve relevant memories.
search
method supports two output formats: v1.0
(default) and v1.1
. To use the latest format, which provides more detailed information about each memory operation, set the output_format
parameter to v1.1
: Use category and metadata filters:
Search using custom filters
Our advanced search allows you to set custom search filters. You can filter by user_id, agent_id, app_id, run_id, created_at, updated_at, categories, and text. The filters support logical operators (AND, OR) and comparison operators (in, gte, lte, gt, lt, ne, contains, icontains). For more details, see V2 Search Memories.
Here you need to define version
as v2
in the search method.
Example 1: Search using user_id and agent_id filters
Example 2: Search using date filters
Example 3: Search using metadata and categories Filters
Example 4: Search using NOT filters
4.3 Get All Users
Get all users, agents, and runs which have memories associated with them.
4.4 Get All Memories
Fetch all memories for a user, agent, or run using the getAll() method.
get_all
method supports two output formats: v1.0
(default) and v1.1
. To use the latest format, which provides more detailed information about each memory operation, set the output_format
parameter to v1.1
: page
and page_size
parameters. The following examples showcase the paginated output format.
Get all memories of a user
Get all memories of an AI Agent
Get the short-term memories for a session
Get specific memory
Get all memories by categories
You can filter memories by their categories when using get_all:
Get all memories using custom filters
Our advanced retrieval allows you to set custom filters when fetching memories. You can filter by user_id, agent_id, app_id, run_id, created_at, updated_at, categories, and keywords. The filters support logical operators (AND, OR) and comparison operators (in, gte, lte, gt, lt, ne, contains, icontains). For more details, see v2 Get Memories.
Here you need to define version
as v2
in the get_all method.
Example 1. Get all memories using user_id and date filters
Example 2: Search using metadata and categories Filters
Example 3: Get all memories using NOT filters
4.5 Memory History
Get history of how a memory has changed over time.
4.6 Update Memory
Update a memory with new data.
4.7 Delete Memory
Delete specific memory.
Delete all memories of a user.
Delete all users.
Delete specific user or agent or app or run.
4.8 Reset Client
Fun fact: You can also delete the memory using the add()
method by passing a natural language command:
4.9 Batch Update Memories
Update multiple memories in a single API call. You can update up to 1000 memories at once.
4.10 Batch Delete Memories
Delete multiple memories in a single API call. You can delete up to 1000 memories at once.
4.11 Working with Zentry in TypeScript
Manage memories using TypeScript with Zentry. Zentry has completet TypeScript support Below is an example demonstrating how to add and search memories.
If you have any questions, please feel free to reach out to us using one of the following methods: