Skip to main content

Memory-as-a-service SDK — add persistent user memory to any LLM app in 5 lines

Project description

palimo

Add persistent user memory to any LLM app in 5 lines. Zero ML dependencies on the client side.

Palimo is a memory-as-a-service that runs a fine-tuned memory LLM on your infrastructure. The SDK is a thin HTTP client — your app sends conversation turns, Palimo extracts and maintains memories, and returns packed context strings you inject into your system prompt.

Install

pip install palimo

Quick Start

from palimo import MemoryClient

mem = MemoryClient(url="http://localhost:8000", api_key="ik_live_...", user_id="user-123")

# Before calling your LLM — get memory context
context = mem.enrich("What's my dog's name?")

# After your LLM responds — commit the turn for memory processing
mem.commit("What's my dog's name?", "Your dog's name is Max!")

That's it. enrich returns a context string you prepend to your system prompt. commit queues the turn for background memory extraction.

Usage with OpenAI

from openai import OpenAI
from palimo import MemoryClient

client = OpenAI()
mem = MemoryClient(url="http://localhost:8000", api_key="ik_live_...", user_id="user-123")

def chat(user_message, history=None):
    # 1. Get memory context
    context = mem.enrich(user_message, history)

    # 2. Build messages with memory injected
    messages = []
    if context:
        messages.append({"role": "system", "content": context})
    messages.append({"role": "system", "content": "You are a helpful assistant."})
    if history:
        messages.extend(history)
    messages.append({"role": "user", "content": user_message})

    # 3. Call OpenAI
    response = client.chat.completions.create(
        model="gpt-5.3",
        messages=messages,
    ).choices[0].message.content

    # 4. Commit turn for memory extraction
    mem.commit(user_message, response, history)

    return response

Usage with Anthropic

import anthropic
from palimo import MemoryClient

client = anthropic.Anthropic()
mem = MemoryClient(url="http://localhost:8000", api_key="ik_live_...", user_id="user-123")

def chat(user_message, history=None):
    context = mem.enrich(user_message, history)

    system = "You are a helpful assistant."
    if context:
        system = context + "\n\n" + system

    messages = []
    if history:
        messages.extend(history)
    messages.append({"role": "user", "content": user_message})

    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=1024,
        system=system,
        messages=messages,
    ).content[0].text

    mem.commit(user_message, response, history)
    return response

Usage with Local LLMs (Ollama, vLLM, llama.cpp)

Any OpenAI-compatible server works:

from openai import OpenAI
from palimo import MemoryClient

# Point at your local server
client = OpenAI(base_url="http://localhost:11434/v1", api_key="unused")
mem = MemoryClient(url="http://localhost:8000", api_key="ik_live_...", user_id="user-123")

def chat(user_message, history=None):
    context = mem.enrich(user_message, history)

    messages = []
    if context:
        messages.append({"role": "system", "content": context})
    if history:
        messages.extend(history)
    messages.append({"role": "user", "content": user_message})

    response = client.chat.completions.create(
        model="llama3",
        messages=messages,
    ).choices[0].message.content

    mem.commit(user_message, response, history)
    return response

One-Shot Convenience

If you don't need fine-grained control, chat() wraps enrich + LLM + commit:

from palimo import MemoryClient

mem = MemoryClient(url="http://localhost:8000", api_key="ik_live_...", user_id="user-123")

response = mem.chat(
    messages=[{"role": "user", "content": "I just moved to Berlin"}],
    llm_fn=your_llm_function,  # (messages) -> str
)

API Reference

MemoryClient(url, api_key, user_id)

Param Description
url Base URL of your Palimo instance
api_key API key (ik_live_...)
user_id User identifier, scoped to your customer account

client.enrich(message, history=None) -> str

Returns a memory context string to inject into your system prompt. Returns empty string if no memories exist yet.

client.commit(message, assistant_response, history=None) -> str

Queues a conversation turn for memory extraction. Returns a turn_id. Processing happens asynchronously — memories are available on the next enrich call.

client.chat(messages, llm_fn) -> str

Convenience method: enrich -> call your LLM -> commit, in one call. llm_fn is a callable that takes a list of message dicts and returns the assistant's response string.

How It Works

  1. enrich retrieves relevant memories via embedding similarity, packs them into a token-budgeted context string (max 2048 tokens), and returns it
  2. You inject that context into your LLM call however you want
  3. commit sends the turn to a background queue where a fine-tuned archivist LLM extracts durable facts (INSERT, UPDATE, SUPERSEDE, DELETE, etc.) into per-user storage
  4. Next time you call enrich, the new memories are included

The memory LLM runs on your infrastructure. No data leaves your servers. No per-call API costs for memory extraction.

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

palimo-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

palimo-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: palimo-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for palimo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 10f1e09133efa1486ae3aafa472e7f11e37f5fc5ea2cba47e18a48d929a5a986
MD5 ec07e047e97e645cceae91b3c15d66ae
BLAKE2b-256 cc87368b40ab5a9f3b61c0207f19396c63910542d575a4a7ba5b3d26d4291fce

See more details on using hashes here.

File details

Details for the file palimo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: palimo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for palimo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 536409cb1f02f171f3d45f51b89e958b7034be56bdab3f363cefcc4c2eb469f6
MD5 6a28f6d97f175c1dc7f91e9fea4e7847
BLAKE2b-256 008e24e45d5a6362d2a2fafa3c31295af8b455df6ce3235720aa6b08f6dc8c98

See more details on using hashes here.

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