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

# What is Kairn?

> Agent infrastructure for AI products. One API to add persistent, memory-aware agents to your product.

## The problem with building AI features

Most teams integrate LLMs directly — glue code, prompt templates, manual context injection. It works for demos. It breaks in production.

* **No memory** — every conversation starts from zero
* **No user isolation** — concurrent users share state or fight over it
* **No autonomy** — agents only run when users ask
* **Ops overhead** — you own the infra, the retries, the scaling

Kairn is the layer between your product and the LLM. It handles the hard parts so you ship the agent, not the scaffolding.

## What Kairn gives you

> [card] Per-user memory
>
> Every user gets a persistent key-value store. The agent reads it at invocation time, writes to it during the session. Memory persists across conversations — no re-seeding required.

> [card] Soul-based identities
>
> Define agent identities once. One soul serves all your users with zero shared state. Change the soul's instructions and every user gets the update instantly.

> [card] Streaming out of the box
>
> `kairn.stream()` yields typed events — tokens, tool calls, memory writes, done. Wire directly into your Next.js route and stream to the browser.

> [card] Mandates — scheduled agents
>
> Agents that run on their own. Cron-triggered, user-scoped, memory-aware. Weekly check-ins, daily reports, proactive nudges — without user interaction.

## How it works

**1. Create a soul**

Define the agent's identity, instructions, and tool access. One soul powers all your users.

**2. Seed memory from your DB**

Before each conversation, write user context from your database into the agent's memory store. Name, plan, recent actions — whatever the agent needs to personalise.

**3. Invoke or stream**

Call `kairn.invoke()` or `kairn.stream()` from your API route. The agent picks up context, runs, and writes what it learned back to memory.

**4. Read back what the agent wrote**

After each turn, `memoryDelta` tells you exactly what the agent updated. Sync it back to your own DB or surface it directly in your UI.

## Pick your path

> [card] [Quickstart](https://docs.kairn.sh/quickstart.md)
>
> From zero to your first agent invocation in under 5 minutes.

> [card] [Core concepts](https://docs.kairn.sh/concepts.md)
>
> Souls, memory, sessions, mandates — the mental model explained.

> [card] [SDK reference](https://docs.kairn.sh/sdk-reference.md)
>
> Full API for every method, type, and error.

> [card] [Use cases](https://docs.kairn.sh/use-cases/customer-support.md)
>
> Real product scenarios with working code you can adapt.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.