Skip to main content

Installation

npm install @memoclaw/sdk

Authentication

MemoClaw uses Ethereum wallet signatures for auth. Any private key works — no ETH balance needed for the free tier.
# Set the env var
export MEMOCLAW_PRIVATE_KEY=0x...
Every wallet gets 100 free API calls.

Quick Example

1

Store a memory

import { MemoClawClient } from "@memoclaw/sdk";

const client = new MemoClawClient(); // uses MEMOCLAW_PRIVATE_KEY env var

const result = await client.store({
  content: "User prefers dark mode and vim keybindings",
  importance: 0.8,
  metadata: { tags: ["preferences", "editor"] },
});
console.log(result.id);
2

Recall memories

const memories = await client.recall({
  query: "editor preferences",
  limit: 5,
});

for (const m of memories.memories) {
  console.log(`[${(m.similarity * 100).toFixed(0)}%] ${m.content}`);
}
Output:
[87%] User prefers dark mode and vim keybindings
3

Update and delete

// Update importance
await client.update(result.id, { importance: 0.95 });

// Delete when no longer needed
await client.delete(result.id);

Ingest a Conversation

Extract facts automatically from conversation history:
const result = await client.ingest({
  messages: [
    { role: "user", content: "I prefer dark mode and use vim. My timezone is PST." },
    { role: "assistant", content: "Got it! I'll remember those preferences." },
  ],
  auto_relate: true,
});
console.log(`Extracted ${result.facts_extracted} facts, created ${result.relations_created} relations`);

Error Handling

import { MemoClawClient, MemoClawError } from "@memoclaw/sdk";

const client = new MemoClawClient();

try {
  await client.delete("nonexistent-id");
} catch (err) {
  if (err instanceof MemoClawError) {
    console.log(`Error ${err.status}: ${err.message}`);
  }
}

All Methods

MethodDescription
store(opts)Store a single memory
storeBatch(memories)Store up to 100 memories
recall(opts)Semantic search
list(opts?)List memories with pagination
update(id, opts)Update a memory
delete(id)Delete a memory
ingest(opts)Auto-extract facts from conversation
extract(messages, opts?)Extract structured facts via LLM
consolidate(opts?)Merge similar memories
suggested(opts?)Get proactive memory suggestions
createRelation(id, opts)Create a relationship
listRelations(id)List relationships
deleteRelation(id, relationId)Delete a relationship
status()Check free tier remaining calls

Configuration

const client = new MemoClawClient({
  privateKey: "0x...",               // or MEMOCLAW_PRIVATE_KEY env var
  baseUrl: "http://localhost:3000",  // for local development
  timeout: 60000,                    // request timeout in ms
});

Next Steps