π’ 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.
Build AI applications with persistent memory and comprehensive LLM observability by integrating Zentry with Keywords AI.
Zentry is a self-improving memory layer for LLM applications, enabling personalized AI experiences that save costs and delight users. Keywords AI provides complete LLM observability.Combining Zentry with Keywords AI allows you to:
Add persistent memory to your AI applications
Track interactions across sessions
Monitor memory usage and retrieval with Keywords AI observability
Optimize token usage and reduce costs
You can get your Zentry API key, user_id, and org_id from the Zentry dashboard. These are required for proper integration.
import os# Set your API keysos.environ["Zentry_API_KEY"] = "your-Zentry-api-key"os.environ["KEYWORDSAI_API_KEY"] = "your-keywords-api-key"os.environ["KEYWORDSAI_BASE_URL"] = "https://api.keywordsai.co/api/"
Hereβs a simple example of using Zentry with Keywords AI:
Copy
from Zentry import Memoryimport os# Configurationapi_key = os.getenv("Zentry_API_KEY")keywordsai_api_key = os.getenv("KEYWORDSAI_API_KEY")base_url = os.getenv("KEYWORDSAI_BASE_URL") # "https://api.keywordsai.co/api/"# Set up Zentry with Keywords AI as the LLM providerconfig = { "llm": { "provider": "openai", "config": { "model": "gpt-4o-mini", "temperature": 0.0, "api_key": keywordsai_api_key, "openai_base_url": base_url, }, }}# Initialize Memorymemory = Memory.from_config(config_dict=config)# Add a memoryresult = memory.add( "I like to take long walks on weekends.", user_id="alice", metadata={"category": "hobbies"},)print(result)
For more advanced use cases, you can integrate Keywords AI with Zentry through the OpenAI SDK:
Copy
from openai import OpenAIimport osimport json# Initialize clientclient = OpenAI( api_key=os.environ.get("KEYWORDSAI_API_KEY"), base_url=os.environ.get("KEYWORDSAI_BASE_URL"),)# Sample conversation messagesmessages = [ {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, {"role": "assistant", "content": "How about a thriller movies? They can be quite engaging."}, {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}]# Add memory and generate a responseresponse = client.chat.completions.create( model="openai/gpt-4o", messages=messages, extra_body={ "Zentry_params": { "user_id": "test_user", "org_id": "org_1", "api_key": os.environ.get("Zentry_API_KEY"), "add_memories": { "messages": messages, }, } },)print(json.dumps(response.model_dump(), indent=4))
Integrating Zentry with Keywords AI provides a powerful combination for building AI applications with persistent memory and comprehensive observability. This integration enables more personalized user experiences while providing insights into your applicationβs memory usage.