> ## Documentation Index
> Fetch the complete documentation index at: https://docs.minns.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get Minns Memory Layer running and log your first event in under 5 minutes.

## Prerequisites

* A **Minns API key** — create one on your [project page](https://minns.ai) (see [Authentication](/authentication))
* **Node.js** 18 or higher
* **npm** or your preferred package manager

## Install the SDK

<CodeGroup>
  ```bash npm theme={null}
  npm install minns-sdk
  ```

  ```bash yarn theme={null}
  yarn add minns-sdk
  ```

  ```bash pnpm theme={null}
  pnpm add minns-sdk
  ```
</CodeGroup>

## Initialize the client

```typescript theme={null}
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:

```typescript theme={null}
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

```typescript theme={null}
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:

```typescript theme={null}
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:

```typescript theme={null}
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:

```typescript theme={null}
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:

```typescript theme={null}
await client.flush();
```

<Warning>
  If you skip `flush()`, any events still in the local auto-batch queue will be lost.
</Warning>

## Next steps

<CardGroup cols={2}>
  <Card title="Event builder" icon="wrench" href="/sdk/event-builder">
    Master the full fluent API for building rich events.
  </Card>

  <Card title="Core concepts" icon="lightbulb" href="/concepts">
    Understand how Events, Episodes, and Memories connect.
  </Card>

  <Card title="Query selection guide" icon="magnifying-glass" href="/guides/query-selection">
    Learn which search to use for every situation.
  </Card>

  <Card title="API Reference" icon="square-terminal" href="/api-reference/introduction">
    Explore every endpoint in detail.
  </Card>
</CardGroup>
