> Documentation index: https://firebase.google.com/docs/reference/js/llms.txt

The Firebase AI Web SDK.

## Functions

| Function | Description |
|---|---|
| **function(app, ...)** |   |
| [getAI(app, options)](https://firebase.google.com/docs/reference/js/ai.md.txt#getai_a94a413) | Returns the default [AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface) instance that is associated with the provided [FirebaseApp](https://firebase.google.com/docs/reference/js/app.firebaseapp.md.txt#firebaseapp_interface). If no instance exists, initializes a new instance with the default settings. |
| **function(ai, ...)** |   |
| [getGenerativeModel(ai, modelParams, requestOptions)](https://firebase.google.com/docs/reference/js/ai.md.txt#getgenerativemodel_c63f46a) | Returns a [GenerativeModel](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodel_class) class with methods for inference and other functionality. |
| [getLiveGenerativeModel(ai, modelParams)](https://firebase.google.com/docs/reference/js/ai.md.txt#getlivegenerativemodel_f2099ac) | ***(Public Preview)*** Returns a [LiveGenerativeModel](https://firebase.google.com/docs/reference/js/ai.livegenerativemodel.md.txt#livegenerativemodel_class) class for real-time, bidirectional communication.The Live API is only supported in modern browser windows and Node \>= 22. |
| [getTemplateGenerativeModel(ai, requestOptions)](https://firebase.google.com/docs/reference/js/ai.md.txt#gettemplategenerativemodel_9476bbc) | ***(Public Preview)*** Returns a [TemplateGenerativeModel](https://firebase.google.com/docs/reference/js/ai.templategenerativemodel.md.txt#templategenerativemodel_class) class for executing server prompt templates. |
| **function(liveSession, ...)** |   |
| [startAudioConversation(liveSession, options)](https://firebase.google.com/docs/reference/js/ai.md.txt#startaudioconversation_01c8e7f) | ***(Public Preview)*** Starts a real-time, bidirectional audio conversation with the model. This helper function manages the complexities of microphone access, audio recording, playback, and interruptions. |

## Classes

| Class | Description |
|---|---|
| [AgentPlatformBackend](https://firebase.google.com/docs/reference/js/ai.agentplatformbackend.md.txt#agentplatformbackend_class) | Configuration class for the Agent Platform Gemini API (formerly known as the Vertex AI Gemini API).Use this with [AIOptions](https://firebase.google.com/docs/reference/js/ai.aioptions.md.txt#aioptions_interface) when initializing the AI service via [getAI()](https://firebase.google.com/docs/reference/js/ai.md.txt#getai_a94a413) to specify the Agent Platform Gemini API as the backend. |
| [AIError](https://firebase.google.com/docs/reference/js/ai.aierror.md.txt#aierror_class) | Error class for the Firebase AI SDK. |
| [AIModel](https://firebase.google.com/docs/reference/js/ai.aimodel.md.txt#aimodel_class) | Base class for Firebase AI model APIs.Instances of this class are associated with a specific Firebase AI [Backend](https://firebase.google.com/docs/reference/js/ai.backend.md.txt#backend_class) and provide methods for interacting with the configured generative model. |
| [AnyOfSchema](https://firebase.google.com/docs/reference/js/ai.anyofschema.md.txt#anyofschema_class) | Schema class representing a value that can conform to any of the provided sub-schemas. This is useful when a field can accept multiple distinct types or structures. |
| [ArraySchema](https://firebase.google.com/docs/reference/js/ai.arrayschema.md.txt#arrayschema_class) | Schema class for "array" types. The `items` param should refer to the type of item that can be a member of the array. |
| [Backend](https://firebase.google.com/docs/reference/js/ai.backend.md.txt#backend_class) | Abstract base class representing the configuration for an AI service backend. This class should not be instantiated directly. Use its subclasses; [GoogleAIBackend](https://firebase.google.com/docs/reference/js/ai.googleaibackend.md.txt#googleaibackend_class) for the Gemini Developer API (via [Google AI](https://ai.google/)) and [AgentPlatformBackend](https://firebase.google.com/docs/reference/js/ai.agentplatformbackend.md.txt#agentplatformbackend_class) for the Agent Platform Gemini API. |
| [BooleanSchema](https://firebase.google.com/docs/reference/js/ai.booleanschema.md.txt#booleanschema_class) | Schema class for "boolean" types. |
| [GenerativeModel](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodel_class) | Class for generative model APIs. |
| [GoogleAIBackend](https://firebase.google.com/docs/reference/js/ai.googleaibackend.md.txt#googleaibackend_class) | Configuration class for the Gemini Developer API.Use this with [AIOptions](https://firebase.google.com/docs/reference/js/ai.aioptions.md.txt#aioptions_interface) when initializing the AI service via [getAI()](https://firebase.google.com/docs/reference/js/ai.md.txt#getai_a94a413) to specify the Gemini Developer API as the backend. |
| [IntegerSchema](https://firebase.google.com/docs/reference/js/ai.integerschema.md.txt#integerschema_class) | Schema class for "integer" types. |
| [LiveGenerativeModel](https://firebase.google.com/docs/reference/js/ai.livegenerativemodel.md.txt#livegenerativemodel_class) | ***(Public Preview)*** Class for Live generative model APIs. The Live API enables low-latency, two-way multimodal interactions with Gemini.This class should only be instantiated with [getLiveGenerativeModel()](https://firebase.google.com/docs/reference/js/ai.md.txt#getlivegenerativemodel_f2099ac). |
| [LiveSession](https://firebase.google.com/docs/reference/js/ai.livesession.md.txt#livesession_class) | ***(Public Preview)*** Represents an active, real-time, bidirectional conversation with the model.This class should only be instantiated by calling [LiveGenerativeModel.connect()](https://firebase.google.com/docs/reference/js/ai.livegenerativemodel.md.txt#livegenerativemodelconnect). |
| [NumberSchema](https://firebase.google.com/docs/reference/js/ai.numberschema.md.txt#numberschema_class) | Schema class for "number" types. |
| [ObjectSchema](https://firebase.google.com/docs/reference/js/ai.objectschema.md.txt#objectschema_class) | Schema class for "object" types. The `properties` param must be a map of `Schema` objects. |
| [Schema](https://firebase.google.com/docs/reference/js/ai.schema.md.txt#schema_class) | Parent class encompassing all Schema types, with static methods that allow building specific Schema types. This class can be converted with `JSON.stringify()` into a JSON string accepted by Agent Platform Gemini API and Gemini Developer API REST endpoints. (This string conversion is automatically done when calling SDK methods.) |
| [StringSchema](https://firebase.google.com/docs/reference/js/ai.stringschema.md.txt#stringschema_class) | Schema class for "string" types. Can be used with or without enum values. |
| [TemplateGenerativeModel](https://firebase.google.com/docs/reference/js/ai.templategenerativemodel.md.txt#templategenerativemodel_class) | ***(Public Preview)*** [GenerativeModel](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodel_class) APIs that execute on a server prompt template.This class should only be instantiated with [getTemplateGenerativeModel()](https://firebase.google.com/docs/reference/js/ai.md.txt#gettemplategenerativemodel_9476bbc). |

## Interfaces

| Interface | Description |
|---|---|
| [AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface) | An instance of the Firebase AI SDK.Do not create this instance directly. Instead, use [getAI()](https://firebase.google.com/docs/reference/js/ai.md.txt#getai_a94a413). |
| [AIOptions](https://firebase.google.com/docs/reference/js/ai.aioptions.md.txt#aioptions_interface) | Options for initializing the AI service using [getAI()](https://firebase.google.com/docs/reference/js/ai.md.txt#getai_a94a413). This allows specifying which backend to use (Gemini Developer API or Agent Platform Gemini API) and configuring its specific options (like location for Agent Platform). |
| [AudioConversationController](https://firebase.google.com/docs/reference/js/ai.audioconversationcontroller.md.txt#audioconversationcontroller_interface) | ***(Public Preview)*** A controller for managing an active audio conversation. |
| [AudioTranscriptionConfig](https://firebase.google.com/docs/reference/js/ai.audiotranscriptionconfig.md.txt#audiotranscriptionconfig_interface) | ***(Public Preview)*** The audio transcription configuration. |
| [BaseParams](https://firebase.google.com/docs/reference/js/ai.baseparams.md.txt#baseparams_interface) | Base parameters for a number of methods. |
| [BaseSpeechConfig](https://firebase.google.com/docs/reference/js/ai.basespeechconfig.md.txt#basespeechconfig_interface) | ***(Public Preview)*** Base configuration for speech synthesis. |
| [ChatSession](https://firebase.google.com/docs/reference/js/ai.chatsession.md.txt#chatsession_interface) | Interface representing a `ChatSession` class that enables sending chat messages and stores a history of sent and received messages so far. |
| [ChromeAdapter](https://firebase.google.com/docs/reference/js/ai.chromeadapter.md.txt#chromeadapter_interface) | Defines an inference "backend" that uses Chrome's on-device model, and encapsulates logic for detecting when on-device inference is possible.These methods should not be called directly by the user. |
| [Citation](https://firebase.google.com/docs/reference/js/ai.citation.md.txt#citation_interface) | A single citation. |
| [CitationMetadata](https://firebase.google.com/docs/reference/js/ai.citationmetadata.md.txt#citationmetadata_interface) | Citation metadata that may be found on a [GenerateContentCandidate](https://firebase.google.com/docs/reference/js/ai.generatecontentcandidate.md.txt#generatecontentcandidate_interface). |
| [CodeExecutionResult](https://firebase.google.com/docs/reference/js/ai.codeexecutionresult.md.txt#codeexecutionresult_interface) | The results of code execution run by the model. |
| [CodeExecutionResultPart](https://firebase.google.com/docs/reference/js/ai.codeexecutionresultpart.md.txt#codeexecutionresultpart_interface) | Represents the code execution result from the model. |
| [CodeExecutionTool](https://firebase.google.com/docs/reference/js/ai.codeexecutiontool.md.txt#codeexecutiontool_interface) | A tool that enables the model to use code execution. |
| [Content](https://firebase.google.com/docs/reference/js/ai.content.md.txt#content_interface) | Content type for both prompts and response candidates. |
| [ContextWindowCompressionConfig](https://firebase.google.com/docs/reference/js/ai.contextwindowcompressionconfig.md.txt#contextwindowcompressionconfig_interface) | ***(Public Preview)*** Enables context window compression to manage the model's context window. |
| [CountTokensRequest](https://firebase.google.com/docs/reference/js/ai.counttokensrequest.md.txt#counttokensrequest_interface) | Params for calling [GenerativeModel.countTokens()](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodelcounttokens) |
| [CountTokensResponse](https://firebase.google.com/docs/reference/js/ai.counttokensresponse.md.txt#counttokensresponse_interface) | Response from calling [GenerativeModel.countTokens()](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodelcounttokens). |
| [CustomErrorData](https://firebase.google.com/docs/reference/js/ai.customerrordata.md.txt#customerrordata_interface) | Details object that contains data originating from a bad HTTP response. |
| [Date_2](https://firebase.google.com/docs/reference/js/ai.date_2.md.txt#date_2_interface) | Protobuf google.type.Date |
| [EnhancedGenerateContentResponse](https://firebase.google.com/docs/reference/js/ai.enhancedgeneratecontentresponse.md.txt#enhancedgeneratecontentresponse_interface) | Response object wrapped with helper methods. |
| [ErrorDetails](https://firebase.google.com/docs/reference/js/ai.errordetails.md.txt#errordetails_interface) | Details object that may be included in an error response. |
| [ExecutableCode](https://firebase.google.com/docs/reference/js/ai.executablecode.md.txt#executablecode_interface) | An interface for executable code returned by the model. |
| [ExecutableCodePart](https://firebase.google.com/docs/reference/js/ai.executablecodepart.md.txt#executablecodepart_interface) | Represents the code that is executed by the model. |
| [FileData](https://firebase.google.com/docs/reference/js/ai.filedata.md.txt#filedata_interface) | Data pointing to a file uploaded on Google Cloud Storage. |
| [FileDataPart](https://firebase.google.com/docs/reference/js/ai.filedatapart.md.txt#filedatapart_interface) | Content part interface if the part represents [FileData](https://firebase.google.com/docs/reference/js/ai.filedata.md.txt#filedata_interface) |
| [FunctionCall](https://firebase.google.com/docs/reference/js/ai.functioncall.md.txt#functioncall_interface) | A predicted [FunctionCall](https://firebase.google.com/docs/reference/js/ai.functioncall.md.txt#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](https://firebase.google.com/docs/reference/js/ai.functiondeclaration.md.txt#functiondeclarationname) and a structured JSON object containing the parameters and their values. |
| [FunctionCallingConfig](https://firebase.google.com/docs/reference/js/ai.functioncallingconfig.md.txt#functioncallingconfig_interface) |   |
| [FunctionCallPart](https://firebase.google.com/docs/reference/js/ai.functioncallpart.md.txt#functioncallpart_interface) | Content part interface if the part represents a [FunctionCall](https://firebase.google.com/docs/reference/js/ai.functioncall.md.txt#functioncall_interface). |
| [FunctionDeclaration](https://firebase.google.com/docs/reference/js/ai.functiondeclaration.md.txt#functiondeclaration_interface) | Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This `FunctionDeclaration` is a representation of a block of code that can be used as a Tool by the model and executed by the client. |
| [FunctionDeclarationsTool](https://firebase.google.com/docs/reference/js/ai.functiondeclarationstool.md.txt#functiondeclarationstool_interface) | A `FunctionDeclarationsTool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. |
| [FunctionResponse](https://firebase.google.com/docs/reference/js/ai.functionresponse.md.txt#functionresponse_interface) | The result output from a [FunctionCall](https://firebase.google.com/docs/reference/js/ai.functioncall.md.txt#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](https://firebase.google.com/docs/reference/js/ai.functiondeclaration.md.txt#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](https://firebase.google.com/docs/reference/js/ai.functioncall.md.txt#functioncall_interface) made based on model prediction. |
| [FunctionResponsePart](https://firebase.google.com/docs/reference/js/ai.functionresponsepart.md.txt#functionresponsepart_interface) | Content part interface if the part represents [FunctionResponse](https://firebase.google.com/docs/reference/js/ai.functionresponse.md.txt#functionresponse_interface). |
| [GenerateContentCandidate](https://firebase.google.com/docs/reference/js/ai.generatecontentcandidate.md.txt#generatecontentcandidate_interface) | A candidate returned as part of a [GenerateContentResponse](https://firebase.google.com/docs/reference/js/ai.generatecontentresponse.md.txt#generatecontentresponse_interface). |
| [GenerateContentRequest](https://firebase.google.com/docs/reference/js/ai.generatecontentrequest.md.txt#generatecontentrequest_interface) | Request sent through [GenerativeModel.generateContent()](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodelgeneratecontent) |
| [GenerateContentResponse](https://firebase.google.com/docs/reference/js/ai.generatecontentresponse.md.txt#generatecontentresponse_interface) | Individual response from [GenerativeModel.generateContent()](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodelgeneratecontentstream). `generateContentStream()` will return one in each chunk until the stream is done. |
| [GenerateContentResult](https://firebase.google.com/docs/reference/js/ai.generatecontentresult.md.txt#generatecontentresult_interface) | Result object returned from [GenerativeModel.generateContent()](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodelgeneratecontent) call. |
| [GenerateContentStreamResult](https://firebase.google.com/docs/reference/js/ai.generatecontentstreamresult.md.txt#generatecontentstreamresult_interface) | Result object returned from [GenerativeModel.generateContentStream()](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodelgeneratecontentstream) call. Iterate over `stream` to get chunks as they come in and/or use the `response` promise to get the aggregated response when the stream is done. |
| [GenerationConfig](https://firebase.google.com/docs/reference/js/ai.generationconfig.md.txt#generationconfig_interface) | Config options for content-related requests |
| [GenerativeContentBlob](https://firebase.google.com/docs/reference/js/ai.generativecontentblob.md.txt#generativecontentblob_interface) | Interface for sending an image. |
| [GoogleMaps](https://firebase.google.com/docs/reference/js/ai.googlemaps.md.txt#googlemaps_interface) | Specifies the Google Maps configuration. |
| [GoogleMapsGroundingChunk](https://firebase.google.com/docs/reference/js/ai.googlemapsgroundingchunk.md.txt#googlemapsgroundingchunk_interface) | A grounding chunk from Google Maps.Important: If using Grounding with Google Maps, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Maps". |
| [GoogleMapsTool](https://firebase.google.com/docs/reference/js/ai.googlemapstool.md.txt#googlemapstool_interface) | A tool that allows a Gemini model to connect to Google Maps to access and incorporate location-based information into its responses.Important: If using Grounding with Google Maps, you are required to comply with the "Grounding with Google Maps" usage requirements for your chosen API provider: [Gemini Developer API](https://ai.google.dev/gemini-api/terms#grounding-with-google-maps) or Agent Platform Gemini API (see [Service Terms](https://cloud.google.com/terms/service-terms) section within the Service Specific Terms). |
| [GoogleSearch](https://firebase.google.com/docs/reference/js/ai.googlesearch.md.txt#googlesearch_interface) | Specifies the Google Search configuration. |
| [GoogleSearchTool](https://firebase.google.com/docs/reference/js/ai.googlesearchtool.md.txt#googlesearchtool_interface) | A tool that allows a Gemini model to connect to Google Search to access and incorporate up-to-date information from the web into its responses.Important: If using Grounding with Google Search, you are required to comply with the "Grounding with Google Search" usage requirements for your chosen API provider: [Gemini Developer API](https://ai.google.dev/gemini-api/terms#grounding-with-google-search) or Agent Platform Gemini API (see [Service Terms](https://cloud.google.com/terms/service-terms) section within the Service Specific Terms). |
| [GroundingChunk](https://firebase.google.com/docs/reference/js/ai.groundingchunk.md.txt#groundingchunk_interface) | Represents a chunk of retrieved data that supports a claim in the model's response. This is part of the grounding information provided when grounding is enabled. |
| [GroundingMetadata](https://firebase.google.com/docs/reference/js/ai.groundingmetadata.md.txt#groundingmetadata_interface) | Metadata returned when grounding is enabled.Currently, only Grounding with Google Search and Grounding with Google Maps are supported (see [GoogleSearchTool](https://firebase.google.com/docs/reference/js/ai.googlesearchtool.md.txt#googlesearchtool_interface) and [GoogleMapsTool](https://firebase.google.com/docs/reference/js/ai.googlemapstool.md.txt#googlemapstool_interface), respectively).Important: If using Grounding with Google Search, you are required to comply with the "Grounding with Google Search" usage requirements for your chosen API provider: [Gemini Developer API](https://ai.google.dev/gemini-api/terms#grounding-with-google-search) or Agent Platform Gemini API (see [Service Terms](https://cloud.google.com/terms/service-terms) section within the Service Specific Terms).Important: If using Grounding with Google Maps, you are required to comply with the "Grounding with Google Maps" usage requirements for your chosen API provider: [Gemini Developer API](https://ai.google.dev/gemini-api/terms#grounding-with-google-maps) or Agent Platform Gemini API (see [Service Terms](https://cloud.google.com/terms/service-terms) section within the Service Specific Terms). |
| [GroundingSupport](https://firebase.google.com/docs/reference/js/ai.groundingsupport.md.txt#groundingsupport_interface) | Provides information about how a specific segment of the model's response is supported by the retrieved grounding chunks. |
| [HybridParams](https://firebase.google.com/docs/reference/js/ai.hybridparams.md.txt#hybridparams_interface) | Configures hybrid inference. |
| [ImageConfig](https://firebase.google.com/docs/reference/js/ai.imageconfig.md.txt#imageconfig_interface) | Configuration options for generating images with Gemini models. |
| [InlineDataPart](https://firebase.google.com/docs/reference/js/ai.inlinedatapart.md.txt#inlinedatapart_interface) | Content part interface if the part represents an image. |
| [LanguageModelCreateCoreOptions](https://firebase.google.com/docs/reference/js/ai.languagemodelcreatecoreoptions.md.txt#languagemodelcreatecoreoptions_interface) | Configures the creation of an on-device language model session. |
| [LanguageModelCreateOptions](https://firebase.google.com/docs/reference/js/ai.languagemodelcreateoptions.md.txt#languagemodelcreateoptions_interface) | Configures the creation of an on-device language model session. |
| [LanguageModelDownloadMonitor](https://firebase.google.com/docs/reference/js/ai.languagemodeldownloadmonitor.md.txt#languagemodeldownloadmonitor_interface) | Interface representing the Chrome Prompt API's native download monitor object. |
| [LanguageModelExpected](https://firebase.google.com/docs/reference/js/ai.languagemodelexpected.md.txt#languagemodelexpected_interface) | Options for the expected inputs for an on-device language model. |
| [LanguageModelMessage](https://firebase.google.com/docs/reference/js/ai.languagemodelmessage.md.txt#languagemodelmessage_interface) | An on-device language model message. |
| [LanguageModelMessageContent](https://firebase.google.com/docs/reference/js/ai.languagemodelmessagecontent.md.txt#languagemodelmessagecontent_interface) | An on-device language model content object. |
| [LanguageModelPromptOptions](https://firebase.google.com/docs/reference/js/ai.languagemodelpromptoptions.md.txt#languagemodelpromptoptions_interface) | Options for an on-device language model prompt. |
| [LatLng](https://firebase.google.com/docs/reference/js/ai.latlng.md.txt#latlng_interface) | An object that represents a latitude/longitude pair. |
| [LiveGenerationConfig](https://firebase.google.com/docs/reference/js/ai.livegenerationconfig.md.txt#livegenerationconfig_interface) | ***(Public Preview)*** Configuration parameters used by [LiveGenerativeModel](https://firebase.google.com/docs/reference/js/ai.livegenerativemodel.md.txt#livegenerativemodel_class) to control live content generation. |
| [LiveModelParams](https://firebase.google.com/docs/reference/js/ai.livemodelparams.md.txt#livemodelparams_interface) | ***(Public Preview)*** Params passed to [getLiveGenerativeModel()](https://firebase.google.com/docs/reference/js/ai.md.txt#getlivegenerativemodel_f2099ac). |
| [LiveServerContent](https://firebase.google.com/docs/reference/js/ai.liveservercontent.md.txt#liveservercontent_interface) | ***(Public Preview)*** An incremental content update from the model. |
| [LiveServerGoingAwayNotice](https://firebase.google.com/docs/reference/js/ai.liveservergoingawaynotice.md.txt#liveservergoingawaynotice_interface) | ***(Public Preview)*** Notification that the server will not be able to service the client soon. |
| [LiveServerToolCall](https://firebase.google.com/docs/reference/js/ai.liveservertoolcall.md.txt#liveservertoolcall_interface) | ***(Public Preview)*** A request from the model for the client to execute one or more functions. |
| [LiveServerToolCallCancellation](https://firebase.google.com/docs/reference/js/ai.liveservertoolcallcancellation.md.txt#liveservertoolcallcancellation_interface) | ***(Public Preview)*** Notification to cancel a previous function call triggered by [LiveServerToolCall](https://firebase.google.com/docs/reference/js/ai.liveservertoolcall.md.txt#liveservertoolcall_interface). |
| [LiveSessionResumptionUpdate](https://firebase.google.com/docs/reference/js/ai.livesessionresumptionupdate.md.txt#livesessionresumptionupdate_interface) | ***(Public Preview)*** An update of the session resumption state.This message is only sent if [SessionResumptionConfig](https://firebase.google.com/docs/reference/js/ai.sessionresumptionconfig.md.txt#sessionresumptionconfig_interface) was set in the session setup. |
| [ModalityTokenCount](https://firebase.google.com/docs/reference/js/ai.modalitytokencount.md.txt#modalitytokencount_interface) | Represents token counting info for a single modality. |
| [ModelParams](https://firebase.google.com/docs/reference/js/ai.modelparams.md.txt#modelparams_interface) | Params passed to [getGenerativeModel()](https://firebase.google.com/docs/reference/js/ai.md.txt#getgenerativemodel_c63f46a). |
| [MultiSpeakerSpeechConfig](https://firebase.google.com/docs/reference/js/ai.multispeakerspeechconfig.md.txt#multispeakerspeechconfig_interface) | ***(Public Preview)*** Configuration for speech synthesis with multiple speakers. |
| [MultiSpeakerVoiceConfig](https://firebase.google.com/docs/reference/js/ai.multispeakervoiceconfig.md.txt#multispeakervoiceconfig_interface) | ***(Public Preview)*** Configuration for multi-speaker setup. |
| [ObjectSchemaRequest](https://firebase.google.com/docs/reference/js/ai.objectschemarequest.md.txt#objectschemarequest_interface) | Interface for JSON parameters in a schema of [SchemaType](https://firebase.google.com/docs/reference/js/ai.md.txt#schematype) "object" when not using the `Schema.object()` helper. |
| [OnDeviceParams](https://firebase.google.com/docs/reference/js/ai.ondeviceparams.md.txt#ondeviceparams_interface) | Encapsulates configuration for on-device inference. |
| [PrebuiltVoiceConfig](https://firebase.google.com/docs/reference/js/ai.prebuiltvoiceconfig.md.txt#prebuiltvoiceconfig_interface) | ***(Public Preview)*** Configuration for a pre-built voice. |
| [PromptFeedback](https://firebase.google.com/docs/reference/js/ai.promptfeedback.md.txt#promptfeedback_interface) | If the prompt was blocked, this will be populated with `blockReason` and the relevant `safetyRatings`. |
| [RequestOptions](https://firebase.google.com/docs/reference/js/ai.requestoptions.md.txt#requestoptions_interface) | Params passed to [getGenerativeModel()](https://firebase.google.com/docs/reference/js/ai.md.txt#getgenerativemodel_c63f46a). |
| [RetrievalConfig](https://firebase.google.com/docs/reference/js/ai.retrievalconfig.md.txt#retrievalconfig_interface) | Configuration options for data retrieval tools. |
| [RetrievedContextAttribution](https://firebase.google.com/docs/reference/js/ai.retrievedcontextattribution.md.txt#retrievedcontextattribution_interface) |   |
| [SafetyRating](https://firebase.google.com/docs/reference/js/ai.safetyrating.md.txt#safetyrating_interface) | A safety rating associated with a [GenerateContentCandidate](https://firebase.google.com/docs/reference/js/ai.generatecontentcandidate.md.txt#generatecontentcandidate_interface) |
| [SafetySetting](https://firebase.google.com/docs/reference/js/ai.safetysetting.md.txt#safetysetting_interface) | Safety setting that can be sent as part of request parameters. |
| [SchemaInterface](https://firebase.google.com/docs/reference/js/ai.schemainterface.md.txt#schemainterface_interface) | Interface for [Schema](https://firebase.google.com/docs/reference/js/ai.schema.md.txt#schema_class) class. |
| [SchemaParams](https://firebase.google.com/docs/reference/js/ai.schemaparams.md.txt#schemaparams_interface) | Params passed to [Schema](https://firebase.google.com/docs/reference/js/ai.schema.md.txt#schema_class) static methods to create specific [Schema](https://firebase.google.com/docs/reference/js/ai.schema.md.txt#schema_class) classes. |
| [SchemaRequest](https://firebase.google.com/docs/reference/js/ai.schemarequest.md.txt#schemarequest_interface) | Final format for [Schema](https://firebase.google.com/docs/reference/js/ai.schema.md.txt#schema_class) params passed to backend requests. |
| [SchemaShared](https://firebase.google.com/docs/reference/js/ai.schemashared.md.txt#schemashared_interface) | Basic [Schema](https://firebase.google.com/docs/reference/js/ai.schema.md.txt#schema_class) properties shared across several Schema-related types. |
| [SearchEntrypoint](https://firebase.google.com/docs/reference/js/ai.searchentrypoint.md.txt#searchentrypoint_interface) | Google search entry point. |
| [Segment](https://firebase.google.com/docs/reference/js/ai.segment.md.txt#segment_interface) | Represents a specific segment within a [Content](https://firebase.google.com/docs/reference/js/ai.content.md.txt#content_interface) object, often used to pinpoint the exact location of text or data that grounding information refers to. |
| [SessionResumptionConfig](https://firebase.google.com/docs/reference/js/ai.sessionresumptionconfig.md.txt#sessionresumptionconfig_interface) | ***(Public Preview)*** Configuration for the session resumption mechanism. |
| [SingleRequestOptions](https://firebase.google.com/docs/reference/js/ai.singlerequestoptions.md.txt#singlerequestoptions_interface) | Options that can be provided per-request. Extends the base [RequestOptions](https://firebase.google.com/docs/reference/js/ai.requestoptions.md.txt#requestoptions_interface) (like `timeout` and `baseUrl`) with request-specific controls like cancellation via `AbortSignal`.Options specified here will override any default [RequestOptions](https://firebase.google.com/docs/reference/js/ai.requestoptions.md.txt#requestoptions_interface) configured on a model (for example, [GenerativeModel](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodel_class)). |
| [SingleSpeakerSpeechConfig](https://firebase.google.com/docs/reference/js/ai.singlespeakerspeechconfig.md.txt#singlespeakerspeechconfig_interface) | ***(Public Preview)*** Configuration for speech synthesis for a single speaker. |
| [SlidingWindow](https://firebase.google.com/docs/reference/js/ai.slidingwindow.md.txt#slidingwindow_interface) | ***(Public Preview)*** Configures the sliding window context compression mechanism. |
| [SpeakerVoiceConfig](https://firebase.google.com/docs/reference/js/ai.speakervoiceconfig.md.txt#speakervoiceconfig_interface) | ***(Public Preview)*** Configuration for a single speaker's voice. |
| [SpeechMetadata](https://firebase.google.com/docs/reference/js/ai.speechmetadata.md.txt#speechmetadata_interface) | ***(Public Preview)*** Structured speech metadata associated with a [TextPart](https://firebase.google.com/docs/reference/js/ai.textpart.md.txt#textpart_interface).Used to guide speech generation for a specific piece of text, such as identifying which speaker says it and the vocal style they should use. |
| [StartAudioConversationOptions](https://firebase.google.com/docs/reference/js/ai.startaudioconversationoptions.md.txt#startaudioconversationoptions_interface) | ***(Public Preview)*** Options for [startAudioConversation()](https://firebase.google.com/docs/reference/js/ai.md.txt#startaudioconversation_01c8e7f). |
| [StartChatParams](https://firebase.google.com/docs/reference/js/ai.startchatparams.md.txt#startchatparams_interface) | Params for [GenerativeModel.startChat()](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodelstartchat). |
| [StartTemplateChatParams](https://firebase.google.com/docs/reference/js/ai.starttemplatechatparams.md.txt#starttemplatechatparams_interface) | ***(Public Preview)*** Parameters for starting a template-based chat session with [TemplateGenerativeModel.startChat()](https://firebase.google.com/docs/reference/js/ai.templategenerativemodel.md.txt#templategenerativemodelstartchat). |
| [TemplateChatSession](https://firebase.google.com/docs/reference/js/ai.templatechatsession.md.txt#templatechatsession_interface) | ***(Public Preview)*** Interface representing a chat session for use with server prompt templates that enables sending chat messages and maintains conversation history. |
| [TemplateFunctionDeclaration](https://firebase.google.com/docs/reference/js/ai.templatefunctiondeclaration.md.txt#templatefunctiondeclaration_interface) | ***(Public Preview)*** Structured representation of a template function declaration. Included in this declaration are the function name and parameters. This `TemplateFunctionDeclaration` is a representation of a block of code that can be used as a Tool by the model and executed by the client. Note: Template function declarations do not support description fields. |
| [TemplateFunctionDeclarationsTool](https://firebase.google.com/docs/reference/js/ai.templatefunctiondeclarationstool.md.txt#templatefunctiondeclarationstool_interface) | ***(Public Preview)*** A piece of code that enables the system to interact with external systems. |
| [TemplateRequest](https://firebase.google.com/docs/reference/js/ai.templaterequest.md.txt#templaterequest_interface) | ***(Public Preview)*** Request parameters for using a server prompt template with [\`TemplateGenerativeModel.generateContent()\`](https://firebase.google.com/docs/reference/js/ai.templategenerativemodel.md.txt#templategenerativemodelgeneratecontent) and [\`TemplateGenerativeModel.generateContentStream()\`](https://firebase.google.com/docs/reference/js/ai.templategenerativemodel.md.txt#templategenerativemodelgeneratecontentstream). |
| [TemplateToolConfig](https://firebase.google.com/docs/reference/js/ai.templatetoolconfig.md.txt#templatetoolconfig_interface) | Tool configuration for `TemplateGenerativeModel`s. This config is shared for all tools provided in the server prompt template request. |
| [TextPart](https://firebase.google.com/docs/reference/js/ai.textpart.md.txt#textpart_interface) | Content part interface if the part represents a text string. |
| [ThinkingConfig](https://firebase.google.com/docs/reference/js/ai.thinkingconfig.md.txt#thinkingconfig_interface) | Configuration for "thinking" behavior of compatible Gemini models.Certain models utilize a thinking process before generating a response. This allows them to reason through complex problems and plan a more coherent and accurate answer. |
| [ToolConfig](https://firebase.google.com/docs/reference/js/ai.toolconfig.md.txt#toolconfig_interface) | Tool config. This config is shared for all tools provided in the request. |
| [Transcription](https://firebase.google.com/docs/reference/js/ai.transcription.md.txt#transcription_interface) | ***(Public Preview)*** Transcription of audio. This can be returned from a [LiveGenerativeModel](https://firebase.google.com/docs/reference/js/ai.livegenerativemodel.md.txt#livegenerativemodel_class) if transcription is enabled with the `inputAudioTranscription` or `outputAudioTranscription` properties on the [LiveGenerationConfig](https://firebase.google.com/docs/reference/js/ai.livegenerationconfig.md.txt#livegenerationconfig_interface). |
| [URLContext](https://firebase.google.com/docs/reference/js/ai.urlcontext.md.txt#urlcontext_interface) | Specifies the URL Context configuration. |
| [URLContextMetadata](https://firebase.google.com/docs/reference/js/ai.urlcontextmetadata.md.txt#urlcontextmetadata_interface) | Metadata related to [URLContextTool](https://firebase.google.com/docs/reference/js/ai.urlcontexttool.md.txt#urlcontexttool_interface). |
| [URLContextTool](https://firebase.google.com/docs/reference/js/ai.urlcontexttool.md.txt#urlcontexttool_interface) | A tool that allows you to provide additional context to the models in the form of public web URLs. By including URLs in your request, the Gemini model will access the content from those pages to inform and enhance its response. |
| [URLMetadata](https://firebase.google.com/docs/reference/js/ai.urlmetadata.md.txt#urlmetadata_interface) | Metadata for a single URL retrieved by the [URLContextTool](https://firebase.google.com/docs/reference/js/ai.urlcontexttool.md.txt#urlcontexttool_interface) tool. |
| [UsageMetadata](https://firebase.google.com/docs/reference/js/ai.usagemetadata.md.txt#usagemetadata_interface) | Usage metadata about a [GenerateContentResponse](https://firebase.google.com/docs/reference/js/ai.generatecontentresponse.md.txt#generatecontentresponse_interface). |
| [VideoMetadata](https://firebase.google.com/docs/reference/js/ai.videometadata.md.txt#videometadata_interface) | Describes the input video content. |
| [VoiceConfig](https://firebase.google.com/docs/reference/js/ai.voiceconfig.md.txt#voiceconfig_interface) | ***(Public Preview)*** Configuration for the voice to be used for speech synthesis. |
| [WebAttribution](https://firebase.google.com/docs/reference/js/ai.webattribution.md.txt#webattribution_interface) |   |
| [WebGroundingChunk](https://firebase.google.com/docs/reference/js/ai.webgroundingchunk.md.txt#webgroundingchunk_interface) | A grounding chunk from the web.Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search". |

## Variables

| Variable | Description |
|---|---|
| [AIErrorCode](https://firebase.google.com/docs/reference/js/ai.md.txt#aierrorcode) | Standardized error codes that [AIError](https://firebase.google.com/docs/reference/js/ai.aierror.md.txt#aierror_class) can have. |
| [BackendType](https://firebase.google.com/docs/reference/js/ai.md.txt#backendtype) | An enum-like object containing constants that represent the supported backends for the Firebase AI SDK. This determines which backend service (Gemini Developer API or Agent Platform Gemini API) the SDK will communicate with.These values are assigned to the `backendType` property within the specific backend configuration objects ([GoogleAIBackend](https://firebase.google.com/docs/reference/js/ai.googleaibackend.md.txt#googleaibackend_class) or [AgentPlatformBackend](https://firebase.google.com/docs/reference/js/ai.agentplatformbackend.md.txt#agentplatformbackend_class)) to identify which service to target. |
| [BlockReason](https://firebase.google.com/docs/reference/js/ai.md.txt#blockreason) | Reason that a prompt was blocked. |
| [FinishReason](https://firebase.google.com/docs/reference/js/ai.md.txt#finishreason) | Reason that a candidate finished. |
| [FunctionCallingMode](https://firebase.google.com/docs/reference/js/ai.md.txt#functioncallingmode) |   |
| [HarmBlockMethod](https://firebase.google.com/docs/reference/js/ai.md.txt#harmblockmethod) | This property is not supported in the Gemini Developer API ([GoogleAIBackend](https://firebase.google.com/docs/reference/js/ai.googleaibackend.md.txt#googleaibackend_class)). |
| [HarmBlockThreshold](https://firebase.google.com/docs/reference/js/ai.md.txt#harmblockthreshold) | Threshold above which a prompt or candidate will be blocked. |
| [HarmCategory](https://firebase.google.com/docs/reference/js/ai.md.txt#harmcategory) | Harm categories that would cause prompts or candidates to be blocked. |
| [HarmProbability](https://firebase.google.com/docs/reference/js/ai.md.txt#harmprobability) | Probability that a prompt or candidate matches a harm category. |
| [HarmSeverity](https://firebase.google.com/docs/reference/js/ai.md.txt#harmseverity) | Harm severity levels. |
| [ImageConfigAspectRatio](https://firebase.google.com/docs/reference/js/ai.md.txt#imageconfigaspectratio) | Aspect ratios for generated images. |
| [ImageConfigImageSize](https://firebase.google.com/docs/reference/js/ai.md.txt#imageconfigimagesize) | Sizes for generated images. For example, '1K' is 1024px, '2K' is 2048px, and '4K' is 4096px. |
| [InferenceMode](https://firebase.google.com/docs/reference/js/ai.md.txt#inferencemode) | Determines whether inference happens on-device or in-cloud. |
| [InferenceSource](https://firebase.google.com/docs/reference/js/ai.md.txt#inferencesource) | Indicates whether inference happened on-device or in-cloud. |
| [Language](https://firebase.google.com/docs/reference/js/ai.md.txt#language) | The programming language of the code. |
| [LiveResponseType](https://firebase.google.com/docs/reference/js/ai.md.txt#liveresponsetype) | ***(Public Preview)*** The types of responses that can be returned by [LiveSession.receive()](https://firebase.google.com/docs/reference/js/ai.livesession.md.txt#livesessionreceive). |
| [Modality](https://firebase.google.com/docs/reference/js/ai.md.txt#modality) | Content part modality. |
| [Outcome](https://firebase.google.com/docs/reference/js/ai.md.txt#outcome) | Represents the result of the code execution. |
| [POSSIBLE_ROLES](https://firebase.google.com/docs/reference/js/ai.md.txt#possible_roles) | Possible roles. |
| [ResponseModality](https://firebase.google.com/docs/reference/js/ai.md.txt#responsemodality) | ***(Public Preview)*** Generation modalities to be returned in generation responses. |
| [SchemaType](https://firebase.google.com/docs/reference/js/ai.md.txt#schematype) | Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) |
| [ThinkingLevel](https://firebase.google.com/docs/reference/js/ai.md.txt#thinkinglevel) | A preset that controls the model's "thinking" process. Use `ThinkingLevel.LOW` for faster responses on less complex tasks, and `ThinkingLevel.HIGH` for better reasoning on more complex tasks. |
| [URLRetrievalStatus](https://firebase.google.com/docs/reference/js/ai.md.txt#urlretrievalstatus) | The status of a URL retrieval. |

## Type Aliases

| Type Alias | Description |
|---|---|
| [AIErrorCode](https://firebase.google.com/docs/reference/js/ai.md.txt#aierrorcode) | Standardized error codes that [AIError](https://firebase.google.com/docs/reference/js/ai.aierror.md.txt#aierror_class) can have. |
| [BackendType](https://firebase.google.com/docs/reference/js/ai.md.txt#backendtype) | Type alias representing valid backend types. It should be either `'AGENT_PLATFORM'` or `'GOOGLE_AI'`. |
| [BlockReason](https://firebase.google.com/docs/reference/js/ai.md.txt#blockreason) | Reason that a prompt was blocked. |
| [FinishReason](https://firebase.google.com/docs/reference/js/ai.md.txt#finishreason) | Reason that a candidate finished. |
| [FunctionCallingMode](https://firebase.google.com/docs/reference/js/ai.md.txt#functioncallingmode) |   |
| [HarmBlockMethod](https://firebase.google.com/docs/reference/js/ai.md.txt#harmblockmethod) | This property is not supported in the Gemini Developer API ([GoogleAIBackend](https://firebase.google.com/docs/reference/js/ai.googleaibackend.md.txt#googleaibackend_class)). |
| [HarmBlockThreshold](https://firebase.google.com/docs/reference/js/ai.md.txt#harmblockthreshold) | Threshold above which a prompt or candidate will be blocked. |
| [HarmCategory](https://firebase.google.com/docs/reference/js/ai.md.txt#harmcategory) | Harm categories that would cause prompts or candidates to be blocked. |
| [HarmProbability](https://firebase.google.com/docs/reference/js/ai.md.txt#harmprobability) | Probability that a prompt or candidate matches a harm category. |
| [HarmSeverity](https://firebase.google.com/docs/reference/js/ai.md.txt#harmseverity) | Harm severity levels. |
| [ImageConfigAspectRatio](https://firebase.google.com/docs/reference/js/ai.md.txt#imageconfigaspectratio) | Aspect ratios for generated images. |
| [ImageConfigImageSize](https://firebase.google.com/docs/reference/js/ai.md.txt#imageconfigimagesize) | Sizes for generated images. |
| [InferenceMode](https://firebase.google.com/docs/reference/js/ai.md.txt#inferencemode) | Determines whether inference happens on-device or in-cloud. |
| [InferenceSource](https://firebase.google.com/docs/reference/js/ai.md.txt#inferencesource) | Indicates whether inference happened on-device or in-cloud. |
| [Language](https://firebase.google.com/docs/reference/js/ai.md.txt#language) | The programming language of the code. |
| [LanguageModelMessageContentValue](https://firebase.google.com/docs/reference/js/ai.md.txt#languagemodelmessagecontentvalue) | Content formats that can be provided as on-device message content. |
| [LanguageModelMessageRole](https://firebase.google.com/docs/reference/js/ai.md.txt#languagemodelmessagerole) | Allowable roles for on-device language model usage. |
| [LanguageModelMessageType](https://firebase.google.com/docs/reference/js/ai.md.txt#languagemodelmessagetype) | Allowable types for on-device language model messages. |
| [LiveResponseType](https://firebase.google.com/docs/reference/js/ai.md.txt#liveresponsetype) | ***(Public Preview)*** The types of responses that can be returned by [LiveSession.receive()](https://firebase.google.com/docs/reference/js/ai.livesession.md.txt#livesessionreceive). This is a property on all messages that can be used for type narrowing. This property is not returned by the server, it is assigned to a server message object once it's parsed. |
| [Modality](https://firebase.google.com/docs/reference/js/ai.md.txt#modality) | Content part modality. |
| [Outcome](https://firebase.google.com/docs/reference/js/ai.md.txt#outcome) | Represents the result of the code execution. |
| [Part](https://firebase.google.com/docs/reference/js/ai.md.txt#part) | Content part - includes text, image/video, or function call/response part types. |
| [ResponseModality](https://firebase.google.com/docs/reference/js/ai.md.txt#responsemodality) | ***(Public Preview)*** Generation modalities to be returned in generation responses. |
| [Role](https://firebase.google.com/docs/reference/js/ai.md.txt#role) | Role is the producer of the content. |
| [SchemaType](https://firebase.google.com/docs/reference/js/ai.md.txt#schematype) | Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) |
| [SpeechConfig](https://firebase.google.com/docs/reference/js/ai.md.txt#speechconfig) | ***(Public Preview)*** Configures speech synthesis. |
| [TemplateTool](https://firebase.google.com/docs/reference/js/ai.md.txt#templatetool) | ***(Public Preview)*** Defines a tool that a [TemplateGenerativeModel](https://firebase.google.com/docs/reference/js/ai.templategenerativemodel.md.txt#templategenerativemodel_class) can call to access external knowledge. Only function declarations are currently supported for templates. |
| [ThinkingLevel](https://firebase.google.com/docs/reference/js/ai.md.txt#thinkinglevel) | A preset that controls the model's "thinking" process. Use `ThinkingLevel.LOW` for faster responses on less complex tasks, and `ThinkingLevel.HIGH` for better reasoning on more complex tasks. |
| [Tool](https://firebase.google.com/docs/reference/js/ai.md.txt#tool) | Defines a tool that model can call to access external knowledge. |
| [TypedSchema](https://firebase.google.com/docs/reference/js/ai.md.txt#typedschema) | A type that includes all specific Schema types. |
| [URLRetrievalStatus](https://firebase.google.com/docs/reference/js/ai.md.txt#urlretrievalstatus) | The status of a URL retrieval. |

## function(app, ...)

### getAI(app, options)

Returns the default [AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface) instance that is associated with the provided [FirebaseApp](https://firebase.google.com/docs/reference/js/app.firebaseapp.md.txt#firebaseapp_interface). If no instance exists, initializes a new instance with the default settings.

**Signature:**

```typescript
export declare function getAI(app?: FirebaseApp, options?: AIOptions): AI;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| app | [FirebaseApp](https://firebase.google.com/docs/reference/js/app.firebaseapp.md.txt#firebaseapp_interface) | The [FirebaseApp](https://firebase.google.com/docs/reference/js/app.firebaseapp.md.txt#firebaseapp_interface) to use. |
| options | [AIOptions](https://firebase.google.com/docs/reference/js/ai.aioptions.md.txt#aioptions_interface) | [AIOptions](https://firebase.google.com/docs/reference/js/ai.aioptions.md.txt#aioptions_interface) that configure the AI instance. |

**Returns:**

[AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface)

The default [AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface) instance for the given [FirebaseApp](https://firebase.google.com/docs/reference/js/app.firebaseapp.md.txt#firebaseapp_interface).

#### Exceptions

If `options.useLimitedUseAppCheckTokens` conflicts with the options of the existing [AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface) instance for the same app and backend.

### Example 1

```javascript
const ai = getAI(app);

```

### Example 2

```javascript
// Get an AI instance configured to use the Gemini Developer API (via Google AI).
const ai = getAI(app, { backend: new GoogleAIBackend() });

```

### Example 3

```javascript
// Get an AI instance configured to use the Agent Platform Gemini API.
const ai = getAI(app, { backend: new AgentPlatformBackend() });

```

## function(ai, ...)

### getGenerativeModel(ai, modelParams, requestOptions)

Returns a [GenerativeModel](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodel_class) class with methods for inference and other functionality.

**Signature:**

```typescript
export declare function getGenerativeModel(ai: AI, modelParams: ModelParams | HybridParams, requestOptions?: RequestOptions): GenerativeModel;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ai | [AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface) |   |
| modelParams | [ModelParams](https://firebase.google.com/docs/reference/js/ai.modelparams.md.txt#modelparams_interface) \| [HybridParams](https://firebase.google.com/docs/reference/js/ai.hybridparams.md.txt#hybridparams_interface) |   |
| requestOptions | [RequestOptions](https://firebase.google.com/docs/reference/js/ai.requestoptions.md.txt#requestoptions_interface) |   |

**Returns:**

[GenerativeModel](https://firebase.google.com/docs/reference/js/ai.generativemodel.md.txt#generativemodel_class)

### getLiveGenerativeModel(ai, modelParams)

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

Returns a [LiveGenerativeModel](https://firebase.google.com/docs/reference/js/ai.livegenerativemodel.md.txt#livegenerativemodel_class) class for real-time, bidirectional communication.

The Live API is only supported in modern browser windows and Node \>= 22.

**Signature:**

```typescript
export declare function getLiveGenerativeModel(ai: AI, modelParams: LiveModelParams): LiveGenerativeModel;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ai | [AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface) | An [AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface) instance. |
| modelParams | [LiveModelParams](https://firebase.google.com/docs/reference/js/ai.livemodelparams.md.txt#livemodelparams_interface) | Parameters to use when setting up a [LiveSession](https://firebase.google.com/docs/reference/js/ai.livesession.md.txt#livesession_class). |

**Returns:**

[LiveGenerativeModel](https://firebase.google.com/docs/reference/js/ai.livegenerativemodel.md.txt#livegenerativemodel_class)

#### Exceptions

If the `apiKey` or `projectId` fields are missing in your Firebase config.

### getTemplateGenerativeModel(ai, 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.

Returns a [TemplateGenerativeModel](https://firebase.google.com/docs/reference/js/ai.templategenerativemodel.md.txt#templategenerativemodel_class) class for executing server prompt templates.

**Signature:**

```typescript
export declare function getTemplateGenerativeModel(ai: AI, requestOptions?: RequestOptions): TemplateGenerativeModel;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| ai | [AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface) | An [AI](https://firebase.google.com/docs/reference/js/ai.ai.md.txt#ai_interface) instance. |
| requestOptions | [RequestOptions](https://firebase.google.com/docs/reference/js/ai.requestoptions.md.txt#requestoptions_interface) | Additional options to use when making requests. |

**Returns:**

[TemplateGenerativeModel](https://firebase.google.com/docs/reference/js/ai.templategenerativemodel.md.txt#templategenerativemodel_class)

## function(liveSession, ...)

### startAudioConversation(liveSession, options)

> 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 real-time, bidirectional audio conversation with the model. This helper function manages the complexities of microphone access, audio recording, playback, and interruptions.

> [!IMPORTANT]
> **Important:** This function must be called in response to a user gesture (for example, a button click) to comply with [browser autoplay policies](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Best_practices#autoplay_policy).

**Signature:**

```typescript
export declare function startAudioConversation(liveSession: LiveSession, options?: StartAudioConversationOptions): Promise<AudioConversationController>;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| liveSession | [LiveSession](https://firebase.google.com/docs/reference/js/ai.livesession.md.txt#livesession_class) | An active [LiveSession](https://firebase.google.com/docs/reference/js/ai.livesession.md.txt#livesession_class) instance. |
| options | [StartAudioConversationOptions](https://firebase.google.com/docs/reference/js/ai.startaudioconversationoptions.md.txt#startaudioconversationoptions_interface) | Configuration options for the audio conversation. |

**Returns:**

Promise\<[AudioConversationController](https://firebase.google.com/docs/reference/js/ai.audioconversationcontroller.md.txt#audioconversationcontroller_interface)\>

A `Promise` that resolves with an [AudioConversationController](https://firebase.google.com/docs/reference/js/ai.audioconversationcontroller.md.txt#audioconversationcontroller_interface).

#### Exceptions

`AIError` if the environment does not support required Web APIs (`UNSUPPORTED`), if a conversation is already active (`REQUEST_ERROR`), the session is closed (`SESSION_CLOSED`), or if an unexpected initialization error occurs (`ERROR`).

`DOMException` Thrown by `navigator.mediaDevices.getUserMedia()` if issues occur with microphone access, such as permissions being denied (`NotAllowedError`) or no compatible hardware being found (`NotFoundError`). See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions) for a full list of exceptions.

### Example

```javascript
const liveSession = await model.connect();
let conversationController;

// This function must be called from within a click handler.
async function startConversation() {
  try {
    conversationController = await startAudioConversation(liveSession);
  } catch (e) {
    // Handle AI-specific errors
    if (e instanceof AIError) {
      console.error("AI Error:", e.message);
    }
    // Handle microphone permission and hardware errors
    else if (e instanceof DOMException) {
      console.error("Microphone Error:", e.message);
    }
    // Handle other unexpected errors
    else {
      console.error("An unexpected error occurred:", e);
    }
  }
}

// Later, to stop the conversation:
// if (conversationController) {
//   await conversationController.stop();
// }

```

## AIErrorCode

Standardized error codes that [AIError](https://firebase.google.com/docs/reference/js/ai.aierror.md.txt#aierror_class) can have.

**Signature:**

```typescript
AIErrorCode: {
    readonly ERROR: "error";
    readonly REQUEST_ERROR: "request-error";
    readonly RESPONSE_ERROR: "response-error";
    readonly FETCH_ERROR: "fetch-error";
    readonly SESSION_CLOSED: "session-closed";
    readonly INVALID_CONTENT: "invalid-content";
    readonly API_NOT_ENABLED: "api-not-enabled";
    readonly ALREADY_INITIALIZED: "already-initialized";
    readonly INVALID_SCHEMA: "invalid-schema";
    readonly NO_API_KEY: "no-api-key";
    readonly NO_APP_ID: "no-app-id";
    readonly NO_MODEL: "no-model";
    readonly NO_PROJECT_ID: "no-project-id";
    readonly PARSE_FAILED: "parse-failed";
    readonly UNSUPPORTED: "unsupported";
}
```

## BackendType

An enum-like object containing constants that represent the supported backends for the Firebase AI SDK. This determines which backend service (Gemini Developer API or Agent Platform Gemini API) the SDK will communicate with.

These values are assigned to the `backendType` property within the specific backend configuration objects ([GoogleAIBackend](https://firebase.google.com/docs/reference/js/ai.googleaibackend.md.txt#googleaibackend_class) or [AgentPlatformBackend](https://firebase.google.com/docs/reference/js/ai.agentplatformbackend.md.txt#agentplatformbackend_class)) to identify which service to target.

**Signature:**

```typescript
BackendType: {
    readonly AGENT_PLATFORM: "AGENT_PLATFORM";
    readonly GOOGLE_AI: "GOOGLE_AI";
}
```

## BlockReason

Reason that a prompt was blocked.

**Signature:**

```typescript
BlockReason: {
    readonly SAFETY: "SAFETY";
    readonly OTHER: "OTHER";
    readonly BLOCKLIST: "BLOCKLIST";
    readonly PROHIBITED_CONTENT: "PROHIBITED_CONTENT";
}
```

## FinishReason

Reason that a candidate finished.

**Signature:**

```typescript
FinishReason: {
    readonly STOP: "STOP";
    readonly MAX_TOKENS: "MAX_TOKENS";
    readonly SAFETY: "SAFETY";
    readonly RECITATION: "RECITATION";
    readonly OTHER: "OTHER";
    readonly BLOCKLIST: "BLOCKLIST";
    readonly PROHIBITED_CONTENT: "PROHIBITED_CONTENT";
    readonly SPII: "SPII";
    readonly MALFORMED_FUNCTION_CALL: "MALFORMED_FUNCTION_CALL";
    readonly IMAGE_SAFETY: "IMAGE_SAFETY";
    readonly IMAGE_PROHIBITED_CONTENT: "IMAGE_PROHIBITED_CONTENT";
    readonly IMAGE_OTHER: "IMAGE_OTHER";
    readonly NO_IMAGE: "NO_IMAGE";
    readonly IMAGE_RECITATION: "IMAGE_RECITATION";
    readonly LANGUAGE: "LANGUAGE";
    readonly UNEXPECTED_TOOL_CALL: "UNEXPECTED_TOOL_CALL";
    readonly TOO_MANY_TOOL_CALLS: "TOO_MANY_TOOL_CALLS";
    readonly MISSING_THOUGHT_SIGNATURE: "MISSING_THOUGHT_SIGNATURE";
    readonly MALFORMED_RESPONSE: "MALFORMED_RESPONSE";
}
```

## FunctionCallingMode

**Signature:**

```typescript
FunctionCallingMode: {
    readonly AUTO: "AUTO";
    readonly ANY: "ANY";
    readonly NONE: "NONE";
}
```

## HarmBlockMethod

This property is not supported in the Gemini Developer API ([GoogleAIBackend](https://firebase.google.com/docs/reference/js/ai.googleaibackend.md.txt#googleaibackend_class)).

**Signature:**

```typescript
HarmBlockMethod: {
    readonly SEVERITY: "SEVERITY";
    readonly PROBABILITY: "PROBABILITY";
}
```

## HarmBlockThreshold

Threshold above which a prompt or candidate will be blocked.

**Signature:**

```typescript
HarmBlockThreshold: {
    readonly BLOCK_LOW_AND_ABOVE: "BLOCK_LOW_AND_ABOVE";
    readonly BLOCK_MEDIUM_AND_ABOVE: "BLOCK_MEDIUM_AND_ABOVE";
    readonly BLOCK_ONLY_HIGH: "BLOCK_ONLY_HIGH";
    readonly BLOCK_NONE: "BLOCK_NONE";
    readonly OFF: "OFF";
}
```

## HarmCategory

Harm categories that would cause prompts or candidates to be blocked.

**Signature:**

```typescript
HarmCategory: {
    readonly HARM_CATEGORY_HATE_SPEECH: "HARM_CATEGORY_HATE_SPEECH";
    readonly HARM_CATEGORY_SEXUALLY_EXPLICIT: "HARM_CATEGORY_SEXUALLY_EXPLICIT";
    readonly HARM_CATEGORY_HARASSMENT: "HARM_CATEGORY_HARASSMENT";
    readonly HARM_CATEGORY_DANGEROUS_CONTENT: "HARM_CATEGORY_DANGEROUS_CONTENT";
}
```

## HarmProbability

Probability that a prompt or candidate matches a harm category.

**Signature:**

```typescript
HarmProbability: {
    readonly NEGLIGIBLE: "NEGLIGIBLE";
    readonly LOW: "LOW";
    readonly MEDIUM: "MEDIUM";
    readonly HIGH: "HIGH";
}
```

## HarmSeverity

Harm severity levels.

**Signature:**

```typescript
HarmSeverity: {
    readonly HARM_SEVERITY_NEGLIGIBLE: "HARM_SEVERITY_NEGLIGIBLE";
    readonly HARM_SEVERITY_LOW: "HARM_SEVERITY_LOW";
    readonly HARM_SEVERITY_MEDIUM: "HARM_SEVERITY_MEDIUM";
    readonly HARM_SEVERITY_HIGH: "HARM_SEVERITY_HIGH";
    readonly HARM_SEVERITY_UNSUPPORTED: "HARM_SEVERITY_UNSUPPORTED";
}
```

## ImageConfigAspectRatio

Aspect ratios for generated images.

**Signature:**

```typescript
ImageConfigAspectRatio: {
    readonly SQUARE_1x1: "1:1";
    readonly PORTRAIT_9x16: "9:16";
    readonly LANDSCAPE_16x9: "16:9";
    readonly PORTRAIT_3x4: "3:4";
    readonly LANDSCAPE_4x3: "4:3";
    readonly PORTRAIT_2x3: "2:3";
    readonly LANDSCAPE_3x2: "3:2";
    readonly PORTRAIT_4x5: "4:5";
    readonly LANDSCAPE_5x4: "5:4";
    readonly PORTRAIT_1x4: "1:4";
    readonly LANDSCAPE_4x1: "4:1";
    readonly PORTRAIT_1x8: "1:8";
    readonly LANDSCAPE_8x1: "8:1";
    readonly ULTRAWIDE_21x9: "21:9";
}
```

## ImageConfigImageSize

Sizes for generated images. For example, '1K' is 1024px, '2K' is 2048px, and '4K' is 4096px.

**Signature:**

```typescript
ImageConfigImageSize: {
    readonly SIZE_512: "512";
    readonly SIZE_1K: "1K";
    readonly SIZE_2K: "2K";
    readonly SIZE_4K: "4K";
}
```

## InferenceMode

Determines whether inference happens on-device or in-cloud.

**PREFER_ON_DEVICE:** Attempt to make inference calls using an on-device model. If on-device inference is not available, the SDK will fall back to using a cloud-hosted model.   
**ONLY_ON_DEVICE:** Only attempt to make inference calls using an on-device model. The SDK will not fall back to a cloud-hosted model. If on-device inference is not available, inference methods will throw.   
**ONLY_IN_CLOUD:** Only attempt to make inference calls using a cloud-hosted model. The SDK will not fall back to an on-device model.   
**PREFER_IN_CLOUD:** Attempt to make inference calls to a cloud-hosted model. If not available, the SDK will fall back to an on-device model.

**Signature:**

```typescript
InferenceMode: {
    readonly PREFER_ON_DEVICE: "prefer_on_device";
    readonly ONLY_ON_DEVICE: "only_on_device";
    readonly ONLY_IN_CLOUD: "only_in_cloud";
    readonly PREFER_IN_CLOUD: "prefer_in_cloud";
}
```

## InferenceSource

Indicates whether inference happened on-device or in-cloud.

**Signature:**

```typescript
InferenceSource: {
    readonly ON_DEVICE: "on_device";
    readonly IN_CLOUD: "in_cloud";
}
```

## Language

The programming language of the code.

**Signature:**

```typescript
Language: {
    UNSPECIFIED: string;
    PYTHON: string;
}
```

## LiveResponseType

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

The types of responses that can be returned by [LiveSession.receive()](https://firebase.google.com/docs/reference/js/ai.livesession.md.txt#livesessionreceive).

**Signature:**

```typescript
LiveResponseType: {
    SERVER_CONTENT: string;
    TOOL_CALL: string;
    TOOL_CALL_CANCELLATION: string;
    GOING_AWAY_NOTICE: string;
    SESSION_RESUMPTION_UPDATE: string;
}
```

## Modality

Content part modality.

**Signature:**

```typescript
Modality: {
    readonly MODALITY_UNSPECIFIED: "MODALITY_UNSPECIFIED";
    readonly TEXT: "TEXT";
    readonly IMAGE: "IMAGE";
    readonly VIDEO: "VIDEO";
    readonly AUDIO: "AUDIO";
    readonly DOCUMENT: "DOCUMENT";
}
```

## Outcome

Represents the result of the code execution.

**Signature:**

```typescript
Outcome: {
    UNSPECIFIED: string;
    OK: string;
    FAILED: string;
    DEADLINE_EXCEEDED: string;
}
```

## POSSIBLE_ROLES

Possible roles.

**Signature:**

```typescript
POSSIBLE_ROLES: readonly ["user", "model", "function", "system"]
```

## ResponseModality

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

Generation modalities to be returned in generation responses.

**Signature:**

```typescript
ResponseModality: {
    readonly TEXT: "TEXT";
    readonly IMAGE: "IMAGE";
    readonly AUDIO: "AUDIO";
}
```

## SchemaType

Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/)

**Signature:**

```typescript
SchemaType: {
    readonly STRING: "string";
    readonly NUMBER: "number";
    readonly INTEGER: "integer";
    readonly BOOLEAN: "boolean";
    readonly ARRAY: "array";
    readonly OBJECT: "object";
}
```

## ThinkingLevel

A preset that controls the model's "thinking" process. Use `ThinkingLevel.LOW` for faster responses on less complex tasks, and `ThinkingLevel.HIGH` for better reasoning on more complex tasks.

**Signature:**

```typescript
ThinkingLevel: {
    MINIMAL: string;
    LOW: string;
    MEDIUM: string;
    HIGH: string;
}
```

## URLRetrievalStatus

The status of a URL retrieval.

**URL_RETRIEVAL_STATUS_UNSPECIFIED:** Unspecified retrieval status.   
**URL_RETRIEVAL_STATUS_SUCCESS:** The URL retrieval was successful.   
**URL_RETRIEVAL_STATUS_ERROR:** The URL retrieval failed.   
**URL_RETRIEVAL_STATUS_PAYWALL:** The URL retrieval failed because the content is behind a paywall.   
**URL_RETRIEVAL_STATUS_UNSAFE:** The URL retrieval failed because the content is unsafe.   

**Signature:**

```typescript
URLRetrievalStatus: {
    URL_RETRIEVAL_STATUS_UNSPECIFIED: string;
    URL_RETRIEVAL_STATUS_SUCCESS: string;
    URL_RETRIEVAL_STATUS_ERROR: string;
    URL_RETRIEVAL_STATUS_PAYWALL: string;
    URL_RETRIEVAL_STATUS_UNSAFE: string;
}
```

## AIErrorCode

Standardized error codes that [AIError](https://firebase.google.com/docs/reference/js/ai.aierror.md.txt#aierror_class) can have.

**Signature:**

```typescript
export type AIErrorCode = (typeof AIErrorCode)[keyof typeof AIErrorCode];
```

## BackendType

Type alias representing valid backend types. It should be either `'AGENT_PLATFORM'` or `'GOOGLE_AI'`.

**Signature:**

```typescript
export type BackendType = (typeof BackendType)[keyof typeof BackendType];
```

## BlockReason

Reason that a prompt was blocked.

**Signature:**

```typescript
export type BlockReason = (typeof BlockReason)[keyof typeof BlockReason];
```

## FinishReason

Reason that a candidate finished.

**Signature:**

```typescript
export type FinishReason = (typeof FinishReason)[keyof typeof FinishReason];
```

## FunctionCallingMode

**Signature:**

```typescript
export type FunctionCallingMode = (typeof FunctionCallingMode)[keyof typeof FunctionCallingMode];
```

## HarmBlockMethod

This property is not supported in the Gemini Developer API ([GoogleAIBackend](https://firebase.google.com/docs/reference/js/ai.googleaibackend.md.txt#googleaibackend_class)).

**Signature:**

```typescript
export type HarmBlockMethod = (typeof HarmBlockMethod)[keyof typeof HarmBlockMethod];
```

## HarmBlockThreshold

Threshold above which a prompt or candidate will be blocked.

**Signature:**

```typescript
export type HarmBlockThreshold = (typeof HarmBlockThreshold)[keyof typeof HarmBlockThreshold];
```

## HarmCategory

Harm categories that would cause prompts or candidates to be blocked.

**Signature:**

```typescript
export type HarmCategory = (typeof HarmCategory)[keyof typeof HarmCategory];
```

## HarmProbability

Probability that a prompt or candidate matches a harm category.

**Signature:**

```typescript
export type HarmProbability = (typeof HarmProbability)[keyof typeof HarmProbability];
```

## HarmSeverity

Harm severity levels.

**Signature:**

```typescript
export type HarmSeverity = (typeof HarmSeverity)[keyof typeof HarmSeverity];
```

## ImageConfigAspectRatio

Aspect ratios for generated images.

**Signature:**

```typescript
export type ImageConfigAspectRatio = (typeof ImageConfigAspectRatio)[keyof typeof ImageConfigAspectRatio];
```

## ImageConfigImageSize

Sizes for generated images.

**Signature:**

```typescript
export type ImageConfigImageSize = (typeof ImageConfigImageSize)[keyof typeof ImageConfigImageSize];
```

## InferenceMode

Determines whether inference happens on-device or in-cloud.

**Signature:**

```typescript
export type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
```

## InferenceSource

Indicates whether inference happened on-device or in-cloud.

**Signature:**

```typescript
export type InferenceSource = (typeof InferenceSource)[keyof typeof InferenceSource];
```

## Language

The programming language of the code.

**Signature:**

```typescript
export type Language = (typeof Language)[keyof typeof Language];
```

## LanguageModelMessageContentValue

Content formats that can be provided as on-device message content.

**Signature:**

```typescript
export type LanguageModelMessageContentValue = ImageBitmapSource | AudioBuffer | BufferSource | string;
```

## LanguageModelMessageRole

Allowable roles for on-device language model usage.

**Signature:**

```typescript
export type LanguageModelMessageRole = 'system' | 'user' | 'assistant';
```

## LanguageModelMessageType

Allowable types for on-device language model messages.

**Signature:**

```typescript
export type LanguageModelMessageType = 'text' | 'image' | 'audio';
```

## LiveResponseType

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

The types of responses that can be returned by [LiveSession.receive()](https://firebase.google.com/docs/reference/js/ai.livesession.md.txt#livesessionreceive). This is a property on all messages that can be used for type narrowing. This property is not returned by the server, it is assigned to a server message object once it's parsed.

**Signature:**

```typescript
export type LiveResponseType = (typeof LiveResponseType)[keyof typeof LiveResponseType];
```

## Modality

Content part modality.

**Signature:**

```typescript
export type Modality = (typeof Modality)[keyof typeof Modality];
```

## Outcome

Represents the result of the code execution.

**Signature:**

```typescript
export type Outcome = (typeof Outcome)[keyof typeof Outcome];
```

## Part

Content part - includes text, image/video, or function call/response part types.

**Signature:**

```typescript
export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart | ExecutableCodePart | CodeExecutionResultPart;
```

## ResponseModality

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

Generation modalities to be returned in generation responses.

**Signature:**

```typescript
export type ResponseModality = (typeof ResponseModality)[keyof typeof ResponseModality];
```

## Role

Role is the producer of the content.

**Signature:**

```typescript
export type Role = (typeof POSSIBLE_ROLES)[number];
```

## SchemaType

Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/)

**Signature:**

```typescript
export type SchemaType = (typeof SchemaType)[keyof typeof SchemaType];
```

## SpeechConfig

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

Configures speech synthesis.

**Signature:**

```typescript
export type SpeechConfig = SingleSpeakerSpeechConfig | MultiSpeakerSpeechConfig;
```

## TemplateTool

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

Defines a tool that a [TemplateGenerativeModel](https://firebase.google.com/docs/reference/js/ai.templategenerativemodel.md.txt#templategenerativemodel_class) can call to access external knowledge. Only function declarations are currently supported for templates.

**Signature:**

```typescript
export type TemplateTool = TemplateFunctionDeclarationsTool;
```

## ThinkingLevel

A preset that controls the model's "thinking" process. Use `ThinkingLevel.LOW` for faster responses on less complex tasks, and `ThinkingLevel.HIGH` for better reasoning on more complex tasks.

**Signature:**

```typescript
export type ThinkingLevel = (typeof ThinkingLevel)[keyof typeof ThinkingLevel];
```

## Tool

Defines a tool that model can call to access external knowledge.

**Signature:**

```typescript
export type Tool = FunctionDeclarationsTool | GoogleMapsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
```

## TypedSchema

A type that includes all specific Schema types.

**Signature:**

```typescript
export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
```

## URLRetrievalStatus

The status of a URL retrieval.

**URL_RETRIEVAL_STATUS_UNSPECIFIED:** Unspecified retrieval status.   
**URL_RETRIEVAL_STATUS_SUCCESS:** The URL retrieval was successful.   
**URL_RETRIEVAL_STATUS_ERROR:** The URL retrieval failed.   
**URL_RETRIEVAL_STATUS_PAYWALL:** The URL retrieval failed because the content is behind a paywall.   
**URL_RETRIEVAL_STATUS_UNSAFE:** The URL retrieval failed because the content is unsafe.   

**Signature:**

```typescript
export type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
```