Skip to main content

Python SDK for the 9D Labs Memory Runtime API (v1 + v2)

Project description

nined-memory

Python SDK for the 9D Labs Memory Runtime API. Supports both v1 and v2 APIs.

Give any AI agent persistent, auditable memory with deterministic context retrieval.

Install

pip install nined-memory

Zero dependencies. Uses only Python standard library.

v1 API (MemoryClient)

from nined.memory import MemoryClient

client = MemoryClient(base_url="https://api.9dlabs.xyz", api_key="your-key")

# Ingest a document
client.ingest(
    workspace_id="ws-1",
    actor_id="agent-1",
    artifact_type="document",
    raw_payload={"title": "Runbook", "content": "If auth fails, restart the pod."},
)

# Retrieve context (deterministic, budget-enforced)
pack = client.context_pack(query="What should I do about auth?", workspace_id="ws-1")
print(pack["context_text"])
print(f"Confidence: {pack['confidence']}")

# Audit trail
receipt = client.get_receipt(pack["receipt_id"])

v1 methods

Method Description
ingest(workspace_id, actor_id, artifact_type, raw_payload, ...) Ingest a single artifact
context_pack(query, workspace_id, max_tokens, mode, ...) Retrieve context pack with rich tuning params
feedback(workspace_id, actor_id, action, ...) Submit correction (pin, private, mark_wrong, ...)
list_receipts(workspace_id, limit, offset) List decision receipts
get_receipt(receipt_id) Get a single receipt
artifact_status(artifact_id) Get indexing status
delete_workspace(workspace_id) Delete all workspace data
ask(query, workspace_id, max_tokens) LLM-synthesized answer
health() Service liveness check
register(email) Register tenant (multi-tenant mode)
regenerate_key(email) Regenerate API key
billing_usage() Current billing usage
billing_plan() Current plan & entitlements

v2 API (MemoryClientV2)

from nined.memory import MemoryClientV2

client = MemoryClientV2(
    base_url="https://api.9dlabs.xyz",
    api_key="your-key",
    workspace_id="my-workspace",
)

# Batch ingest
client.ingest([
    {"artifact_type": "document", "raw_payload": {"content": "Deploy runbook..."}},
    {"artifact_type": "note", "raw_payload": {"content": "Meeting notes..."}},
])

# Retrieve with serving profile
pack = client.context_pack("What happened?", profile="high_recall")
for snippet in pack["snippets"]:
    print(snippet["content"])

# Async ingest + job tracking
result = client.ingest([...], async_index=True)
status = client.job_status(result["queued_jobs"][0]["job_id"])

v2 methods

Method Description
ingest(artifacts, async_index=False) Batch ingest (sync or async)
context_pack(query, max_tokens, profile) Retrieve with serving profiles
feedback(action, artifact_id, ...) Submit correction
list_receipts(limit, offset) List receipts
get_receipt(pack_hash) Get receipt by pack hash
artifact_status(artifact_id) Indexing status
job_status(job_id) Async job status
ask(query, max_tokens, profile) LLM-synthesized answer
delete_workspace() Delete workspace
health() Liveness check
ready() Readiness + storage health

Serving profiles (v2)

Profile Use case
low_latency Fastest retrieval, fewer results
balanced Default — good recall with reasonable latency
high_recall Maximum evidence, higher latency

Error handling

from nined.memory import MemoryClient, PolicyDeniedError, RateLimitError

try:
    pack = client.context_pack(query="...", workspace_id="...")
except PolicyDeniedError as e:
    print(f"Denied: {e.detail}")
except RateLimitError:
    print("Slow down!")
Exception HTTP status When
AuthorizationError 401, 403 Missing/invalid API key
PolicyDeniedError 403 Policy violation
NotFoundError 404 Resource not found
RateLimitError 429 Rate limit exceeded
MemoryAPIError any Base class for all API errors

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

nined_memory-0.1.1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

nined_memory-0.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nined_memory-0.1.1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for nined_memory-0.1.1.tar.gz
Algorithm Hash digest
SHA256 eafe9948fd8e247a0909c49bf6d50639785a2d486c1e939001d85c0e32843b16
MD5 0700e9062ee2be245bef3d6aecebb40f
BLAKE2b-256 003a65e6042938f04e9c3f82bf106f6b61fde49a2a44498a747510648a309c6a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nined_memory-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for nined_memory-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce2562fc77edb6dd8f7a9d8ea6b740bf8c8356e4f10ed0cded26e03d3ee87156
MD5 90f9b01115f392d9df99b3f5e1cf67ca
BLAKE2b-256 8f1daba285f7016b0771e16c7afae2fdf907f90329d129b8ff82f35942256a2e

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