Skip to content

TypeScript / Node SDK

The TypeScript / Node SDK wraps the Context API for use in any Node agent or backend.

Terminal window
npm install @wexa/sdk
agent.ts
import { Wexa } from "@wexa/sdk";
const wexa = new Wexa({ apiKey: process.env.WEXA_API_KEY });
const context = await wexa.context.query({
workspace: "ws_<your_project>",
query: "top accounts at churn risk",
});
console.log(context.entities);
  • apiKey — a project-scoped fab_sk_… key. Generate one in Simple Mode. Read it from the environment (WEXA_API_KEY) rather than hardcoding it.
  • workspace — your workspace ID (ws_<your_project>); it pins the call’s scope.

context.query(...) resolves to the ranked entities, relationships, and facts that ground the query, plus a lifecycle_id for tracing and audit — the same result the MCP query-context tool returns.

Option Purpose
apiKey Project-scoped credential (fab_sk_…).
Base URL Defaults to the managed cloud; set it to your deployment’s apiBaseUrl (from connection-info) for on-prem / air-gapped.