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

# TypeScript SDK

> The official TypeScript client for the IBF API.

Install via npm or your preferred package manager.

```bash theme={null}
npm install @blankstate/sdk
```

## Initialise

```typescript theme={null}
import { Blankstate } from "@blankstate/sdk";

const bks = new Blankstate({ apiKey: process.env.BKS_KEY });
```

## Sense

```typescript theme={null}
const result = await bks.sense({
  content: "I understand this has been a difficult quarter...",
  modality: "text",
  protocols: ["empathy"],
  actantId: "user_001",
});

console.log(result.score); // 0.74
console.log(result.metamarkers); // [{nuance: "acknowledges-emotional-state", ...}]
```

## Use a Blueprint

```typescript theme={null}
const result = await bks.sense({
  content: "...",
  modality: "text",
  blueprint: "advisory-quality",
  actantId: "user_001",
});
```

## Get a Signature

```typescript theme={null}
const sig = await bks.signatures.get("user_001");
console.log(sig.vector); // Float32Array
```

## Stream

The SDK supports streaming metamarkers for real-time use cases.

```typescript theme={null}
const stream = await bks.sense.stream({
  content: "...",
  modality: "text",
  protocols: ["empathy"],
});

for await (const event of stream) {
  console.log(event); // {type: "metamarker", data: {...}}
}
```

## Error handling

```typescript theme={null}
import { BlankstateError } from "@blankstate/sdk";

try {
  const result = await bks.sense({ ... });
} catch (err) {
  if (err instanceof BlankstateError) {
    console.error(err.status, err.code, err.message);
  }
}
```
