semvec/pypi-packages huggingface dataset:
memryapi 1.0.0
Official Python SDK for MemryAPI — Memory-as-a-Service for AI Applications.
License: MIT
Requires Python: >=3.8
Keywords: agents, ai, llm, long-term-memory, memory, openai, rag

# MemryAPI Python SDK

The Sovereign Persistence Layer for AI Agents.

## Installation

```bash
pip install memryapi
```

## Quick Start

```python
from memryapi import MemryAPI

client = MemryAPI("your-api-key")

# Store a memory
client.remember("user-123", "Prefers dark chocolate over milk chocolate")

# Recall memories by semantic similarity
result = client.recall("user-123", "What chocolate do they like?")
print(result.results[0].content)
# → "Prefers dark chocolate over milk chocolate"
```

## Session Helper

Avoid repeating `user_id` on every call:

```python
session = client.session("user-123")

session.remember("Has a golden retriever named Max")
session.remember("Works remotely from Austin, TX")

memories = session.recall("pets")
summary = session.summarize()
```

## LLM Wrapper (Experimental)

Automatically inject memory context into your LLM calls:

```python
from openai import OpenAI

openai = OpenAI()

def ask(context: str) -> str:
    response = openai.chat.completions.create(
        model="gpt-4",
        messages=[
            {"role": "system", "content": f"User context:\n{context}"},
            {"role": "user", "content": "What should I get them for their birthday?"},
        ],
    )
    return response.choices[0].message.content

# Recalls memories, passes as context, saves the AI response
answer = client.wrap("user-123", ask, query="preferences interests")
```

## Context Manager

```python
with MemryAPI("your-api-key") as client:
    client.remember("user-123", "Some fact")
    result = client.recall("user-123", "query")
# HTTP client is automatically closed
```

## API Reference

| Method | Description |
|--------|-------------|
| `remember(user_id, text, metadata)` | Store a memory |
| `recall(user_id, query, top_k, threshold, time_weight)` | Semantic recall |
| `forget(memory_id)` | Delete a specific memory |
| `forget_all(user_id)` | Delete all user memories |
| `summarize(user_id, limit, save_as_memory)` | AI-powered summary |
| `session(user_id)` | Session-scoped client |
| `wrap(user_id, fn, query)` | Auto memory-augmented LLM calls |

## License

MIT