Skip to main content

SPM Python client

Client for SPM's evidence-gated memory: store observations, recall with a verdict, read the exact cited text, export, and subscribe to lifecycle events. The OpenAI-compatible Gateway methods remain available at the bottom.

Status: pre-release (0.2.0). The licence is proprietary (see the repository LICENSE); the package is safe to install and use, and the API below is versioned with /v2.

Install

pip install spm-client
# or, in this repository:
pip install -e sdk/python

Memory

from spm_client import SpmClient

with SpmClient("your-api-key", base_url="https://api.spmos.ai") as client:
    client.remember(
        "Acme 完成 A 轮融资 8000 万元",
        idempotency_key="acme-financing-2026-11",
        topic="financing",
        user_partition="ent-91330",
        source_timestamp="2026-11-30T00:00:00Z",
    )

    result = client.recall("Acme 最近融资多少", user_partition="ent-91330", topics=["financing"])
    if result["gate_reason"] == "passed":
        print(result["answer"])
        for ref in result["evidence_refs"]:
            print(ref["source_id"], ref["console_url"])
        print(client.read([r["read_token"] for r in result["evidence_refs"]])["spans"])
    else:
        print("no supporting memory:", result["gate_reason"])

gate_reason is passed or a refusal (no_candidate, no_semantic_support, superseded, …). Treat a refusal as information, not an error: it means no stored source supports the claim.

Conventions

  • idempotency_key (≥8 chars) makes a write safe to retry; the same key with a different payload is a conflict.
  • Re-observing the same source_id with changed content increments its version instead of creating a second source.
  • user_partition isolates an entity or end user; the key needs memory:partition for it.
  • Read tokens live ~300 seconds — call read soon after recall.
  • Limits: 12 000 chars per source, top_k ≤ 100, 500 items per batch, 32 read tokens per call.

Export and deletion

bundle = client.export(user_partition="ent-91330")      # checksummed
client.import_bundle(bundle, user_partition="ent-copy") # ids are re-tagged
client.purge(source_id="s1")                            # signed receipt
client.wipe_partition("ent-91330")                      # per-source receipts

Events

sub = client.subscribe("https://hooks.example/spm", ["source.accepted", "source.purged"])
# Deliveries carry X-SPM-Signature: t=<ts>,v1=<hmac-sha256 of "ts.body">
client.replay_events(since_id="evt_...")
client.unsubscribe(sub["id"])

Errors

from spm_client import AuthError, NotFoundError, QuotaError, ServerError, SpmError

try:
    client.recall("q")
except AuthError:
    ...
except QuotaError:
    ...
except ServerError as exc:
    print(exc.status_code, exc)

All errors carry the server's code when it sent one.

Gateway

SpmClient also speaks the OpenAI/Anthropic-compatible Gateway:

with SpmClient("your-api-key") as client:
    reply = client.session().send("Hello, remember my name is Alice.")
    print(reply)
Method Description
client.health() Gateway health
client.chat(messages, model=..., stream=...) Raw chat completion
client.session(system_prompt=...) Stateful ChatSession
client.list_receipts() Request receipts

API reference (memory)

Method Endpoint
remember(text, idempotency_key=..., …) POST /v2/ingest
remember_many(items) POST /v2/ingest/batch
recall(query, topics=..., since=..., until=..., …) POST /v2/recall
recall_text(query, …) recall + read joined
read(tokens) POST /v2/read
purge(source_id=...) POST /v2/purge
partitions() / export_partition(p) / wipe_partition(p) /v2/partitions…
export() / import_bundle(bundle) /v2/export, /v2/import
subscribe / subscriptions / unsubscribe / replay_events /v2/events…

Metadata

Release files for spm-client 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spm-client 0.2.0
File Size Uploaded Provenance Actions
spm_client-0.2.0.tar.gz 12.7 kB Without provenance Details for spm_client-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spm-client 0.2.0
File Interpreter ABI Platform Actions
spm_client-0.2.0-py3-none-any.whl Python 3 none any Details for spm_client-0.2.0-py3-none-any.whl

Total release size: 30.1 kB

Release files / spm_client-0.2.0.tar.gz

Download URL spm_client-0.2.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4f3a1a22d101174f37b6cdbcc71af2a4fdcb0c5a022a19d747c5bc89c2208157
BLAKE2b-256 checksum
How to use checksums
f0883db114c9ee7a8aa2a95a6debea7bc187e06e4ae5b3d4214e9411a7fd1280
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / spm_client-0.2.0-py3-none-any.whl

Download URL spm_client-0.2.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebf8a20612a23162ddcd75495bc2d3c7eeda9fbbd4773dfbb2ba5ef23cddc593
BLAKE2b-256 checksum
How to use checksums
30b1bc60b2d993e366913b06f96beb0a7db3c37db7e9948d156524ae6ab66a85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for spm-client 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page