Skip to content

TypeScript SDK

Official TypeScript client for Momo. Published as @momomemory/sdk on npm.

Terminal window
npm install @momomemory/sdk
# or
bun add @momomemory/sdk

Requires Node.js 18+ or Bun. ESM-only.

import { MomoClient } from "@momomemory/sdk";
const momo = new MomoClient({
baseUrl: "http://localhost:3000",
apiKey: "your-api-key",
defaultContainerTag: "my-app",
});
// Create a document
const doc = await momo.documents.create({
content: "TypeScript was released in 2012 by Microsoft.",
});
// Search
const results = await momo.search.search({
q: "When was TypeScript created?",
limit: 5,
});
// List memories
const { memories } = await momo.memories.list({ limit: 10 });
// Forget a memory
await momo.memories.forgetById("mem-id", { reason: "outdated" });
OptionTypeDescription
baseUrlstringMomo server URL
apiKeystringStatic API key for Bearer auth
getApiKey() => string | Promise<string>Dynamic key provider
defaultContainerTagstringContainer tag applied to all scoped requests
fetchtypeof fetchCustom fetch implementation

All API errors are thrown as MomoError:

import { MomoClient, MomoError } from "@momomemory/sdk";
const momo = new MomoClient({ baseUrl: "http://localhost:3000" });
try {
await momo.documents.get("nonexistent");
} catch (e) {
if (e instanceof MomoError) {
console.error(e.code); // "not_found" | "unauthorized" | ...
console.error(e.status); // 404
console.error(e.message); // Human-readable message
console.error(e.path); // "/api/v1/documents/nonexistent"
console.error(e.method); // "GET"
}
}

Error codes: invalid_request, unauthorized, not_found, conflict, internal_error, not_implemented.

MethodDescription
create(body)Create a text document
batchCreate(body)Create multiple documents
upload(file, options?)Upload a file
uploadFromPath(path, options?)Upload from a file path (Node/Bun)
get(documentId, options?)Fetch a document
update(documentId, body, options?)Update document metadata
delete(documentId, options?)Delete a document
list(params?, options?)List documents
getIngestionStatus(ingestionId, options?)Poll ingestion status
MethodDescription
create(body, options?)Create a memory
get(memoryId, options?)Fetch a memory
update(memoryId, body, options?)Update a memory
list(params?, options?)List memories
forget(body, options?)Content-based forget
forgetById(memoryId, body?, options?)Forget by ID
MethodDescription
search(body, options?)Hybrid search across documents and memories
MethodDescription
ingest(body, options?)Ingest a conversation thread
MethodDescription
getMemoryGraph(memoryId, params?, options?)Graph for a memory
getContainerGraph(tag, params?, options?)Graph for a container
MethodDescription
compute(body, options?)Compute a container profile
MethodDescription
runForgetting(options?)Trigger a forgetting pass
MethodDescription
check(options?)Check server health

The underlying openapi-fetch client is exposed for direct API access:

const { data, error } = await momo.raw.GET("/api/v1/health");

The raw client shares the same auth and envelope-unwrapping middleware.