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

# Attributes and init options

> Every script tag attribute and every PaperlinkAIChat.init option, with types and defaults.

You configure the widget with attributes on the script tag or with options that you pass to `window.PaperlinkAIChat.init`. Use the attributes for a standard install. Use `init` when you need an option that has no attribute, as [Start the widget from your code](https://paperlinkai.com/docs/developers/install/script-tag.md#start-the-widget-from-your-code) explains.

**Script tag attributes**

**data-api-key** `string`

Your API key. The key starts with `pl_live_` for production. With this attribute, the tag starts a floating widget. Without it, the tag starts no widget and you call `init`.

**data-api-base-url** `string` (default: the URL of the script without /widget.js)

The API base URL that the widget calls. Most sites never set this attribute.

**data-turnstile-site-key** `string`

Overrides the Turnstile site key. Without this attribute, the widget uses the key from your bot configuration. Production ignores this value and always uses the Paperlink AI key.

**data-open** `string`

Set the value to `"true"` to open the widget when the page loads.

**init options**

**apiKey** `string` *required*

Your API key. `init` throws an error when this option is empty.

**apiBaseUrl** `string` (default: the API base URL of the script tag)

The API base URL. The default is `data-api-base-url`, or else the URL of the script without `/widget.js`. Most sites never set this option. Values that end in `/api/v1` or `/v1` are accepted.

**mode** `'floating' | 'inline'` (default: 'floating')

`floating` shows a launcher and a pop-up panel that sits in a corner of the page. `inline` renders the chat panel inside `container` and shows no launcher.

**container** `HTMLElement` (default: document.body)

The element that holds the widget. This option is required when `mode` is `'inline'`.

**defaultOpen** `boolean`

Floating mode only. Starts the widget with the panel open.

**turnstileSiteKey** `string`

Overrides the Turnstile site key from the bot configuration. Production ignores this value and always uses the Paperlink AI key.

**historyLimit** `number` (default: 20)

The number of past messages to restore when a stored conversation reopens. Use a value from 1 to 100. The server rejects other values, and the widget then restores no history.

**onAnalyticsEvent** `(event) =\> void`

A function that receives metadata-only events. It never receives the text of a question or an answer. See [Analytics events](https://paperlinkai.com/docs/developers/configure/analytics-events.md).

## Where appearance lives

> [!NOTE]
>
> The bot name, brand color, logo, welcome message and widget position are dashboard settings. Change them in the dashboard, as [Appearance](https://paperlinkai.com/docs/guides/bot/appearance.md) explains. The widget has no theme, CSS or locale options.

## Errors that init throws

`init` checks your options before it mounts the widget. It throws one of these errors.

| Message | Cause |
| - | - |
| `PaperlinkAIChat.init requires an apiKey` | The `apiKey` option is missing or empty. |
| `PaperlinkAIChat can only be initialized in a browser` | `init` ran where `window` or `document` does not exist, for example on the server. |
| `PaperlinkAIChat.init with mode 'inline' requires a container element` | `mode` is `'inline'` and you passed no `container`. |

> **[JavaScript API](https://paperlinkai.com/docs/developers/configure/javascript-api.md)**
>
> Control the widget from your own code with open, close, resetSession and destroy.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.