> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Interface representing a chat session for use with server prompt templates that enables sending chat messages and maintains conversation history.

**Signature:**

    export interface TemplateChatSession 

## Properties

| Property | Type | Description |
|---|---|---|
| [params](https://firebase.google.com/docs/reference/js/ai.templatechatsession#templatechatsessionparams) | [StartTemplateChatParams](https://firebase.google.com/docs/reference/js/ai.starttemplatechatparams#starttemplatechatparams_interface) | ***(Public Preview)*** |
| [requestOptions](https://firebase.google.com/docs/reference/js/ai.templatechatsession#templatechatsessionrequestoptions) | [RequestOptions](https://firebase.google.com/docs/reference/js/ai.requestoptions#requestoptions_interface) | ***(Public Preview)*** |

## Methods

| Method | Description |
|---|---|
| [getHistory()](https://firebase.google.com/docs/reference/js/ai.templatechatsession#templatechatsessiongethistory) | ***(Public Preview)*** Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. |
| [sendMessage(request, singleRequestOptions)](https://firebase.google.com/docs/reference/js/ai.templatechatsession#templatechatsessionsendmessage) | ***(Public Preview)*** Sends a chat message and receives a non-streaming [GenerateContentResult](https://firebase.google.com/docs/reference/js/ai.generatecontentresult#generatecontentresult_interface) |
| [sendMessageStream(request, singleRequestOptions)](https://firebase.google.com/docs/reference/js/ai.templatechatsession#templatechatsessionsendmessagestream) | ***(Public Preview)*** Sends a chat message and receives the response as a [GenerateContentStreamResult](https://firebase.google.com/docs/reference/js/ai.generatecontentstreamresult#generatecontentstreamresult_interface) containing an iterable stream and a response promise. |

## TemplateChatSession.params

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

**Signature:**

    params: StartTemplateChatParams;

## TemplateChatSession.requestOptions

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

**Signature:**

    requestOptions?: RequestOptions;

## TemplateChatSession.getHistory()

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history.

**Signature:**

    getHistory(): Promise<Content[]>;

**Returns:**

Promise\<[Content](https://firebase.google.com/docs/reference/js/ai.content#content_interface)\[\]\>

## TemplateChatSession.sendMessage()

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Sends a chat message and receives a non-streaming [GenerateContentResult](https://firebase.google.com/docs/reference/js/ai.generatecontentresult#generatecontentresult_interface)

**Signature:**

    sendMessage(request: string | Array<string | Part>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| request | string \| Array\<string \| [Part](https://firebase.google.com/docs/reference/js/ai#part)\> |   |
| singleRequestOptions | [SingleRequestOptions](https://firebase.google.com/docs/reference/js/ai.singlerequestoptions#singlerequestoptions_interface) |   |

**Returns:**

Promise\<[GenerateContentResult](https://firebase.google.com/docs/reference/js/ai.generatecontentresult#generatecontentresult_interface)\>

## TemplateChatSession.sendMessageStream()

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Sends a chat message and receives the response as a [GenerateContentStreamResult](https://firebase.google.com/docs/reference/js/ai.generatecontentstreamresult#generatecontentstreamresult_interface) containing an iterable stream and a response promise.

**Signature:**

    sendMessageStream(request: string | Array<string | Part>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| request | string \| Array\<string \| [Part](https://firebase.google.com/docs/reference/js/ai#part)\> |   |
| singleRequestOptions | [SingleRequestOptions](https://firebase.google.com/docs/reference/js/ai.singlerequestoptions#singlerequestoptions_interface) |   |

**Returns:**

Promise\<[GenerateContentStreamResult](https://firebase.google.com/docs/reference/js/ai.generatecontentstreamresult#generatecontentstreamresult_interface)\>