@google/genai 0.7.0 → 0.9.0
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.
- package/README.md +9 -34
- package/dist/genai.d.ts +530 -57
- package/dist/index.js +1984 -483
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1985 -484
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +2028 -526
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +530 -57
- package/dist/web/index.mjs +2024 -523
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +530 -57
- package/package.json +6 -2
package/dist/web/web.d.ts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
import { GoogleAuthOptions } from 'google-auth-library';
|
|
2
2
|
|
|
3
|
+
/** Marks the end of user activity.
|
|
4
|
+
|
|
5
|
+
This can only be sent if automatic (i.e. server-side) activity detection is
|
|
6
|
+
disabled.
|
|
7
|
+
*/
|
|
8
|
+
export declare interface ActivityEnd {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The different ways of handling user activity. */
|
|
12
|
+
export declare enum ActivityHandling {
|
|
13
|
+
ACTIVITY_HANDLING_UNSPECIFIED = "ACTIVITY_HANDLING_UNSPECIFIED",
|
|
14
|
+
START_OF_ACTIVITY_INTERRUPTS = "START_OF_ACTIVITY_INTERRUPTS",
|
|
15
|
+
NO_INTERRUPTION = "NO_INTERRUPTION"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Marks the start of user activity.
|
|
19
|
+
|
|
20
|
+
This can only be sent if automatic (i.e. server-side) activity detection is
|
|
21
|
+
disabled.
|
|
22
|
+
*/
|
|
23
|
+
export declare interface ActivityStart {
|
|
24
|
+
}
|
|
25
|
+
|
|
3
26
|
/**
|
|
4
27
|
* The ApiClient class is used to send requests to the Gemini API or Vertex AI
|
|
5
28
|
* endpoints.
|
|
@@ -20,13 +43,14 @@ declare class ApiClient {
|
|
|
20
43
|
getWebsocketBaseUrl(): string;
|
|
21
44
|
setBaseUrl(url: string): void;
|
|
22
45
|
private constructUrl;
|
|
46
|
+
private shouldPrependVertexProjectPath;
|
|
23
47
|
request(request: HttpRequest): Promise<HttpResponse>;
|
|
24
48
|
private patchHttpOptions;
|
|
25
|
-
requestStream(request: HttpRequest): Promise<
|
|
49
|
+
requestStream(request: HttpRequest): Promise<AsyncGenerator<HttpResponse>>;
|
|
26
50
|
private includeExtraHttpOptionsToRequestInit;
|
|
27
51
|
private unaryApiCall;
|
|
28
52
|
private streamApiCall;
|
|
29
|
-
processStreamResponse(response: Response): AsyncGenerator<
|
|
53
|
+
processStreamResponse(response: Response): AsyncGenerator<HttpResponse>;
|
|
30
54
|
private apiCall;
|
|
31
55
|
getDefaultHeaders(): Record<string, string>;
|
|
32
56
|
private getHeadersInternal;
|
|
@@ -97,6 +121,10 @@ declare interface ApiClientInitOptions {
|
|
|
97
121
|
userAgentExtra?: string;
|
|
98
122
|
}
|
|
99
123
|
|
|
124
|
+
/** The audio transcription configuration in Setup. */
|
|
125
|
+
export declare interface AudioTranscriptionConfig {
|
|
126
|
+
}
|
|
127
|
+
|
|
100
128
|
/**
|
|
101
129
|
* @license
|
|
102
130
|
* Copyright 2025 Google LLC
|
|
@@ -114,6 +142,25 @@ declare interface Auth {
|
|
|
114
142
|
addAuthHeaders(headers: Headers): Promise<void>;
|
|
115
143
|
}
|
|
116
144
|
|
|
145
|
+
/** Configures automatic detection of activity. */
|
|
146
|
+
export declare interface AutomaticActivityDetection {
|
|
147
|
+
/** If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals. */
|
|
148
|
+
disabled?: boolean;
|
|
149
|
+
/** Determines how likely speech is to be detected. */
|
|
150
|
+
startOfSpeechSensitivity?: StartSensitivity;
|
|
151
|
+
/** Determines how likely detected speech is ended. */
|
|
152
|
+
endOfSpeechSensitivity?: EndSensitivity;
|
|
153
|
+
/** The required duration of detected speech before start-of-speech is committed. The lower this value the more sensitive the start-of-speech detection is and the shorter speech can be recognized. However, this also increases the probability of false positives. */
|
|
154
|
+
prefixPaddingMs?: number;
|
|
155
|
+
/** The required duration of detected non-speech (e.g. silence) before end-of-speech is committed. The larger this value, the longer speech gaps can be without interrupting the user's activity but this will increase the model's latency. */
|
|
156
|
+
silenceDurationMs?: number;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @license
|
|
161
|
+
* Copyright 2025 Google LLC
|
|
162
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
163
|
+
*/
|
|
117
164
|
declare class BaseModule {
|
|
118
165
|
}
|
|
119
166
|
|
|
@@ -126,6 +173,7 @@ declare interface Blob_2 {
|
|
|
126
173
|
}
|
|
127
174
|
export { Blob_2 as Blob }
|
|
128
175
|
|
|
176
|
+
/** Output only. Blocked reason. */
|
|
129
177
|
export declare enum BlockedReason {
|
|
130
178
|
BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED",
|
|
131
179
|
SAFETY = "SAFETY",
|
|
@@ -189,8 +237,8 @@ export declare class Caches extends BaseModule {
|
|
|
189
237
|
*
|
|
190
238
|
* @remarks
|
|
191
239
|
* Context caching is only supported for specific models. See [Gemini
|
|
192
|
-
* Developer API reference]
|
|
193
|
-
* and [Vertex AI reference]
|
|
240
|
+
* Developer API reference](https://ai.google.dev/gemini-api/docs/caching?lang=node/context-cac)
|
|
241
|
+
* and [Vertex AI reference](https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-overview#supported_models)
|
|
194
242
|
* for more information.
|
|
195
243
|
*
|
|
196
244
|
* @param params - The parameters for the create request.
|
|
@@ -435,16 +483,6 @@ export declare interface CodeExecutionResult {
|
|
|
435
483
|
output?: string;
|
|
436
484
|
}
|
|
437
485
|
|
|
438
|
-
declare namespace common {
|
|
439
|
-
export {
|
|
440
|
-
formatMap,
|
|
441
|
-
setValueByPath,
|
|
442
|
-
getValueByPath,
|
|
443
|
-
BaseModule,
|
|
444
|
-
UploadFileParameters
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
486
|
/** Optional parameters for computing tokens. */
|
|
449
487
|
export declare interface ComputeTokensConfig {
|
|
450
488
|
/** Used to override HTTP request options. */
|
|
@@ -476,7 +514,7 @@ export declare interface Content {
|
|
|
476
514
|
parts?: Part[];
|
|
477
515
|
/** Optional. The producer of the content. Must be either 'user' or
|
|
478
516
|
'model'. Useful to set for multi-turn conversations, otherwise can be
|
|
479
|
-
|
|
517
|
+
empty. If role is not specified, SDK will determine the role. */
|
|
480
518
|
role?: string;
|
|
481
519
|
}
|
|
482
520
|
|
|
@@ -502,10 +540,18 @@ export declare interface ContentEmbeddingStatistics {
|
|
|
502
540
|
tokenCount?: number;
|
|
503
541
|
}
|
|
504
542
|
|
|
505
|
-
export declare type ContentListUnion =
|
|
543
|
+
export declare type ContentListUnion = Content | Content[] | PartUnion | PartUnion[];
|
|
506
544
|
|
|
507
545
|
export declare type ContentUnion = Content | PartUnion[] | PartUnion;
|
|
508
546
|
|
|
547
|
+
/** Enables context window compression -- mechanism managing model context window so it does not exceed given length. */
|
|
548
|
+
export declare interface ContextWindowCompressionConfig {
|
|
549
|
+
/** Number of tokens (before running turn) that triggers context window compression mechanism. */
|
|
550
|
+
triggerTokens?: string;
|
|
551
|
+
/** Sliding window compression mechanism. */
|
|
552
|
+
slidingWindow?: SlidingWindow;
|
|
553
|
+
}
|
|
554
|
+
|
|
509
555
|
/** Configuration for a Control reference image. */
|
|
510
556
|
export declare interface ControlReferenceConfig {
|
|
511
557
|
/** The type of control reference image to use. */
|
|
@@ -537,6 +583,7 @@ export declare interface ControlReferenceImage {
|
|
|
537
583
|
config?: ControlReferenceConfig;
|
|
538
584
|
}
|
|
539
585
|
|
|
586
|
+
/** Enum representing the control type of a control reference image. */
|
|
540
587
|
export declare enum ControlReferenceType {
|
|
541
588
|
CONTROL_TYPE_DEFAULT = "CONTROL_TYPE_DEFAULT",
|
|
542
589
|
CONTROL_TYPE_CANNY = "CONTROL_TYPE_CANNY",
|
|
@@ -672,7 +719,7 @@ export declare class CreateFileResponse {
|
|
|
672
719
|
export declare function createModelContent(partOrString: PartListUnion | string): Content;
|
|
673
720
|
|
|
674
721
|
/**
|
|
675
|
-
* Creates a `Part` object from a `base64` `string`.
|
|
722
|
+
* Creates a `Part` object from a `base64` encoded `string`.
|
|
676
723
|
*/
|
|
677
724
|
export declare function createPartFromBase64(data: string, mimeType: string): Part;
|
|
678
725
|
|
|
@@ -763,6 +810,7 @@ export declare interface DynamicRetrievalConfig {
|
|
|
763
810
|
dynamicThreshold?: number;
|
|
764
811
|
}
|
|
765
812
|
|
|
813
|
+
/** Config for the dynamic retrieval config mode. */
|
|
766
814
|
export declare enum DynamicRetrievalConfigMode {
|
|
767
815
|
MODE_UNSPECIFIED = "MODE_UNSPECIFIED",
|
|
768
816
|
MODE_DYNAMIC = "MODE_DYNAMIC"
|
|
@@ -826,6 +874,21 @@ export declare class EmbedContentResponse {
|
|
|
826
874
|
metadata?: EmbedContentMetadata;
|
|
827
875
|
}
|
|
828
876
|
|
|
877
|
+
/** An endpoint where you deploy models. */
|
|
878
|
+
export declare interface Endpoint {
|
|
879
|
+
/** Resource name of the endpoint. */
|
|
880
|
+
name?: string;
|
|
881
|
+
/** ID of the model that's deployed to the endpoint. */
|
|
882
|
+
deployedModelId?: string;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/** End of speech sensitivity. */
|
|
886
|
+
export declare enum EndSensitivity {
|
|
887
|
+
END_SENSITIVITY_UNSPECIFIED = "END_SENSITIVITY_UNSPECIFIED",
|
|
888
|
+
END_SENSITIVITY_HIGH = "END_SENSITIVITY_HIGH",
|
|
889
|
+
END_SENSITIVITY_LOW = "END_SENSITIVITY_LOW"
|
|
890
|
+
}
|
|
891
|
+
|
|
829
892
|
/** Code generated by the model that is meant to be executed, and the result returned to the model. Generated when using the [FunctionDeclaration] tool and [FunctionCallingConfig] mode is set to [Mode.CODE]. */
|
|
830
893
|
export declare interface ExecutableCode {
|
|
831
894
|
/** Required. The code to be executed. */
|
|
@@ -834,6 +897,14 @@ export declare interface ExecutableCode {
|
|
|
834
897
|
language?: Language;
|
|
835
898
|
}
|
|
836
899
|
|
|
900
|
+
/** Options for feature selection preference. */
|
|
901
|
+
export declare enum FeatureSelectionPreference {
|
|
902
|
+
FEATURE_SELECTION_PREFERENCE_UNSPECIFIED = "FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",
|
|
903
|
+
PRIORITIZE_QUALITY = "PRIORITIZE_QUALITY",
|
|
904
|
+
BALANCED = "BALANCED",
|
|
905
|
+
PRIORITIZE_COST = "PRIORITIZE_COST"
|
|
906
|
+
}
|
|
907
|
+
|
|
837
908
|
export declare interface FetchPredictOperationConfig {
|
|
838
909
|
/** Used to override HTTP request options. */
|
|
839
910
|
httpOptions?: HttpOptions;
|
|
@@ -934,7 +1005,9 @@ export declare class Files extends BaseModule {
|
|
|
934
1005
|
* This section can contain multiple paragraphs and code examples.
|
|
935
1006
|
*
|
|
936
1007
|
* @param params - Optional parameters specified in the
|
|
937
|
-
* `
|
|
1008
|
+
* `types.UploadFileParameters` interface.
|
|
1009
|
+
* @see {@link types.UploadFileParameters#config} for the optional
|
|
1010
|
+
* config in the parameters.
|
|
938
1011
|
* @return A promise that resolves to a `types.File` object.
|
|
939
1012
|
* @throws An error if called on a Vertex AI client.
|
|
940
1013
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
@@ -951,7 +1024,7 @@ export declare class Files extends BaseModule {
|
|
|
951
1024
|
* console.log(file.name);
|
|
952
1025
|
* ```
|
|
953
1026
|
*/
|
|
954
|
-
upload(params:
|
|
1027
|
+
upload(params: types.UploadFileParameters): Promise<types.File>;
|
|
955
1028
|
private listInternal;
|
|
956
1029
|
private createInternal;
|
|
957
1030
|
/**
|
|
@@ -986,6 +1059,7 @@ export declare class Files extends BaseModule {
|
|
|
986
1059
|
delete(params: types.DeleteFileParameters): Promise<types.DeleteFileResponse>;
|
|
987
1060
|
}
|
|
988
1061
|
|
|
1062
|
+
/** Source of the File. */
|
|
989
1063
|
export declare enum FileSource {
|
|
990
1064
|
SOURCE_UNSPECIFIED = "SOURCE_UNSPECIFIED",
|
|
991
1065
|
UPLOADED = "UPLOADED",
|
|
@@ -1009,6 +1083,7 @@ declare interface FileStat {
|
|
|
1009
1083
|
type: string | undefined;
|
|
1010
1084
|
}
|
|
1011
1085
|
|
|
1086
|
+
/** State for the lifecycle of a File. */
|
|
1012
1087
|
export declare enum FileState {
|
|
1013
1088
|
STATE_UNSPECIFIED = "STATE_UNSPECIFIED",
|
|
1014
1089
|
PROCESSING = "PROCESSING",
|
|
@@ -1026,6 +1101,10 @@ export declare interface FileStatus {
|
|
|
1026
1101
|
code?: number;
|
|
1027
1102
|
}
|
|
1028
1103
|
|
|
1104
|
+
/** Output only. The reason why the model stopped generating tokens.
|
|
1105
|
+
|
|
1106
|
+
If empty, the model has not stopped generating the tokens.
|
|
1107
|
+
*/
|
|
1029
1108
|
export declare enum FinishReason {
|
|
1030
1109
|
FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED",
|
|
1031
1110
|
STOP = "STOP",
|
|
@@ -1040,8 +1119,6 @@ export declare enum FinishReason {
|
|
|
1040
1119
|
IMAGE_SAFETY = "IMAGE_SAFETY"
|
|
1041
1120
|
}
|
|
1042
1121
|
|
|
1043
|
-
declare function formatMap(templateString: string, valueMap: Record<string, unknown>): string;
|
|
1044
|
-
|
|
1045
1122
|
/** A function call. */
|
|
1046
1123
|
export declare interface FunctionCall {
|
|
1047
1124
|
/** The unique id of the function call. If populated, the client to execute the
|
|
@@ -1061,6 +1138,7 @@ export declare interface FunctionCallingConfig {
|
|
|
1061
1138
|
allowedFunctionNames?: string[];
|
|
1062
1139
|
}
|
|
1063
1140
|
|
|
1141
|
+
/** Config for the function calling config mode. */
|
|
1064
1142
|
export declare enum FunctionCallingConfigMode {
|
|
1065
1143
|
MODE_UNSPECIFIED = "MODE_UNSPECIFIED",
|
|
1066
1144
|
AUTO = "AUTO",
|
|
@@ -1169,6 +1247,9 @@ export declare interface GenerateContentConfig {
|
|
|
1169
1247
|
/** Configuration for model router requests.
|
|
1170
1248
|
*/
|
|
1171
1249
|
routingConfig?: GenerationConfigRoutingConfig;
|
|
1250
|
+
/** Configuration for model selection.
|
|
1251
|
+
*/
|
|
1252
|
+
modelSelectionConfig?: ModelSelectionConfig;
|
|
1172
1253
|
/** Safety settings in the request to block unsafe content in the
|
|
1173
1254
|
response.
|
|
1174
1255
|
*/
|
|
@@ -1385,6 +1466,8 @@ export declare class GenerateContentResponseUsageMetadata {
|
|
|
1385
1466
|
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
1386
1467
|
/** Total token count for prompt, response candidates, and tool-use prompts (if present). */
|
|
1387
1468
|
totalTokenCount?: number;
|
|
1469
|
+
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
1470
|
+
trafficType?: TrafficType;
|
|
1388
1471
|
}
|
|
1389
1472
|
|
|
1390
1473
|
/** An output image. */
|
|
@@ -1531,10 +1614,8 @@ export declare interface GenerateVideosOperation {
|
|
|
1531
1614
|
done?: boolean;
|
|
1532
1615
|
/** The error result of the operation in case of failure or cancellation. */
|
|
1533
1616
|
error?: Record<string, unknown>;
|
|
1534
|
-
/** The normal response of the operation in case of success. */
|
|
1535
|
-
response?: Record<string, unknown>;
|
|
1536
1617
|
/** The generated videos. */
|
|
1537
|
-
|
|
1618
|
+
response?: GenerateVideosResponse;
|
|
1538
1619
|
}
|
|
1539
1620
|
|
|
1540
1621
|
/** Class that represents the parameters for generating an image. */
|
|
@@ -1573,6 +1654,8 @@ export declare interface GenerationConfig {
|
|
|
1573
1654
|
logprobs?: number;
|
|
1574
1655
|
/** Optional. The maximum number of output tokens to generate per message. */
|
|
1575
1656
|
maxOutputTokens?: number;
|
|
1657
|
+
/** Optional. If specified, the media resolution specified will be used. */
|
|
1658
|
+
mediaResolution?: MediaResolution;
|
|
1576
1659
|
/** Optional. Positive penalties. */
|
|
1577
1660
|
presencePenalty?: number;
|
|
1578
1661
|
/** Optional. If true, export the logprobs results in response. */
|
|
@@ -1645,6 +1728,18 @@ export declare interface GetFileParameters {
|
|
|
1645
1728
|
config?: GetFileConfig;
|
|
1646
1729
|
}
|
|
1647
1730
|
|
|
1731
|
+
/** Optional parameters for models.get method. */
|
|
1732
|
+
export declare interface GetModelConfig {
|
|
1733
|
+
/** Used to override HTTP request options. */
|
|
1734
|
+
httpOptions?: HttpOptions;
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
export declare interface GetModelParameters {
|
|
1738
|
+
model: string;
|
|
1739
|
+
/** Optional parameters for the request. */
|
|
1740
|
+
config?: GetModelConfig;
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1648
1743
|
export declare interface GetOperationConfig {
|
|
1649
1744
|
/** Used to override HTTP request options. */
|
|
1650
1745
|
httpOptions?: HttpOptions;
|
|
@@ -1658,8 +1753,6 @@ export declare interface GetOperationParameters {
|
|
|
1658
1753
|
config?: GetOperationConfig;
|
|
1659
1754
|
}
|
|
1660
1755
|
|
|
1661
|
-
declare function getValueByPath(data: unknown, keys: string[]): unknown;
|
|
1662
|
-
|
|
1663
1756
|
/**
|
|
1664
1757
|
* The Google GenAI SDK.
|
|
1665
1758
|
*
|
|
@@ -1811,6 +1904,8 @@ export declare interface GroundingChunkRetrievedContext {
|
|
|
1811
1904
|
|
|
1812
1905
|
/** Chunk from the web. */
|
|
1813
1906
|
export declare interface GroundingChunkWeb {
|
|
1907
|
+
/** Domain of the (original) URI. */
|
|
1908
|
+
domain?: string;
|
|
1814
1909
|
/** Title of the chunk. */
|
|
1815
1910
|
title?: string;
|
|
1816
1911
|
/** URI reference of the chunk. */
|
|
@@ -1843,12 +1938,14 @@ export declare interface GroundingSupport {
|
|
|
1843
1938
|
segment?: Segment;
|
|
1844
1939
|
}
|
|
1845
1940
|
|
|
1941
|
+
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
|
|
1846
1942
|
export declare enum HarmBlockMethod {
|
|
1847
1943
|
HARM_BLOCK_METHOD_UNSPECIFIED = "HARM_BLOCK_METHOD_UNSPECIFIED",
|
|
1848
1944
|
SEVERITY = "SEVERITY",
|
|
1849
1945
|
PROBABILITY = "PROBABILITY"
|
|
1850
1946
|
}
|
|
1851
1947
|
|
|
1948
|
+
/** Required. The harm block threshold. */
|
|
1852
1949
|
export declare enum HarmBlockThreshold {
|
|
1853
1950
|
HARM_BLOCK_THRESHOLD_UNSPECIFIED = "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
1854
1951
|
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
@@ -1858,6 +1955,7 @@ export declare enum HarmBlockThreshold {
|
|
|
1858
1955
|
OFF = "OFF"
|
|
1859
1956
|
}
|
|
1860
1957
|
|
|
1958
|
+
/** Required. Harm category. */
|
|
1861
1959
|
export declare enum HarmCategory {
|
|
1862
1960
|
HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED",
|
|
1863
1961
|
HARM_CATEGORY_HATE_SPEECH = "HARM_CATEGORY_HATE_SPEECH",
|
|
@@ -1867,6 +1965,7 @@ export declare enum HarmCategory {
|
|
|
1867
1965
|
HARM_CATEGORY_CIVIC_INTEGRITY = "HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
1868
1966
|
}
|
|
1869
1967
|
|
|
1968
|
+
/** Output only. Harm probability levels in the content. */
|
|
1870
1969
|
export declare enum HarmProbability {
|
|
1871
1970
|
HARM_PROBABILITY_UNSPECIFIED = "HARM_PROBABILITY_UNSPECIFIED",
|
|
1872
1971
|
NEGLIGIBLE = "NEGLIGIBLE",
|
|
@@ -1875,6 +1974,7 @@ export declare enum HarmProbability {
|
|
|
1875
1974
|
HIGH = "HIGH"
|
|
1876
1975
|
}
|
|
1877
1976
|
|
|
1977
|
+
/** Output only. Harm severity levels in the content. */
|
|
1878
1978
|
export declare enum HarmSeverity {
|
|
1879
1979
|
HARM_SEVERITY_UNSPECIFIED = "HARM_SEVERITY_UNSPECIFIED",
|
|
1880
1980
|
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE",
|
|
@@ -1967,6 +2067,7 @@ declare interface Image_2 {
|
|
|
1967
2067
|
}
|
|
1968
2068
|
export { Image_2 as Image }
|
|
1969
2069
|
|
|
2070
|
+
/** Enum that specifies the language of the text in the prompt. */
|
|
1970
2071
|
export declare enum ImagePromptLanguage {
|
|
1971
2072
|
auto = "auto",
|
|
1972
2073
|
en = "en",
|
|
@@ -1975,6 +2076,7 @@ export declare enum ImagePromptLanguage {
|
|
|
1975
2076
|
hi = "hi"
|
|
1976
2077
|
}
|
|
1977
2078
|
|
|
2079
|
+
/** Required. Programming language of the `code`. */
|
|
1978
2080
|
export declare enum Language {
|
|
1979
2081
|
LANGUAGE_UNSPECIFIED = "LANGUAGE_UNSPECIFIED",
|
|
1980
2082
|
PYTHON = "PYTHON"
|
|
@@ -2042,17 +2144,20 @@ export declare class Live {
|
|
|
2042
2144
|
@experimental
|
|
2043
2145
|
|
|
2044
2146
|
@remarks
|
|
2045
|
-
If using the Gemini API, Live is currently only supported behind API
|
|
2046
|
-
version `v1alpha`. Ensure that the API version is set to `v1alpha` when
|
|
2047
|
-
initializing the SDK if relying on the Gemini API.
|
|
2048
2147
|
|
|
2049
2148
|
@param params - The parameters for establishing a connection to the model.
|
|
2050
2149
|
@return A live session.
|
|
2051
2150
|
|
|
2052
2151
|
@example
|
|
2053
2152
|
```ts
|
|
2153
|
+
let model: string;
|
|
2154
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
2155
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
2156
|
+
} else {
|
|
2157
|
+
model = 'gemini-2.0-flash-live-001';
|
|
2158
|
+
}
|
|
2054
2159
|
const session = await ai.live.connect({
|
|
2055
|
-
model:
|
|
2160
|
+
model: model,
|
|
2056
2161
|
config: {
|
|
2057
2162
|
responseModalities: [Modality.AUDIO],
|
|
2058
2163
|
},
|
|
@@ -2078,9 +2183,21 @@ export declare class Live {
|
|
|
2078
2183
|
|
|
2079
2184
|
/** Callbacks for the live API. */
|
|
2080
2185
|
export declare interface LiveCallbacks {
|
|
2186
|
+
/**
|
|
2187
|
+
* Called when the websocket connection is established.
|
|
2188
|
+
*/
|
|
2081
2189
|
onopen?: (() => void) | null;
|
|
2190
|
+
/**
|
|
2191
|
+
* Called when a message is received from the server.
|
|
2192
|
+
*/
|
|
2082
2193
|
onmessage: (e: LiveServerMessage) => void;
|
|
2194
|
+
/**
|
|
2195
|
+
* Called when an error occurs.
|
|
2196
|
+
*/
|
|
2083
2197
|
onerror?: ((e: ErrorEvent) => void) | null;
|
|
2198
|
+
/**
|
|
2199
|
+
* Called when the websocket connection is closed.
|
|
2200
|
+
*/
|
|
2084
2201
|
onclose?: ((e: CloseEvent) => void) | null;
|
|
2085
2202
|
}
|
|
2086
2203
|
|
|
@@ -2119,11 +2236,11 @@ export declare interface LiveClientMessage {
|
|
|
2119
2236
|
|
|
2120
2237
|
/** User input that is sent in real time.
|
|
2121
2238
|
|
|
2122
|
-
This is different from `
|
|
2239
|
+
This is different from `LiveClientContent` in a few ways:
|
|
2123
2240
|
|
|
2124
2241
|
- Can be sent continuously without interruption to model generation.
|
|
2125
2242
|
- If there is a need to mix data interleaved across the
|
|
2126
|
-
`
|
|
2243
|
+
`LiveClientContent` and the `LiveClientRealtimeInput`, server attempts to
|
|
2127
2244
|
optimize for best response, but there are no guarantees.
|
|
2128
2245
|
- End of turn is not explicitly specified, but is rather derived from user
|
|
2129
2246
|
activity (for example, end of speech).
|
|
@@ -2135,6 +2252,10 @@ export declare interface LiveClientMessage {
|
|
|
2135
2252
|
export declare interface LiveClientRealtimeInput {
|
|
2136
2253
|
/** Inlined bytes data for media input. */
|
|
2137
2254
|
mediaChunks?: Blob_2[];
|
|
2255
|
+
/** Marks the start of user activity. */
|
|
2256
|
+
activityStart?: ActivityStart;
|
|
2257
|
+
/** Marks the end of user activity. */
|
|
2258
|
+
activityEnd?: ActivityEnd;
|
|
2138
2259
|
}
|
|
2139
2260
|
|
|
2140
2261
|
/** Message contains configuration that will apply for the duration of the streaming session. */
|
|
@@ -2145,27 +2266,36 @@ export declare interface LiveClientSetup {
|
|
|
2145
2266
|
*/
|
|
2146
2267
|
model?: string;
|
|
2147
2268
|
/** The generation configuration for the session.
|
|
2148
|
-
|
|
2149
|
-
The following fields are supported:
|
|
2150
|
-
- `response_logprobs`
|
|
2151
|
-
- `response_mime_type`
|
|
2152
|
-
- `logprobs`
|
|
2153
|
-
- `response_schema`
|
|
2154
|
-
- `stop_sequence`
|
|
2155
|
-
- `routing_config`
|
|
2156
|
-
- `audio_timestamp`
|
|
2269
|
+
Note: only a subset of fields are supported.
|
|
2157
2270
|
*/
|
|
2158
2271
|
generationConfig?: GenerationConfig;
|
|
2159
2272
|
/** The user provided system instructions for the model.
|
|
2160
2273
|
Note: only text should be used in parts and content in each part will be
|
|
2161
2274
|
in a separate paragraph. */
|
|
2162
|
-
systemInstruction?:
|
|
2275
|
+
systemInstruction?: ContentUnion;
|
|
2163
2276
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2164
2277
|
|
|
2165
2278
|
A `Tool` is a piece of code that enables the system to interact with
|
|
2166
2279
|
external systems to perform an action, or set of actions, outside of
|
|
2167
2280
|
knowledge and scope of the model. */
|
|
2168
2281
|
tools?: ToolListUnion;
|
|
2282
|
+
/** Configures the realtime input behavior in BidiGenerateContent. */
|
|
2283
|
+
realtimeInputConfig?: RealtimeInputConfig;
|
|
2284
|
+
/** Configures session resumption mechanism.
|
|
2285
|
+
|
|
2286
|
+
If included server will send SessionResumptionUpdate messages. */
|
|
2287
|
+
sessionResumption?: SessionResumptionConfig;
|
|
2288
|
+
/** Configures context window compression mechanism.
|
|
2289
|
+
|
|
2290
|
+
If included, server will compress context window to fit into given length. */
|
|
2291
|
+
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2292
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2293
|
+
*/
|
|
2294
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2295
|
+
/** The transcription of the output aligns with the language code
|
|
2296
|
+
specified for the output audio.
|
|
2297
|
+
*/
|
|
2298
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2169
2299
|
}
|
|
2170
2300
|
|
|
2171
2301
|
/** Client generated response to a `ToolCall` received from the server.
|
|
@@ -2191,19 +2321,65 @@ export declare interface LiveConnectConfig {
|
|
|
2191
2321
|
modalities that the model can return. Defaults to AUDIO if not specified.
|
|
2192
2322
|
*/
|
|
2193
2323
|
responseModalities?: Modality[];
|
|
2324
|
+
/** Value that controls the degree of randomness in token selection.
|
|
2325
|
+
Lower temperatures are good for prompts that require a less open-ended or
|
|
2326
|
+
creative response, while higher temperatures can lead to more diverse or
|
|
2327
|
+
creative results.
|
|
2328
|
+
*/
|
|
2329
|
+
temperature?: number;
|
|
2330
|
+
/** Tokens are selected from the most to least probable until the sum
|
|
2331
|
+
of their probabilities equals this value. Use a lower value for less
|
|
2332
|
+
random responses and a higher value for more random responses.
|
|
2333
|
+
*/
|
|
2334
|
+
topP?: number;
|
|
2335
|
+
/** For each token selection step, the ``top_k`` tokens with the
|
|
2336
|
+
highest probabilities are sampled. Then tokens are further filtered based
|
|
2337
|
+
on ``top_p`` with the final token selected using temperature sampling. Use
|
|
2338
|
+
a lower number for less random responses and a higher number for more
|
|
2339
|
+
random responses.
|
|
2340
|
+
*/
|
|
2341
|
+
topK?: number;
|
|
2342
|
+
/** Maximum number of tokens that can be generated in the response.
|
|
2343
|
+
*/
|
|
2344
|
+
maxOutputTokens?: number;
|
|
2345
|
+
/** If specified, the media resolution specified will be used.
|
|
2346
|
+
*/
|
|
2347
|
+
mediaResolution?: MediaResolution;
|
|
2348
|
+
/** When ``seed`` is fixed to a specific number, the model makes a best
|
|
2349
|
+
effort to provide the same response for repeated requests. By default, a
|
|
2350
|
+
random number is used.
|
|
2351
|
+
*/
|
|
2352
|
+
seed?: number;
|
|
2194
2353
|
/** The speech generation configuration.
|
|
2195
2354
|
*/
|
|
2196
2355
|
speechConfig?: SpeechConfig;
|
|
2197
2356
|
/** The user provided system instructions for the model.
|
|
2198
2357
|
Note: only text should be used in parts and content in each part will be
|
|
2199
2358
|
in a separate paragraph. */
|
|
2200
|
-
systemInstruction?:
|
|
2359
|
+
systemInstruction?: ContentUnion;
|
|
2201
2360
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2202
2361
|
|
|
2203
2362
|
A `Tool` is a piece of code that enables the system to interact with
|
|
2204
2363
|
external systems to perform an action, or set of actions, outside of
|
|
2205
2364
|
knowledge and scope of the model. */
|
|
2206
2365
|
tools?: ToolListUnion;
|
|
2366
|
+
/** Configures session resumption mechanism.
|
|
2367
|
+
|
|
2368
|
+
If included the server will send SessionResumptionUpdate messages. */
|
|
2369
|
+
sessionResumption?: SessionResumptionConfig;
|
|
2370
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2371
|
+
*/
|
|
2372
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2373
|
+
/** The transcription of the output aligns with the language code
|
|
2374
|
+
specified for the output audio.
|
|
2375
|
+
*/
|
|
2376
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2377
|
+
/** Configures the realtime input behavior in BidiGenerateContent. */
|
|
2378
|
+
realtimeInputConfig?: RealtimeInputConfig;
|
|
2379
|
+
/** Configures context window compression mechanism.
|
|
2380
|
+
|
|
2381
|
+
If included, server will compress context window to fit into given length. */
|
|
2382
|
+
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2207
2383
|
}
|
|
2208
2384
|
|
|
2209
2385
|
/** Parameters for connecting to the live API. */
|
|
@@ -2232,6 +2408,10 @@ export declare interface LiveSendClientContentParameters {
|
|
|
2232
2408
|
export declare interface LiveSendRealtimeInputParameters {
|
|
2233
2409
|
/** Realtime input to send to the session. */
|
|
2234
2410
|
media: Blob_2;
|
|
2411
|
+
/** Marks the start of user activity. */
|
|
2412
|
+
activityStart?: ActivityStart;
|
|
2413
|
+
/** Marks the end of user activity. */
|
|
2414
|
+
activityEnd?: ActivityEnd;
|
|
2235
2415
|
}
|
|
2236
2416
|
|
|
2237
2417
|
/** Parameters for sending tool responses to the live API. */
|
|
@@ -2252,6 +2432,30 @@ export declare interface LiveServerContent {
|
|
|
2252
2432
|
turnComplete?: boolean;
|
|
2253
2433
|
/** If true, indicates that a client message has interrupted current model generation. If the client is playing out the content in realtime, this is a good signal to stop and empty the current queue. */
|
|
2254
2434
|
interrupted?: boolean;
|
|
2435
|
+
/** If true, indicates that the model is done generating. When model is
|
|
2436
|
+
interrupted while generating there will be no generation_complete message
|
|
2437
|
+
in interrupted turn, it will go through interrupted > turn_complete.
|
|
2438
|
+
When model assumes realtime playback there will be delay between
|
|
2439
|
+
generation_complete and turn_complete that is caused by model
|
|
2440
|
+
waiting for playback to finish. If true, indicates that the model
|
|
2441
|
+
has finished generating all content. This is a signal to the client
|
|
2442
|
+
that it can stop sending messages. */
|
|
2443
|
+
generationComplete?: boolean;
|
|
2444
|
+
/** Input transcription. The transcription is independent to the model
|
|
2445
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2446
|
+
model turn. */
|
|
2447
|
+
inputTranscription?: Transcription;
|
|
2448
|
+
/** Output transcription. The transcription is independent to the model
|
|
2449
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2450
|
+
model turn.
|
|
2451
|
+
*/
|
|
2452
|
+
outputTranscription?: Transcription;
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
/** Server will not be able to service client soon. */
|
|
2456
|
+
export declare interface LiveServerGoAway {
|
|
2457
|
+
/** The remaining time before the connection will be terminated as ABORTED. The minimal time returned here is specified differently together with the rate limits for a given model. */
|
|
2458
|
+
timeLeft?: string;
|
|
2255
2459
|
}
|
|
2256
2460
|
|
|
2257
2461
|
/** Response message for API call. */
|
|
@@ -2264,6 +2468,29 @@ export declare interface LiveServerMessage {
|
|
|
2264
2468
|
toolCall?: LiveServerToolCall;
|
|
2265
2469
|
/** Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled. */
|
|
2266
2470
|
toolCallCancellation?: LiveServerToolCallCancellation;
|
|
2471
|
+
/** Usage metadata about model response(s). */
|
|
2472
|
+
usageMetadata?: UsageMetadata;
|
|
2473
|
+
/** Server will disconnect soon. */
|
|
2474
|
+
goAway?: LiveServerGoAway;
|
|
2475
|
+
/** Update of the session resumption state. */
|
|
2476
|
+
sessionResumptionUpdate?: LiveServerSessionResumptionUpdate;
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
/** Update of the session resumption state.
|
|
2480
|
+
|
|
2481
|
+
Only sent if `session_resumption` was set in the connection config.
|
|
2482
|
+
*/
|
|
2483
|
+
export declare interface LiveServerSessionResumptionUpdate {
|
|
2484
|
+
/** New handle that represents state that can be resumed. Empty if `resumable`=false. */
|
|
2485
|
+
newHandle?: string;
|
|
2486
|
+
/** True if session can be resumed at this point. It might be not possible to resume session at some points. In that case we send update empty new_handle and resumable=false. Example of such case could be model executing function calls or just generating. Resuming session (using previous session token) in such state will result in some data loss. */
|
|
2487
|
+
resumable?: boolean;
|
|
2488
|
+
/** Index of last message sent by client that is included in state represented by this SessionResumptionToken. Only sent when `SessionResumptionConfig.transparent` is set.
|
|
2489
|
+
|
|
2490
|
+
Presence of this index allows users to transparently reconnect and avoid issue of losing some part of realtime audio input/video. If client wishes to temporarily disconnect (for example as result of receiving GoAway) they can do it without losing state by buffering messages sent since last `SessionResmumptionTokenUpdate`. This field will enable them to limit buffering (avoid keeping all requests in RAM).
|
|
2491
|
+
|
|
2492
|
+
Note: This should not be used for when resuming a session at some time later -- in those cases partial audio and video frames arelikely not needed. */
|
|
2493
|
+
lastConsumedClientMessageIndex?: string;
|
|
2267
2494
|
}
|
|
2268
2495
|
|
|
2269
2496
|
/** Sent in response to a `LiveGenerateContentSetup` message from the client. */
|
|
@@ -2345,6 +2572,7 @@ export declare interface MaskReferenceImage {
|
|
|
2345
2572
|
config?: MaskReferenceConfig;
|
|
2346
2573
|
}
|
|
2347
2574
|
|
|
2575
|
+
/** Enum representing the mask mode of a mask reference image. */
|
|
2348
2576
|
export declare enum MaskReferenceMode {
|
|
2349
2577
|
MASK_MODE_DEFAULT = "MASK_MODE_DEFAULT",
|
|
2350
2578
|
MASK_MODE_USER_PROVIDED = "MASK_MODE_USER_PROVIDED",
|
|
@@ -2353,6 +2581,7 @@ export declare enum MaskReferenceMode {
|
|
|
2353
2581
|
MASK_MODE_SEMANTIC = "MASK_MODE_SEMANTIC"
|
|
2354
2582
|
}
|
|
2355
2583
|
|
|
2584
|
+
/** Server content modalities. */
|
|
2356
2585
|
export declare enum MediaModality {
|
|
2357
2586
|
MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED",
|
|
2358
2587
|
TEXT = "TEXT",
|
|
@@ -2362,6 +2591,7 @@ export declare enum MediaModality {
|
|
|
2362
2591
|
DOCUMENT = "DOCUMENT"
|
|
2363
2592
|
}
|
|
2364
2593
|
|
|
2594
|
+
/** The media resolution to use. */
|
|
2365
2595
|
export declare enum MediaResolution {
|
|
2366
2596
|
MEDIA_RESOLUTION_UNSPECIFIED = "MEDIA_RESOLUTION_UNSPECIFIED",
|
|
2367
2597
|
MEDIA_RESOLUTION_LOW = "MEDIA_RESOLUTION_LOW",
|
|
@@ -2369,6 +2599,7 @@ export declare enum MediaResolution {
|
|
|
2369
2599
|
MEDIA_RESOLUTION_HIGH = "MEDIA_RESOLUTION_HIGH"
|
|
2370
2600
|
}
|
|
2371
2601
|
|
|
2602
|
+
/** Server content modalities. */
|
|
2372
2603
|
export declare enum Modality {
|
|
2373
2604
|
MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED",
|
|
2374
2605
|
TEXT = "TEXT",
|
|
@@ -2384,11 +2615,40 @@ export declare interface ModalityTokenCount {
|
|
|
2384
2615
|
tokenCount?: number;
|
|
2385
2616
|
}
|
|
2386
2617
|
|
|
2618
|
+
/** The mode of the predictor to be used in dynamic retrieval. */
|
|
2387
2619
|
export declare enum Mode {
|
|
2388
2620
|
MODE_UNSPECIFIED = "MODE_UNSPECIFIED",
|
|
2389
2621
|
MODE_DYNAMIC = "MODE_DYNAMIC"
|
|
2390
2622
|
}
|
|
2391
2623
|
|
|
2624
|
+
/** A trained machine learning model. */
|
|
2625
|
+
export declare interface Model {
|
|
2626
|
+
/** Resource name of the model. */
|
|
2627
|
+
name?: string;
|
|
2628
|
+
/** Display name of the model. */
|
|
2629
|
+
displayName?: string;
|
|
2630
|
+
/** Description of the model. */
|
|
2631
|
+
description?: string;
|
|
2632
|
+
/** Version ID of the model. A new version is committed when a new
|
|
2633
|
+
model version is uploaded or trained under an existing model ID. The
|
|
2634
|
+
version ID is an auto-incrementing decimal number in string
|
|
2635
|
+
representation. */
|
|
2636
|
+
version?: string;
|
|
2637
|
+
/** List of deployed models created from this base model. Note that a
|
|
2638
|
+
model could have been deployed to endpoints in different locations. */
|
|
2639
|
+
endpoints?: Endpoint[];
|
|
2640
|
+
/** Labels with user-defined metadata to organize your models. */
|
|
2641
|
+
labels?: Record<string, string>;
|
|
2642
|
+
/** Information about the tuned model from the base model. */
|
|
2643
|
+
tunedModelInfo?: TunedModelInfo;
|
|
2644
|
+
/** The maximum number of input tokens that the model can handle. */
|
|
2645
|
+
inputTokenLimit?: number;
|
|
2646
|
+
/** The maximum number of output tokens that the model can generate. */
|
|
2647
|
+
outputTokenLimit?: number;
|
|
2648
|
+
/** List of actions that are supported by the model. */
|
|
2649
|
+
supportedActions?: string[];
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2392
2652
|
export declare class Models extends BaseModule {
|
|
2393
2653
|
private readonly apiClient;
|
|
2394
2654
|
constructor(apiClient: ApiClient);
|
|
@@ -2539,6 +2799,15 @@ export declare class Models extends BaseModule {
|
|
|
2539
2799
|
* ```
|
|
2540
2800
|
*/
|
|
2541
2801
|
private generateImagesInternal;
|
|
2802
|
+
/**
|
|
2803
|
+
* Fetches information about a model by name.
|
|
2804
|
+
*
|
|
2805
|
+
* @example
|
|
2806
|
+
* ```ts
|
|
2807
|
+
* const modelInfo = await ai.models.get({model: 'gemini-2.0-flash'});
|
|
2808
|
+
* ```
|
|
2809
|
+
*/
|
|
2810
|
+
get(params: types.GetModelParameters): Promise<types.Model>;
|
|
2542
2811
|
/**
|
|
2543
2812
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
2544
2813
|
* supported for Gemini models.
|
|
@@ -2592,15 +2861,21 @@ export declare class Models extends BaseModule {
|
|
|
2592
2861
|
*
|
|
2593
2862
|
* while (!operation.done) {
|
|
2594
2863
|
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
2595
|
-
* operation = await ai.operations.
|
|
2864
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
2596
2865
|
* }
|
|
2597
2866
|
*
|
|
2598
|
-
* console.log(operation.
|
|
2867
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
2599
2868
|
* ```
|
|
2600
2869
|
*/
|
|
2601
2870
|
generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
|
|
2602
2871
|
}
|
|
2603
2872
|
|
|
2873
|
+
/** Config for model selection. */
|
|
2874
|
+
export declare interface ModelSelectionConfig {
|
|
2875
|
+
/** Options for feature selection preference. */
|
|
2876
|
+
featureSelectionPreference?: FeatureSelectionPreference;
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2604
2879
|
/** Parameters for the get method of the operations module. */
|
|
2605
2880
|
export declare interface OperationGetParameters {
|
|
2606
2881
|
/** The operation to be retrieved. */
|
|
@@ -2615,10 +2890,10 @@ export declare class Operations extends BaseModule {
|
|
|
2615
2890
|
/**
|
|
2616
2891
|
* Gets the status of a long-running operation.
|
|
2617
2892
|
*
|
|
2618
|
-
* @param
|
|
2893
|
+
* @param parameters The parameters for the get operation request.
|
|
2619
2894
|
* @return The updated Operation object, with the latest status or result.
|
|
2620
2895
|
*/
|
|
2621
|
-
|
|
2896
|
+
getVideosOperation(parameters: types.OperationGetParameters): Promise<types.GenerateVideosOperation>;
|
|
2622
2897
|
private getVideosOperationInternal;
|
|
2623
2898
|
private fetchPredictVideosOperationInternal;
|
|
2624
2899
|
}
|
|
@@ -2628,6 +2903,7 @@ export declare class Operations extends BaseModule {
|
|
|
2628
2903
|
* Copyright 2025 Google LLC
|
|
2629
2904
|
* SPDX-License-Identifier: Apache-2.0
|
|
2630
2905
|
*/
|
|
2906
|
+
/** Required. Outcome of the code execution. */
|
|
2631
2907
|
export declare enum Outcome {
|
|
2632
2908
|
OUTCOME_UNSPECIFIED = "OUTCOME_UNSPECIFIED",
|
|
2633
2909
|
OUTCOME_OK = "OUTCOME_OK",
|
|
@@ -2793,6 +3069,7 @@ export declare type PartListUnion = PartUnion[] | PartUnion;
|
|
|
2793
3069
|
|
|
2794
3070
|
export declare type PartUnion = Part | string;
|
|
2795
3071
|
|
|
3072
|
+
/** Enum that controls the generation of people. */
|
|
2796
3073
|
export declare enum PersonGeneration {
|
|
2797
3074
|
DONT_ALLOW = "DONT_ALLOW",
|
|
2798
3075
|
ALLOW_ADULT = "ALLOW_ADULT",
|
|
@@ -2806,6 +3083,54 @@ export declare interface PrebuiltVoiceConfig {
|
|
|
2806
3083
|
voiceName?: string;
|
|
2807
3084
|
}
|
|
2808
3085
|
|
|
3086
|
+
/** Specifies the context retrieval config. */
|
|
3087
|
+
export declare interface RagRetrievalConfig {
|
|
3088
|
+
/** Optional. Config for filters. */
|
|
3089
|
+
filter?: RagRetrievalConfigFilter;
|
|
3090
|
+
/** Optional. Config for Hybrid Search. */
|
|
3091
|
+
hybridSearch?: RagRetrievalConfigHybridSearch;
|
|
3092
|
+
/** Optional. Config for ranking and reranking. */
|
|
3093
|
+
ranking?: RagRetrievalConfigRanking;
|
|
3094
|
+
/** Optional. The number of contexts to retrieve. */
|
|
3095
|
+
topK?: number;
|
|
3096
|
+
}
|
|
3097
|
+
|
|
3098
|
+
/** Config for filters. */
|
|
3099
|
+
export declare interface RagRetrievalConfigFilter {
|
|
3100
|
+
/** Optional. String for metadata filtering. */
|
|
3101
|
+
metadataFilter?: string;
|
|
3102
|
+
/** Optional. Only returns contexts with vector distance smaller than the threshold. */
|
|
3103
|
+
vectorDistanceThreshold?: number;
|
|
3104
|
+
/** Optional. Only returns contexts with vector similarity larger than the threshold. */
|
|
3105
|
+
vectorSimilarityThreshold?: number;
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
/** Config for Hybrid Search. */
|
|
3109
|
+
export declare interface RagRetrievalConfigHybridSearch {
|
|
3110
|
+
/** Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally. */
|
|
3111
|
+
alpha?: number;
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
/** Config for ranking and reranking. */
|
|
3115
|
+
export declare interface RagRetrievalConfigRanking {
|
|
3116
|
+
/** Optional. Config for LlmRanker. */
|
|
3117
|
+
llmRanker?: RagRetrievalConfigRankingLlmRanker;
|
|
3118
|
+
/** Optional. Config for Rank Service. */
|
|
3119
|
+
rankService?: RagRetrievalConfigRankingRankService;
|
|
3120
|
+
}
|
|
3121
|
+
|
|
3122
|
+
/** Config for LlmRanker. */
|
|
3123
|
+
export declare interface RagRetrievalConfigRankingLlmRanker {
|
|
3124
|
+
/** Optional. The model name used for ranking. Format: `gemini-1.5-pro` */
|
|
3125
|
+
modelName?: string;
|
|
3126
|
+
}
|
|
3127
|
+
|
|
3128
|
+
/** Config for Rank Service. */
|
|
3129
|
+
export declare interface RagRetrievalConfigRankingRankService {
|
|
3130
|
+
/** Optional. The model name of the rank service. Format: `semantic-ranker-512@latest` */
|
|
3131
|
+
modelName?: string;
|
|
3132
|
+
}
|
|
3133
|
+
|
|
2809
3134
|
/** A raw reference image.
|
|
2810
3135
|
|
|
2811
3136
|
A raw reference image represents the base image to edit, provided by the user.
|
|
@@ -2821,6 +3146,20 @@ export declare interface RawReferenceImage {
|
|
|
2821
3146
|
referenceType?: string;
|
|
2822
3147
|
}
|
|
2823
3148
|
|
|
3149
|
+
/** Marks the end of user activity.
|
|
3150
|
+
|
|
3151
|
+
This can only be sent if automatic (i.e. server-side) activity detection is
|
|
3152
|
+
disabled.
|
|
3153
|
+
*/
|
|
3154
|
+
export declare interface RealtimeInputConfig {
|
|
3155
|
+
/** If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals. */
|
|
3156
|
+
automaticActivityDetection?: AutomaticActivityDetection;
|
|
3157
|
+
/** Defines what effect activity has. */
|
|
3158
|
+
activityHandling?: ActivityHandling;
|
|
3159
|
+
/** Defines which input is included in the user's turn. */
|
|
3160
|
+
turnCoverage?: TurnCoverage;
|
|
3161
|
+
}
|
|
3162
|
+
|
|
2824
3163
|
/** Represents a recorded session. */
|
|
2825
3164
|
export declare interface ReplayFile {
|
|
2826
3165
|
replayId?: string;
|
|
@@ -2878,6 +3217,7 @@ export declare interface SafetyAttributes {
|
|
|
2878
3217
|
contentType?: string;
|
|
2879
3218
|
}
|
|
2880
3219
|
|
|
3220
|
+
/** Enum that controls the safety filter level for objectionable content. */
|
|
2881
3221
|
export declare enum SafetyFilterLevel {
|
|
2882
3222
|
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
2883
3223
|
BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -3113,8 +3453,14 @@ export declare class Session {
|
|
|
3113
3453
|
|
|
3114
3454
|
@example
|
|
3115
3455
|
```ts
|
|
3456
|
+
let model: string;
|
|
3457
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
3458
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
3459
|
+
} else {
|
|
3460
|
+
model = 'gemini-2.0-flash-live-001';
|
|
3461
|
+
}
|
|
3116
3462
|
const session = await ai.live.connect({
|
|
3117
|
-
model:
|
|
3463
|
+
model: model,
|
|
3118
3464
|
config: {
|
|
3119
3465
|
responseModalities: [Modality.AUDIO],
|
|
3120
3466
|
}
|
|
@@ -3126,21 +3472,50 @@ export declare class Session {
|
|
|
3126
3472
|
close(): void;
|
|
3127
3473
|
}
|
|
3128
3474
|
|
|
3129
|
-
|
|
3475
|
+
/** Configuration of session resumption mechanism.
|
|
3476
|
+
|
|
3477
|
+
Included in `LiveConnectConfig.session_resumption`. If included server
|
|
3478
|
+
will send `LiveServerSessionResumptionUpdate` messages.
|
|
3479
|
+
*/
|
|
3480
|
+
export declare interface SessionResumptionConfig {
|
|
3481
|
+
/** Session resumption handle of previous session (session to restore).
|
|
3482
|
+
|
|
3483
|
+
If not present new session will be started. */
|
|
3484
|
+
handle?: string;
|
|
3485
|
+
/** If set the server will send `last_consumed_client_message_index` in the `session_resumption_update` messages to allow for transparent reconnections. */
|
|
3486
|
+
transparent?: boolean;
|
|
3487
|
+
}
|
|
3488
|
+
|
|
3489
|
+
/** Context window will be truncated by keeping only suffix of it.
|
|
3490
|
+
|
|
3491
|
+
Context window will always be cut at start of USER role turn. System
|
|
3492
|
+
instructions and `BidiGenerateContentSetup.prefix_turns` will not be
|
|
3493
|
+
subject to the sliding window mechanism, they will always stay at the
|
|
3494
|
+
beginning of context window.
|
|
3495
|
+
*/
|
|
3496
|
+
export declare interface SlidingWindow {
|
|
3497
|
+
/** Session reduction target -- how many tokens we should keep. Window shortening operation has some latency costs, so we should avoid running it on every turn. Should be < trigger_tokens. If not set, trigger_tokens/2 is assumed. */
|
|
3498
|
+
targetTokens?: string;
|
|
3499
|
+
}
|
|
3130
3500
|
|
|
3131
3501
|
/** The speech generation configuration. */
|
|
3132
3502
|
export declare interface SpeechConfig {
|
|
3133
3503
|
/** The configuration for the speaker to use.
|
|
3134
3504
|
*/
|
|
3135
3505
|
voiceConfig?: VoiceConfig;
|
|
3506
|
+
/** Language code (ISO 639. e.g. en-US) for the speech synthesization.
|
|
3507
|
+
Only available for Live API.
|
|
3508
|
+
*/
|
|
3509
|
+
languageCode?: string;
|
|
3136
3510
|
}
|
|
3137
3511
|
|
|
3138
3512
|
export declare type SpeechConfigUnion = SpeechConfig | string;
|
|
3139
3513
|
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3514
|
+
/** Start of speech sensitivity. */
|
|
3515
|
+
export declare enum StartSensitivity {
|
|
3516
|
+
START_SENSITIVITY_UNSPECIFIED = "START_SENSITIVITY_UNSPECIFIED",
|
|
3517
|
+
START_SENSITIVITY_HIGH = "START_SENSITIVITY_HIGH",
|
|
3518
|
+
START_SENSITIVITY_LOW = "START_SENSITIVITY_LOW"
|
|
3144
3519
|
}
|
|
3145
3520
|
|
|
3146
3521
|
/** Configuration for a Style reference image. */
|
|
@@ -3195,6 +3570,7 @@ export declare interface SubjectReferenceImage {
|
|
|
3195
3570
|
config?: SubjectReferenceConfig;
|
|
3196
3571
|
}
|
|
3197
3572
|
|
|
3573
|
+
/** Enum representing the subject type of a subject reference image. */
|
|
3198
3574
|
export declare enum SubjectReferenceType {
|
|
3199
3575
|
SUBJECT_TYPE_DEFAULT = "SUBJECT_TYPE_DEFAULT",
|
|
3200
3576
|
SUBJECT_TYPE_PERSON = "SUBJECT_TYPE_PERSON",
|
|
@@ -3233,6 +3609,9 @@ export declare interface ThinkingConfig {
|
|
|
3233
3609
|
/** Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.
|
|
3234
3610
|
*/
|
|
3235
3611
|
includeThoughts?: boolean;
|
|
3612
|
+
/** Indicates the thinking budget in tokens.
|
|
3613
|
+
*/
|
|
3614
|
+
thinkingBudget?: number;
|
|
3236
3615
|
}
|
|
3237
3616
|
|
|
3238
3617
|
/** Tokens info with a list of tokens and the corresponding list of token ids. */
|
|
@@ -3275,6 +3654,41 @@ export declare interface ToolConfig {
|
|
|
3275
3654
|
|
|
3276
3655
|
export declare type ToolListUnion = Tool[];
|
|
3277
3656
|
|
|
3657
|
+
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
3658
|
+
export declare enum TrafficType {
|
|
3659
|
+
TRAFFIC_TYPE_UNSPECIFIED = "TRAFFIC_TYPE_UNSPECIFIED",
|
|
3660
|
+
ON_DEMAND = "ON_DEMAND",
|
|
3661
|
+
PROVISIONED_THROUGHPUT = "PROVISIONED_THROUGHPUT"
|
|
3662
|
+
}
|
|
3663
|
+
|
|
3664
|
+
/** Audio transcription in Server Conent. */
|
|
3665
|
+
export declare interface Transcription {
|
|
3666
|
+
/** Transcription text.
|
|
3667
|
+
*/
|
|
3668
|
+
text?: string;
|
|
3669
|
+
/** The bool indicates the end of the transcription.
|
|
3670
|
+
*/
|
|
3671
|
+
finished?: boolean;
|
|
3672
|
+
}
|
|
3673
|
+
|
|
3674
|
+
/** A tuned machine learning model. */
|
|
3675
|
+
export declare interface TunedModelInfo {
|
|
3676
|
+
/** ID of the base model that you want to tune. */
|
|
3677
|
+
baseModel?: string;
|
|
3678
|
+
/** Date and time when the base model was created. */
|
|
3679
|
+
createTime?: string;
|
|
3680
|
+
/** Date and time when the base model was last updated. */
|
|
3681
|
+
updateTime?: string;
|
|
3682
|
+
}
|
|
3683
|
+
|
|
3684
|
+
/** Options about which input is included in the user's turn. */
|
|
3685
|
+
export declare enum TurnCoverage {
|
|
3686
|
+
TURN_COVERAGE_UNSPECIFIED = "TURN_COVERAGE_UNSPECIFIED",
|
|
3687
|
+
TURN_INCLUDES_ONLY_ACTIVITY = "TURN_INCLUDES_ONLY_ACTIVITY",
|
|
3688
|
+
TURN_INCLUDES_ALL_INPUT = "TURN_INCLUDES_ALL_INPUT"
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3691
|
+
/** Optional. The type of the data. */
|
|
3278
3692
|
export declare enum Type {
|
|
3279
3693
|
TYPE_UNSPECIFIED = "TYPE_UNSPECIFIED",
|
|
3280
3694
|
STRING = "STRING",
|
|
@@ -3307,11 +3721,12 @@ declare namespace types {
|
|
|
3307
3721
|
HarmProbability,
|
|
3308
3722
|
HarmSeverity,
|
|
3309
3723
|
BlockedReason,
|
|
3724
|
+
TrafficType,
|
|
3310
3725
|
Modality,
|
|
3311
|
-
|
|
3726
|
+
MediaResolution,
|
|
3727
|
+
FeatureSelectionPreference,
|
|
3312
3728
|
DynamicRetrievalConfigMode,
|
|
3313
3729
|
FunctionCallingConfigMode,
|
|
3314
|
-
MediaResolution,
|
|
3315
3730
|
SafetyFilterLevel,
|
|
3316
3731
|
PersonGeneration,
|
|
3317
3732
|
ImagePromptLanguage,
|
|
@@ -3321,6 +3736,10 @@ declare namespace types {
|
|
|
3321
3736
|
ControlReferenceType,
|
|
3322
3737
|
SubjectReferenceType,
|
|
3323
3738
|
MediaModality,
|
|
3739
|
+
StartSensitivity,
|
|
3740
|
+
EndSensitivity,
|
|
3741
|
+
ActivityHandling,
|
|
3742
|
+
TurnCoverage,
|
|
3324
3743
|
VideoMetadata,
|
|
3325
3744
|
CodeExecutionResult,
|
|
3326
3745
|
ExecutableCode,
|
|
@@ -3332,6 +3751,7 @@ declare namespace types {
|
|
|
3332
3751
|
Content,
|
|
3333
3752
|
HttpOptions,
|
|
3334
3753
|
Schema,
|
|
3754
|
+
ModelSelectionConfig,
|
|
3335
3755
|
SafetySetting,
|
|
3336
3756
|
FunctionDeclaration,
|
|
3337
3757
|
GoogleSearch,
|
|
@@ -3339,6 +3759,12 @@ declare namespace types {
|
|
|
3339
3759
|
GoogleSearchRetrieval,
|
|
3340
3760
|
VertexAISearch,
|
|
3341
3761
|
VertexRagStoreRagResource,
|
|
3762
|
+
RagRetrievalConfigFilter,
|
|
3763
|
+
RagRetrievalConfigHybridSearch,
|
|
3764
|
+
RagRetrievalConfigRankingLlmRanker,
|
|
3765
|
+
RagRetrievalConfigRankingRankService,
|
|
3766
|
+
RagRetrievalConfigRanking,
|
|
3767
|
+
RagRetrievalConfig,
|
|
3342
3768
|
VertexRagStore,
|
|
3343
3769
|
Retrieval,
|
|
3344
3770
|
ToolCodeExecution,
|
|
@@ -3386,6 +3812,11 @@ declare namespace types {
|
|
|
3386
3812
|
SafetyAttributes,
|
|
3387
3813
|
GeneratedImage,
|
|
3388
3814
|
GenerateImagesResponse,
|
|
3815
|
+
GetModelConfig,
|
|
3816
|
+
GetModelParameters,
|
|
3817
|
+
Endpoint,
|
|
3818
|
+
TunedModelInfo,
|
|
3819
|
+
Model,
|
|
3389
3820
|
GenerationConfig,
|
|
3390
3821
|
CountTokensConfig,
|
|
3391
3822
|
CountTokensParameters,
|
|
@@ -3423,6 +3854,7 @@ declare namespace types {
|
|
|
3423
3854
|
CreateFileParameters,
|
|
3424
3855
|
HttpResponse,
|
|
3425
3856
|
LiveCallbacks,
|
|
3857
|
+
UploadFileParameters,
|
|
3426
3858
|
CreateFileResponse,
|
|
3427
3859
|
GetFileConfig,
|
|
3428
3860
|
GetFileParameters,
|
|
@@ -3453,12 +3885,24 @@ declare namespace types {
|
|
|
3453
3885
|
SubjectReferenceConfig,
|
|
3454
3886
|
SubjectReferenceImage,
|
|
3455
3887
|
LiveServerSetupComplete,
|
|
3888
|
+
Transcription,
|
|
3456
3889
|
LiveServerContent,
|
|
3457
3890
|
LiveServerToolCall,
|
|
3458
3891
|
LiveServerToolCallCancellation,
|
|
3892
|
+
UsageMetadata,
|
|
3893
|
+
LiveServerGoAway,
|
|
3894
|
+
LiveServerSessionResumptionUpdate,
|
|
3459
3895
|
LiveServerMessage,
|
|
3896
|
+
AutomaticActivityDetection,
|
|
3897
|
+
RealtimeInputConfig,
|
|
3898
|
+
SessionResumptionConfig,
|
|
3899
|
+
SlidingWindow,
|
|
3900
|
+
ContextWindowCompressionConfig,
|
|
3901
|
+
AudioTranscriptionConfig,
|
|
3460
3902
|
LiveClientSetup,
|
|
3461
3903
|
LiveClientContent,
|
|
3904
|
+
ActivityStart,
|
|
3905
|
+
ActivityEnd,
|
|
3462
3906
|
LiveClientRealtimeInput,
|
|
3463
3907
|
LiveClientToolResponse,
|
|
3464
3908
|
LiveClientMessage,
|
|
@@ -3535,9 +3979,9 @@ export declare interface UploadFileConfig {
|
|
|
3535
3979
|
}
|
|
3536
3980
|
|
|
3537
3981
|
/** Parameters for the upload file method. */
|
|
3538
|
-
declare interface UploadFileParameters {
|
|
3982
|
+
export declare interface UploadFileParameters {
|
|
3539
3983
|
/** The string path to the file to be uploaded or a Blob object. */
|
|
3540
|
-
file: string | Blob;
|
|
3984
|
+
file: string | globalThis.Blob;
|
|
3541
3985
|
/** Configuration that contains optional parameters. */
|
|
3542
3986
|
config?: UploadFileConfig;
|
|
3543
3987
|
}
|
|
@@ -3573,6 +4017,33 @@ export declare interface UpscaleImageParameters {
|
|
|
3573
4017
|
config?: UpscaleImageConfig;
|
|
3574
4018
|
}
|
|
3575
4019
|
|
|
4020
|
+
/** Usage metadata about response(s). */
|
|
4021
|
+
export declare interface UsageMetadata {
|
|
4022
|
+
/** Number of tokens in the prompt. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content. */
|
|
4023
|
+
promptTokenCount?: number;
|
|
4024
|
+
/** Number of tokens in the cached part of the prompt (the cached content). */
|
|
4025
|
+
cachedContentTokenCount?: number;
|
|
4026
|
+
/** Total number of tokens across all the generated response candidates. */
|
|
4027
|
+
responseTokenCount?: number;
|
|
4028
|
+
/** Number of tokens present in tool-use prompt(s). */
|
|
4029
|
+
toolUsePromptTokenCount?: number;
|
|
4030
|
+
/** Number of tokens of thoughts for thinking models. */
|
|
4031
|
+
thoughtsTokenCount?: number;
|
|
4032
|
+
/** Total token count for prompt, response candidates, and tool-use prompts(if present). */
|
|
4033
|
+
totalTokenCount?: number;
|
|
4034
|
+
/** List of modalities that were processed in the request input. */
|
|
4035
|
+
promptTokensDetails?: ModalityTokenCount[];
|
|
4036
|
+
/** List of modalities that were processed in the cache input. */
|
|
4037
|
+
cacheTokensDetails?: ModalityTokenCount[];
|
|
4038
|
+
/** List of modalities that were returned in the response. */
|
|
4039
|
+
responseTokensDetails?: ModalityTokenCount[];
|
|
4040
|
+
/** List of modalities that were processed in the tool-use prompt. */
|
|
4041
|
+
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
4042
|
+
/** Traffic type. This shows whether a request consumes Pay-As-You-Go
|
|
4043
|
+
or Provisioned Throughput quota. */
|
|
4044
|
+
trafficType?: TrafficType;
|
|
4045
|
+
}
|
|
4046
|
+
|
|
3576
4047
|
/** Retrieve from Vertex AI Search datastore or engine for grounding. datastore and engine are mutually exclusive. See https://cloud.google.com/products/agent-builder */
|
|
3577
4048
|
export declare interface VertexAISearch {
|
|
3578
4049
|
/** Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}` */
|
|
@@ -3587,6 +4058,8 @@ export declare interface VertexRagStore {
|
|
|
3587
4058
|
ragCorpora?: string[];
|
|
3588
4059
|
/** Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support. */
|
|
3589
4060
|
ragResources?: VertexRagStoreRagResource[];
|
|
4061
|
+
/** Optional. The retrieval config for the Rag query. */
|
|
4062
|
+
ragRetrievalConfig?: RagRetrievalConfig;
|
|
3590
4063
|
/** Optional. Number of top k results to return from the selected corpora. */
|
|
3591
4064
|
similarityTopK?: number;
|
|
3592
4065
|
/** Optional. Only return results with vector distance smaller than the threshold. */
|