docs-devsite/ai.templategenerativemodel.md
Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference
{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}
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.
GenerativeModel APIs that execute on a server-side template.
This class should only be instantiated with getTemplateGenerativeModel()<!-- -->.
<b>Signature:</b>
export declare class TemplateGenerativeModel
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(ai, requestOptions) | <b><i>(Public Preview)</i></b> Constructs a new instance of the <code>TemplateGenerativeModel</code> class |
| Property | Modifiers | Type | Description |
|---|---|---|---|
| requestOptions | RequestOptions | <b><i>(Public Preview)</i></b> Additional options to use when making requests. |
| Method | Modifiers | Description |
|---|---|---|
| generateContent(templateId, templateVariables, singleRequestOptions) | <b><i>(Public Preview)</i></b> Makes a single non-streaming call to the model and returns an object containing a single GenerateContentResponse<!-- -->. | |
| generateContentStream(templateId, templateVariables, singleRequestOptions) | <b><i>(Public Preview)</i></b> Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | |
| startChat(params) | <b><i>(Public Preview)</i></b> Starts a TemplateChatSession that will use this template to respond to messages. |
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.
Constructs a new instance of the TemplateGenerativeModel class
<b>Signature:</b>
constructor(ai: AI, requestOptions?: RequestOptions);
| Parameter | Type | Description |
|---|---|---|
| ai | AI | |
| requestOptions | 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.
Additional options to use when making requests.
<b>Signature:</b>
requestOptions?: 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.
Makes a single non-streaming call to the model and returns an object containing a single GenerateContentResponse<!-- -->.
<b>Signature:</b>
generateContent(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;
| Parameter | Type | Description |
|---|---|---|
| templateId | string | The ID of the server-side template to execute. |
| templateVariables | Record<string, unknown> | A key-value map of variables to populate the template with. |
| singleRequestOptions | SingleRequestOptions |
<b>Returns:</b>
Promise<GenerateContentResult<!-- -->>
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.
Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response.
<b>Signature:</b>
generateContentStream(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;
| Parameter | Type | Description |
|---|---|---|
| templateId | string | The ID of the server-side template to execute. |
| templateVariables | Record<string, unknown> | A key-value map of variables to populate the template with. |
| singleRequestOptions | SingleRequestOptions |
<b>Returns:</b>
Promise<GenerateContentStreamResult<!-- -->>
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.
Starts a TemplateChatSession that will use this template to respond to messages.
<b>Signature:</b>
startChat(params: StartTemplateChatParams): TemplateChatSession;
| Parameter | Type | Description |
|---|---|---|
| params | StartTemplateChatParams | Configurations for the chat, including the template ID and input variables. |
<b>Returns:</b>