@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/genai.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
|
*
|
|
@@ -1806,6 +1899,8 @@ export declare interface GroundingChunkRetrievedContext {
|
|
|
1806
1899
|
|
|
1807
1900
|
/** Chunk from the web. */
|
|
1808
1901
|
export declare interface GroundingChunkWeb {
|
|
1902
|
+
/** Domain of the (original) URI. */
|
|
1903
|
+
domain?: string;
|
|
1809
1904
|
/** Title of the chunk. */
|
|
1810
1905
|
title?: string;
|
|
1811
1906
|
/** URI reference of the chunk. */
|
|
@@ -1838,12 +1933,14 @@ export declare interface GroundingSupport {
|
|
|
1838
1933
|
segment?: Segment;
|
|
1839
1934
|
}
|
|
1840
1935
|
|
|
1936
|
+
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
|
|
1841
1937
|
export declare enum HarmBlockMethod {
|
|
1842
1938
|
HARM_BLOCK_METHOD_UNSPECIFIED = "HARM_BLOCK_METHOD_UNSPECIFIED",
|
|
1843
1939
|
SEVERITY = "SEVERITY",
|
|
1844
1940
|
PROBABILITY = "PROBABILITY"
|
|
1845
1941
|
}
|
|
1846
1942
|
|
|
1943
|
+
/** Required. The harm block threshold. */
|
|
1847
1944
|
export declare enum HarmBlockThreshold {
|
|
1848
1945
|
HARM_BLOCK_THRESHOLD_UNSPECIFIED = "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
1849
1946
|
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
@@ -1853,6 +1950,7 @@ export declare enum HarmBlockThreshold {
|
|
|
1853
1950
|
OFF = "OFF"
|
|
1854
1951
|
}
|
|
1855
1952
|
|
|
1953
|
+
/** Required. Harm category. */
|
|
1856
1954
|
export declare enum HarmCategory {
|
|
1857
1955
|
HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED",
|
|
1858
1956
|
HARM_CATEGORY_HATE_SPEECH = "HARM_CATEGORY_HATE_SPEECH",
|
|
@@ -1862,6 +1960,7 @@ export declare enum HarmCategory {
|
|
|
1862
1960
|
HARM_CATEGORY_CIVIC_INTEGRITY = "HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
1863
1961
|
}
|
|
1864
1962
|
|
|
1963
|
+
/** Output only. Harm probability levels in the content. */
|
|
1865
1964
|
export declare enum HarmProbability {
|
|
1866
1965
|
HARM_PROBABILITY_UNSPECIFIED = "HARM_PROBABILITY_UNSPECIFIED",
|
|
1867
1966
|
NEGLIGIBLE = "NEGLIGIBLE",
|
|
@@ -1870,6 +1969,7 @@ export declare enum HarmProbability {
|
|
|
1870
1969
|
HIGH = "HIGH"
|
|
1871
1970
|
}
|
|
1872
1971
|
|
|
1972
|
+
/** Output only. Harm severity levels in the content. */
|
|
1873
1973
|
export declare enum HarmSeverity {
|
|
1874
1974
|
HARM_SEVERITY_UNSPECIFIED = "HARM_SEVERITY_UNSPECIFIED",
|
|
1875
1975
|
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE",
|
|
@@ -1962,6 +2062,7 @@ declare interface Image_2 {
|
|
|
1962
2062
|
}
|
|
1963
2063
|
export { Image_2 as Image }
|
|
1964
2064
|
|
|
2065
|
+
/** Enum that specifies the language of the text in the prompt. */
|
|
1965
2066
|
export declare enum ImagePromptLanguage {
|
|
1966
2067
|
auto = "auto",
|
|
1967
2068
|
en = "en",
|
|
@@ -1970,6 +2071,7 @@ export declare enum ImagePromptLanguage {
|
|
|
1970
2071
|
hi = "hi"
|
|
1971
2072
|
}
|
|
1972
2073
|
|
|
2074
|
+
/** Required. Programming language of the `code`. */
|
|
1973
2075
|
export declare enum Language {
|
|
1974
2076
|
LANGUAGE_UNSPECIFIED = "LANGUAGE_UNSPECIFIED",
|
|
1975
2077
|
PYTHON = "PYTHON"
|
|
@@ -2037,17 +2139,20 @@ export declare class Live {
|
|
|
2037
2139
|
@experimental
|
|
2038
2140
|
|
|
2039
2141
|
@remarks
|
|
2040
|
-
If using the Gemini API, Live is currently only supported behind API
|
|
2041
|
-
version `v1alpha`. Ensure that the API version is set to `v1alpha` when
|
|
2042
|
-
initializing the SDK if relying on the Gemini API.
|
|
2043
2142
|
|
|
2044
2143
|
@param params - The parameters for establishing a connection to the model.
|
|
2045
2144
|
@return A live session.
|
|
2046
2145
|
|
|
2047
2146
|
@example
|
|
2048
2147
|
```ts
|
|
2148
|
+
let model: string;
|
|
2149
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
2150
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
2151
|
+
} else {
|
|
2152
|
+
model = 'gemini-2.0-flash-live-001';
|
|
2153
|
+
}
|
|
2049
2154
|
const session = await ai.live.connect({
|
|
2050
|
-
model:
|
|
2155
|
+
model: model,
|
|
2051
2156
|
config: {
|
|
2052
2157
|
responseModalities: [Modality.AUDIO],
|
|
2053
2158
|
},
|
|
@@ -2073,9 +2178,21 @@ export declare class Live {
|
|
|
2073
2178
|
|
|
2074
2179
|
/** Callbacks for the live API. */
|
|
2075
2180
|
export declare interface LiveCallbacks {
|
|
2181
|
+
/**
|
|
2182
|
+
* Called when the websocket connection is established.
|
|
2183
|
+
*/
|
|
2076
2184
|
onopen?: (() => void) | null;
|
|
2185
|
+
/**
|
|
2186
|
+
* Called when a message is received from the server.
|
|
2187
|
+
*/
|
|
2077
2188
|
onmessage: (e: LiveServerMessage) => void;
|
|
2189
|
+
/**
|
|
2190
|
+
* Called when an error occurs.
|
|
2191
|
+
*/
|
|
2078
2192
|
onerror?: ((e: ErrorEvent) => void) | null;
|
|
2193
|
+
/**
|
|
2194
|
+
* Called when the websocket connection is closed.
|
|
2195
|
+
*/
|
|
2079
2196
|
onclose?: ((e: CloseEvent) => void) | null;
|
|
2080
2197
|
}
|
|
2081
2198
|
|
|
@@ -2114,11 +2231,11 @@ export declare interface LiveClientMessage {
|
|
|
2114
2231
|
|
|
2115
2232
|
/** User input that is sent in real time.
|
|
2116
2233
|
|
|
2117
|
-
This is different from `
|
|
2234
|
+
This is different from `LiveClientContent` in a few ways:
|
|
2118
2235
|
|
|
2119
2236
|
- Can be sent continuously without interruption to model generation.
|
|
2120
2237
|
- If there is a need to mix data interleaved across the
|
|
2121
|
-
`
|
|
2238
|
+
`LiveClientContent` and the `LiveClientRealtimeInput`, server attempts to
|
|
2122
2239
|
optimize for best response, but there are no guarantees.
|
|
2123
2240
|
- End of turn is not explicitly specified, but is rather derived from user
|
|
2124
2241
|
activity (for example, end of speech).
|
|
@@ -2130,6 +2247,10 @@ export declare interface LiveClientMessage {
|
|
|
2130
2247
|
export declare interface LiveClientRealtimeInput {
|
|
2131
2248
|
/** Inlined bytes data for media input. */
|
|
2132
2249
|
mediaChunks?: Blob_2[];
|
|
2250
|
+
/** Marks the start of user activity. */
|
|
2251
|
+
activityStart?: ActivityStart;
|
|
2252
|
+
/** Marks the end of user activity. */
|
|
2253
|
+
activityEnd?: ActivityEnd;
|
|
2133
2254
|
}
|
|
2134
2255
|
|
|
2135
2256
|
/** Message contains configuration that will apply for the duration of the streaming session. */
|
|
@@ -2140,27 +2261,36 @@ export declare interface LiveClientSetup {
|
|
|
2140
2261
|
*/
|
|
2141
2262
|
model?: string;
|
|
2142
2263
|
/** The generation configuration for the session.
|
|
2143
|
-
|
|
2144
|
-
The following fields are supported:
|
|
2145
|
-
- `response_logprobs`
|
|
2146
|
-
- `response_mime_type`
|
|
2147
|
-
- `logprobs`
|
|
2148
|
-
- `response_schema`
|
|
2149
|
-
- `stop_sequence`
|
|
2150
|
-
- `routing_config`
|
|
2151
|
-
- `audio_timestamp`
|
|
2264
|
+
Note: only a subset of fields are supported.
|
|
2152
2265
|
*/
|
|
2153
2266
|
generationConfig?: GenerationConfig;
|
|
2154
2267
|
/** The user provided system instructions for the model.
|
|
2155
2268
|
Note: only text should be used in parts and content in each part will be
|
|
2156
2269
|
in a separate paragraph. */
|
|
2157
|
-
systemInstruction?:
|
|
2270
|
+
systemInstruction?: ContentUnion;
|
|
2158
2271
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2159
2272
|
|
|
2160
2273
|
A `Tool` is a piece of code that enables the system to interact with
|
|
2161
2274
|
external systems to perform an action, or set of actions, outside of
|
|
2162
2275
|
knowledge and scope of the model. */
|
|
2163
2276
|
tools?: ToolListUnion;
|
|
2277
|
+
/** Configures the realtime input behavior in BidiGenerateContent. */
|
|
2278
|
+
realtimeInputConfig?: RealtimeInputConfig;
|
|
2279
|
+
/** Configures session resumption mechanism.
|
|
2280
|
+
|
|
2281
|
+
If included server will send SessionResumptionUpdate messages. */
|
|
2282
|
+
sessionResumption?: SessionResumptionConfig;
|
|
2283
|
+
/** Configures context window compression mechanism.
|
|
2284
|
+
|
|
2285
|
+
If included, server will compress context window to fit into given length. */
|
|
2286
|
+
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2287
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2288
|
+
*/
|
|
2289
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2290
|
+
/** The transcription of the output aligns with the language code
|
|
2291
|
+
specified for the output audio.
|
|
2292
|
+
*/
|
|
2293
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2164
2294
|
}
|
|
2165
2295
|
|
|
2166
2296
|
/** Client generated response to a `ToolCall` received from the server.
|
|
@@ -2186,19 +2316,65 @@ export declare interface LiveConnectConfig {
|
|
|
2186
2316
|
modalities that the model can return. Defaults to AUDIO if not specified.
|
|
2187
2317
|
*/
|
|
2188
2318
|
responseModalities?: Modality[];
|
|
2319
|
+
/** Value that controls the degree of randomness in token selection.
|
|
2320
|
+
Lower temperatures are good for prompts that require a less open-ended or
|
|
2321
|
+
creative response, while higher temperatures can lead to more diverse or
|
|
2322
|
+
creative results.
|
|
2323
|
+
*/
|
|
2324
|
+
temperature?: number;
|
|
2325
|
+
/** Tokens are selected from the most to least probable until the sum
|
|
2326
|
+
of their probabilities equals this value. Use a lower value for less
|
|
2327
|
+
random responses and a higher value for more random responses.
|
|
2328
|
+
*/
|
|
2329
|
+
topP?: number;
|
|
2330
|
+
/** For each token selection step, the ``top_k`` tokens with the
|
|
2331
|
+
highest probabilities are sampled. Then tokens are further filtered based
|
|
2332
|
+
on ``top_p`` with the final token selected using temperature sampling. Use
|
|
2333
|
+
a lower number for less random responses and a higher number for more
|
|
2334
|
+
random responses.
|
|
2335
|
+
*/
|
|
2336
|
+
topK?: number;
|
|
2337
|
+
/** Maximum number of tokens that can be generated in the response.
|
|
2338
|
+
*/
|
|
2339
|
+
maxOutputTokens?: number;
|
|
2340
|
+
/** If specified, the media resolution specified will be used.
|
|
2341
|
+
*/
|
|
2342
|
+
mediaResolution?: MediaResolution;
|
|
2343
|
+
/** When ``seed`` is fixed to a specific number, the model makes a best
|
|
2344
|
+
effort to provide the same response for repeated requests. By default, a
|
|
2345
|
+
random number is used.
|
|
2346
|
+
*/
|
|
2347
|
+
seed?: number;
|
|
2189
2348
|
/** The speech generation configuration.
|
|
2190
2349
|
*/
|
|
2191
2350
|
speechConfig?: SpeechConfig;
|
|
2192
2351
|
/** The user provided system instructions for the model.
|
|
2193
2352
|
Note: only text should be used in parts and content in each part will be
|
|
2194
2353
|
in a separate paragraph. */
|
|
2195
|
-
systemInstruction?:
|
|
2354
|
+
systemInstruction?: ContentUnion;
|
|
2196
2355
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2197
2356
|
|
|
2198
2357
|
A `Tool` is a piece of code that enables the system to interact with
|
|
2199
2358
|
external systems to perform an action, or set of actions, outside of
|
|
2200
2359
|
knowledge and scope of the model. */
|
|
2201
2360
|
tools?: ToolListUnion;
|
|
2361
|
+
/** Configures session resumption mechanism.
|
|
2362
|
+
|
|
2363
|
+
If included the server will send SessionResumptionUpdate messages. */
|
|
2364
|
+
sessionResumption?: SessionResumptionConfig;
|
|
2365
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2366
|
+
*/
|
|
2367
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2368
|
+
/** The transcription of the output aligns with the language code
|
|
2369
|
+
specified for the output audio.
|
|
2370
|
+
*/
|
|
2371
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2372
|
+
/** Configures the realtime input behavior in BidiGenerateContent. */
|
|
2373
|
+
realtimeInputConfig?: RealtimeInputConfig;
|
|
2374
|
+
/** Configures context window compression mechanism.
|
|
2375
|
+
|
|
2376
|
+
If included, server will compress context window to fit into given length. */
|
|
2377
|
+
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2202
2378
|
}
|
|
2203
2379
|
|
|
2204
2380
|
/** Parameters for connecting to the live API. */
|
|
@@ -2227,6 +2403,10 @@ export declare interface LiveSendClientContentParameters {
|
|
|
2227
2403
|
export declare interface LiveSendRealtimeInputParameters {
|
|
2228
2404
|
/** Realtime input to send to the session. */
|
|
2229
2405
|
media: Blob_2;
|
|
2406
|
+
/** Marks the start of user activity. */
|
|
2407
|
+
activityStart?: ActivityStart;
|
|
2408
|
+
/** Marks the end of user activity. */
|
|
2409
|
+
activityEnd?: ActivityEnd;
|
|
2230
2410
|
}
|
|
2231
2411
|
|
|
2232
2412
|
/** Parameters for sending tool responses to the live API. */
|
|
@@ -2247,6 +2427,30 @@ export declare interface LiveServerContent {
|
|
|
2247
2427
|
turnComplete?: boolean;
|
|
2248
2428
|
/** 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. */
|
|
2249
2429
|
interrupted?: boolean;
|
|
2430
|
+
/** If true, indicates that the model is done generating. When model is
|
|
2431
|
+
interrupted while generating there will be no generation_complete message
|
|
2432
|
+
in interrupted turn, it will go through interrupted > turn_complete.
|
|
2433
|
+
When model assumes realtime playback there will be delay between
|
|
2434
|
+
generation_complete and turn_complete that is caused by model
|
|
2435
|
+
waiting for playback to finish. If true, indicates that the model
|
|
2436
|
+
has finished generating all content. This is a signal to the client
|
|
2437
|
+
that it can stop sending messages. */
|
|
2438
|
+
generationComplete?: boolean;
|
|
2439
|
+
/** Input transcription. The transcription is independent to the model
|
|
2440
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2441
|
+
model turn. */
|
|
2442
|
+
inputTranscription?: Transcription;
|
|
2443
|
+
/** Output transcription. The transcription is independent to the model
|
|
2444
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2445
|
+
model turn.
|
|
2446
|
+
*/
|
|
2447
|
+
outputTranscription?: Transcription;
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
/** Server will not be able to service client soon. */
|
|
2451
|
+
export declare interface LiveServerGoAway {
|
|
2452
|
+
/** 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. */
|
|
2453
|
+
timeLeft?: string;
|
|
2250
2454
|
}
|
|
2251
2455
|
|
|
2252
2456
|
/** Response message for API call. */
|
|
@@ -2259,6 +2463,29 @@ export declare interface LiveServerMessage {
|
|
|
2259
2463
|
toolCall?: LiveServerToolCall;
|
|
2260
2464
|
/** Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled. */
|
|
2261
2465
|
toolCallCancellation?: LiveServerToolCallCancellation;
|
|
2466
|
+
/** Usage metadata about model response(s). */
|
|
2467
|
+
usageMetadata?: UsageMetadata;
|
|
2468
|
+
/** Server will disconnect soon. */
|
|
2469
|
+
goAway?: LiveServerGoAway;
|
|
2470
|
+
/** Update of the session resumption state. */
|
|
2471
|
+
sessionResumptionUpdate?: LiveServerSessionResumptionUpdate;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
/** Update of the session resumption state.
|
|
2475
|
+
|
|
2476
|
+
Only sent if `session_resumption` was set in the connection config.
|
|
2477
|
+
*/
|
|
2478
|
+
export declare interface LiveServerSessionResumptionUpdate {
|
|
2479
|
+
/** New handle that represents state that can be resumed. Empty if `resumable`=false. */
|
|
2480
|
+
newHandle?: string;
|
|
2481
|
+
/** 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. */
|
|
2482
|
+
resumable?: boolean;
|
|
2483
|
+
/** Index of last message sent by client that is included in state represented by this SessionResumptionToken. Only sent when `SessionResumptionConfig.transparent` is set.
|
|
2484
|
+
|
|
2485
|
+
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).
|
|
2486
|
+
|
|
2487
|
+
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. */
|
|
2488
|
+
lastConsumedClientMessageIndex?: string;
|
|
2262
2489
|
}
|
|
2263
2490
|
|
|
2264
2491
|
/** Sent in response to a `LiveGenerateContentSetup` message from the client. */
|
|
@@ -2340,6 +2567,7 @@ export declare interface MaskReferenceImage {
|
|
|
2340
2567
|
config?: MaskReferenceConfig;
|
|
2341
2568
|
}
|
|
2342
2569
|
|
|
2570
|
+
/** Enum representing the mask mode of a mask reference image. */
|
|
2343
2571
|
export declare enum MaskReferenceMode {
|
|
2344
2572
|
MASK_MODE_DEFAULT = "MASK_MODE_DEFAULT",
|
|
2345
2573
|
MASK_MODE_USER_PROVIDED = "MASK_MODE_USER_PROVIDED",
|
|
@@ -2348,6 +2576,7 @@ export declare enum MaskReferenceMode {
|
|
|
2348
2576
|
MASK_MODE_SEMANTIC = "MASK_MODE_SEMANTIC"
|
|
2349
2577
|
}
|
|
2350
2578
|
|
|
2579
|
+
/** Server content modalities. */
|
|
2351
2580
|
export declare enum MediaModality {
|
|
2352
2581
|
MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED",
|
|
2353
2582
|
TEXT = "TEXT",
|
|
@@ -2357,6 +2586,7 @@ export declare enum MediaModality {
|
|
|
2357
2586
|
DOCUMENT = "DOCUMENT"
|
|
2358
2587
|
}
|
|
2359
2588
|
|
|
2589
|
+
/** The media resolution to use. */
|
|
2360
2590
|
export declare enum MediaResolution {
|
|
2361
2591
|
MEDIA_RESOLUTION_UNSPECIFIED = "MEDIA_RESOLUTION_UNSPECIFIED",
|
|
2362
2592
|
MEDIA_RESOLUTION_LOW = "MEDIA_RESOLUTION_LOW",
|
|
@@ -2364,6 +2594,7 @@ export declare enum MediaResolution {
|
|
|
2364
2594
|
MEDIA_RESOLUTION_HIGH = "MEDIA_RESOLUTION_HIGH"
|
|
2365
2595
|
}
|
|
2366
2596
|
|
|
2597
|
+
/** Server content modalities. */
|
|
2367
2598
|
export declare enum Modality {
|
|
2368
2599
|
MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED",
|
|
2369
2600
|
TEXT = "TEXT",
|
|
@@ -2379,11 +2610,40 @@ export declare interface ModalityTokenCount {
|
|
|
2379
2610
|
tokenCount?: number;
|
|
2380
2611
|
}
|
|
2381
2612
|
|
|
2613
|
+
/** The mode of the predictor to be used in dynamic retrieval. */
|
|
2382
2614
|
export declare enum Mode {
|
|
2383
2615
|
MODE_UNSPECIFIED = "MODE_UNSPECIFIED",
|
|
2384
2616
|
MODE_DYNAMIC = "MODE_DYNAMIC"
|
|
2385
2617
|
}
|
|
2386
2618
|
|
|
2619
|
+
/** A trained machine learning model. */
|
|
2620
|
+
export declare interface Model {
|
|
2621
|
+
/** Resource name of the model. */
|
|
2622
|
+
name?: string;
|
|
2623
|
+
/** Display name of the model. */
|
|
2624
|
+
displayName?: string;
|
|
2625
|
+
/** Description of the model. */
|
|
2626
|
+
description?: string;
|
|
2627
|
+
/** Version ID of the model. A new version is committed when a new
|
|
2628
|
+
model version is uploaded or trained under an existing model ID. The
|
|
2629
|
+
version ID is an auto-incrementing decimal number in string
|
|
2630
|
+
representation. */
|
|
2631
|
+
version?: string;
|
|
2632
|
+
/** List of deployed models created from this base model. Note that a
|
|
2633
|
+
model could have been deployed to endpoints in different locations. */
|
|
2634
|
+
endpoints?: Endpoint[];
|
|
2635
|
+
/** Labels with user-defined metadata to organize your models. */
|
|
2636
|
+
labels?: Record<string, string>;
|
|
2637
|
+
/** Information about the tuned model from the base model. */
|
|
2638
|
+
tunedModelInfo?: TunedModelInfo;
|
|
2639
|
+
/** The maximum number of input tokens that the model can handle. */
|
|
2640
|
+
inputTokenLimit?: number;
|
|
2641
|
+
/** The maximum number of output tokens that the model can generate. */
|
|
2642
|
+
outputTokenLimit?: number;
|
|
2643
|
+
/** List of actions that are supported by the model. */
|
|
2644
|
+
supportedActions?: string[];
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2387
2647
|
export declare class Models extends BaseModule {
|
|
2388
2648
|
private readonly apiClient;
|
|
2389
2649
|
constructor(apiClient: ApiClient);
|
|
@@ -2534,6 +2794,15 @@ export declare class Models extends BaseModule {
|
|
|
2534
2794
|
* ```
|
|
2535
2795
|
*/
|
|
2536
2796
|
private generateImagesInternal;
|
|
2797
|
+
/**
|
|
2798
|
+
* Fetches information about a model by name.
|
|
2799
|
+
*
|
|
2800
|
+
* @example
|
|
2801
|
+
* ```ts
|
|
2802
|
+
* const modelInfo = await ai.models.get({model: 'gemini-2.0-flash'});
|
|
2803
|
+
* ```
|
|
2804
|
+
*/
|
|
2805
|
+
get(params: types.GetModelParameters): Promise<types.Model>;
|
|
2537
2806
|
/**
|
|
2538
2807
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
2539
2808
|
* supported for Gemini models.
|
|
@@ -2587,15 +2856,21 @@ export declare class Models extends BaseModule {
|
|
|
2587
2856
|
*
|
|
2588
2857
|
* while (!operation.done) {
|
|
2589
2858
|
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
2590
|
-
* operation = await ai.operations.
|
|
2859
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
2591
2860
|
* }
|
|
2592
2861
|
*
|
|
2593
|
-
* console.log(operation.
|
|
2862
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
2594
2863
|
* ```
|
|
2595
2864
|
*/
|
|
2596
2865
|
generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
|
|
2597
2866
|
}
|
|
2598
2867
|
|
|
2868
|
+
/** Config for model selection. */
|
|
2869
|
+
export declare interface ModelSelectionConfig {
|
|
2870
|
+
/** Options for feature selection preference. */
|
|
2871
|
+
featureSelectionPreference?: FeatureSelectionPreference;
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2599
2874
|
/** Parameters for the get method of the operations module. */
|
|
2600
2875
|
export declare interface OperationGetParameters {
|
|
2601
2876
|
/** The operation to be retrieved. */
|
|
@@ -2610,10 +2885,10 @@ export declare class Operations extends BaseModule {
|
|
|
2610
2885
|
/**
|
|
2611
2886
|
* Gets the status of a long-running operation.
|
|
2612
2887
|
*
|
|
2613
|
-
* @param
|
|
2888
|
+
* @param parameters The parameters for the get operation request.
|
|
2614
2889
|
* @return The updated Operation object, with the latest status or result.
|
|
2615
2890
|
*/
|
|
2616
|
-
|
|
2891
|
+
getVideosOperation(parameters: types.OperationGetParameters): Promise<types.GenerateVideosOperation>;
|
|
2617
2892
|
private getVideosOperationInternal;
|
|
2618
2893
|
private fetchPredictVideosOperationInternal;
|
|
2619
2894
|
}
|
|
@@ -2623,6 +2898,7 @@ export declare class Operations extends BaseModule {
|
|
|
2623
2898
|
* Copyright 2025 Google LLC
|
|
2624
2899
|
* SPDX-License-Identifier: Apache-2.0
|
|
2625
2900
|
*/
|
|
2901
|
+
/** Required. Outcome of the code execution. */
|
|
2626
2902
|
export declare enum Outcome {
|
|
2627
2903
|
OUTCOME_UNSPECIFIED = "OUTCOME_UNSPECIFIED",
|
|
2628
2904
|
OUTCOME_OK = "OUTCOME_OK",
|
|
@@ -2788,6 +3064,7 @@ export declare type PartListUnion = PartUnion[] | PartUnion;
|
|
|
2788
3064
|
|
|
2789
3065
|
export declare type PartUnion = Part | string;
|
|
2790
3066
|
|
|
3067
|
+
/** Enum that controls the generation of people. */
|
|
2791
3068
|
export declare enum PersonGeneration {
|
|
2792
3069
|
DONT_ALLOW = "DONT_ALLOW",
|
|
2793
3070
|
ALLOW_ADULT = "ALLOW_ADULT",
|
|
@@ -2801,6 +3078,54 @@ export declare interface PrebuiltVoiceConfig {
|
|
|
2801
3078
|
voiceName?: string;
|
|
2802
3079
|
}
|
|
2803
3080
|
|
|
3081
|
+
/** Specifies the context retrieval config. */
|
|
3082
|
+
export declare interface RagRetrievalConfig {
|
|
3083
|
+
/** Optional. Config for filters. */
|
|
3084
|
+
filter?: RagRetrievalConfigFilter;
|
|
3085
|
+
/** Optional. Config for Hybrid Search. */
|
|
3086
|
+
hybridSearch?: RagRetrievalConfigHybridSearch;
|
|
3087
|
+
/** Optional. Config for ranking and reranking. */
|
|
3088
|
+
ranking?: RagRetrievalConfigRanking;
|
|
3089
|
+
/** Optional. The number of contexts to retrieve. */
|
|
3090
|
+
topK?: number;
|
|
3091
|
+
}
|
|
3092
|
+
|
|
3093
|
+
/** Config for filters. */
|
|
3094
|
+
export declare interface RagRetrievalConfigFilter {
|
|
3095
|
+
/** Optional. String for metadata filtering. */
|
|
3096
|
+
metadataFilter?: string;
|
|
3097
|
+
/** Optional. Only returns contexts with vector distance smaller than the threshold. */
|
|
3098
|
+
vectorDistanceThreshold?: number;
|
|
3099
|
+
/** Optional. Only returns contexts with vector similarity larger than the threshold. */
|
|
3100
|
+
vectorSimilarityThreshold?: number;
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
/** Config for Hybrid Search. */
|
|
3104
|
+
export declare interface RagRetrievalConfigHybridSearch {
|
|
3105
|
+
/** 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. */
|
|
3106
|
+
alpha?: number;
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
/** Config for ranking and reranking. */
|
|
3110
|
+
export declare interface RagRetrievalConfigRanking {
|
|
3111
|
+
/** Optional. Config for LlmRanker. */
|
|
3112
|
+
llmRanker?: RagRetrievalConfigRankingLlmRanker;
|
|
3113
|
+
/** Optional. Config for Rank Service. */
|
|
3114
|
+
rankService?: RagRetrievalConfigRankingRankService;
|
|
3115
|
+
}
|
|
3116
|
+
|
|
3117
|
+
/** Config for LlmRanker. */
|
|
3118
|
+
export declare interface RagRetrievalConfigRankingLlmRanker {
|
|
3119
|
+
/** Optional. The model name used for ranking. Format: `gemini-1.5-pro` */
|
|
3120
|
+
modelName?: string;
|
|
3121
|
+
}
|
|
3122
|
+
|
|
3123
|
+
/** Config for Rank Service. */
|
|
3124
|
+
export declare interface RagRetrievalConfigRankingRankService {
|
|
3125
|
+
/** Optional. The model name of the rank service. Format: `semantic-ranker-512@latest` */
|
|
3126
|
+
modelName?: string;
|
|
3127
|
+
}
|
|
3128
|
+
|
|
2804
3129
|
/** A raw reference image.
|
|
2805
3130
|
|
|
2806
3131
|
A raw reference image represents the base image to edit, provided by the user.
|
|
@@ -2816,6 +3141,20 @@ export declare interface RawReferenceImage {
|
|
|
2816
3141
|
referenceType?: string;
|
|
2817
3142
|
}
|
|
2818
3143
|
|
|
3144
|
+
/** Marks the end of user activity.
|
|
3145
|
+
|
|
3146
|
+
This can only be sent if automatic (i.e. server-side) activity detection is
|
|
3147
|
+
disabled.
|
|
3148
|
+
*/
|
|
3149
|
+
export declare interface RealtimeInputConfig {
|
|
3150
|
+
/** If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals. */
|
|
3151
|
+
automaticActivityDetection?: AutomaticActivityDetection;
|
|
3152
|
+
/** Defines what effect activity has. */
|
|
3153
|
+
activityHandling?: ActivityHandling;
|
|
3154
|
+
/** Defines which input is included in the user's turn. */
|
|
3155
|
+
turnCoverage?: TurnCoverage;
|
|
3156
|
+
}
|
|
3157
|
+
|
|
2819
3158
|
/** Represents a recorded session. */
|
|
2820
3159
|
export declare interface ReplayFile {
|
|
2821
3160
|
replayId?: string;
|
|
@@ -2873,6 +3212,7 @@ export declare interface SafetyAttributes {
|
|
|
2873
3212
|
contentType?: string;
|
|
2874
3213
|
}
|
|
2875
3214
|
|
|
3215
|
+
/** Enum that controls the safety filter level for objectionable content. */
|
|
2876
3216
|
export declare enum SafetyFilterLevel {
|
|
2877
3217
|
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
2878
3218
|
BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -3108,8 +3448,14 @@ export declare class Session {
|
|
|
3108
3448
|
|
|
3109
3449
|
@example
|
|
3110
3450
|
```ts
|
|
3451
|
+
let model: string;
|
|
3452
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
3453
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
3454
|
+
} else {
|
|
3455
|
+
model = 'gemini-2.0-flash-live-001';
|
|
3456
|
+
}
|
|
3111
3457
|
const session = await ai.live.connect({
|
|
3112
|
-
model:
|
|
3458
|
+
model: model,
|
|
3113
3459
|
config: {
|
|
3114
3460
|
responseModalities: [Modality.AUDIO],
|
|
3115
3461
|
}
|
|
@@ -3121,21 +3467,50 @@ export declare class Session {
|
|
|
3121
3467
|
close(): void;
|
|
3122
3468
|
}
|
|
3123
3469
|
|
|
3124
|
-
|
|
3470
|
+
/** Configuration of session resumption mechanism.
|
|
3471
|
+
|
|
3472
|
+
Included in `LiveConnectConfig.session_resumption`. If included server
|
|
3473
|
+
will send `LiveServerSessionResumptionUpdate` messages.
|
|
3474
|
+
*/
|
|
3475
|
+
export declare interface SessionResumptionConfig {
|
|
3476
|
+
/** Session resumption handle of previous session (session to restore).
|
|
3477
|
+
|
|
3478
|
+
If not present new session will be started. */
|
|
3479
|
+
handle?: string;
|
|
3480
|
+
/** If set the server will send `last_consumed_client_message_index` in the `session_resumption_update` messages to allow for transparent reconnections. */
|
|
3481
|
+
transparent?: boolean;
|
|
3482
|
+
}
|
|
3483
|
+
|
|
3484
|
+
/** Context window will be truncated by keeping only suffix of it.
|
|
3485
|
+
|
|
3486
|
+
Context window will always be cut at start of USER role turn. System
|
|
3487
|
+
instructions and `BidiGenerateContentSetup.prefix_turns` will not be
|
|
3488
|
+
subject to the sliding window mechanism, they will always stay at the
|
|
3489
|
+
beginning of context window.
|
|
3490
|
+
*/
|
|
3491
|
+
export declare interface SlidingWindow {
|
|
3492
|
+
/** 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. */
|
|
3493
|
+
targetTokens?: string;
|
|
3494
|
+
}
|
|
3125
3495
|
|
|
3126
3496
|
/** The speech generation configuration. */
|
|
3127
3497
|
export declare interface SpeechConfig {
|
|
3128
3498
|
/** The configuration for the speaker to use.
|
|
3129
3499
|
*/
|
|
3130
3500
|
voiceConfig?: VoiceConfig;
|
|
3501
|
+
/** Language code (ISO 639. e.g. en-US) for the speech synthesization.
|
|
3502
|
+
Only available for Live API.
|
|
3503
|
+
*/
|
|
3504
|
+
languageCode?: string;
|
|
3131
3505
|
}
|
|
3132
3506
|
|
|
3133
3507
|
export declare type SpeechConfigUnion = SpeechConfig | string;
|
|
3134
3508
|
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3509
|
+
/** Start of speech sensitivity. */
|
|
3510
|
+
export declare enum StartSensitivity {
|
|
3511
|
+
START_SENSITIVITY_UNSPECIFIED = "START_SENSITIVITY_UNSPECIFIED",
|
|
3512
|
+
START_SENSITIVITY_HIGH = "START_SENSITIVITY_HIGH",
|
|
3513
|
+
START_SENSITIVITY_LOW = "START_SENSITIVITY_LOW"
|
|
3139
3514
|
}
|
|
3140
3515
|
|
|
3141
3516
|
/** Configuration for a Style reference image. */
|
|
@@ -3190,6 +3565,7 @@ export declare interface SubjectReferenceImage {
|
|
|
3190
3565
|
config?: SubjectReferenceConfig;
|
|
3191
3566
|
}
|
|
3192
3567
|
|
|
3568
|
+
/** Enum representing the subject type of a subject reference image. */
|
|
3193
3569
|
export declare enum SubjectReferenceType {
|
|
3194
3570
|
SUBJECT_TYPE_DEFAULT = "SUBJECT_TYPE_DEFAULT",
|
|
3195
3571
|
SUBJECT_TYPE_PERSON = "SUBJECT_TYPE_PERSON",
|
|
@@ -3228,6 +3604,9 @@ export declare interface ThinkingConfig {
|
|
|
3228
3604
|
/** Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.
|
|
3229
3605
|
*/
|
|
3230
3606
|
includeThoughts?: boolean;
|
|
3607
|
+
/** Indicates the thinking budget in tokens.
|
|
3608
|
+
*/
|
|
3609
|
+
thinkingBudget?: number;
|
|
3231
3610
|
}
|
|
3232
3611
|
|
|
3233
3612
|
/** Tokens info with a list of tokens and the corresponding list of token ids. */
|
|
@@ -3270,6 +3649,41 @@ export declare interface ToolConfig {
|
|
|
3270
3649
|
|
|
3271
3650
|
export declare type ToolListUnion = Tool[];
|
|
3272
3651
|
|
|
3652
|
+
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
3653
|
+
export declare enum TrafficType {
|
|
3654
|
+
TRAFFIC_TYPE_UNSPECIFIED = "TRAFFIC_TYPE_UNSPECIFIED",
|
|
3655
|
+
ON_DEMAND = "ON_DEMAND",
|
|
3656
|
+
PROVISIONED_THROUGHPUT = "PROVISIONED_THROUGHPUT"
|
|
3657
|
+
}
|
|
3658
|
+
|
|
3659
|
+
/** Audio transcription in Server Conent. */
|
|
3660
|
+
export declare interface Transcription {
|
|
3661
|
+
/** Transcription text.
|
|
3662
|
+
*/
|
|
3663
|
+
text?: string;
|
|
3664
|
+
/** The bool indicates the end of the transcription.
|
|
3665
|
+
*/
|
|
3666
|
+
finished?: boolean;
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
/** A tuned machine learning model. */
|
|
3670
|
+
export declare interface TunedModelInfo {
|
|
3671
|
+
/** ID of the base model that you want to tune. */
|
|
3672
|
+
baseModel?: string;
|
|
3673
|
+
/** Date and time when the base model was created. */
|
|
3674
|
+
createTime?: string;
|
|
3675
|
+
/** Date and time when the base model was last updated. */
|
|
3676
|
+
updateTime?: string;
|
|
3677
|
+
}
|
|
3678
|
+
|
|
3679
|
+
/** Options about which input is included in the user's turn. */
|
|
3680
|
+
export declare enum TurnCoverage {
|
|
3681
|
+
TURN_COVERAGE_UNSPECIFIED = "TURN_COVERAGE_UNSPECIFIED",
|
|
3682
|
+
TURN_INCLUDES_ONLY_ACTIVITY = "TURN_INCLUDES_ONLY_ACTIVITY",
|
|
3683
|
+
TURN_INCLUDES_ALL_INPUT = "TURN_INCLUDES_ALL_INPUT"
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
/** Optional. The type of the data. */
|
|
3273
3687
|
export declare enum Type {
|
|
3274
3688
|
TYPE_UNSPECIFIED = "TYPE_UNSPECIFIED",
|
|
3275
3689
|
STRING = "STRING",
|
|
@@ -3302,11 +3716,12 @@ declare namespace types {
|
|
|
3302
3716
|
HarmProbability,
|
|
3303
3717
|
HarmSeverity,
|
|
3304
3718
|
BlockedReason,
|
|
3719
|
+
TrafficType,
|
|
3305
3720
|
Modality,
|
|
3306
|
-
|
|
3721
|
+
MediaResolution,
|
|
3722
|
+
FeatureSelectionPreference,
|
|
3307
3723
|
DynamicRetrievalConfigMode,
|
|
3308
3724
|
FunctionCallingConfigMode,
|
|
3309
|
-
MediaResolution,
|
|
3310
3725
|
SafetyFilterLevel,
|
|
3311
3726
|
PersonGeneration,
|
|
3312
3727
|
ImagePromptLanguage,
|
|
@@ -3316,6 +3731,10 @@ declare namespace types {
|
|
|
3316
3731
|
ControlReferenceType,
|
|
3317
3732
|
SubjectReferenceType,
|
|
3318
3733
|
MediaModality,
|
|
3734
|
+
StartSensitivity,
|
|
3735
|
+
EndSensitivity,
|
|
3736
|
+
ActivityHandling,
|
|
3737
|
+
TurnCoverage,
|
|
3319
3738
|
VideoMetadata,
|
|
3320
3739
|
CodeExecutionResult,
|
|
3321
3740
|
ExecutableCode,
|
|
@@ -3327,6 +3746,7 @@ declare namespace types {
|
|
|
3327
3746
|
Content,
|
|
3328
3747
|
HttpOptions,
|
|
3329
3748
|
Schema,
|
|
3749
|
+
ModelSelectionConfig,
|
|
3330
3750
|
SafetySetting,
|
|
3331
3751
|
FunctionDeclaration,
|
|
3332
3752
|
GoogleSearch,
|
|
@@ -3334,6 +3754,12 @@ declare namespace types {
|
|
|
3334
3754
|
GoogleSearchRetrieval,
|
|
3335
3755
|
VertexAISearch,
|
|
3336
3756
|
VertexRagStoreRagResource,
|
|
3757
|
+
RagRetrievalConfigFilter,
|
|
3758
|
+
RagRetrievalConfigHybridSearch,
|
|
3759
|
+
RagRetrievalConfigRankingLlmRanker,
|
|
3760
|
+
RagRetrievalConfigRankingRankService,
|
|
3761
|
+
RagRetrievalConfigRanking,
|
|
3762
|
+
RagRetrievalConfig,
|
|
3337
3763
|
VertexRagStore,
|
|
3338
3764
|
Retrieval,
|
|
3339
3765
|
ToolCodeExecution,
|
|
@@ -3381,6 +3807,11 @@ declare namespace types {
|
|
|
3381
3807
|
SafetyAttributes,
|
|
3382
3808
|
GeneratedImage,
|
|
3383
3809
|
GenerateImagesResponse,
|
|
3810
|
+
GetModelConfig,
|
|
3811
|
+
GetModelParameters,
|
|
3812
|
+
Endpoint,
|
|
3813
|
+
TunedModelInfo,
|
|
3814
|
+
Model,
|
|
3384
3815
|
GenerationConfig,
|
|
3385
3816
|
CountTokensConfig,
|
|
3386
3817
|
CountTokensParameters,
|
|
@@ -3418,6 +3849,7 @@ declare namespace types {
|
|
|
3418
3849
|
CreateFileParameters,
|
|
3419
3850
|
HttpResponse,
|
|
3420
3851
|
LiveCallbacks,
|
|
3852
|
+
UploadFileParameters,
|
|
3421
3853
|
CreateFileResponse,
|
|
3422
3854
|
GetFileConfig,
|
|
3423
3855
|
GetFileParameters,
|
|
@@ -3448,12 +3880,24 @@ declare namespace types {
|
|
|
3448
3880
|
SubjectReferenceConfig,
|
|
3449
3881
|
SubjectReferenceImage,
|
|
3450
3882
|
LiveServerSetupComplete,
|
|
3883
|
+
Transcription,
|
|
3451
3884
|
LiveServerContent,
|
|
3452
3885
|
LiveServerToolCall,
|
|
3453
3886
|
LiveServerToolCallCancellation,
|
|
3887
|
+
UsageMetadata,
|
|
3888
|
+
LiveServerGoAway,
|
|
3889
|
+
LiveServerSessionResumptionUpdate,
|
|
3454
3890
|
LiveServerMessage,
|
|
3891
|
+
AutomaticActivityDetection,
|
|
3892
|
+
RealtimeInputConfig,
|
|
3893
|
+
SessionResumptionConfig,
|
|
3894
|
+
SlidingWindow,
|
|
3895
|
+
ContextWindowCompressionConfig,
|
|
3896
|
+
AudioTranscriptionConfig,
|
|
3455
3897
|
LiveClientSetup,
|
|
3456
3898
|
LiveClientContent,
|
|
3899
|
+
ActivityStart,
|
|
3900
|
+
ActivityEnd,
|
|
3457
3901
|
LiveClientRealtimeInput,
|
|
3458
3902
|
LiveClientToolResponse,
|
|
3459
3903
|
LiveClientMessage,
|
|
@@ -3530,9 +3974,9 @@ export declare interface UploadFileConfig {
|
|
|
3530
3974
|
}
|
|
3531
3975
|
|
|
3532
3976
|
/** Parameters for the upload file method. */
|
|
3533
|
-
declare interface UploadFileParameters {
|
|
3977
|
+
export declare interface UploadFileParameters {
|
|
3534
3978
|
/** The string path to the file to be uploaded or a Blob object. */
|
|
3535
|
-
file: string | Blob;
|
|
3979
|
+
file: string | globalThis.Blob;
|
|
3536
3980
|
/** Configuration that contains optional parameters. */
|
|
3537
3981
|
config?: UploadFileConfig;
|
|
3538
3982
|
}
|
|
@@ -3568,6 +4012,33 @@ export declare interface UpscaleImageParameters {
|
|
|
3568
4012
|
config?: UpscaleImageConfig;
|
|
3569
4013
|
}
|
|
3570
4014
|
|
|
4015
|
+
/** Usage metadata about response(s). */
|
|
4016
|
+
export declare interface UsageMetadata {
|
|
4017
|
+
/** 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. */
|
|
4018
|
+
promptTokenCount?: number;
|
|
4019
|
+
/** Number of tokens in the cached part of the prompt (the cached content). */
|
|
4020
|
+
cachedContentTokenCount?: number;
|
|
4021
|
+
/** Total number of tokens across all the generated response candidates. */
|
|
4022
|
+
responseTokenCount?: number;
|
|
4023
|
+
/** Number of tokens present in tool-use prompt(s). */
|
|
4024
|
+
toolUsePromptTokenCount?: number;
|
|
4025
|
+
/** Number of tokens of thoughts for thinking models. */
|
|
4026
|
+
thoughtsTokenCount?: number;
|
|
4027
|
+
/** Total token count for prompt, response candidates, and tool-use prompts(if present). */
|
|
4028
|
+
totalTokenCount?: number;
|
|
4029
|
+
/** List of modalities that were processed in the request input. */
|
|
4030
|
+
promptTokensDetails?: ModalityTokenCount[];
|
|
4031
|
+
/** List of modalities that were processed in the cache input. */
|
|
4032
|
+
cacheTokensDetails?: ModalityTokenCount[];
|
|
4033
|
+
/** List of modalities that were returned in the response. */
|
|
4034
|
+
responseTokensDetails?: ModalityTokenCount[];
|
|
4035
|
+
/** List of modalities that were processed in the tool-use prompt. */
|
|
4036
|
+
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
4037
|
+
/** Traffic type. This shows whether a request consumes Pay-As-You-Go
|
|
4038
|
+
or Provisioned Throughput quota. */
|
|
4039
|
+
trafficType?: TrafficType;
|
|
4040
|
+
}
|
|
4041
|
+
|
|
3571
4042
|
/** Retrieve from Vertex AI Search datastore or engine for grounding. datastore and engine are mutually exclusive. See https://cloud.google.com/products/agent-builder */
|
|
3572
4043
|
export declare interface VertexAISearch {
|
|
3573
4044
|
/** Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}` */
|
|
@@ -3582,6 +4053,8 @@ export declare interface VertexRagStore {
|
|
|
3582
4053
|
ragCorpora?: string[];
|
|
3583
4054
|
/** 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. */
|
|
3584
4055
|
ragResources?: VertexRagStoreRagResource[];
|
|
4056
|
+
/** Optional. The retrieval config for the Rag query. */
|
|
4057
|
+
ragRetrievalConfig?: RagRetrievalConfig;
|
|
3585
4058
|
/** Optional. Number of top k results to return from the selected corpora. */
|
|
3586
4059
|
similarityTopK?: number;
|
|
3587
4060
|
/** Optional. Only return results with vector distance smaller than the threshold. */
|