Skip to main content

Python SDK for the Episodial cognitive memory API

Project description

episodial

Python SDK for the Episodial cognitive memory API. Includes both synchronous and async clients.

Install

pip install episodial

Quick Start

from episodial import Episodial

ep = Episodial(
    base_url="https://api.episodial.ai",
    api_key="ep_live_...",
    project_id="my-app",
)

# Store a memory
ep.remember(
    user_id="user_123",
    user_message="How do I reset my password?",
    assistant_message="Go to Settings > Security > Reset password.",
)

# Recall relevant memories
result = ep.recall("user_123", "password help")
for mem in result.memories:
    print(mem.content, mem.salience)

Async Client

import asyncio
from episodial import AsyncEpisodial

async def main():
    async with AsyncEpisodial(
        base_url="https://api.episodial.ai",
        api_key="ep_live_...",
    ) as ep:
        result = await ep.recall("user_123", "password help")
        print(result.memories)

asyncio.run(main())

Configuration

ep = Episodial(
    base_url="http://localhost:8000",  # Memory Core URL
    api_key="ep_live_...",             # API key (optional in dev)
    organization_id="org_...",         # For billing endpoints
    project_id="default",             # Default project for all calls
    timeout=30.0,                     # Request timeout in seconds
)

Memory Operations

Ingest

ep.ingest(
    user_id="user_123",
    project_id="my-app",
    chat_id="conv_1",        # optional — scope to a conversation
    event_type="llm_interaction",
    payload={
        "user_message": "What is Kubernetes?",
        "assistant_message": "Kubernetes is a container orchestration platform...",
    },
    initial_salience=0.7,
)

Or use the convenience method:

ep.remember(
    user_id="user_123",
    user_message="What is Kubernetes?",
    assistant_message="Kubernetes is a container orchestration platform...",
    chat_id="conv_1",        # optional — scope to a conversation
    salience=0.7,
)

Retrieve

result = ep.retrieve(
    user_id="user_123",
    project_id="my-app",
    chat_id="conv_1",        # optional — filter by conversation
    task_goal="Help user with deployment",
    token_budget=2000,
)

for memory in result.memories:
    print(memory.content, memory.memory_type, memory.salience)

Or use the shorthand:

result = ep.recall("user_123", "deployment help", chat_id="conv_1")

Conversation Scoping

Use chat_id to isolate memories per conversation. Omit it (or pass None) for cross-conversation global memories.

# Retrieve memories from this chat + global memories (default)
result = ep.retrieve(
    user_id="user_123",
    project_id="my-app",
    chat_id="conv_1",
    include_global=True,
    task_goal="deployment help",
)

# Only memories from this specific chat
result = ep.retrieve(
    user_id="user_123",
    project_id="my-app",
    chat_id="conv_1",
    chat_only=True,
    task_goal="deployment help",
)

# All memories for the user (no chat filter)
result = ep.retrieve(
    user_id="user_123",
    project_id="my-app",
    task_goal="deployment help",
)

Feedback

ep.helpful("memory_id_123")    # positive feedback
ep.unhelpful("memory_id_456")  # negative feedback

# Fine-grained control
ep.feedback(
    memory_id="memory_id_123",
    feedback_type="success",
    value=0.8,
    context="User confirmed this solved their issue",
)

Forget

# Forget specific memories
ep.forget(
    memory_ids=["mem_1", "mem_2"],
    reason="User requested data deletion",
)

# Forget all memories for a user
ep.forget(
    user_id="user_123",
    project_id="my-app",
    reason="Account deletion",
)

Consolidation

ep.consolidate("user_123", "my-app")

Procedural Learning

ep.mine_procedures("user_123", "my-app")

result = ep.match_procedures(
    "user_123",
    "user wants to deploy to production",
)
for proc in result.procedures:
    print(proc.readable, proc.confidence)

Billing

balance = ep.get_balance()
print(f"${balance.balance_dollars} remaining")

pricing = ep.get_pricing()

ep.topup("growth")  # $50 + 20% bonus

Error Handling

from episodial import Episodial, EpisodialError, InsufficientBalanceError

try:
    ep.recall("user_123", "hello")
except InsufficientBalanceError:
    print("Balance too low — top up!")
except EpisodialError as e:
    print(f"API error {e.status}: {e}")

Context Manager

Both clients support context managers for automatic cleanup:

with Episodial(api_key="ep_live_...") as ep:
    ep.remember(
        user_id="u1",
        user_message="hi",
        assistant_message="hello!",
    )
# httpx client closed automatically

async with AsyncEpisodial(api_key="ep_live_...") as ep:
    await ep.remember(
        user_id="u1",
        user_message="hi",
        assistant_message="hello!",
    )

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

episodial-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

episodial-0.1.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file episodial-0.1.1.tar.gz.

File metadata

  • Download URL: episodial-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for episodial-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fbec3ca57565b6d0f677eaf5f6fae6705293f5dea1c15aec72844ada43f54b62
MD5 a91657f51331e565e996cbe84be8dc95
BLAKE2b-256 c1ec752b7ff387b3c6e93a362eeabcc257c946a8d75c5a4d9fbc2df0608e360f

See more details on using hashes here.

Provenance

The following attestation bundles were made for episodial-0.1.1.tar.gz:

Publisher: publish-sdk-python.yml on mvpmule/episodial

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file episodial-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: episodial-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for episodial-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b8bbf8b07c7786ced8fb9e84e5cfc17a477072be5a46c8f4096a9a7a5606be5
MD5 c4b00292d176fb61fc9ce42fda3661d2
BLAKE2b-256 4c12a9f37fdf060ee2a943d8d6d5e3e34e52e0a70341a9ab9b3fc002bd353a9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for episodial-0.1.1-py3-none-any.whl:

Publisher: publish-sdk-python.yml on mvpmule/episodial

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page