# Welcome to Brain 🧠

**Brain is a financial brain in one API.** Give an AI agent memory of a user's money, the rules to act on it safely, and a verifiable trail of everything it did.

```typescript
import { Brain } from "@brain/sdk";

const brain = new Brain({ apiKey: process.env.BRAIN_API_KEY });

// What's our cash position?
const answer = await brain.ask("acme", "What's our cash position right now?");

// Pay this invoice if it's under our limit; otherwise queue for approval.
const action = await brain.pay("acme", { invoiceId: "inv_8231" });

// Prove what just happened.
const proof = await brain.proof(action.id);
```

Three calls. One API key. No on-chain knowledge required. Brain handles the rest.

<table data-view="cards"><thead><tr><th></th><th></th><th data-type="content-ref"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>🚀 Quickstart</strong></td><td>Five minutes from <code>npm install</code> to a working integration.</td><td><a href="/pages/PbRFcMj0jEeGN8bAgAQD">/pages/PbRFcMj0jEeGN8bAgAQD</a></td><td></td></tr><tr><td><strong>🛠 Build</strong></td><td>Task-shaped guides. The patterns most apps need in their first hour.</td><td><a href="/pages/sMrrX25ZQX2RkFLnKr3L">/pages/sMrrX25ZQX2RkFLnKr3L</a></td><td></td></tr><tr><td><strong>📐 Concepts</strong></td><td>The mental model. Memory, policy, execution, proof.</td><td><a href="/pages/xLV8vzuuJnAyV80xBwME">/pages/xLV8vzuuJnAyV80xBwME</a></td><td></td></tr><tr><td><strong>📦 Protocol</strong></td><td>The deep stack. Six layers, smart contracts, on-chain anchoring.</td><td><a href="/pages/DGQRMedmp626EiwDlcTi">/pages/DGQRMedmp626EiwDlcTi</a></td><td></td></tr></tbody></table>

### What You Can Build

| In an afternoon                   | What it looks like                                                                |
| --------------------------------- | --------------------------------------------------------------------------------- |
| **A finance copilot**             | Ask natural-language questions about a tenant's money; get answers with citations |
| **A spending agent**              | Let an AI agent pay invoices under a limit, with anything bigger going to a human |
| **An ops dashboard**              | Read transactions, balances, obligations, and counterparties from one feed        |
| **An external agent integration** | Plug into any MCP-compatible runtime; full read and propose surface               |
| **A compliance trail**            | Every read, every decision, every action, exportable as a tamper-evident log      |

### Why Brain

Most fintech infrastructure was built for software written by humans. Brain is built for software written by agents.

| You don't write                          | Because Brain handles                                                        |
| ---------------------------------------- | ---------------------------------------------------------------------------- |
| Bank, ERP, and on-chain integrations     | Source ingestion across Plaid, NetSuite, Alchemy, Stripe, and more           |
| A memory layer for your agent            | A continuously updated record per tenant, queryable in natural language      |
| A permissioning DSL                      | Plain-English policies compiled to deterministic rules, signed by the tenant |
| A safe execution path                    | A deterministic gate that checks every payment before it leaves              |
| An audit trail your customers can verify | A Merkle-anchored history on Base L2                                         |

### A First Request

```bash
npm install @brain/sdk
```

```typescript
import { Brain } from "@brain/sdk";

const brain = new Brain({ apiKey: process.env.BRAIN_API_KEY });

const tenant = await brain.tenants.get("acme");
console.log(tenant.displayName);
```

**→ Continue to the Quickstart**

### What's in These Docs

| Section         | For                     |
| --------------- | ----------------------- |
| Quickstart      | Your first integration  |
| Build           | Common patterns         |
| Concepts        | The mental model        |
| Protocol        | How it works underneath |
| API Reference   | Every endpoint          |
| MCP Server      | For external AI agents  |
| Smart Contracts | The on-chain surface    |
| Resources       | Errors, status, support |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.brain.fi/welcome-to-brain.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
