Files
firebase-js-sdk/docs-devsite/ai.templategenerativemodel.md
DellaBittaandGitHub ed491d18fc feat(ai) Google Maps Grounding Support (#9458)
### Discussion

Implement new tools to use Grounding with Google Maps, similar to how Grounding with Google Search works.

### Testing

Integration tests.
Unit tests.
Node standalone app.
Updated Quickstart React-based app (not part of this PR).

### API Changes

 - Grounding with Google Maps support, see internal doc: go/fal-maps-grounding-api
 - TemplateToolConfig, see internal doc: go/firebase-ai-server-prompt-template
2026-04-23 15:47:21 -04:00

6.9 KiB

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 %}

TemplateGenerativeModel class

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().

Signature:

export declare class TemplateGenerativeModel 

Constructors

Constructor Modifiers Description
(constructor)(ai, requestOptions) (Public Preview) Constructs a new instance of the TemplateGenerativeModel class

Properties

Property Modifiers Type Description
requestOptions RequestOptions (Public Preview) Additional options to use when making requests.

Methods

Method Modifiers Description
generateContent(templateId, templateVariables, singleRequestOptions, templateToolConfig) (Public Preview) Makes a single non-streaming call to the model and returns an object containing a single GenerateContentResponse.
generateContentStream(templateId, templateVariables, singleRequestOptions, templateToolConfig) (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.
startChat(params) (Public Preview) Starts a TemplateChatSession that will use this template to respond to messages.

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 the TemplateGenerativeModel 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 single GenerateContentResponse.

Signature:

generateContent(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions, templateToolConfig?: TemplateToolConfig): Promise<GenerateContentResult>;

Parameters

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 Optional. Options to use for this request.
templateToolConfig TemplateToolConfig Optional. Configuration for tools to use with this request.

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: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions, templateToolConfig?: TemplateToolConfig): Promise<GenerateContentStreamResult>;

Parameters

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 Optional.Options to use for this request.
templateToolConfig TemplateToolConfig Optional. Configuration for tools to use with this request.

Returns:

Promise<GenerateContentStreamResult>

TemplateGenerativeModel.startChat()

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.

Signature:

startChat(params: StartTemplateChatParams): TemplateChatSession;

Parameters

Parameter Type Description
params StartTemplateChatParams Configurations for the chat, including the template ID and input variables.

Returns:

TemplateChatSession