@youraimemory/sdk
v0.0.9
Published
A tiny TypeScript/JavaScript client for the YourAIMemory API. It makes it easy to **store, search, and auto-extract memories about your users** with just a few lines of code.
Readme
@youraimemory/sdk
A tiny TypeScript/JavaScript client for the YourAIMemory API. It makes it easy to store, search, and auto-extract memories about your users with just a few lines of code.
Installation
npm install @youraimemory/sdk
# or
yarn add @youraimemory/sdk
# or
pnpm add @youraimemory/sdkQuick start
import MemoryClient from "@youraimemory/sdk";
const client = new MemoryClient({
// If omitted, the client will fall back to process.env.YOURAIMEMORY_API_KEY (in Node)
apiKey: process.env.YOURAIMEMORY_API_KEY,
});
// Add a memory
await client.add({
userId: "user_123",
content: "Meeting notes from Q1 planning",
});
// Find memories
const result = await client.find({
userId: "user_123",
query: "planning notes",
// optional:
// limit: 10,
// relevanceThreshold: 0.7,
});
console.log(result); // { memories: [...] }API Overview
The client exposes a small, ergonomic surface on top of the HTTP API:
new MemoryClient(options)apiKey?: string– Your YourAIMemory API key. If omitted (Node), falls back toprocess.env.YOURAIMEMORY_API_KEY.baseUrl?: string– Override the API base URL (defaults tohttps://api.youraimemory.com).fetchFn?: typeof fetch– Custom fetch implementation (for tests, Node polyfills, etc.).
High-level helpers
client.add({ userId, content, metadata? })Store a single memory for a user.client.find({ userId, query, limit?, relevanceThreshold? })Search for the most relevant memories for a user.client.auto({ userId, messages, maxMemories?, importanceThreshold? })Send a conversation transcript and let the API extract and store memories automatically.client.list({ userId, limit?, offset? })List recent memories for a user.client.deleteMemory(memoryId)Delete a memory by its ID.
Low-level access
client.memories.auto(...)client.memories.search(...)client.memories.store(...)client.memories.list(...)client.memories.delete(...)
These map 1:1 to the underlying /v1/memories HTTP endpoints and accept the full typed request payloads from @aimemory/shared.
Why use YourAIMemory?
Long‑term memory for your AI apps Store user profile details, preferences, tasks, and episodic events so your AI can stay consistent over time.
Smart retrieval Hybrid search (vectors + keywords), recency, importance, usage frequency, and memory type signals are combined to surface the most relevant memories.
Automatic extraction Send raw conversation logs and let the API extract structured memories for you.
Simple integration Just a few lines of code with
client.addandclient.find– no need to manage embeddings, indexes, or ranking logic yourself.
