Official Python SDK for SpAIder Memory Infrastructure
Project description
spaider-client
Official Python SDK for SpAIder, the memory infrastructure for AI agents.
Installation
pip install spaider-client
With LangChain integration:
pip install "spaider-client[langchain]"
With LlamaIndex integration:
pip install "spaider-client[llamaindex]"
All integrations:
pip install "spaider-client[all]"
Requirements
- Python 3.9+
- A SpAIder API key (
sk-...) from a self-hosted instance
Getting an API key (Phase 1: self-hosted only)
There is no hosted SpAIder service yet; every key comes from an instance you run yourself. The fast path:
git clone https://github.com/Spaider-studio/spaider.git
cd spaider
pip install -e ./cli # or: pipx install ./cli
spaider init # ~5 min interactive wizard
spaider init brings up the backend stack, provisions a personal agent, and prints the sk-... key it issues. Re-run spaider doctor later if you want to inspect the install. Manual install (make setup → edit .env → make dev → scripts/dev/setup_mcp_dev_agent.sh) is documented in the main repo README for hackers who want to see every step.
Hosted SpAIder (managed instance, no self-hosting required) is on the roadmap but not yet open for signup.
Quickstart
from spaider import Spaider
sp = Spaider(api_key="sk-your-key-here", agent_id="my-agent")
# Ingest unstructured text
result = sp.ingest("Max Mustermann arbeitet seit 2023 als Engineer bei Google.")
print(f"Created {result.nodes_created} nodes, {result.edges_created} edges")
# Natural-language query
answer = sp.query("Wo arbeitet Max?")
print(answer.text)
# => "Max Mustermann works at Google as an Engineer since 2023."
# Inspect the supporting subgraph
for node in answer.subgraph.nodes:
print(f" {node.type}: {node.label}")
# Traverse from a specific node
subgraph = sp.traverse(node_id=answer.subgraph.nodes[0].id, depth=3)
# GDPR: delete a node
sp.delete_node("node-uuid-here")
# Generate a fine-tuning dataset
dataset = sp.synthesize(strategy="reasoning", max_samples=1000)
dataset.save("training.jsonl")
Async Client
import asyncio
from spaider import AsyncSpaider
async def main():
async with AsyncSpaider(api_key="sk-your-key-here", agent_id="my-agent") as sp:
result = await sp.ingest("Alice ist CEO von Acme Corp.")
answer = await sp.query("Wer leitet Acme Corp?")
print(answer.text)
asyncio.run(main())
Swarm Queries
Connect multiple agents and query across their graphs:
sp = Spaider(api_key="sk-...", agent_id="agent-hr")
# Connect to another agent
sp.create_swarm_connection(target_agent="agent-sales")
# Query across both graphs
result = sp.swarm_query(
"What are our top clients and who manages their accounts?",
target_agents=["agent-sales"],
)
print(result.text)
LangChain Integration
from langchain.llms import OpenAI
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from spaider.integrations.langchain import SpaiderMemory
# Create Spaider-backed memory
memory = SpaiderMemory(
api_key="sk-your-key-here",
agent_id="my-agent",
memory_key="history", # injected into prompt as {history}
input_key="input",
output_key="output",
top_k=5,
)
prompt = PromptTemplate(
input_variables=["history", "input"],
template=(
"You are a helpful assistant with access to a knowledge graph.\n"
"Relevant context:\n{history}\n\n"
"Human: {input}\nAssistant:"
),
)
chain = LLMChain(llm=OpenAI(temperature=0), prompt=prompt, memory=memory)
# The memory automatically ingests each turn and retrieves relevant context
response = chain.predict(input="Who is Max Mustermann?")
print(response)
LlamaIndex Integration
from spaider.integrations.llamaindex import SpaiderIndex, SpaiderQueryEngine
# Use as a knowledge index
index = SpaiderIndex(api_key="sk-your-key-here", agent_id="my-agent")
index.add_text("Acme Corp was founded in 2001 by John Doe.")
index.add_texts([
"John Doe is also a board member of TechStart Inc.",
"TechStart Inc. raised $50M in Series B in 2023.",
])
response = index.query("Who founded Acme Corp and what else do they do?")
print(response.text)
# Use as a LlamaIndex QueryEngine
engine = SpaiderQueryEngine(api_key="sk-your-key-here", agent_id="my-agent")
response = engine.query("What do we know about John Doe?")
print(str(response))
API Reference
Spaider / AsyncSpaider
| Method | Description |
|---|---|
ingest(text, source?) |
Extract and store knowledge from text |
query(question, top_k?) |
Natural-language query, returns QueryResult |
traverse(node_id, depth?) |
Subgraph traversal from a node |
get_graph() |
Fetch the full agent graph |
get_node(node_id) |
Fetch a single node |
delete_node(node_id) |
Delete a node (GDPR) |
synthesize(strategy?, max_samples?) |
Generate fine-tuning dataset |
create_swarm_connection(target_agent) |
Connect to another agent |
swarm_query(question, target_agents?, top_k?) |
Cross-agent query |
Models
| Model | Description |
|---|---|
Node |
A graph node with id, label, type, properties |
Edge |
A directed edge with source_id, target_id, relation |
GraphPayload |
Collection of nodes and edges |
QueryResult |
Answer text + supporting subgraph |
IngestResult |
Creation/merge counts |
SynthesisDataset |
Fine-tuning samples + .save(path) |
Exceptions
| Exception | HTTP Status | Description |
|---|---|---|
SpaiderError |
n/a | Base exception |
AuthError |
401 | Invalid or missing API key |
NotFoundError |
404 | Resource not found |
RateLimitError |
429 | Rate limit exceeded |
ServerError |
5xx | SpAIder server error |
Self-Hosted
Point the client at your own deployment:
sp = Spaider(
api_key="sk-...",
agent_id="my-agent",
base_url="http://localhost:8080", # or your Kong gateway URL
)
License
Apache 2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spaider_client-0.1.0.tar.gz.
File metadata
- Download URL: spaider_client-0.1.0.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40ccd14ff1216107219c022930738dbf1a1fddf0f21ef42069ec364ac2de712e
|
|
| MD5 |
dcf8ea8991e4c13e2c39a5b40cac4ad4
|
|
| BLAKE2b-256 |
d4baa79ca8e93af37a7f1b304b1616ec71e56c26341b04983c471e38ae8fc4fc
|
Provenance
The following attestation bundles were made for spaider_client-0.1.0.tar.gz:
Publisher:
sdk-python-release.yml on Spaider-studio/spaider
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spaider_client-0.1.0.tar.gz -
Subject digest:
40ccd14ff1216107219c022930738dbf1a1fddf0f21ef42069ec364ac2de712e - Sigstore transparency entry: 1853130465
- Sigstore integration time:
-
Permalink:
Spaider-studio/spaider@f1ef174e9886eb50f492ab8a0ed8195f9fd343e8 -
Branch / Tag:
refs/tags/sdk-python/v0.1.0 - Owner: https://github.com/Spaider-studio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-python-release.yml@f1ef174e9886eb50f492ab8a0ed8195f9fd343e8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file spaider_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: spaider_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8825d15ccf5dfbcdbea4ffa56d9a5c313f8611852c0e66e0b10b87dc1b22eb8
|
|
| MD5 |
c942425c1c44b30126cd8cbee29b49ab
|
|
| BLAKE2b-256 |
389a6f4e0ff112d3510ca09a87e7f954ed7fd901bd66d49402ecfc3a87e3ad25
|
Provenance
The following attestation bundles were made for spaider_client-0.1.0-py3-none-any.whl:
Publisher:
sdk-python-release.yml on Spaider-studio/spaider
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spaider_client-0.1.0-py3-none-any.whl -
Subject digest:
b8825d15ccf5dfbcdbea4ffa56d9a5c313f8611852c0e66e0b10b87dc1b22eb8 - Sigstore transparency entry: 1853130521
- Sigstore integration time:
-
Permalink:
Spaider-studio/spaider@f1ef174e9886eb50f492ab8a0ed8195f9fd343e8 -
Branch / Tag:
refs/tags/sdk-python/v0.1.0 - Owner: https://github.com/Spaider-studio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-python-release.yml@f1ef174e9886eb50f492ab8a0ed8195f9fd343e8 -
Trigger Event:
workflow_dispatch
-
Statement type: