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/typescript-sdk
Or with your preferred package manager:
yarn add @memnexus-ai/typescript-sdk
pnpm add @memnexus-ai/typescript-sdk
Initialize the client
The exported class is Memnexus. Authenticate with an API key passed as token:
import { Memnexus } from "@memnexus-ai/typescript-sdk";
const client = new Memnexus({
token: process.env.MX_API_KEY,
});
Custom API URL
If you're running a self-hosted instance:
const client = new Memnexus({
token: process.env.MX_API_KEY,
baseUrl: "https://your-instance.example.com",
});
Verify the connection
const health = await client.health.healthCheck();
console.log("Status:", health.data?.status);
TypeScript support
The SDK is fully typed. All request and response types are exported:
import type {
Memory,
CreateMemoryRequest,
SearchRequest,
SearchResponse,
} from "@memnexus-ai/typescript-sdk";
Your editor will provide autocompletion for all methods and parameters.
Error handling
Failed requests throw an SdkError carrying the HTTP status code:
import { Memnexus, SdkError } from "@memnexus-ai/typescript-sdk";
try {
const memory = await client.memories.getMemoryById("non-existent-id");
} catch (error) {
if (error instanceof SdkError && error.status === 404) {
console.log("Memory not found");
} else if (error instanceof SdkError && error.status === 401) {
console.log("Invalid API key");
} else {
console.error("Unexpected error:", error);
}
}
Next steps
- Authentication — API key management in code
- Memory Operations — Create, update, and organize memories
- Search — Find memories programmatically