SDK

JavaScript SDK

Use the JavaScript SDK for server-side apps, workers, and API integrations.

Client initialization

Initialize one client per process and reuse it. This keeps connection overhead low and centralizes retry and timeout policy.

Prefer environment-variable configuration for endpoint URLs and API keys.

Create client
import { AletheiaClient } from "@aletheia/sdk";

const client = new AletheiaClient({
  baseUrl: process.env.ALETHEIA_URL!,
  apiKey: process.env.ALETHEIA_API_KEY!
});

Ingest and query

Basic flow
await client.ingest({
  entityId: "user-123",
  textualContent: "I switched to pour-over coffee last month."
});

const results = await client.querySemantic({
  entityId: "user-123",
  textualQuery: "What coffee style do I use now?",
  limit: 5
});

Production patterns

  • Set request deadlines per endpoint class.
  • Use circuit breakers for dependency outages.
  • Attach request IDs for traceability.
  • Implement idempotent ingest retries.