Python SDK

Full reference for the agentrecall-sdk Python package.

Installation

pip install agentrecall-sdk

Quick Start

The fastest way to get started with cloud mode:

# 1. Create an agent in the dashboard
# 2. Create an API key for that agent
# 3. Use the key — agent_id is automatic

from agentrecall_sdk import AgentRecall

memory = AgentRecall(api_key="ark_your_api_key")

# No need to pass agent_id — it's bound to your API key
memory.store("User prefers dark mode")
results = memory.search("UI preferences")

Setup

Cloud Mode (Recommended)

API keys are agent-specific. Each key is tied to one agent, so you don't need to pass agent_id in every call.

from agentrecall_sdk import AgentRecall

memory = AgentRecall(
    api_key="ark_your_api_key",  # bound to a specific agent
    mode="cloud",  # default
    base_url="https://api.agentrecall.cloud"  # optional
)

Local Mode

memory = AgentRecall(
    mode="local",
    neo4j_uri="bolt://localhost:7687",
    neo4j_user="neo4j",
    neo4j_password="password",
    model_path="Qwen/Qwen2.5-7B"  # optional
)

API Reference

store()

ParameterTypeRequiredDescription
contentstrYesMemory text content
agent_idstrNo*Agent identifier. Auto-inferred from API key. Required only with JWT auth.
categorystrNoMemory category
metadatadictNoExtra key-value data
importancefloatNoManual importance (0–1)
processboolNoEnable AI processing (default: True)
# With API key (agent_id is automatic)
result = memory.store(
    content="User prefers TypeScript over JavaScript",
    category="preferences",
    metadata={"source": "code_review"},
    importance=0.7
)

# With JWT auth (agent_id required)
result = memory.store(
    content="User prefers TypeScript",
    agent_id="coding-assistant",
)
print(result.id)  # "mem_abc123"

search()

ParameterTypeRequiredDescription
querystrYesNatural language search query
agent_idstrNo*Agent scope. Auto-inferred from API key.
categorystrNoFilter by category
limitintNoMax results (default: 10)
min_scorefloatNoMinimum relevance score
results = memory.search(
    query="what are the user's coding preferences?",
    category="preferences",
    limit=5
)

for r in results:
    print(f"[{r.score:.2f}] {r.content}")

traverse()

ParameterTypeRequiredDescription
entitystrYes*Starting entity name
sourcestrYes*Source entity (for path finding)
targetstrNoTarget entity (for path finding)
depthintNoTraversal depth (default: 2)
agent_idstrNo*Agent scope. Auto-inferred from API key.
# Find connections from an entity
connections = memory.traverse(entity="User", depth=3)

# Find shortest path between two entities
paths = memory.traverse(source="User", target="San Francisco")

agent()

# Create a high-level agent with memory
agent = memory.agent(
    agent_id="my-agent",
    system_prompt="You are a helpful assistant with memory."
)

# The agent automatically stores and retrieves memories
response = agent.chat("Remember that I like coffee")

Configuration

OptionDefaultDescription
api_keyCloud API key (agent-specific)
mode"cloud""cloud" or "local"
base_urlapi.agentrecall.cloudAPI endpoint
timeout30Request timeout in seconds
retries3Max retry attempts

How Agent-Specific Keys Work

When you create an API key in the dashboard, you select which agent it belongs to. This means:

If you need to access multiple agents from one SDK instance, use JWT auth instead and pass agent_id explicitly.