Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/vectorize-io/hindsight/llms.txt

Use this file to discover all available pages before exploring further.

The Hindsight Node.js SDK (@vectorize-io/hindsight-client) provides a fully typed TypeScript client for the Hindsight HTTP API. It works in Node.js and Deno, and all operations are async-first using native Promises. Use it when you have a Hindsight server running and want to add persistent agent memory to a JavaScript or TypeScript application.

Installation

npm install @vectorize-io/hindsight-client

Create the client

import { HindsightClient } from '@vectorize-io/hindsight-client';

const client = new HindsightClient({
    baseUrl: 'http://localhost:8888',
    apiKey: 'your-api-key',   // optional
});
baseUrl
string
required
The base URL of your Hindsight API server.
apiKey
string
Bearer token for authenticated servers. Omit when authentication is not required.

Quick start

import { HindsightClient } from '@vectorize-io/hindsight-client';

const client = new HindsightClient({ baseUrl: 'http://localhost:8888' });

// Store a memory
await client.retain('my-bank', 'Alice works at Google');

// Search memories
const response = await client.recall('my-bank', 'What does Alice do?');
for (const r of response.results) {
    console.log(r.text);
}

// Generate a contextual answer
const answer = await client.reflect('my-bank', 'Tell me about Alice');
console.log(answer.text);

Core operations

retain

Store a single memory in a bank.
// Minimal
await client.retain('my-bank', 'Alice works at Google');

// With options
await client.retain('my-bank', 'Alice got promoted', {
    timestamp: new Date('2024-06-01'),
    context: 'career update',
    metadata: { source: 'slack', channel: '#general' },
    tags: ['career', 'alice'],
    async: false,   // true → background processing
});
bankId
string
required
The memory bank to write to.
content
string
required
The text to store.
options.timestamp
Date
Event time for the memory.
options.context
string
Brief description of the content source.
options.metadata
Record<string, string>
Arbitrary key-value pairs for later filtering.
options.tags
string[]
Tags for filtering during recall and reflect.
options.async
boolean
If true, processing is queued in the background. Default false.

retainBatch

Store multiple memories in one request.
await client.retainBatch('my-bank', [
    { content: 'Alice works at Google', context: 'career', tags: ['alice'] },
    { content: 'Bob is a data scientist', context: 'career', tags: ['bob'] },
], {
    documentId: 'conversation_001',
    async: false,
});

recall

Search memories by semantic similarity.
// Basic
const response = await client.recall('my-bank', 'What does Alice do?');
for (const r of response.results) {
    console.log(`${r.text}  (type: ${r.type})`);
}

// With options
const filtered = await client.recall('my-bank', 'What does Alice do?', {
    types: ['world', 'observation'],   // fact types to include
    maxTokens: 4096,
    budget: 'high',                    // 'low' | 'mid' | 'high'
    tags: ['alice'],
    tagsMatch: 'all_strict',
});
bankId
string
required
The memory bank to search.
query
string
required
Natural-language search query.
options.maxTokens
number
Maximum tokens in the result set. Default 4096.
options.budget
string
Retrieval effort: "low", "mid" (default), or "high".
options.types
string[]
Limit to specific fact types: world, experience, opinion, observation.
options.tags
string[]
Filter by tags.
options.tagsMatch
string
Tag matching mode. "any" (OR, includes untagged), "all" (AND, includes untagged), "any_strict" (OR, excludes untagged), "all_strict" (AND, excludes untagged). Default "any".

reflect

Generate a contextual answer from stored memories.
const answer = await client.reflect('my-bank', 'What should I know about Alice?', {
    budget: 'mid',
    context: 'preparing for a 1:1',
});

console.log(answer.text);
bankId
string
required
The memory bank to reason over.
query
string
required
The question or prompt.
options.budget
string
Retrieval effort: "low" (default), "mid", or "high".
options.context
string
Extra context injected alongside the query.

Bank management

// Create or update a bank
await client.createBank('my-bank', {
    name: 'Assistant',
    mission: "You're a helpful assistant. Track user preferences and context.",
    disposition: {
        skepticism: 2,   // 1 (trusting) – 5 (skeptical)
        literalism: 3,
        empathy: 4,
    },
});

// List memories
const memories = await client.listMemories('my-bank', {
    type: 'world',     // optional fact-type filter
    q: 'Alice',        // optional text search
    limit: 100,
    offset: 0,
});

Document management

// Get a document
const doc = await client.getDocument('my-bank', 'conversation_001');

// List documents
const docs = await client.listDocuments('my-bank', { limit: 50, offset: 0 });

// Update document metadata
await client.updateDocument('my-bank', 'conversation_001', {
    tags: ['important', 'meeting-notes'],
});

// Delete a document and its memories
await client.deleteDocument('my-bank', 'conversation_001');

TypeScript types

The SDK ships full TypeScript declarations. Key types returned by the API:
import type {
    RecallResponse,
    RecallResult,
    ReflectResponse,
    RetainResponse,
    BankProfileResponse,
} from '@vectorize-io/hindsight-client';

// recall() returns RecallResponse
const response: RecallResponse = await client.recall('my-bank', 'query');
const first: RecallResult = response.results[0];
console.log(first.text, first.type);

// reflect() returns ReflectResponse
const answer: ReflectResponse = await client.reflect('my-bank', 'question');
console.log(answer.text);

Full async example

import { HindsightClient } from '@vectorize-io/hindsight-client';

async function main() {
    const client = new HindsightClient({
        baseUrl: process.env.HINDSIGHT_BASE_URL ?? 'http://localhost:8888',
        apiKey: process.env.HINDSIGHT_API_KEY,
    });

    // Store several memories
    await client.retainBatch('agent-bank', [
        { content: 'User prefers concise answers', context: 'user feedback' },
        { content: 'User is building a Node.js application', context: 'project info' },
    ]);

    // Search
    const results = await client.recall('agent-bank', 'What is the user working on?');
    console.log('Recall results:');
    for (const r of results.results) {
        console.log(' •', r.text);
    }

    // Reflect
    const answer = await client.reflect('agent-bank', 'How should I respond to this user?');
    console.log('\nReflect answer:', answer.text);
}

main().catch(console.error);

Build docs developers (and LLMs) love