TemplateGenerativeModel

@PublicPreviewAPI
classTemplateGenerativeModel


Represents a multimodal model (like Gemini), capable of generating content based on various templated input types.

Summary

Public functions

suspendGenerateContentResponse
generateContent(templateId: String, inputs: Map<StringAny>)

Generates content from a prompt template and inputs.

Flow<GenerateContentResponse>
generateContentStream(templateId: String, inputs: Map<StringAny>)

Generates content as a stream from a prompt template and inputs.

Public functions

generateContent

suspend fun generateContent(templateId: String, inputs: Map<StringAny>): GenerateContentResponse

Generates content from a prompt template and inputs.

Parameters
templateId: String

The ID of the prompt template to use.

inputs: Map<StringAny>

A map of variables to substitute into the template.

Returns
GenerateContentResponse

The content generated by the model.

Throws
com.google.firebase.ai.type.FirebaseAIException: com.google.firebase.ai.type.FirebaseAIException

if the request failed.

See also
FirebaseAIException

for types of errors.

generateContentStream

fun generateContentStream(templateId: String, inputs: Map<StringAny>): Flow<GenerateContentResponse>

Generates content as a stream from a prompt template and inputs.

Parameters
templateId: String

The ID of the prompt template to use.

inputs: Map<StringAny>

A map of variables to substitute into the template.

Returns
Flow<GenerateContentResponse>

AFlow which will emit responses as they are returned by the model.

Throws
com.google.firebase.ai.type.FirebaseAIException: com.google.firebase.ai.type.FirebaseAIException

if the request failed.

See also
FirebaseAIException

for types of errors.

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.