Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Spector Python Client SDK (spector-client)

Lightweight, zero-dependency Python client for the Spector Cognitive Memory & Vector Search platform.

spector-client is generated from OpenAPI 3.1 with an ergonomic handwritten facade providing 1-to-1 cognitive verb parity (remember, recall, forget, inspect, reinforce) and real-time Server-Sent Events (SSE) streaming.

Highlights

  • Zero Mandatory Dependencies: Built entirely on the Python standard library (urllib.request, asyncio, json, dataclasses).
  • Zero Java Prerequisite for REST: Connects directly to Spector Synapse over HTTP REST on port :7070 with no JVM or incubator flags required.
  • Sync & Async (asyncio): Dual clients (SpectorClient and AsyncSpectorClient) with identical cognitive signatures.
  • Real-Time Streaming: Stream live cognitive consolidation events, Hebbian graph co-activations, and recall telemetry over Server-Sent Events (SSE).
  • Multi-Transport Support: Connect via HTTP REST (default), remote MCP over HTTP/SSE, or local standalone spector.jar subprocess.

Installation

# Install via pip
pip install spector-client

# Or install locally for development
cd sdks/python
pip install -e ".[dev]"

Quick Start (Synchronous)

from spector_client import SpectorClient, MemoryTier

# Connect to running Spector Synapse instance (default: http://localhost:7070)
client = SpectorClient.builder() \
    .with_rest(base_url="http://localhost:7070", api_key="optional-api-key") \
    .build()

# 1. Remember — Store with cognitive metadata
client.memory.remember(
    text="User prefers concise answers and dark mode UI",
    tier=MemoryTier.SEMANTIC,
    tags=["preferences", "ui"],
    interest=0.9,
    valence=1,
)

# 2. Recall — Retrieve using multi-tier associative cognitive scoring
results = client.memory.recall("user preferences", top_k=5)
for record in results:
    print(f"[{record.id}] score={record.score:.4f} | {record.text}")

# 3. Stream Events — Real-time Server-Sent Events (SSE)
for event in client.events.stream(topics=["memory", "cortex"]):
    print(f"📡 Real-time event: {event.event} -> {event.data}")

Quick Start (Asynchronous asyncio)

import asyncio
from spector_client import AsyncSpectorClient, MemoryTier

async def main():
    async with AsyncSpectorClient.builder().with_rest("http://localhost:7070").build() as client:
        # Asynchronously remember
        await client.memory.remember(
            "Working memory context for active task",
            tier=MemoryTier.WORKING,
            tags=["task-42"]
        )

        # Asynchronously recall
        memories = await client.memory.recall("active task context")
        for mem in memories:
            print(mem.text)

        # Asynchronously stream events
        async for event in client.events.stream(topics=["memory"]):
            print(f"Stream: {event.event}")

asyncio.run(main())

Multi-Transport Modes

1. High-Throughput REST (Default)

client = SpectorClient.builder() \
    .with_rest(base_url="http://localhost:7070", api_key="secret-key") \
    .build()

2. Standalone Subprocess (spector.jar)

from spector_client.transports import StdioTransport

transport = StdioTransport(
    jar_path="/path/to/spector.jar",
    config_path="/path/to/spector.yml",
    java_bin="java"
)
transport.start()
client = SpectorClient(transport=transport)

Cognitive Verbs API Reference

Verb Signature Description
remember() (text, tier, tags, interest, urgency, challenge, valence, arousal) Asynchronously store memory with cognitive tier hints.
store() (text, tags) Synchronous store returning assigned memory ID.
recall() (query, top_k, profile, min_salience, tags) Retrieve memories via fused cognitive scoring.
search() (query, top_k) Pure dense vector semantic similarity search.
get() / find() (id) Retrieve full memory record by ID.
forget() (id, reason) Tombstone memory.
reinforce() (id, valence) Hebbian Long-Term Potentiation (LTP).
suppress() / unsuppress() (id, reason) Active recall inhibition / habituation.
resolve() / unresolve() (id) Zeigarnik closure.
status() () Real-time memory tier counts and index health.
browse() (tags) Fast inverted tag index lookup.
table() (page, page_size, tier) Paginated database records.
vector() (id) INT8 quantized embedding vector retrieval.
consolidate() () Trigger circadian sleep consolidation sweep.
vacuum() (tier) Trigger vacuum compaction.

Development & Testing

cd sdks/python
python -m unittest discover -s tests -t .
# Or if package is installed in editable mode:
# pip install -e ".[dev]" && pytest

License

Apache License, Version 2.0 — see LICENSE for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spector_client-0.1.0a0.tar.gz (125.8 kB view details)

Uploaded Source

Built Distribution

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

spector_client-0.1.0a0-py3-none-any.whl (315.1 kB view details)

Uploaded Python 3

File details

Details for the file spector_client-0.1.0a0.tar.gz.

File metadata

  • Download URL: spector_client-0.1.0a0.tar.gz
  • Upload date:
  • Size: 125.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for spector_client-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 45e1c6b36b2f16b15204fcadfdcdc2e43b70f73467c0461d9dfd52fe7db3d6e4
MD5 ae7c3482d066c5a16f62d5ddb4240de5
BLAKE2b-256 5561955fd40a88254b7751e870d96ad98f9fd6d09a334b03fd1fd9f6844a4e35

See more details on using hashes here.

Provenance

The following attestation bundles were made for spector_client-0.1.0a0.tar.gz:

Publisher: release-pypi.yml on spectrayan/spector

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

File details

Details for the file spector_client-0.1.0a0-py3-none-any.whl.

File metadata

File hashes

Hashes for spector_client-0.1.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa758026d461ed79ae59fbafdd2881a23586fbb24c796b3366462415bd800baf
MD5 3c53080da8fa3088c6b2925102053964
BLAKE2b-256 9caeff56aacc9c68fd5a9819c557a104d0e1bcdd538494c1b678c7884ac78cda

See more details on using hashes here.

Provenance

The following attestation bundles were made for spector_client-0.1.0a0-py3-none-any.whl:

Publisher: release-pypi.yml on spectrayan/spector

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

Release history Release notifications | RSS feed

This release

0.1.0a0 This release

2 files

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