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

# TypeScript SDK

> Use the typed Node.js client for browser runs, workflows, and published Blueprints.

The `@infragrid/sdk` package provides a typed client, workflow builder, polling helpers, and the Infragrid CLI. It requires Node.js 18 or newer.

<Note>
  Version 0.1.0 is implemented in the source workspace but is not yet represented as published to npm.
</Note>

## Install

<Tabs>
  <Tab title="Source checkout">
    ```bash theme={null}
    npm ci
    npm run build --workspace @infragrid/sdk
    npm install /absolute/path/to/agentic-browser/packages/sdk
    ```
  </Tab>

  <Tab title="After npm release">
    ```bash theme={null}
    npm install @infragrid/sdk
    ```
  </Tab>
</Tabs>

## Create a client

```typescript theme={null}
import { Infragrid } from "@infragrid/sdk"

const client = new Infragrid() // reads INFRAGRID_API_KEY
```

Constructor options:

| Option       | Default                                | Purpose                                 |
| ------------ | -------------------------------------- | --------------------------------------- |
| `apiKey`     | `INFRAGRID_API_KEY`                    | Workspace server credential             |
| `baseUrl`    | `INFRAGRID_BASE_URL` or production API | Explicit preview or self-hosted URL     |
| `timeoutMs`  | 30,000                                 | Per-request timeout                     |
| `maxRetries` | 2                                      | Retries for safe or idempotent requests |
| `fetch`      | `globalThis.fetch`                     | Custom transport                        |

## Browser runs

```typescript theme={null}
const created = await client.runs.create({
  task: "Open example.com and summarize it.",
  metadata: { jobId: "job_123" },
  idempotencyKey: "job-123-v1"
})

const finished = await client.runs.wait(created.id, {
  pollIntervalMs: 2_000,
  timeoutMs: 15 * 60_000,
  onUpdate: (run) => console.log(run.status, run.step_count)
})
```

| Method                         | Returns                          |
| ------------------------------ | -------------------------------- |
| `runs.create(input)`           | Accepted `CloudRun`              |
| `runs.get(runId)`              | One `CloudRun`                   |
| `runs.list({ limit, offset })` | Bounded run list                 |
| `runs.wait(runId, options)`    | Terminal `CloudRun`              |
| `runs.cancel(runId)`           | Cancelled or terminal `CloudRun` |

Pass an `AbortSignal` to `runs.wait` to interrupt polling and active retry backoff.

## Ordered workflows

```typescript theme={null}
const finished = await client
  .workflow("pricing-review")
  .navigate("https://example.com")
  .extract("Return the page heading", { name: "heading" })
  .run()
```

See [Ordered workflows](/guides/ordered-workflows) for every builder primitive.

## Published Blueprints

| Method                                       | Purpose                              |
| -------------------------------------------- | ------------------------------------ |
| `blueprints.list({ limit })`                 | Discover active published Blueprints |
| `blueprints.get(blueprintId)`                | Retrieve one public definition       |
| `blueprints.runs.create(blueprintId, input)` | Start a pinned revision              |
| `blueprints.runs.get(runId)`                 | Retrieve one Blueprint run           |
| `blueprints.runs.list(options)`              | Cursor-page Blueprint runs           |
| `blueprints.runs.events(runId, { after })`   | Read a safe snapshot                 |
| `blueprints.runs.wait(runId, options)`       | Wait for a terminal run              |
| `blueprints.runs.cancel(runId)`              | Cancel a run                         |

## Errors

All exported error classes derive from `InfragridError` and expose `status`, `body`, `requestId`, and response `headers` when available. See [Errors and retries](/production/errors-retries).


## Related topics

- [Infragrid overview](/overview.md)
- [Versioning](/production/versioning.md)
- [CLI](/tools/cli.md)
- [Quickstart](/get-started/quickstart.md)
- [Changelog](/changelog.md)
