marius ndini

JavaScript and Python SDKs for Mnexium

The Mnexium SDKs give you a complete memory infrastructure as a service. Install the package, pass your LLM provider key, and your AI remembers.

Node (https://www.npmjs.com/package/@mnexium/sdk)

Python (https://pypi.org/project/mnexium/)

Docs (https://mnexium.com/docs)

Get Started

Both SDKs are MIT licensed and available now. No sign-up required — omit the API key and a trial key is auto-provisioned on your first request.

JavaScript / TypeScript

npm install @mnexium/sdk
import { Mnexium } from '@mnexium/sdk';

const mnx = new Mnexium({
  apiKey: 'mnx_...',
  openai: { apiKey: process.env.OPENAI_API_KEY },
});

const alice = mnx.subject('user_123');

// Chat with memory — learns and recalls automatically
const chat = alice.createChat({ learn: true, recall: true });
await chat.process('My favorite color is blue');
await chat.process('What is my favorite color?'); // Remembers!

Python

pip install mnexium
from mnexium import Mnexium, ProviderConfig, ChatOptions
import os

mnx = Mnexium(
    api_key="mnx_...",
    openai=ProviderConfig(api_key=os.environ["OPENAI_API_KEY"]),
)

alice = mnx.subject("user_123")

# Chat with memory — learns and recalls automatically
chat = alice.create_chat(ChatOptions(learn=True, recall=True))
chat.process("My favorite color is blue")
chat.process("What is my favorite color?")  # Remembers!

Core Concepts

Subjects

A Subject is a logical identity — a user, an agent, an organization, or a device. Every Subject owns its own memories, profile, claims, state, and chat history. Creating a Subject is instant and requires no network call.

Memories

Memories are facts, preferences, and context extracted from conversations. The SDK can learn memories automatically from chat (learn: true) or you can add them directly via the API. Search is semantic — ask in natural language and get the most relevant memories back.

Claims

Claims are structured, slot-based facts with confidence scores. Think of them as a knowledge graph for each user: favorite_color → blue (0.95). Claims support history tracking and retraction, so your AI always has the latest truth.

Profiles

Profiles are structured key-value fields — display names, timezones, preferences — automatically extracted from conversations or set via API. They're injected into the LLM context so your AI knows who it's talking to.

Agent State

Persist arbitrary key-value state with optional TTL. Perfect for multi-step workflows, wizard progress, or agent continuity across sessions.

Multi-Provider, Shared Memory

Both SDKs support OpenAI, Anthropic, and Google Gemini out of the box. The provider is auto-detected from the model name. Switch models freely — memories are shared across all providers.

// Learn with GPT-4o
await chat.process({ content: 'I love hiking', model: 'gpt-4o-mini' });

// Recall with Claude
await chat.process({ content: 'What do I love?', model: 'claude-sonnet-4-20250514' });

// Recall with Gemini
await chat.process({ content: 'Tell me my hobbies', model: 'gemini-2.0-flash' });

Memories persist regardless of which model you use.

Real-time Streaming

Both SDKs support native streaming with async iterators. Responses stream in real-time while memory extraction happens in the background.

// JavaScript
const stream = await chat.process({ content: 'Tell me a story', stream: true });
for await (const chunk of stream) {
  process.stdout.write(chunk.content);
}

# Python
stream = chat.process(ChatProcessOptions(content="Tell me a story", stream=True))
for chunk in stream:
    print(chunk.content, end="", flush=True)

Real-time Memory Events

Subscribe to memory changes via Server-Sent Events. Get notified the instant a memory is created, updated, superseded, or deleted — perfect for building reactive UIs or triggering downstream workflows.

const events = alice.memories.subscribe();

for await (const event of events) {
  if (event.type === 'memory.created') {
    console.log('New memory:', event.data);
  }
}

What You Get

  • Persistent memory — Your AI remembers users across sessions, not just within a single chat

  • Automatic learning — Facts, preferences, and context are extracted from conversations automatically

  • Semantic search — Search memories in natural language with hybrid embedding + keyword retrieval

  • Structured claims — Slot-based facts with confidence scores and history tracking

  • Multi-provider — OpenAI, Anthropic, and Google Gemini with shared memory across all providers

  • Real-time events — SSE subscriptions for memory changes

  • Trial keys — Start building immediately with auto-provisioned trial keys, no sign-up required

  • Full TypeScript support — Exported types, interfaces, and IntelliSense for the JS SDK

4 views

Add a comment

Replies

Be the first to comment