Skip to main content

Prerequisites

  • A Minns API key — create one on your project page (see Authentication)
  • Node.js 18 or higher
  • npm or your preferred package manager

Install the SDK

npm install minns-sdk

Initialize the client

import { createClient } from 'minns-sdk';

const client = createClient({
  baseUrl: "https://minns.ai/api/",
  apiKey: process.env.MINNS_API_KEY,
  defaultAsync: true,
  autoBatch: true,
  batchInterval: 100,
  batchMaxSize: 20,
});

Log your first event

Use the fluent event builder to send a user message tied to a goal:
const response = await client.event("movie-bot", { agentId: 1, sessionId: 5001 })
  .context("I want to book Interstellar for tonight.", "conversation")
  .goal("book_movie", 5)
  .send();

console.log(response);
// { success: true, nodes_created: 5, patterns_detected: 2, processing_time_ms: 15 }

Log an action with an outcome

const actionResponse = await client.event("movie-bot", { agentId: 1, sessionId: 5001 })
  .action("book_movie_ticket", { movie: "Interstellar", seat: "H12" })
  .outcome({ confirmation_id: "CONF-123" })
  .goal("book_movie", 5, 1.0) // progress = 1.0 completes the episode
  .send();

Recall memories

After your agent has completed a few episodes, you can query for relevant past experiences:
const memories = await client.getContextMemories({
  active_goals: [{ id: 101, description: "book_movie", priority: 0.9, progress: 0.5, subgoals: [] }],
  environment: { variables: { user_id: "user_99" }, temporal: { deadlines: [], patterns: [] } },
  resources: {
    computational: { cpu_percent: 50.0, memory_bytes: 1024000, storage_bytes: 1024000000, network_bandwidth: 1000 },
    external: {}
  }
});

console.log(memories);

Search extracted knowledge

Query soft facts using natural language:
const claims = await client.searchClaims({
  query_text: "What are the user's movie preferences?",
  top_k: 3,
  min_similarity: 0.7,
});

claims.forEach(c => console.log(c.claim_text));

Get action suggestions

Ask the Policy Guide what your agent should do next:
const suggestions = await client.getActionSuggestions(contextHash);

suggestions.forEach(s => {
  console.log(`${s.action_name}${(s.success_probability * 100).toFixed(0)}% success`);
  console.log(`  Reasoning: ${s.reasoning}`);
});

Clean shutdown

Always flush the event buffer before your process exits:
await client.flush();
If you skip flush(), any events still in the local auto-batch queue will be lost.

Next steps

Event builder

Master the full fluent API for building rich events.

Core concepts

Understand how Events, Episodes, and Memories connect.

Query selection guide

Learn which search to use for every situation.

API Reference

Explore every endpoint in detail.