## Documentation Index

Fetch the complete documentation index at: [/llms.txt](/content/llms.txt)

Use this file to discover all available pages before exploring further.

JavaScript

- [JavaScriptInstantSearch.js](/content/doc/api-reference/widgets/chat/js/index.html)
- [ReactReact InstantSearch](/content/doc/api-reference/widgets/chat/react/index.html)

This widget is **in beta** and is subject to change in minor versions.

For more information, see [Agent Studio](/content/doc/guides/algolia-ai/agent-studio/index.html).

### Signature

```javascript
chat({
  container: string | HTMLElement,
  // Required parameter, either one of
  agentId?: string,
  transport?: object,
  // Optional parameters (agentId only)
  feedback?: boolean,
  requestOptions?: object,
  // Optional parameters
  getSearchPageURL?: function,
  tools?: object,
  context?: object | function,
  initialMessages?: array,
  initialUserMessage?: string,
  resume?: boolean,
  persistence?: boolean,
  disableTriggerValidation?: boolean,
  onFinish?: function,
  requiresSearch?: boolean,
  showReasoning?: boolean,
  templates?: object,
  cssClasses?: object,
});
```

### Import

**Package manager**

**CDN**

```javascript
import { chat } from 'instantsearch.js/es/widgets';
```

```javascript
// "chat" is not available from the UMD build.
// Please use InstantSearch.js with a packaging system.
```

### About this widget

Use the `chat` widget to display a chat interface that interacts with a generative AI assistant. See also: [Agent Studio](/content/doc/guides/algolia-ai/agent-studio/index.html)

The `chat` widget renders the chat panel but doesn’t provide a way to open it. Add one entry point to the same InstantSearch instance: the [`chatTrigger`](/content/doc/api-reference/widgets/chat-trigger/js/index.html) widget, [AI mode](/content/doc/guides/building-search-ui/going-further/chat-customization/ai-search-experience/js/index.html) on a `searchBox` or autocomplete, or an inline layout. Otherwise, the widget logs a development warning. To silence it, set [`disableTriggerValidation`](/content/doc/api-reference/widgets/chat/js#param-disable-trigger-validation/index.html) to `true`.

### Examples

JavaScript

```javascript
chat({
  container: '#chat',
  agentId: '8f7c4a2d-3b1e-4d5f-9a6c-e2b1f5d0c3e9',
});

chatTrigger({
  container: '#chat-trigger',
});
```

### Options

#### container

string | HTMLElement

**Required**  
The CSS Selector or `HTMLElement` to insert the widget into.

```javascript
chat({
  container: '#chat',
});
```

```javascript
chat({
  container: document.querySelector('#chat'),
});
```

#### agentId

string  
The unique identifier of the agent to connect to. You can find the `agentId` in the [Agent Studio dashboard](https://dashboard.algolia.com/generativeAi/agent-studio/agents).

```javascript
chat({
  // ...
  agentId: '8f7c4a2d-3b1e-4d5f-9a6c-e2b1f5d0c3e9',
});
```

#### feedback

boolean  
Whether to enable feedback (thumbs up/down) on assistant messages. Only available when using `agentId`.

```javascript
chat({
  // ...
  agentId: '8f7c4a2d-3b1e-4d5f-9a6c-e2b1f5d0c3e9',
  feedback: true,
});
```

#### transport

object  
A custom transport object to handle the communication between the chat widget and the agent. The API endpoint must be compatible with [Vercel AI SDK 5](https://ai-sdk.dev/docs/ai-sdk-ui/transport#custom-transport-configuration).

```javascript
chat({
  // ...
  transport: {
    api: 'https://chatapi.example.com/api/v1/chat',
    headers: {
      'X-Session-Id': '8f7c4a2d-3b1e-4d5f-9a6c-e2b1f5d0c3e9',
      'X-Api-Version': '2025-01-01',
    },
  },
});
```

... (truncated for brevity)
