Option A: LiteLLM callback(recommended). Two lines. Every LLM call automatically retrieves relevant memories and injects them. After each response the Q&A turn is stored automatically.
python
import litellm
from anona.integrations.litellm import AnonaMemory
mem = AnonaMemory(
api_key="anona_live_YOUR_KEY",
space_id="YOUR_SPACE_ID",
base_url="http://anona-prod-alb-747552680.us-east-1.elb.amazonaws.com",
)
mem.enable() # registers callback with litellm
# All subsequent calls auto-inject memories + auto-store responses
response = litellm.completion(
model="gemini/gemini-2.5-flash", # any litellm model
messages=[{"role": "user", "content": "What should I focus on today?"}],
)
print(response.choices[0].message.content)
Option B: Direct SDK. Full control: you decide what to store and when to recall.
python
from anona import AnonaClient
client = AnonaClient(
api_key="anona_live_YOUR_KEY",
base_url="http://anona-prod-alb-747552680.us-east-1.elb.amazonaws.com",
)
# Store a memory
client.add_memory(
space_id="YOUR_SPACE_ID",
content="User prefers concise Python answers.",
)
# Search memories (semantic)
results = client.search(
space_id="YOUR_SPACE_ID",
query="what does the user prefer?",
limit=5,
)
for r in results:
print(r["content"])
# Synthesise insights
summary = client.insights(
space_id="YOUR_SPACE_ID",
query="Summarise what you know about this user",
)
print(summary)
client.close()
4
Manual injection (any LLM / framework)
Not using LiteLLM? Retrieve memories and inject them yourself before calling any LLM.
python
from anona import AnonaClient
client = AnonaClient(api_key="anona_live_YOUR_KEY", base_url="http://anona-prod-alb-747552680.us-east-1.elb.amazonaws.com")
user_message = "What should I work on today?"
# 1. Retrieve relevant memories
memories = client.search(space_id="YOUR_SPACE_ID", query=user_message, limit=5)
memory_block = "\n".join(f"{i+1}. {r['content']}" for i, r in enumerate(memories))
# 2. Inject into messages
messages = []
if memory_block:
messages.append({
"role": "system",
"content": f"# Relevant Memories\n{memory_block}",
})
messages.append({"role": "user", "content": user_message})
# 3. Send to any LLM: OpenAI, Anthropic, Gemini, etc.
# response = your_llm_client.chat(messages)
# 4. Store the exchange
# client.add_memory(space_id="YOUR_SPACE_ID", content=f"User: {user_message}\nAssistant: {response}")