NewDakera v0.12.0 is out: multilingual, multimodal and multi-vector memory, faster reranked recall, one-command rollbackSee what's new →

LangChain.js Integration

This page covers @dakera-ai/langchain, the LangChain.js package for Dakera. It is for TypeScript and Node.js developers who want LangChain chains and retrievers backed by Dakera's persistent agent memory and server-side embeddings.

The current release is @dakera-ai/langchain 0.3.0. It builds on the TypeScript SDK (@dakera-ai/dakera 0.12.1 or later, peer dependency ^0.12.1) and @langchain/core 1.1 or later.

Quick start

npm install @dakera-ai/langchain @dakera-ai/dakera @langchain/core

Requires Node.js 20 or later and a running Dakera server (v0.12.0 or v0.11.108) (see the Quickstart).

import { DakeraMemory, DakeraVectorStore } from "@dakera-ai/langchain";

const memory = new DakeraMemory({
  apiUrl: "http://localhost:3000",
  apiKey: "dk-mykey",
  agentId: "my-agent",
});

const vectorstore = new DakeraVectorStore({
  apiUrl: "http://localhost:3000",
  apiKey: "dk-mykey",
  namespace: "my-docs",
});

Exports

Examples

Conversation chain with persistent memory

With LangChain.js v1, the legacy ConversationChain lives in @langchain/classic: npm install @langchain/classic @langchain/openai.

import { ChatOpenAI } from "@langchain/openai";
import { ConversationChain } from "@langchain/classic/chains";
import { DakeraMemory } from "@dakera-ai/langchain";

const memory = new DakeraMemory({
  apiUrl: "http://localhost:3000",
  apiKey: "dk-mykey",
  agentId: "chat-agent",
  recallK: 5,
  importance: 0.7,
});

const chain = new ConversationChain({
  llm: new ChatOpenAI({ model: "gpt-4o" }),
  memory,
});

await chain.invoke({ input: "My name is Alice." });

// Later, in another process: the memory is still on the Dakera server
const res = await chain.invoke({ input: "What's my name?" });

RAG retriever

import { DakeraVectorStore } from "@dakera-ai/langchain";

const vectorstore = new DakeraVectorStore({
  apiUrl: "http://localhost:3000",
  apiKey: "dk-mykey",
  namespace: "my-docs",
});

// Add documents (IDs are generated when you do not pass { ids })
await vectorstore.addDocuments([
  { pageContent: "Dakera computes embeddings on the server.", metadata: {} },
  { pageContent: "Memory decay lowers the importance of stale memories.", metadata: {} },
]);

// Retrieve
const retriever = vectorstore.asRetriever({ k: 4 });
const docs = await retriever.invoke("How does Dakera embed text?");

Session management

import { DakeraSessionManager } from "@dakera-ai/langchain";

const sessions = new DakeraSessionManager({
  apiUrl: "http://localhost:3000",
  apiKey: "dk-mykey",
  agentId: "my-agent",
});

const sessionId = await sessions.start({ user: "alice" }); // metadata; returns the session ID
// ... pass sessionId to memory operations ...
await sessions.end(); // ends the active session

end() accepts a summary argument but 0.3.0 does not send it to the server.

API reference

DakeraMemory options

ParameterTypeDefaultDescription
apiUrlstring—Dakera server URL (required)
apiKeystring—API key
agentIdstring—Agent whose memories are read and written (required)
recallKnumber5Memories to surface per turn
minImportancenumber0Minimum importance of recalled memories
importancenumber0.7Importance assigned to stored memories
memoryKeystring"history"Key injected into the prompt
inputKeystring—Input key to read the user message from

DakeraVectorStore options

ParameterTypeDefaultDescription
apiUrlstring—Dakera server URL (required)
apiKeystring—API key
namespacestring—Vector namespace to read and write (required)

Configuration

The package does not read environment variables; pass apiUrl and apiKey to each constructor. To keep them out of source code, read them yourself:

const memory = new DakeraMemory({
  apiUrl: process.env.DAKERA_API_URL ?? "http://localhost:3000",
  apiKey: process.env.DAKERA_API_KEY,
  agentId: "my-agent",
});

Links

LangChain.js + Dakera in production

npm install @dakera-ai/langchain: persistent memory for TypeScript LangChain agents, with embeddings computed on your Dakera server and no external embedding API.

Get Started → TypeScript SDK Reference →

TypeScript SDK: TypeScript SDK reference · Cursor (MCP) · Claude Desktop (MCP) · Python: LangChain

Stay sharp on agent memory
Benchmark results, SDK releases, and production patterns. Under 500 words per issue.
✓ You're in. First issue lands soon — watch for Dakera in your inbox.