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

# SDK Overview

> Install and use the Refrain TypeScript SDK for programmatic browser automation.

## Overview

The **Refrain SDK** provides programmatic access to runbook execution from your TypeScript/JavaScript applications. It never reads `process.env` — all configuration is passed explicitly.

## Install

<CodeGroup>
  ```bash npm theme={null}
  npm install @refrainai/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @refrainai/sdk
  ```
</CodeGroup>

## Quick start

```typescript theme={null}
import { Refrain, loadRunbook } from "@refrainai/sdk";

// 1. Create client
const client = new Refrain({
  ai: {
    modelId: "claude-sonnet-4-6",
    provider: "anthropic",
    apiKey: "sk-ant-...",
  },
  headless: true,
});

// 2. Load runbook
const runbook = await loadRunbook("./runbooks/login-flow.yaml");

// 3. Execute
const report = await client.execute(runbook, {
  contextMarkdown: "# Login Info\n- Use staging credentials",
  variables: { username: "user@example.com" },
  secrets: { password: "secret123" },
});

// 4. Check results
console.log(`${report.succeeded}/${report.totalSteps} steps succeeded`);

// 5. Cleanup
await client.dispose();
```

## Key exports

| Export        | Type     | Description                        |
| ------------- | -------- | ---------------------------------- |
| `Refrain`     | class    | Main client for local execution    |
| `loadRunbook` | function | Load and parse a runbook YAML file |

## Design principles

* **Zero `process.env`** — All configuration passed explicitly via constructor and method arguments
* **Non-interactive** — No user prompts; unresolved required variables throw errors
* **Plan-aware** — Features silently disabled if not available in your plan tier
* **Comprehensive diagnostics** — Step results include retry counts, resolve methods, and failure categories

## Next steps

<CardGroup cols={2}>
  <Card title="Local Execution" icon="laptop" href="/sdk/local-execution">
    Refrain class, configuration, and execution options.
  </Card>

  <Card title="Type Reference" icon="code" href="/sdk/types">
    All exported types organized by category.
  </Card>

  <Card title="Examples" icon="book" href="/sdk/examples">
    Practical examples for common use cases.
  </Card>
</CardGroup>
