TemplateGenerativeModel

@PublicPreviewAPI
public final classTemplateGenerativeModel


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

Summary

Public methods

final @NonNullGenerateContentResponse
generateContent(
    @NonNullString templateId,
    @NonNullMap<@NonNullString, @NonNullObject> inputs
)

Generates content from a prompt template and inputs.

final @NonNullFlow<@NonNullGenerateContentResponse>
generateContentStream(
    @NonNullString templateId,
    @NonNullMap<@NonNullString, @NonNullObject> inputs
)

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

Public methods

generateContent

public final @NonNullGenerateContentResponse generateContent(
    @NonNullString templateId,
    @NonNullMap<@NonNullString, @NonNullObject> inputs
)

Generates content from a prompt template and inputs.

Parameters
@NonNullString templateId

The ID of the prompt template to use.

@NonNullMap<@NonNullString, @NonNullObject> inputs

A map of variables to substitute into the template.

Returns
@NonNullGenerateContentResponse

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

public final @NonNullFlow<@NonNullGenerateContentResponsegenerateContentStream(
    @NonNullString templateId,
    @NonNullMap<@NonNullString, @NonNullObject> inputs
)

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

Parameters
@NonNullString templateId

The ID of the prompt template to use.

@NonNullMap<@NonNullString, @NonNullObject> inputs

A map of variables to substitute into the template.

Returns
@NonNullFlow<@NonNullGenerateContentResponse>

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.