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

# API reference

> Plugin options, composable, components, and events exposed by the Vue SDK.

## Plugin / `AdsProvider` options

**publisherToken** `string` *required*

Your unique publisher token.

**userId** `string` *required*

Unique identifier that remains the same for the user's lifetime (used for retargeting and rewarded ads).

**userEmail** `string`

Email of the user.

**conversationId** `string` *required*

Unique ID of the conversation.

**enabledPlacementCodes** `array`

Placement codes enabled for the conversation. Defaults to `['inlineAd']`.

**character** `object`

Character object used in this conversation.

**Properties**

**id** `string` *required*

Unique ID of the character.

**name** `string` *required*

Name of the character.

**avatarUrl** `string` *required*

URL of the character's avatar.

**isNsfw** `boolean`

Indicates whether the character is NSFW.

**greeting** `string`

The character's greeting.

**persona** `string`

Description of the character's personality.

**tags** `array`

Tags describing the character.

**regulatory** `object`

Regulatory object used in this conversation.

**Properties**

**gdpr** `integer`

Indicates whether the request is subject to GDPR regulations. (0 = No, 1 = Yes, null = Unknown)

**gdprConsent** `string`

The IAB Transparency and Consent Framework (TCF) consent string.

**coppa** `integer`

Indicates whether the request is subject to COPPA. (0 = No, 1 = Yes, null = Unknown)

**gpp** `string`

Global Privacy Platform (GPP) consent string.

**gppSid** `array`

IDs of the GPP sections that apply to this transaction.

**usPrivacy** `string`

Signals regarding consumer privacy under US privacy regulations (e.g., CCPA, LSPA).

**variantId** `string`

Publisher-provided identifier for the user cohort (for A/B testing).

**onEvent** `function`

Callback triggered when an event occurs. See [Supported events](#supported-events) below.

**onDebugEvent** `function`

Callback for SDK-internal diagnostic events. Receives `(name, data?)` — useful when investigating preload/session behaviour during integration. Off by default.

## `useAds()` composable

Returns `addMessage`, a forwarder that always routes to the current session. If `<AdsProvider>` swaps the session (e.g. `publisherToken` change), the next call hits the new one automatically.

**addMessage** `function` *required*

`(message: Message, options?: AddMessageOptions) => void` — register a new chat message with the SDK. The next preload is scheduled automatically.

`AddMessageOptions` currently exposes one flag:

**AddMessageOptions**

**trackOnly** `boolean`

When `true`, the preload request still goes out for analytics but no ad will be shown for this message. Use this to suppress ads without losing tracking data.

## `Message` shape

**id** `string` *required*

Unique ID of the message.

**role** `string` *required*

Role of the message (`user` or `assistant`).

**content** `string` *required*

Message text.

**createdAt** `Date` *required*

Timestamp when the message was created.

## `InlineAd` properties

**messageId** `string` *required*

Unique ID of the message this ad belongs to.

**code** `string`

Placement code provided during onboarding. Defaults to `'inlineAd'`.

**theme** `string`

Theme of the ad, e.g. `light` or `dark`.

### Slots

**wrapper** `slot`

Render-prop slot that lets you wrap the ad iframe in your own markup. The slot receives the rendered ad as `ad`:

```vue theme={null}
<InlineAd :messageId="m.id">
  <template #wrapper="{ ad }">
    <div class="my-ad-card">{{ ad }}</div>
  </template>
</InlineAd>
```

## Supported events

### `ad.clicked`

The user has clicked the ad.

**Payload**

**id** `string`

Ad ID.

**content** `string`

Generated ad content.

**messageId** `string`

Message ID.

**url** `string`

Click URL.

**format** `string`

Ad format.

**area** `string`

Region of the creative the user clicked (e.g. `'cta'`, `'banner'`).

### `ad.viewed`

The user has viewed the ad.

**Payload**

**id** `string`

Ad ID.

**content** `string`

Generated ad content.

**messageId** `string`

Message ID.

**format** `string`

Ad format.

**revenue** `number`

The revenue of the ad (eCPM in USD).

### `ad.filled`

Ad is available.

**Payload**

**id** `string`

Ad ID.

**code** `string`

Placement code this ad was matched to.

**revenue** `number`

The revenue of the ad (eCPM in USD).

### `ad.no-fill`

Ad is not available.

**Payload**

**skipCode** `string`

The code indicating the reason why the ad was skipped.

### `ad.render-started`

Triggered before the first token is received.

**Payload**

**id** `string`

Ad ID.

### `ad.render-completed`

Triggered after the last token is received.

**Payload**

**id** `string`

Ad ID.

### `ad.error`

Triggered when an error occurs.

**Payload**

**message** `string`

Error message.

**errCode** `string`

Error code.

### `video.started`

Triggered when the video playback starts.

**Payload**

**id** `string`

Ad ID.

### `video.completed`

Triggered when the video playback finishes.

**Payload**

**id** `string`

Ad ID.

### `reward.granted`

Triggered when a rewarded-ad reward is granted to the user.

**Payload**

**id** `string`

Ad ID.


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