OpenAI SDK + Memanto
@moorcheh-ai/memanto TypeScript SDK.
Prerequisites
- Node.js 20+
uv(shipsuvx) — theMemantoclient spawns a local Memanto server viauvxon first use unless you passbaseUrl- Memanto / Moorcheh credentials — Moorcheh API key (cloud) or an on-prem backend (no Moorcheh API key). Set
MOORCHEH_API_KEYor passapiKeytonew Memanto({ ... }) - OpenAI API key — the quick start uses
gpt-4oviarunTools(), which readsOPENAI_API_KEYfrom the environment (or passapiKeytonew OpenAI({ ... })). openaiandzodinstalled in your app (optional peer dependencies of@moorcheh-ai/memanto)
Install
openai and zod are optional peer dependencies of @moorcheh-ai/memanto — install them yourself in the host app. Importing @moorcheh-ai/memanto/openai without them installed will fail at module load with a standard Node resolution error.
Quick Start
createMemantoOpenAITools returns an array of tools built with zodFunction, ready to hand to the OpenAI Node SDK’s runTools() helper — each tool auto-parses its JSON arguments against a Zod schema before invoking Memanto.
Each tool’s description is written for the model to decide when to call it (e.g. recallMemory: “Call this before answering whenever the user refers to information from earlier or from a previous session”).
Available Tools
answerMemory calls Memanto’s Generate AI Answer API (memanto.answer() → Moorcheh answer.generate). Memanto retrieves relevant memories and synthesizes a grounded response using Memanto’s configured LLM — not the model you pass to runTools(). Your agent model only decides when to call the tool and how to use the result. recallMemory and rememberMemory do not invoke an LLM.Unlike the Vercel AI SDK and Mastra variants, this integration’s schemas use nullable fields (
.nullable()) instead of optional ones, matching the OpenAI function-calling convention where the model must explicitly pass null rather than omit a field.Options
Memory Types
type fields are constrained to Memanto’s 13 supported types via a shared MEMORY_TYPES export:
On-Prem
The integration talks to Memanto through theMemanto client, so it works identically against an on-prem backend — no code changes, just configure the backend once with the CLI. See On-Prem Overview and the TypeScript SDK Reference.
Next Steps
- TypeScript SDK Reference for the full
Memantoclient API - Vercel AI SDK Integration for the equivalent AI SDK tools
- Mastra Integration for the equivalent Mastra tools
- Memory Types Reference