Skip to main content

Python SDK for the Portable AI Memory (PAM) interchange format

Project description

Portable AI Memory (PAM) — Python SDK

A Python SDK for the Portable AI Memory (PAM) interchange format — a universal way to store, validate, and convert AI user memories across providers.

What is PAM?

AI assistants learn about you over time — your preferences, facts about your life, project context. But these memories are locked inside each provider. If you switch from ChatGPT to Claude, or use both, your context doesn't follow you.

PAM solves this with an open interchange format. It defines three document types:

  • MemoryStore — your memories (preferences, facts, context) with integrity checksums and semantic relations
  • Conversation — full chat history with messages, tool calls, citations, and attachments
  • EmbeddingsFile — vector embeddings linked to memories for semantic search

This SDK lets you:

  1. Convert exports from ChatGPT, Claude, Gemini, Grok, and Copilot into PAM format
  2. Validate PAM documents with deep integrity checks (cross-references, temporal ordering, content hashes)
  3. Build PAM documents programmatically with type-safe Pydantic models

Installation

pip install portable-ai-memory        # core SDK (models, I/O, validation, converters)
pip install 'portable-ai-memory[cli]' # + CLI tool: typer, rich (pam command)
pip install 'portable-ai-memory[dev]' # + dev tools: pytest, ruff, mypy
pip install 'portable-ai-memory[all]' # cli + dev combined

Quick Start

Load and validate a PAM file

from portable_ai_memory import load, validate_memory_store

store = load("memory-store.json")
result = validate_memory_store(store)

if result.is_valid:
    print(f"Valid — {len(store.memories)} memories")
else:
    for issue in result.errors:
        print(issue)

Convert a provider export

import json
from pathlib import Path

from portable_ai_memory.converters import detect_provider
from portable_ai_memory import ProviderNotDetectedError

try:
    converter = detect_provider("conversations.json")
    data = json.loads(Path("conversations.json").read_text())
    conversations = converter.convert_conversations(
        data, owner_id="user-123",
    )
except ProviderNotDetectedError as e:
    print(f"Unknown format: {e}")

Build a memory store from scratch

from portable_ai_memory import MemoryStore, MemoryObject, Owner, save

# MemoryObject.create() auto-fills content_hash, temporal, provenance
store = MemoryStore(
    schema_version="1.0",
    owner=Owner(id="user-123"),
    memories=[
        MemoryObject.create(
            id="mem-001",
            type="preference",
            content="User prefers dark mode.",
            platform="my-app",
        )
    ],
)
save(store, "memory-store.json")

# Convenience lookups
mem = store.get_memory_by_id("mem-001")
prefs = store.get_memories_by_type("preference")

CLI

# Validate a PAM file or bundle directory
pam validate memory-store.json
pam validate ./my-pam-bundle/

# Convert a provider export to a PAM bundle
pam convert ~/chatgpt-export/ -o ./pam-bundle/ --owner-id user-123

# Inspect a PAM file
pam inspect memory-store.json

Supported Providers

Provider Format
OpenAI (ChatGPT) conversations.json
Anthropic (Claude) conversations.json + memories.json
Google (Gemini) Takeout JSON or HTML
xAI (Grok) prod-grok-backend.json
Microsoft (Copilot) CSV exports

To list registered converters programmatically:

from portable_ai_memory.converters import list_converters

print(list_converters())  # ['chatgpt', 'claude', 'gemini', 'grok', 'copilot']

Development

git clone --recurse-submodules git@github.com:portable-ai-memory/python-sdk.git
cd python-sdk
uv sync --all-extras
uv run pytest

Note: The PAM JSON Schemas live in the main portable-ai-memory repo and are included here as a git submodule under vendor/portable-ai-memory. If you cloned without --recurse-submodules, run: git submodule update --init --recursive

Links

License

Apache License 2.0

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

portable_ai_memory-1.0.0.tar.gz (88.8 kB view details)

Uploaded Source

Built Distribution

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

portable_ai_memory-1.0.0-py3-none-any.whl (72.6 kB view details)

Uploaded Python 3

File details

Details for the file portable_ai_memory-1.0.0.tar.gz.

File metadata

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

File hashes

Hashes for portable_ai_memory-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a98abfdf11ee4a09f581da98ec1e34b5fce22c1b149a1e0e573b8ec1f7376dfa
MD5 9fa598d5eff5af8566e6a5b034df6963
BLAKE2b-256 edb9b14e8812f999587b61b79a638ff5d1b093c4f12e00207768aa8430984eb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for portable_ai_memory-1.0.0.tar.gz:

Publisher: release-please.yml on portable-ai-memory/python-sdk

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

File details

Details for the file portable_ai_memory-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for portable_ai_memory-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dbdb1cb4235f59943aa15b69603b962f39cabd5d40bcc196f0f885c9e4071f19
MD5 fb8f7ab98d848dbf989b333d6568ca08
BLAKE2b-256 cbc9b17d9de62fd6c6aeecdcd3350cf1d3ce136e790f1a8ff16e368c129ef8b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for portable_ai_memory-1.0.0-py3-none-any.whl:

Publisher: release-please.yml on portable-ai-memory/python-sdk

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