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",
    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...",
    salience=0.7,
)

Retrieve

result = ep.retrieve(
    user_id="user_123",
    project_id="my-app",
    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")

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.0.tar.gz (7.8 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.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: episodial-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 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.0.tar.gz
Algorithm Hash digest
SHA256 8c728509666d96d721e3e64aea731a0a944f742458ebeb03581b63fbeaf5ce86
MD5 5d8f7cd0c086f41771a2eff521e5c070
BLAKE2b-256 b916f0822601a603f98081c71f285fcf936ea5f53e27a523878ed8662facdb7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for episodial-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: episodial-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3188b0a46c5d55fbc8c71a024d2e94e4725535f1923edea89033d3bef8640a7
MD5 a7648cbe5b75195cd3e5a4de2662f75c
BLAKE2b-256 6ee05a4ca567052b1edb9ba50ad2065eddbcf24524cbdb78b7a2ce40f6978fdc

See more details on using hashes here.

Provenance

The following attestation bundles were made for episodial-0.1.0-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