You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-devsite/ai.md
+75Lines changed: 75 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,8 @@ The Firebase AI Web SDK.
22
22
|[getGenerativeModel(ai, modelParams, requestOptions)](./ai.md#getgenerativemodel_80bd839)| Returns a [GenerativeModel](./ai.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. |
23
23
|[getImagenModel(ai, modelParams, requestOptions)](./ai.md#getimagenmodel_e1f6645)| <b><i>(Public Preview)</i></b> Returns an [ImagenModel](./ai.imagenmodel.md#imagenmodel_class) class with methods for using Imagen.<!---->Only Imagen 3 models (named <code>imagen-3.0-*</code>) are supported. |
24
24
|[getLiveGenerativeModel(ai, modelParams)](./ai.md#getlivegenerativemodel_f2099ac)| <b><i>(Public Preview)</i></b> Returns a [LiveGenerativeModel](./ai.livegenerativemodel.md#livegenerativemodel_class) class for real-time, bidirectional communication.<!---->The Live API is only supported in modern browser windows and Node ><!---->= 22. |
25
+
| <b>function(liveSession, ...)</b> |
26
+
|[startAudioConversation(liveSession, options)](./ai.md#startaudioconversation_01c8e7f)| <b><i>(Public Preview)</i></b> Starts a real-time, bidirectional audio conversation with the model. This helper function manages the complexities of microphone access, audio recording, playback, and interruptions. |
25
27
26
28
## Classes
27
29
@@ -53,6 +55,7 @@ The Firebase AI Web SDK.
53
55
| --- | --- |
54
56
|[AI](./ai.ai.md#ai_interface)| An instance of the Firebase AI SDK.<!---->Do not create this instance directly. Instead, use [getAI()](./ai.md#getai_a94a413)<!---->. |
55
57
|[AIOptions](./ai.aioptions.md#aioptions_interface)| Options for initializing the AI service using [getAI()](./ai.md#getai_a94a413)<!---->. This allows specifying which backend to use (Vertex AI Gemini API or Gemini Developer API) and configuring its specific options (like location for Vertex AI). |
58
+
|[AudioConversationController](./ai.audioconversationcontroller.md#audioconversationcontroller_interface)| <b><i>(Public Preview)</i></b> A controller for managing an active audio conversation. |
56
59
|[BaseParams](./ai.baseparams.md#baseparams_interface)| Base parameters for a number of methods. |
57
60
|[Citation](./ai.citation.md#citation_interface)| A single citation. |
58
61
|[CitationMetadata](./ai.citationmetadata.md#citationmetadata_interface)| Citation metadata that may be found on a [GenerateContentCandidate](./ai.generatecontentcandidate.md#generatecontentcandidate_interface)<!---->. |
@@ -112,6 +115,7 @@ The Firebase AI Web SDK.
112
115
|[SearchEntrypoint](./ai.searchentrypoint.md#searchentrypoint_interface)| Google search entry point. |
113
116
|[Segment](./ai.segment.md#segment_interface)| Represents a specific segment within a [Content](./ai.content.md#content_interface) object, often used to pinpoint the exact location of text or data that grounding information refers to. |
|[StartAudioConversationOptions](./ai.startaudioconversationoptions.md#startaudioconversationoptions_interface)| <b><i>(Public Preview)</i></b> Options for [startAudioConversation()](./ai.md#startaudioconversation_01c8e7f)<!---->. |
115
119
|[StartChatParams](./ai.startchatparams.md#startchatparams_interface)| Params for [GenerativeModel.startChat()](./ai.generativemodel.md#generativemodelstartchat)<!---->. |
116
120
|[TextPart](./ai.textpart.md#textpart_interface)| Content part interface if the part represents a text string. |
117
121
|[ThinkingConfig](./ai.thinkingconfig.md#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. |
> 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.
319
+
>
320
+
321
+
Starts a real-time, bidirectional audio conversation with the model. This helper function manages the complexities of microphone access, audio recording, playback, and interruptions.
322
+
323
+
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)<!---->.
| liveSession |[LiveSession](./ai.livesession.md#livesession_class)| An active [LiveSession](./ai.livesession.md#livesession_class) instance. |
336
+
| options |[StartAudioConversationOptions](./ai.startaudioconversationoptions.md#startaudioconversationoptions_interface)| Configuration options for the audio conversation. |
A `Promise` that resolves with an [AudioConversationController](./ai.audioconversationcontroller.md#audioconversationcontroller_interface)<!---->.
343
+
344
+
#### Exceptions
345
+
346
+
`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`<!---->).
347
+
348
+
`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.
349
+
350
+
### Example
351
+
352
+
353
+
```javascript
354
+
constliveSession=awaitmodel.connect();
355
+
let conversationController;
356
+
357
+
// This function must be called from within a click handler.
0 commit comments