Back to Docs

API Reference

Three surfaces: in-process engine (@aimemory/core), hosted SDK (@aimemory/sdk), and REST at https://api.aimemory.lat/api/v1.

Stability:stableProduction-readybetaAvailable, may changeplannedComing soon

In-process AIMemory

Local engine — package @aimemory/core / ai-memory

MethodStabilityDescription
remember(content, metadata?)stableAdd a memory with content and optional metadata
rememberFact(content, metadata?)stableAdd a factual memory
rememberPreference(content, metadata?)stableAdd a user preference memory
rememberInstruction(content, metadata?)stableAdd an instruction-style memory
rememberConversation(content, role, metadata?)stableAdd a conversation message (user/assistant)
recall(query, options?)stableSearch memories by semantic similarity; options may include collection, tags, type
getContext(query)stableBuild optimized context for an LLM; pass collection to scope results
getMemory(id)stableRetrieve a specific memory by ID
updateMemory(id, updates)stableUpdate content or metadata of an existing memory
forget(id)stableDelete a memory permanently
getRecentMemories(limit?)stableList most recent memories
getStats()stableMemory statistics and usage metrics
exportData()stableExport all memories as JSON
importData(memories)betaImport memories from JSON
clear()stableRemove all memories from the store
cleanup()stableRun automatic cleanup based on config

Hosted SDK (AIMemoryClient)

Typed client for the hosted API — package @aimemory/sdk

MethodStabilityDescription
capture(content, metadata?)stableCreate a memory in the hosted workspace
trackEvent(type, payload?)stableRecord an analytics or usage event
search(query, options?)stableSemantic search; options: collection, tags, type, limit, threshold
listMemories(options?)stableList memories with filters (collection, tags, type)
getMemory(id)stableFetch a single memory by ID
updateMemory(id, updates)stableUpdate memory content or metadata
deleteMemory(id)stableDelete a memory permanently
retrieveContext(query, options?)stableBuild LLM-ready context; options: collection, tags, type, maxMemories
injectContext(messages, query)stableInject retrieved context into a message list
buildPrompt(query, systemPrompt?)stableBuild a prompt with embedded memory context
createWorkspace(options)stableCreate a workspace
listWorkspaces()stableList workspaces for the API key
getWorkspace(id)stableGet workspace details
updateWorkspace(id, updates)stableUpdate workspace settings
deleteWorkspace(id)stableDelete a workspace
exportData(workspaceId)stableExport workspace memories
importData(workspaceId, memories)betaImport memories into a workspace
linkMemories(sourceId, targetId)plannedLink two memories (SDK; API route planned)
getMemoryRelations(memoryId)plannedList related memory IDs (SDK; API route planned)
client.ts
import { AIMemoryClient } from '@aimemory/sdk';

const memory = new AIMemoryClient({
  apiKey: process.env.AIMEMORY_API_KEY!,
  workspaceId: process.env.AIMEMORY_WORKSPACE_ID,
});

const results = await memory.search('project stack', {
  collection: 'project:my-app',
});
const context = await memory.retrieveContext('What do we use for auth?', {
  collection: 'project:my-app',
});

Configuration (in-process)

Options for createAIMemory()

OptionTypeDefaultDescription
maxMemoriesnumber10000Maximum memories to store
embeddingDimensionnumber1536Embedding vector dimension
maxTokensnumber4000Max tokens for context
relevanceThresholdnumber0.7Min similarity score (0–1)
defaultImportancenumber0.5Default importance (0–1)
autoCleanupobjectAutomatic cleanup configuration
storageobjectmemoryStorage backend config

Collections (scoped memory)

Group memories by topic so search stays in the right bucket. Pass collection on create, search, recall, and context.

Slug patternExampleUse for
project:<name>project:henry-memoryAll facts about one project
personal:preferencespersonal:preferencesTastes, habits, personal defaults (auto for type=preference)
work:<name>work:client-acmeWork context not tied to a side project
inboxinboxUnsorted conversation snippets

Remote MCP tools

MethodStabilityDescription
remember(content, type?, collection?, tags?, append_to?)stableSave scoped memory; use collection=project:<slug> for projects
recall(query, collection?, tags?, type?)stableSearch only within the given collection/scope
get_context(topic, collection?, tags?, type?)stableBuild context block scoped to a collection
list_memories(collection?, tags?, type?)stableList recent memories in a scope
list_collections()stableList collection slugs for this user
forget(memory_id)stableDelete a memory by UUID
memory_stats()stableCounts by type and collection

REST API endpoints

Base URL: https://api.aimemory.lat/api/v1 — authenticate with Bearer API key

GET/healthstableService health check (unauthenticated)
GET/api/v1stableAPI version and metadata
POST/api/v1/eventsstableIngest a single event
POST/api/v1/events/batchstableIngest events in batch
GET/api/v1/memoriesstableList memories (?collection, ?tags, ?type)
POST/api/v1/memoriesstableCreate memory (collection, tags, append_to)
POST/api/v1/memories/searchstableSemantic search (body: query, collection?, tags?, type?)
GET/api/v1/collectionsstableList memory collections
POST/api/v1/collectionsstableCreate a named collection (slug + name)
GET/api/v1/collections/:slug/memoriesstableList memories in a collection
PUT/api/v1/collections/:slugstableUpdate collection metadata
DELETE/api/v1/collections/:slugstableDelete collection registry (memories keep slug)
GET/api/v1/memories/:idstableGet memory by ID
PUT/api/v1/memories/:idstableUpdate a memory
DELETE/api/v1/memories/:idstableDelete a memory
POST/api/v1/context/retrievestableRetrieve LLM context (body: topic, collection?, tags?, type?)
POST/api/v1/chatbetaMemory-aware chat completion
GET/api/v1/workspacesstableList workspaces
POST/api/v1/workspacesstableCreate workspace
GET/api/v1/workspaces/:idstableGet workspace
PUT/api/v1/workspaces/:idstableUpdate workspace
DELETE/api/v1/workspaces/:idstableDelete workspace
GET/api/v1/organizationsstableList organizations
POST/api/v1/organizationsstableCreate organization
GET/api/v1/organizations/:idstableGet organization
PUT/api/v1/organizations/:idstableUpdate organization
GET/api/v1/projectsstableList projects
POST/api/v1/projectsstableCreate project
GET/api/v1/projects/:idstableGet project
PUT/api/v1/projects/:idstableUpdate project
DELETE/api/v1/projects/:idstableDelete project
GET/api/v1/members/organizations/:id/membersstableList organization members
POST/api/v1/members/organizations/:id/membersstableAdd organization member
DELETE/api/v1/members/organizations/:id/members/:userIdstableRemove organization member
GET/api/v1/members/workspaces/:id/membersstableList workspace members
POST/api/v1/members/workspaces/:id/membersstableAdd workspace member
DELETE/api/v1/members/workspaces/:id/members/:userIdstableRemove workspace member
GET/api/v1/webhooksbetaList API keys / webhook configs
POST/api/v1/webhooksbetaCreate API key
DELETE/api/v1/webhooks/:idbetaDelete API key
POST/api/v1/webhooks/ingestbetaIngest event via webhook
GET/api/v1/analytics/usagebetaUsage analytics
GET/api/v1/analytics/memoriesbetaMemory analytics
GET/api/v1/analytics/sourcesbetaSource analytics
GET/api/v1/analytics/summarybetaAnalytics summary

Plan limits

Aligned with the public pricing page. Hosted workspaces enforce quotas on the API.

Free, Pro ($12/mo), Team ($49/mo), and Enterprise ($199/mo) tiers differ in API calls, memory retention, workspaces, and team features. See pricing for the full comparison table.