JavaScript SDK
Build with Epitome using the official TypeScript client package @epitomefyi/sdk.
The JavaScript SDK wraps Epitome's REST API with strong TypeScript types and sensible defaults. It is the fastest way to add memory, profile access, table queries, and graph queries to your app.
Install
bash
npm install @epitomefyi/sdkPackage page: npmjs.com/package/@epitomefyi/sdk
Initialize Client
ts
import { EpitomeClient } from '@epitomefyi/sdk';
const client = new EpitomeClient({
apiKey: process.env.EPITOME_API_KEY!,
// Optional for self-hosted:
// baseUrl: 'http://localhost:3000',
defaultCollection: 'memories',
});Direct SDK Usage
ts
// Save a memory
await client.saveMemory({
text: 'Bruce prefers concise execution updates.',
collection: 'preferences',
metadata: { source: 'app', channel: 'web' },
});
// Semantic search
const memoryResults = await client.searchMemory({
query: 'What are my communication preferences?',
collection: 'preferences',
limit: 5,
minSimilarity: 0.72,
});
// Alias (same as searchMemory)
const aliasResults = await client.search({ query: 'execution updates' });Profile, Tables, Graph
ts
// Profile
const profile = await client.getProfile();
await client.updateProfile({
patch: {
timezone: 'America/New_York',
preferences: { communication: 'concise' },
},
});
// Tables
await client.addRecord({
table: 'projects',
data: { name: 'Epitome SDK', status: 'in_progress' },
});
const tableRows = await client.queryTable({
table: 'projects',
filters: { status: 'in_progress' },
limit: 20,
});
const tables = await client.listTables();
// Graph
const graph = await client.queryGraph({
query: 'project priorities',
limit: 10,
});User Context
`getUserContext` returns a structured snapshot (profile, tables, collections, top entities, recent memories) and can optionally use a topic hint.
ts
const context = await client.getUserContext({
topic: 'project priorities',
});
console.log(context.profile);
console.log(context.tables);
console.log(context.hints.suggestedTools);Hosted vs Self-Hosted
- Hosted: default base URL is
https://epitome.fyi. - Self-hosted: set
baseUrlto your API origin, e.g.http://localhost:3000.
Auth + Error Handling
ts
import {
EpitomeAuthError,
EpitomeConsentError,
EpitomeRateLimitError,
} from '@epitomefyi/sdk';
try {
await client.getProfile();
} catch (error) {
if (error instanceof EpitomeAuthError) {
// 401
} else if (error instanceof EpitomeConsentError) {
// 403 / consent denied
} else if (error instanceof EpitomeRateLimitError) {
// 429 + rateLimit metadata
console.log(error.rateLimit);
} else {
throw error;
}
}Browser CORS Notes
For production apps, prefer calling Epitome from your server/backend and keep API keys off the client. If you call from the browser directly, configure allowed origins and key handling carefully.