Quickstart

Quickstart Guide

This guide will walk you through the core workflow of MindSim: creating a Mind, training it with data (Snapshots), and running a Simulation.

Prerequisites

  1. Install the SDK: npm install mindsim
  2. Authenticate: Run mindsim auth in your terminal and follow the browser prompts.

The Workflow

1. Initialize the Client

Import the client and instantiate it. If you have run mindsim auth, you do not need to pass an API key explicitly.

1import { MindSim } from "mindsim";
2
3const mindsim = new MindSim();

2. Create a Mind

A “Mind” is the container for the digital persona you are building.

1const bobby = await mindsim.minds.create({
2 name: "Bobby Tables",
3 email: "bobby@test.com",
4 tags: ["developer", "sql-expert"],
5});
6
7console.log(`Created Mind: ${bobby.name} (ID: ${bobby.id})`);

3. Upload Training Data (Snapshot)

Upload a transcript, PDF, or document to train the mind. The SDK handles the file upload strategy automatically.

1import fs from "node:fs";
2
3// Read a file from your disk
4const fileBuffer = fs.readFileSync("./data/chat-history.pdf");
5
6// Create the snapshot
7const snapshot = await mindsim.snapshots.create(bobby.id, {
8 file: fileBuffer,
9 fileName: "chat-history.pdf",
10 contentType: "application/pdf"
11});
12
13console.log(`Processing Snapshot ID: ${snapshot.mindAssessmentId}`);

4. Wait for Processing

Snapshots take time to analyze. You must wait for the status to change to completed before simulating.

1const checkStatus = async () => {
2 const status = await mindsim.snapshots.getStatus(bobby.id, snapshot.mindAssessmentId);
3
4 if (status.status === 'completed') {
5 console.log("Mind is ready!");
6 return true;
7 } else if (status.status === 'failed') {
8 throw new Error("Snapshot processing failed.");
9 }
10
11 console.log("Still processing...");
12 return false;
13};

5. Run a Simulation

Once trained, you can ask the Mind how it would respond to a specific scenario.

1const simulation = await mindsim.simulations.run({
2 mindId: bobby.id,
3 scenario: {
4 message: "I'm thinking about skipping the input sanitization on this query to save time. What do you think?",
5 },
6});
7
8console.log("Bobby says:", simulation.message);