> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hystersis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> Python SDK reference for Hystersis

# Python SDK

Complete reference for the Hystersis Python SDK.

## Installation

```bash theme={null}
pip install hystersis
```

## Initialization

```python theme={null}
from hystersis import Hystersis

client = Hystersis(
    base_url="https://api.hystersis.com",
    api_key="your-key"
)
```

## Memories

### Create Memory

```python theme={null}
memory = client.create_memory(
    content="User prefers dark mode",
    user_id="user-123",
    category="preferences",
    metadata={"source": "settings"}
)
```

### Search Memories

```python theme={null}
results = client.search(
    query="display settings",
    limit=10,
    threshold=0.7
)
```

### Get Memory

```python theme={null}
memory = client.get_memory(memory_id)
```

### Update Memory

```python theme={null}
client.update_memory(
    memory_id="...",
    content="Updated content"
)
```

### Delete Memory

```python theme={null}
client.delete_memory(memory_id)
```

## Sessions

### Create Session

```python theme={null}
session = client.create_session(
    agent_id="assistant-bot"
)
```

### Add Message

```python theme={null}
client.add_message(
    session_id=session["id"],
    role="user",
    content="Hello!"
)
```

## Entities

### Create Entity

```python theme={null}
entity = client.create_entity(
    name="Machine Learning",
    entity_type="topic",
    properties={"category": "AI"}
)
```

## Feedback

```python theme={null}
client.add_feedback(
    memory_id="...",
    feedback_type="positive"
)
```

## Error Handling

```python theme={null}
from hystersis import Hystersis, AuthenticationError, NotFoundError

try:
    memory = client.get_memory("invalid-id")
except NotFoundError:
    print("Memory not found")
except AuthenticationError:
    print("Invalid API key")
```
