@firebase/ai 2.1.0 → 2.2.0-canary.095c098de

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/ai-public.d.ts +443 -10
  2. package/dist/ai.d.ts +525 -11
  3. package/dist/esm/index.esm.js +1255 -368
  4. package/dist/esm/index.esm.js.map +1 -1
  5. package/dist/esm/src/api.d.ts +18 -3
  6. package/dist/esm/src/constants.d.ts +1 -1
  7. package/dist/esm/src/index.d.ts +2 -1
  8. package/dist/esm/src/methods/chrome-adapter.d.ts +30 -24
  9. package/dist/esm/src/methods/live-session-helpers.d.ts +154 -0
  10. package/dist/esm/src/methods/live-session.d.ts +90 -0
  11. package/dist/esm/src/models/ai-model.d.ts +1 -1
  12. package/dist/esm/src/models/index.d.ts +1 -0
  13. package/dist/esm/src/models/live-generative-model.d.ts +55 -0
  14. package/dist/esm/src/public-types.d.ts +10 -1
  15. package/dist/esm/src/requests/request.d.ts +6 -0
  16. package/dist/esm/src/requests/response-helpers.d.ts +9 -5
  17. package/dist/esm/src/service.d.ts +7 -2
  18. package/dist/esm/src/types/chrome-adapter.d.ts +6 -4
  19. package/dist/esm/src/types/content.d.ts +42 -0
  20. package/dist/esm/src/types/enums.d.ts +5 -0
  21. package/dist/esm/src/types/error.d.ts +2 -0
  22. package/dist/esm/src/types/imagen/internal.d.ts +10 -0
  23. package/dist/esm/src/types/live-responses.d.ts +53 -0
  24. package/dist/esm/src/types/requests.d.ts +109 -1
  25. package/dist/esm/src/types/responses.d.ts +87 -4
  26. package/dist/esm/src/websocket.d.ts +67 -0
  27. package/dist/index.cjs.js +1258 -366
  28. package/dist/index.cjs.js.map +1 -1
  29. package/dist/index.node.cjs.js +907 -311
  30. package/dist/index.node.cjs.js.map +1 -1
  31. package/dist/index.node.mjs +904 -313
  32. package/dist/index.node.mjs.map +1 -1
  33. package/dist/src/api.d.ts +18 -3
  34. package/dist/src/constants.d.ts +1 -1
  35. package/dist/src/index.d.ts +2 -1
  36. package/dist/src/methods/chrome-adapter.d.ts +30 -24
  37. package/dist/src/methods/live-session-helpers.d.ts +154 -0
  38. package/dist/src/methods/live-session.d.ts +90 -0
  39. package/dist/src/models/ai-model.d.ts +1 -1
  40. package/dist/src/models/index.d.ts +1 -0
  41. package/dist/src/models/live-generative-model.d.ts +55 -0
  42. package/dist/src/public-types.d.ts +10 -1
  43. package/dist/src/requests/request.d.ts +6 -0
  44. package/dist/src/requests/response-helpers.d.ts +9 -5
  45. package/dist/src/service.d.ts +7 -2
  46. package/dist/src/types/chrome-adapter.d.ts +6 -4
  47. package/dist/src/types/content.d.ts +42 -0
  48. package/dist/src/types/enums.d.ts +5 -0
  49. package/dist/src/types/error.d.ts +2 -0
  50. package/dist/src/types/imagen/internal.d.ts +10 -0
  51. package/dist/src/types/live-responses.d.ts +53 -0
  52. package/dist/src/types/requests.d.ts +109 -1
  53. package/dist/src/types/responses.d.ts +87 -4
  54. package/dist/src/websocket.d.ts +67 -0
  55. package/package.json +10 -8
package/dist/ai.d.ts CHANGED
@@ -27,6 +27,10 @@ export declare interface AI {
27
27
  * Vertex AI Gemini API (using {@link VertexAIBackend}).
28
28
  */
29
29
  backend: Backend;
30
+ /**
31
+ * Options applied to this {@link AI} instance.
32
+ */
33
+ options?: AIOptions;
30
34
  /**
31
35
  * @deprecated use `AI.backend.location` instead.
32
36
  *
@@ -67,6 +71,8 @@ export declare const AIErrorCode: {
67
71
  readonly RESPONSE_ERROR: "response-error";
68
72
  /** An error occurred while performing a fetch. */
69
73
  readonly FETCH_ERROR: "fetch-error";
74
+ /** An error occurred because an operation was attempted on a closed session. */
75
+ readonly SESSION_CLOSED: "session-closed";
70
76
  /** An error associated with a Content object. */
71
77
  readonly INVALID_CONTENT: "invalid-content";
72
78
  /** An error due to the Firebase API not being enabled in the Console. */
@@ -111,7 +117,7 @@ export declare abstract class AIModel {
111
117
  /**
112
118
  * @internal
113
119
  */
114
- protected _apiSettings: ApiSettings;
120
+ _apiSettings: ApiSettings;
115
121
  /**
116
122
  * Constructs a new instance of the {@link AIModel} class.
117
123
  *
@@ -159,8 +165,13 @@ export declare abstract class AIModel {
159
165
  export declare interface AIOptions {
160
166
  /**
161
167
  * The backend configuration to use for the AI service instance.
168
+ * Defaults to the Gemini Developer API backend ({@link GoogleAIBackend}).
162
169
  */
163
- backend: Backend;
170
+ backend?: Backend;
171
+ /**
172
+ * Whether to use App Check limited use tokens. Defaults to false.
173
+ */
174
+ useLimitedUseAppCheckTokens?: boolean;
164
175
  }
165
176
 
166
177
  /**
@@ -208,6 +219,19 @@ export declare class ArraySchema extends Schema {
208
219
  toJSON(): SchemaRequest;
209
220
  }
210
221
 
222
+ /**
223
+ * A controller for managing an active audio conversation.
224
+ *
225
+ * @beta
226
+ */
227
+ export declare interface AudioConversationController {
228
+ /**
229
+ * Stops the audio conversation, closes the microphone connection, and
230
+ * cleans up resources. Returns a promise that resolves when cleanup is complete.
231
+ */
232
+ stop: () => Promise<void>;
233
+ }
234
+
211
235
  /**
212
236
  * Abstract base class representing the configuration for an AI service backend.
213
237
  * This class should not be instantiated directly. Use its subclasses; {@link GoogleAIBackend} for
@@ -360,16 +384,18 @@ export declare interface ChromeAdapter {
360
384
  /**
361
385
  * Generates content using on-device inference.
362
386
  *
363
- * <p>This is comparable to {@link GenerativeModel.generateContent} for generating
364
- * content using in-cloud inference.</p>
387
+ * @remarks
388
+ * This is comparable to {@link GenerativeModel.generateContent} for generating
389
+ * content using in-cloud inference.
365
390
  * @param request - a standard Firebase AI {@link GenerateContentRequest}
366
391
  */
367
392
  generateContent(request: GenerateContentRequest): Promise<Response>;
368
393
  /**
369
394
  * Generates a content stream using on-device inference.
370
395
  *
371
- * <p>This is comparable to {@link GenerativeModel.generateContentStream} for generating
372
- * a content stream using in-cloud inference.</p>
396
+ * @remarks
397
+ * This is comparable to {@link GenerativeModel.generateContentStream} for generating
398
+ * a content stream using in-cloud inference.
373
399
  * @param request - a standard Firebase AI {@link GenerateContentRequest}
374
400
  */
375
401
  generateContentStream(request: GenerateContentRequest): Promise<Response>;
@@ -500,15 +526,34 @@ export declare interface EnhancedGenerateContentResponse extends GenerateContent
500
526
  */
501
527
  text: () => string;
502
528
  /**
503
- * Aggregates and returns all {@link InlineDataPart}s from the {@link GenerateContentResponse}'s
504
- * first candidate.
505
- *
506
- * @returns An array of {@link InlineDataPart}s containing data from the response, if available.
529
+ * Aggregates and returns every {@link InlineDataPart} from the first candidate of
530
+ * {@link GenerateContentResponse}.
507
531
  *
508
532
  * @throws If the prompt or candidate was blocked.
509
533
  */
510
534
  inlineDataParts: () => InlineDataPart[] | undefined;
535
+ /**
536
+ * Aggregates and returns every {@link FunctionCall} from the first candidate of
537
+ * {@link GenerateContentResponse}.
538
+ *
539
+ * @throws If the prompt or candidate was blocked.
540
+ */
511
541
  functionCalls: () => FunctionCall[] | undefined;
542
+ /**
543
+ * Aggregates and returns every {@link TextPart} with their `thought` property set
544
+ * to `true` from the first candidate of {@link GenerateContentResponse}.
545
+ *
546
+ * @throws If the prompt or candidate was blocked.
547
+ *
548
+ * @remarks
549
+ * Thought summaries provide a brief overview of the model's internal thinking process,
550
+ * offering insight into how it arrived at the final answer. This can be useful for
551
+ * debugging, understanding the model's reasoning, and verifying its accuracy.
552
+ *
553
+ * Thoughts will only be included if {@link ThinkingConfig.includeThoughts} is
554
+ * set to `true`.
555
+ */
556
+ thoughtSummary: () => string | undefined;
512
557
  }
513
558
 
514
559
  /**
@@ -547,6 +592,11 @@ export declare interface FileDataPart {
547
592
  functionCall?: never;
548
593
  functionResponse?: never;
549
594
  fileData: FileData;
595
+ thought?: boolean;
596
+ /**
597
+ * @internal
598
+ */
599
+ thoughtSignature?: never;
550
600
  }
551
601
 
552
602
  /**
@@ -605,6 +655,15 @@ export declare type FinishReason = (typeof FinishReason)[keyof typeof FinishReas
605
655
  * @public
606
656
  */
607
657
  export declare interface FunctionCall {
658
+ /**
659
+ * The id of the function call. This must be sent back in the associated {@link FunctionResponse}.
660
+ *
661
+ *
662
+ * @remarks This property is only supported in the Gemini Developer API ({@link GoogleAIBackend}).
663
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), this property will be
664
+ * `undefined`.
665
+ */
666
+ id?: string;
608
667
  name: string;
609
668
  args: object;
610
669
  }
@@ -654,6 +713,11 @@ export declare interface FunctionCallPart {
654
713
  inlineData?: never;
655
714
  functionCall: FunctionCall;
656
715
  functionResponse?: never;
716
+ thought?: boolean;
717
+ /**
718
+ * @internal
719
+ */
720
+ thoughtSignature?: never;
657
721
  }
658
722
 
659
723
  /**
@@ -715,6 +779,14 @@ export declare interface FunctionDeclarationsTool {
715
779
  * @public
716
780
  */
717
781
  export declare interface FunctionResponse {
782
+ /**
783
+ * The id of the {@link FunctionCall}.
784
+ *
785
+ * @remarks This property is only supported in the Gemini Developer API ({@link GoogleAIBackend}).
786
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), this property will be
787
+ * `undefined`.
788
+ */
789
+ id?: string;
718
790
  name: string;
719
791
  response: object;
720
792
  }
@@ -728,6 +800,11 @@ export declare interface FunctionResponsePart {
728
800
  inlineData?: never;
729
801
  functionCall?: never;
730
802
  functionResponse: FunctionResponse;
803
+ thought?: boolean;
804
+ /**
805
+ * @internal
806
+ */
807
+ thoughtSignature?: never;
731
808
  }
732
809
 
733
810
  /**
@@ -937,6 +1014,20 @@ export declare function getGenerativeModel(ai: AI, modelParams: ModelParams | Hy
937
1014
  */
938
1015
  export declare function getImagenModel(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
939
1016
 
1017
+ /**
1018
+ * Returns a {@link LiveGenerativeModel} class for real-time, bidirectional communication.
1019
+ *
1020
+ * The Live API is only supported in modern browser windows and Node >= 22.
1021
+ *
1022
+ * @param ai - An {@link AI} instance.
1023
+ * @param modelParams - Parameters to use when setting up a {@link LiveSession}.
1024
+ * @throws If the `apiKey` or `projectId` fields are missing in your
1025
+ * Firebase config.
1026
+ *
1027
+ * @beta
1028
+ */
1029
+ export declare function getLiveGenerativeModel(ai: AI, modelParams: LiveModelParams): LiveGenerativeModel;
1030
+
940
1031
  /**
941
1032
  * Configuration class for the Gemini Developer API.
942
1033
  *
@@ -1759,6 +1850,11 @@ export declare interface InlineDataPart {
1759
1850
  * Applicable if `inlineData` is a video.
1760
1851
  */
1761
1852
  videoMetadata?: VideoMetadata;
1853
+ thought?: boolean;
1854
+ /**
1855
+ * @internal
1856
+ */
1857
+ thoughtSignature?: never;
1762
1858
  }
1763
1859
 
1764
1860
  /**
@@ -1849,6 +1945,247 @@ export declare interface LanguageModelPromptOptions {
1849
1945
  responseConstraint?: object;
1850
1946
  }
1851
1947
 
1948
+ /**
1949
+ * Configuration parameters used by {@link LiveGenerativeModel} to control live content generation.
1950
+ *
1951
+ * @beta
1952
+ */
1953
+ export declare interface LiveGenerationConfig {
1954
+ /**
1955
+ * Configuration for speech synthesis.
1956
+ */
1957
+ speechConfig?: SpeechConfig;
1958
+ /**
1959
+ * Specifies the maximum number of tokens that can be generated in the response. The number of
1960
+ * tokens per word varies depending on the language outputted. Is unbounded by default.
1961
+ */
1962
+ maxOutputTokens?: number;
1963
+ /**
1964
+ * Controls the degree of randomness in token selection. A `temperature` value of 0 means that the highest
1965
+ * probability tokens are always selected. In this case, responses for a given prompt are mostly
1966
+ * deterministic, but a small amount of variation is still possible.
1967
+ */
1968
+ temperature?: number;
1969
+ /**
1970
+ * Changes how the model selects tokens for output. Tokens are
1971
+ * selected from the most to least probable until the sum of their probabilities equals the `topP`
1972
+ * value. For example, if tokens A, B, and C have probabilities of 0.3, 0.2, and 0.1 respectively
1973
+ * and the `topP` value is 0.5, then the model will select either A or B as the next token by using
1974
+ * the `temperature` and exclude C as a candidate. Defaults to 0.95 if unset.
1975
+ */
1976
+ topP?: number;
1977
+ /**
1978
+ * Changes how the model selects token for output. A `topK` value of 1 means the select token is
1979
+ * the most probable among all tokens in the model's vocabulary, while a `topK` value 3 means that
1980
+ * the next token is selected from among the 3 most probably using probabilities sampled. Tokens
1981
+ * are then further filtered with the highest selected `temperature` sampling. Defaults to 40
1982
+ * if unspecified.
1983
+ */
1984
+ topK?: number;
1985
+ /**
1986
+ * Positive penalties.
1987
+ */
1988
+ presencePenalty?: number;
1989
+ /**
1990
+ * Frequency penalties.
1991
+ */
1992
+ frequencyPenalty?: number;
1993
+ /**
1994
+ * The modalities of the response.
1995
+ */
1996
+ responseModalities?: ResponseModality[];
1997
+ }
1998
+
1999
+ /**
2000
+ * Class for Live generative model APIs. The Live API enables low-latency, two-way multimodal
2001
+ * interactions with Gemini.
2002
+ *
2003
+ * This class should only be instantiated with {@link getLiveGenerativeModel}.
2004
+ *
2005
+ * @beta
2006
+ */
2007
+ export declare class LiveGenerativeModel extends AIModel {
2008
+ /**
2009
+ * @internal
2010
+ */
2011
+ private _webSocketHandler;
2012
+ generationConfig: LiveGenerationConfig;
2013
+ tools?: Tool[];
2014
+ toolConfig?: ToolConfig;
2015
+ systemInstruction?: Content;
2016
+ /**
2017
+ * @internal
2018
+ */
2019
+ constructor(ai: AI, modelParams: LiveModelParams,
2020
+ /**
2021
+ * @internal
2022
+ */
2023
+ _webSocketHandler: WebSocketHandler);
2024
+ /**
2025
+ * Starts a {@link LiveSession}.
2026
+ *
2027
+ * @returns A {@link LiveSession}.
2028
+ * @throws If the connection failed to be established with the server.
2029
+ *
2030
+ * @beta
2031
+ */
2032
+ connect(): Promise<LiveSession>;
2033
+ }
2034
+
2035
+ /**
2036
+ * Params passed to {@link getLiveGenerativeModel}.
2037
+ * @beta
2038
+ */
2039
+ export declare interface LiveModelParams {
2040
+ model: string;
2041
+ generationConfig?: LiveGenerationConfig;
2042
+ tools?: Tool[];
2043
+ toolConfig?: ToolConfig;
2044
+ systemInstruction?: string | Part | Content;
2045
+ }
2046
+
2047
+ /**
2048
+ * The types of responses that can be returned by {@link LiveSession.receive}.
2049
+ *
2050
+ * @beta
2051
+ */
2052
+ export declare const LiveResponseType: {
2053
+ SERVER_CONTENT: string;
2054
+ TOOL_CALL: string;
2055
+ TOOL_CALL_CANCELLATION: string;
2056
+ };
2057
+
2058
+ /**
2059
+ * The types of responses that can be returned by {@link LiveSession.receive}.
2060
+ * This is a property on all messages that can be used for type narrowing. This property is not
2061
+ * returned by the server, it is assigned to a server message object once it's parsed.
2062
+ *
2063
+ * @beta
2064
+ */
2065
+ export declare type LiveResponseType = (typeof LiveResponseType)[keyof typeof LiveResponseType];
2066
+
2067
+ /**
2068
+ * An incremental content update from the model.
2069
+ *
2070
+ * @beta
2071
+ */
2072
+ export declare interface LiveServerContent {
2073
+ type: 'serverContent';
2074
+ /**
2075
+ * The content that the model has generated as part of the current conversation with the user.
2076
+ */
2077
+ modelTurn?: Content;
2078
+ /**
2079
+ * Indicates whether the turn is complete. This is `undefined` if the turn is not complete.
2080
+ */
2081
+ turnComplete?: boolean;
2082
+ /**
2083
+ * Indicates whether the model was interrupted by the client. An interruption occurs when
2084
+ * the client sends a message before the model finishes it's turn. This is `undefined` if the
2085
+ * model was not interrupted.
2086
+ */
2087
+ interrupted?: boolean;
2088
+ }
2089
+
2090
+ /**
2091
+ * A request from the model for the client to execute one or more functions.
2092
+ *
2093
+ * @beta
2094
+ */
2095
+ export declare interface LiveServerToolCall {
2096
+ type: 'toolCall';
2097
+ /**
2098
+ * An array of function calls to run.
2099
+ */
2100
+ functionCalls: FunctionCall[];
2101
+ }
2102
+
2103
+ /**
2104
+ * Notification to cancel a previous function call triggered by {@link LiveServerToolCall}.
2105
+ *
2106
+ * @beta
2107
+ */
2108
+ export declare interface LiveServerToolCallCancellation {
2109
+ type: 'toolCallCancellation';
2110
+ /**
2111
+ * IDs of function calls that were cancelled. These refer to the `id` property of a {@link FunctionCall}.
2112
+ */
2113
+ functionIds: string[];
2114
+ }
2115
+
2116
+ /**
2117
+ * Represents an active, real-time, bidirectional conversation with the model.
2118
+ *
2119
+ * This class should only be instantiated by calling {@link LiveGenerativeModel.connect}.
2120
+ *
2121
+ * @beta
2122
+ */
2123
+ export declare class LiveSession {
2124
+ private webSocketHandler;
2125
+ private serverMessages;
2126
+ /**
2127
+ * Indicates whether this Live session is closed.
2128
+ *
2129
+ * @beta
2130
+ */
2131
+ isClosed: boolean;
2132
+ /**
2133
+ * Indicates whether this Live session is being controlled by an `AudioConversationController`.
2134
+ *
2135
+ * @beta
2136
+ */
2137
+ inConversation: boolean;
2138
+ /**
2139
+ * @internal
2140
+ */
2141
+ constructor(webSocketHandler: WebSocketHandler, serverMessages: AsyncGenerator<unknown>);
2142
+ /**
2143
+ * Sends content to the server.
2144
+ *
2145
+ * @param request - The message to send to the model.
2146
+ * @param turnComplete - Indicates if the turn is complete. Defaults to false.
2147
+ * @throws If this session has been closed.
2148
+ *
2149
+ * @beta
2150
+ */
2151
+ send(request: string | Array<string | Part>, turnComplete?: boolean): Promise<void>;
2152
+ /**
2153
+ * Sends realtime input to the server.
2154
+ *
2155
+ * @param mediaChunks - The media chunks to send.
2156
+ * @throws If this session has been closed.
2157
+ *
2158
+ * @beta
2159
+ */
2160
+ sendMediaChunks(mediaChunks: GenerativeContentBlob[]): Promise<void>;
2161
+ /**
2162
+ * Sends a stream of {@link GenerativeContentBlob}.
2163
+ *
2164
+ * @param mediaChunkStream - The stream of {@link GenerativeContentBlob} to send.
2165
+ * @throws If this session has been closed.
2166
+ *
2167
+ * @beta
2168
+ */
2169
+ sendMediaStream(mediaChunkStream: ReadableStream<GenerativeContentBlob>): Promise<void>;
2170
+ /**
2171
+ * Yields messages received from the server.
2172
+ * This can only be used by one consumer at a time.
2173
+ *
2174
+ * @returns An `AsyncGenerator` that yields server messages as they arrive.
2175
+ * @throws If the session is already closed, or if we receive a response that we don't support.
2176
+ *
2177
+ * @beta
2178
+ */
2179
+ receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation>;
2180
+ /**
2181
+ * Closes this session.
2182
+ * All methods on this session will throw an error once this resolves.
2183
+ *
2184
+ * @beta
2185
+ */
2186
+ close(): Promise<void>;
2187
+ }
2188
+
1852
2189
  /**
1853
2190
  * Content part modality.
1854
2191
  * @public
@@ -1977,6 +2314,20 @@ export declare type Part = TextPart | InlineDataPart | FunctionCallPart | Functi
1977
2314
  */
1978
2315
  export declare const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"];
1979
2316
 
2317
+ /**
2318
+ * Configuration for a pre-built voice.
2319
+ *
2320
+ * @beta
2321
+ */
2322
+ export declare interface PrebuiltVoiceConfig {
2323
+ /**
2324
+ * The voice name to use for speech synthesis.
2325
+ *
2326
+ * For a full list of names and demos of what each voice sounds like, see {@link https://cloud.google.com/text-to-speech/docs/chirp3-hd | Chirp 3: HD Voices}.
2327
+ */
2328
+ voiceName?: string;
2329
+ }
2330
+
1980
2331
  /**
1981
2332
  * If the prompt was blocked, this will be populated with `blockReason` and
1982
2333
  * the relevant `safetyRatings`.
@@ -2003,7 +2354,10 @@ export declare interface RequestOptions {
2003
2354
  */
2004
2355
  timeout?: number;
2005
2356
  /**
2006
- * Base url for endpoint. Defaults to https://firebasevertexai.googleapis.com
2357
+ * Base url for endpoint. Defaults to
2358
+ * https://firebasevertexai.googleapis.com, which is the
2359
+ * {@link https://console.cloud.google.com/apis/library/firebasevertexai.googleapis.com?project=_ | Firebase AI Logic API}
2360
+ * (used regardless of your chosen Gemini API provider).
2007
2361
  */
2008
2362
  baseUrl?: string;
2009
2363
  }
@@ -2024,6 +2378,11 @@ export declare const ResponseModality: {
2024
2378
  * @beta
2025
2379
  */
2026
2380
  readonly IMAGE: "IMAGE";
2381
+ /**
2382
+ * Audio.
2383
+ * @beta
2384
+ */
2385
+ readonly AUDIO: "AUDIO";
2027
2386
  };
2028
2387
 
2029
2388
  /**
@@ -2347,6 +2706,80 @@ export declare interface Segment {
2347
2706
  text: string;
2348
2707
  }
2349
2708
 
2709
+ /**
2710
+ * Configures speech synthesis.
2711
+ *
2712
+ * @beta
2713
+ */
2714
+ export declare interface SpeechConfig {
2715
+ /**
2716
+ * Configures the voice to be used in speech synthesis.
2717
+ */
2718
+ voiceConfig?: VoiceConfig;
2719
+ }
2720
+
2721
+ /**
2722
+ * Starts a real-time, bidirectional audio conversation with the model. This helper function manages
2723
+ * the complexities of microphone access, audio recording, playback, and interruptions.
2724
+ *
2725
+ * @remarks Important: This function must be called in response to a user gesture
2726
+ * (for example, a button click) to comply with {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Best_practices#autoplay_policy | browser autoplay policies}.
2727
+ *
2728
+ * @example
2729
+ * ```javascript
2730
+ * const liveSession = await model.connect();
2731
+ * let conversationController;
2732
+ *
2733
+ * // This function must be called from within a click handler.
2734
+ * async function startConversation() {
2735
+ * try {
2736
+ * conversationController = await startAudioConversation(liveSession);
2737
+ * } catch (e) {
2738
+ * // Handle AI-specific errors
2739
+ * if (e instanceof AIError) {
2740
+ * console.error("AI Error:", e.message);
2741
+ * }
2742
+ * // Handle microphone permission and hardware errors
2743
+ * else if (e instanceof DOMException) {
2744
+ * console.error("Microphone Error:", e.message);
2745
+ * }
2746
+ * // Handle other unexpected errors
2747
+ * else {
2748
+ * console.error("An unexpected error occurred:", e);
2749
+ * }
2750
+ * }
2751
+ * }
2752
+ *
2753
+ * // Later, to stop the conversation:
2754
+ * // if (conversationController) {
2755
+ * // await conversationController.stop();
2756
+ * // }
2757
+ * ```
2758
+ *
2759
+ * @param liveSession - An active {@link LiveSession} instance.
2760
+ * @param options - Configuration options for the audio conversation.
2761
+ * @returns A `Promise` that resolves with an {@link AudioConversationController}.
2762
+ * @throws `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`).
2763
+ * @throws `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 {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions | MDN documentation} for a full list of exceptions.
2764
+ *
2765
+ * @beta
2766
+ */
2767
+ export declare function startAudioConversation(liveSession: LiveSession, options?: StartAudioConversationOptions): Promise<AudioConversationController>;
2768
+
2769
+ /**
2770
+ * Options for {@link startAudioConversation}.
2771
+ *
2772
+ * @beta
2773
+ */
2774
+ export declare interface StartAudioConversationOptions {
2775
+ /**
2776
+ * An async handler that is called when the model requests a function to be executed.
2777
+ * The handler should perform the function call and return the result as a `Part`,
2778
+ * which will then be sent back to the model.
2779
+ */
2780
+ functionCallingHandler?: (functionCalls: LiveServerToolCall['functionCalls']) => Promise<Part>;
2781
+ }
2782
+
2350
2783
  /**
2351
2784
  * Params for {@link GenerativeModel.startChat}.
2352
2785
  * @public
@@ -2381,6 +2814,11 @@ export declare interface TextPart {
2381
2814
  inlineData?: never;
2382
2815
  functionCall?: never;
2383
2816
  functionResponse?: never;
2817
+ thought?: boolean;
2818
+ /**
2819
+ * @internal
2820
+ */
2821
+ thoughtSignature?: string;
2384
2822
  }
2385
2823
 
2386
2824
  /**
@@ -2406,6 +2844,15 @@ export declare interface ThinkingConfig {
2406
2844
  * feature or if the specified budget is not within the model's supported range.
2407
2845
  */
2408
2846
  thinkingBudget?: number;
2847
+ /**
2848
+ * Whether to include "thought summaries" in the model's response.
2849
+ *
2850
+ * @remarks
2851
+ * Thought summaries provide a brief overview of the model's internal thinking process,
2852
+ * offering insight into how it arrived at the final answer. This can be useful for
2853
+ * debugging, understanding the model's reasoning, and verifying its accuracy.
2854
+ */
2855
+ includeThoughts?: boolean;
2409
2856
  }
2410
2857
 
2411
2858
  /**
@@ -2487,6 +2934,18 @@ export declare interface VideoMetadata {
2487
2934
  endOffset: string;
2488
2935
  }
2489
2936
 
2937
+ /**
2938
+ * Configuration for the voice to used in speech synthesis.
2939
+ *
2940
+ * @beta
2941
+ */
2942
+ export declare interface VoiceConfig {
2943
+ /**
2944
+ * Configures the voice using a pre-built voice configuration.
2945
+ */
2946
+ prebuiltVoiceConfig?: PrebuiltVoiceConfig;
2947
+ }
2948
+
2490
2949
  /**
2491
2950
  * @public
2492
2951
  */
@@ -2522,4 +2981,59 @@ export declare interface WebGroundingChunk {
2522
2981
  domain?: string;
2523
2982
  }
2524
2983
 
2984
+ /**
2985
+ * @license
2986
+ * Copyright 2025 Google LLC
2987
+ *
2988
+ * Licensed under the Apache License, Version 2.0 (the "License");
2989
+ * you may not use this file except in compliance with the License.
2990
+ * You may obtain a copy of the License at
2991
+ *
2992
+ * http://www.apache.org/licenses/LICENSE-2.0
2993
+ *
2994
+ * Unless required by applicable law or agreed to in writing, software
2995
+ * distributed under the License is distributed on an "AS IS" BASIS,
2996
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2997
+ * See the License for the specific language governing permissions and
2998
+ * limitations under the License.
2999
+ */
3000
+ /**
3001
+ * A standardized interface for interacting with a WebSocket connection.
3002
+ * This abstraction allows the SDK to use the appropriate WebSocket implementation
3003
+ * for the current JS environment (Browser vs. Node) without
3004
+ * changing the core logic of the `LiveSession`.
3005
+ * @internal
3006
+ */
3007
+ declare interface WebSocketHandler {
3008
+ /**
3009
+ * Establishes a connection to the given URL.
3010
+ *
3011
+ * @param url The WebSocket URL (e.g., wss://...).
3012
+ * @returns A promise that resolves on successful connection or rejects on failure.
3013
+ */
3014
+ connect(url: string): Promise<void>;
3015
+ /**
3016
+ * Sends data over the WebSocket.
3017
+ *
3018
+ * @param data The string or binary data to send.
3019
+ */
3020
+ send(data: string | ArrayBuffer): void;
3021
+ /**
3022
+ * Returns an async generator that yields parsed JSON objects from the server.
3023
+ * The yielded type is `unknown` because the handler cannot guarantee the shape of the data.
3024
+ * The consumer is responsible for type validation.
3025
+ * The generator terminates when the connection is closed.
3026
+ *
3027
+ * @returns A generator that allows consumers to pull messages using a `for await...of` loop.
3028
+ */
3029
+ listen(): AsyncGenerator<unknown>;
3030
+ /**
3031
+ * Closes the WebSocket connection.
3032
+ *
3033
+ * @param code - A numeric status code explaining why the connection is closing.
3034
+ * @param reason - A human-readable string explaining why the connection is closing.
3035
+ */
3036
+ close(code?: number, reason?: string): Promise<void>;
3037
+ }
3038
+
2525
3039
  export { }