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

# Client

> Create and configure the TryAgent SDK client.

# Client

Install the SDK and create a client. The client is the entry point for every
SDK call.

```bash theme={null}
pnpm add @tryagent/sdk
```

```typescript theme={null}
import { TryAgent } from "@tryagent/sdk";

const tryagent = new TryAgent({
  apiKey: process.env.TRYAGENT_API_KEY!,
});
```

## Authentication

Provide exactly one of `apiKey`, `token`, or `getToken`. Passing zero or more
than one throws at construction.

| Option     | Type                              | Use it for                                                                                    |
| ---------- | --------------------------------- | --------------------------------------------------------------------------------------------- |
| `apiKey`   | `string`                          | Agent runtimes creating escalations. A workspace key that looks like `ain_live_...`.          |
| `token`    | `string`                          | A static user bearer token. An alternative to a scoped API key for reviewer and read methods. |
| `getToken` | `() => string \| Promise<string>` | A user token fetched lazily per request — refresh it without recreating the client.           |

```typescript theme={null}
// Agent runtime — create escalations with a workspace API key.
const agent = new TryAgent({ apiKey: process.env.TRYAGENT_API_KEY! });

// Reviewer / dashboard — read and decide on behalf of a user.
const reviewer = new TryAgent({
  getToken: () => session.getAccessToken(),
});
```

<Note>
  Read and reviewer methods (`list`, `get`, `acknowledge`, `decide`, `cancel`)
  work with an `ain_live_` API key or a workspace user `token`/`getToken`. Keys
  are issued with all escalation scopes (`escalations:write`, `:read`,
  `:acknowledge`, `:decide`, `:cancel`) by default; pass a narrower `scopes`
  array to `POST /api-keys` to restrict one. A call missing the scope returns
  `403`.
</Note>

## Options

| Option    | Default                   | Description                                                                               |
| --------- | ------------------------- | ----------------------------------------------------------------------------------------- |
| `baseUrl` | `https://api.tryagent.ai` | Override only for local development or tests.                                             |
| `fetch`   | global `fetch`            | Supply a custom `fetch` implementation (proxies, instrumentation, non-standard runtimes). |

```typescript theme={null}
const tryagent = new TryAgent({
  apiKey: process.env.TRYAGENT_API_KEY!,
  baseUrl: "http://localhost:4000",
});
```

## Resources

* [Escalations](/sdk/escalations) — create, read, and decide on escalations.
* [Webhooks](/sdk/webhooks) — verify signed resume callbacks.
* [Errors](/sdk/errors) — handle API, network, and signature failures.
