# Firebase.AI.TemplateGenerativeModel

A type that represents a remote multimodal model (like Gemini), with the ability to generate content based on defined server prompt templates.

## Summary

| ### Public functions ||
|---|---|
| `https://firebase.google.com/docs/reference/unity/class/firebase/a-i/template-generative-model#class_firebase_1_1_a_i_1_1_template_generative_model_1a670f6ba6a421b7f531de0ae54d54a0b7(string templateId, IDictionary< string, object > inputs, https://firebase.google.com/docs/reference/unity/struct/firebase/a-i/template-tool-config#struct_firebase_1_1_a_i_1_1_template_tool_config? toolConfig, CancellationToken cancellationToken)` | `Task< https://firebase.google.com/docs/reference/unity/struct/firebase/a-i/generate-content-response#struct_firebase_1_1_a_i_1_1_generate_content_response >` Generates new content by calling into a server prompt template. |
| `https://firebase.google.com/docs/reference/unity/class/firebase/a-i/template-generative-model#class_firebase_1_1_a_i_1_1_template_generative_model_1a5838f6ed5abdca20eda0dd7fdcf7543a(string templateId, IDictionary< string, object > inputs, https://firebase.google.com/docs/reference/unity/struct/firebase/a-i/template-tool-config#struct_firebase_1_1_a_i_1_1_template_tool_config? toolConfig, CancellationToken cancellationToken)` | `IAsyncEnumerable< https://firebase.google.com/docs/reference/unity/struct/firebase/a-i/generate-content-response#struct_firebase_1_1_a_i_1_1_generate_content_response >` Generates new content as a stream by calling into a server prompt template. |
| `https://firebase.google.com/docs/reference/unity/class/firebase/a-i/template-generative-model#class_firebase_1_1_a_i_1_1_template_generative_model_1ab9cb0f0bada8ad66c21b53a17c183c4d(string templateId, IDictionary< string, object > inputs, IEnumerable< https://firebase.google.com/docs/reference/unity/struct/firebase/a-i/model-content#struct_firebase_1_1_a_i_1_1_model_content > history, IEnumerable< https://firebase.google.com/docs/reference/unity/interface/firebase/a-i/i-template-tool#interface_firebase_1_1_a_i_1_1_i_template_tool > tools, https://firebase.google.com/docs/reference/unity/struct/firebase/a-i/template-tool-config#struct_firebase_1_1_a_i_1_1_template_tool_config? toolConfig)` | `https://firebase.google.com/docs/reference/unity/class/firebase/a-i/template-chat-session#class_firebase_1_1_a_i_1_1_template_chat_session` Starts a [TemplateChatSession](https://firebase.google.com/docs/reference/unity/class/firebase/a-i/template-chat-session#class_firebase_1_1_a_i_1_1_template_chat_session) that uses this template generative model to respond to messages. |

## Public functions

### GenerateContentAsync

```c#
Task< GenerateContentResponse > GenerateContentAsync(
  string templateId,
  IDictionary< string, object > inputs,
  TemplateToolConfig? toolConfig,
  CancellationToken cancellationToken
)
```
Generates new content by calling into a server prompt template.

<br />

Details Parameters `templateId` The id of the server prompt template to use. `inputs` Any input parameters expected by the server prompt template. `toolConfig` Optional tool configuration. `cancellationToken` An optional token to cancel the operation. Exceptions `HttpRequestException` Thrown when an error occurs during content generation. **Returns** The generated content response from the model.

### GenerateContentStreamAsync

```c#
IAsyncEnumerable< GenerateContentResponse > GenerateContentStreamAsync(
  string templateId,
  IDictionary< string, object > inputs,
  TemplateToolConfig? toolConfig,
  CancellationToken cancellationToken
)
```
Generates new content as a stream by calling into a server prompt template.

<br />

Details Parameters `templateId` The id of the server prompt template to use. `inputs` Any input parameters expected by the server prompt template. `toolConfig` Optional tool configuration. `cancellationToken` An optional token to cancel the operation. Exceptions `HttpRequestException` Thrown when an error occurs during content generation. **Returns** A stream of generated content responses from the model.

### StartChat

```c#
TemplateChatSession StartChat(
  string templateId,
  IDictionary< string, object > inputs,
  IEnumerable< ModelContent > history,
  IEnumerable< ITemplateTool > tools,
  TemplateToolConfig? toolConfig
)
```
Starts a [TemplateChatSession](https://firebase.google.com/docs/reference/unity/class/firebase/a-i/template-chat-session#class_firebase_1_1_a_i_1_1_template_chat_session) that uses this template generative model to respond to messages.

<br />

Details Parameters `templateId` The id of the server prompt template to use. `inputs` Any input parameters expected by the server prompt template. `history` Optional chat history. `tools` Optional tools (e.g., auto functions) to use. `toolConfig` Optional tool configuration. **Returns** A new [TemplateChatSession](https://firebase.google.com/docs/reference/unity/class/firebase/a-i/template-chat-session#class_firebase_1_1_a_i_1_1_template_chat_session) instance.