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

# Configure the Figranium SDK Client

> Configure the Figranium JavaScript SDK: baseUrl, timeouts, custom fetch, default headers, and session versus API-key authentication.

The `Figranium` class takes a single options object. Every option is optional; the SDK falls back to sensible defaults so a local install works with `new Figranium({ apiKey })`.

## Constructor options

<ParamField path="baseUrl" type="string">
  Absolute URL of your Figranium server. Must use `http` or `https`. Trailing slashes are trimmed. Defaults to `http://localhost:11345`.
</ParamField>

<ParamField path="apiKey" type="string">
  API key sent as `Authorization: Bearer <key>` by default. Mutually exclusive with `session`.
</ParamField>

<ParamField path="apiKeyHeader" type="string">
  Header name for the API key. Either `"authorization"` (default) or `"x-api-key"`.
</ParamField>

<ParamField path="session" type="boolean">
  Set to `true` to send credentials (`fetch(..., { credentials: "include" })`) so cookies are attached to every request. Required for `settings.*` endpoints. Mutually exclusive with `apiKey`.
</ParamField>

<ParamField path="timeoutMs" type="number">
  Client-wide default timeout for non-stream requests, in milliseconds. Defaults to `30_000` (30 seconds). Streams have no default timeout.
</ParamField>

<ParamField path="fetch" type="function">
  Any `fetch`-compatible implementation. Useful for tracing, retries, cookie jars, test doubles, or proxying through instrumented HTTP clients.
</ParamField>

<ParamField path="headers" type="HeadersInit">
  Default headers merged into every request. Per-call `headers` override these.
</ParamField>

## Option details

### `baseUrl`

```ts theme={null}
new Figranium({ baseUrl: "https://figranium.example" });
```

### `apiKey` and `apiKeyHeader`

Pass `apiKey` to authenticate every request with an API key. By default the key is sent as `Authorization: Bearer <key>`. Set `apiKeyHeader: "x-api-key"` if your deployment expects that header.

```ts theme={null}
new Figranium({ apiKey: "fig_...", apiKeyHeader: "x-api-key" });
```

`apiKey` and `session` are mutually exclusive. See [Authentication](/docs/sdk/js/authentication).

### `session`

Set `session: true` to send credentials (`fetch(..., { credentials: "include" })`) so cookies are attached to every request. Required for `settings.*` endpoints, which are session-only.

```ts theme={null}
new Figranium({ baseUrl: "https://figranium.example", session: true });
```

<Note>
  Node's built-in `fetch` does not keep a cookie jar. For Node-based administration, provide a cookie-aware `fetch` implementation through the `fetch` option.
</Note>

### `timeoutMs`

Client-wide default timeout for non-stream requests, in milliseconds. Defaults to `30_000` (30 seconds). Streams have no default timeout; set a per-call `timeoutMs` if you want a terminal deadline.

```ts theme={null}
new Figranium({ apiKey: "fig_...", timeoutMs: 60_000 });
```

Individual requests can override this per call with `{ timeoutMs }`. See [Request options](/docs/sdk/js/request-options).

### `fetch`

Provide any `fetch`-compatible implementation. Useful for tracing, retries, cookie jars, test doubles, or proxying through instrumented HTTP clients.

```ts theme={null}
const figranium = new Figranium({
  apiKey: "fig_...",
  fetch: instrumentedFetch,
});
```

### `headers`

Default headers merged into every request. Per-call `headers` override these.

```ts theme={null}
new Figranium({
  apiKey: "fig_...",
  headers: { "x-client-name": "my-service" },
});
```

## Complete example

```ts theme={null}
import { Figranium } from "@figranium/sdk";

const figranium = new Figranium({
  baseUrl: process.env.FIGRANIUM_BASE_URL,
  apiKey: process.env.FIGRANIUM_API_KEY!,
  timeoutMs: 45_000,
  headers: { "x-client-name": "orders-worker" },
});
```

## Client resources

The `Figranium` instance exposes one property per resource, plus a few top-level convenience helpers.

| Property                                       | Purpose                                                              |
| :--------------------------------------------- | :------------------------------------------------------------------- |
| [`tasks`](/docs/sdk/js/resources/tasks)             | Save, update, delete, version, generate, and execute tasks           |
| [`executions`](/docs/sdk/js/resources/executions)   | List, inspect, stop, delete, clear, and stream runs                  |
| [`schedules`](/docs/sdk/js/resources/schedules)     | Configure, describe, disable, and inspect schedules                  |
| [`captures`](/docs/sdk/js/resources/captures)       | List and delete recordings and screenshots; manage cookies           |
| [`credentials`](/docs/sdk/js/resources/credentials) | Manage output credentials and browse Baserow metadata                |
| [`browser`](/docs/sdk/js/resources/browser)         | Open browser sessions, highlight selectors, inspect headful sessions |
| [`execution`](/docs/sdk/js/resources/execution)     | Direct `scrape`, `agent`, and `headful` execution endpoints          |
| [`settings`](/docs/sdk/js/resources/settings)       | Session-protected API keys, AI providers, theme, user agent, proxies |
| [`auth`](/docs/sdk/js/resources/auth)               | Initial setup and session login, logout, and current-user methods    |
| [`health`](/docs/sdk/js/resources/health)           | Service health check                                                 |

Top-level shortcuts:

* `figranium.runTask(id, input?)` proxies to `tasks.run`.
* `figranium.scrape(input)` proxies to `execution.scrape`.
* `figranium.agent(input)` proxies to `execution.agent`.
* `figranium.headful(input)` proxies to `execution.headful`.
