MemNexus
GuidesUsing the SDK

SDK Installation

Install and configure the MemNexus TypeScript SDK.

The MemNexus TypeScript SDK provides a typed client for all API operations. Use it to integrate memory management directly into your applications.

Requirements

  • Node.js 18 or later
  • TypeScript 5.0+ (recommended)

Install

npm install @memnexus-ai/mx-typescript-sdk

Or with your preferred package manager:

yarn add @memnexus-ai/mx-typescript-sdk
pnpm add @memnexus-ai/mx-typescript-sdk

Initialize the client

import { MemnexusClient } from "@memnexus-ai/mx-typescript-sdk";

const client = new MemnexusClient({
  apiKey: process.env.MX_API_KEY,
});

Custom API URL

If you're running a self-hosted instance:

const client = new MemnexusClient({
  apiKey: process.env.MX_API_KEY,
  baseUrl: "https://your-instance.example.com",
});

Verify the connection

const health = await client.system.health();
console.log("Status:", health.status);

TypeScript support

The SDK is fully typed. All request and response types are exported:

import type {
  Memory,
  CreateMemoryRequest,
  SearchRequest,
  SearchResponse,
} from "@memnexus-ai/mx-typescript-sdk";

Your editor will provide autocompletion for all methods and parameters.

Error handling

try {
  const memory = await client.memories.get("non-existent-id");
} catch (error) {
  if (error.status === 404) {
    console.log("Memory not found");
  } else if (error.status === 401) {
    console.log("Invalid API key");
  } else {
    console.error("Unexpected error:", error.message);
  }
}

Next steps