TemplateGenerativeModel class Stay organized with collections Save and categorize content based on your preferences.
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 withgetTemplateGenerativeModel().
Signature:
exportdeclareclassTemplateGenerativeModelConstructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(ai, requestOptions) | (Public Preview) Constructs a new instance of theTemplateGenerativeModel class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| requestOptions | RequestOptions | (Public Preview) Additional options to use when making requests. |
Methods
| Method | Modifiers | Description |
|---|---|---|
| generateContent(templateId, templateVariables) | (Public Preview) Makes a single non-streaming call to the model and returns an object containing a singleGenerateContentResponse. | |
| generateContentStream(templateId, templateVariables) | (Public Preview) 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. |
TemplateGenerativeModel.(constructor)
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 theTemplateGenerativeModel class
Signature:
constructor(ai:AI,requestOptions?:RequestOptions);Parameters
| Parameter | Type | Description |
|---|---|---|
| ai | AI | |
| requestOptions | RequestOptions |
TemplateGenerativeModel.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.
Signature:
requestOptions?:RequestOptions;TemplateGenerativeModel.generateContent()
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 singleGenerateContentResponse.
Signature:
generateContent(templateId:string,templateVariables:object):Promise<GenerateContentResult>;Parameters
| Parameter | Type | Description |
|---|---|---|
| templateId | string | The ID of the server-side template to execute. |
| templateVariables | object | A key-value map of variables to populate the template with. |
Returns:
Promise<GenerateContentResult>
TemplateGenerativeModel.generateContentStream()
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.
Signature:
generateContentStream(templateId:string,templateVariables:object):Promise<GenerateContentStreamResult>;Parameters
| Parameter | Type | Description |
|---|---|---|
| templateId | string | The ID of the server-side template to execute. |
| templateVariables | object | A key-value map of variables to populate the template with. |
Returns:
Promise<GenerateContentStreamResult>
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-11-14 UTC.