@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/node/node.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
|
*
|
|
@@ -1818,6 +1911,8 @@ export declare interface GroundingChunkRetrievedContext {
|
|
|
1818
1911
|
|
|
1819
1912
|
/** Chunk from the web. */
|
|
1820
1913
|
export declare interface GroundingChunkWeb {
|
|
1914
|
+
/** Domain of the (original) URI. */
|
|
1915
|
+
domain?: string;
|
|
1821
1916
|
/** Title of the chunk. */
|
|
1822
1917
|
title?: string;
|
|
1823
1918
|
/** URI reference of the chunk. */
|
|
@@ -1850,12 +1945,14 @@ export declare interface GroundingSupport {
|
|
|
1850
1945
|
segment?: Segment;
|
|
1851
1946
|
}
|
|
1852
1947
|
|
|
1948
|
+
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
|
|
1853
1949
|
export declare enum HarmBlockMethod {
|
|
1854
1950
|
HARM_BLOCK_METHOD_UNSPECIFIED = "HARM_BLOCK_METHOD_UNSPECIFIED",
|
|
1855
1951
|
SEVERITY = "SEVERITY",
|
|
1856
1952
|
PROBABILITY = "PROBABILITY"
|
|
1857
1953
|
}
|
|
1858
1954
|
|
|
1955
|
+
/** Required. The harm block threshold. */
|
|
1859
1956
|
export declare enum HarmBlockThreshold {
|
|
1860
1957
|
HARM_BLOCK_THRESHOLD_UNSPECIFIED = "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
1861
1958
|
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
@@ -1865,6 +1962,7 @@ export declare enum HarmBlockThreshold {
|
|
|
1865
1962
|
OFF = "OFF"
|
|
1866
1963
|
}
|
|
1867
1964
|
|
|
1965
|
+
/** Required. Harm category. */
|
|
1868
1966
|
export declare enum HarmCategory {
|
|
1869
1967
|
HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED",
|
|
1870
1968
|
HARM_CATEGORY_HATE_SPEECH = "HARM_CATEGORY_HATE_SPEECH",
|
|
@@ -1874,6 +1972,7 @@ export declare enum HarmCategory {
|
|
|
1874
1972
|
HARM_CATEGORY_CIVIC_INTEGRITY = "HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
1875
1973
|
}
|
|
1876
1974
|
|
|
1975
|
+
/** Output only. Harm probability levels in the content. */
|
|
1877
1976
|
export declare enum HarmProbability {
|
|
1878
1977
|
HARM_PROBABILITY_UNSPECIFIED = "HARM_PROBABILITY_UNSPECIFIED",
|
|
1879
1978
|
NEGLIGIBLE = "NEGLIGIBLE",
|
|
@@ -1882,6 +1981,7 @@ export declare enum HarmProbability {
|
|
|
1882
1981
|
HIGH = "HIGH"
|
|
1883
1982
|
}
|
|
1884
1983
|
|
|
1984
|
+
/** Output only. Harm severity levels in the content. */
|
|
1885
1985
|
export declare enum HarmSeverity {
|
|
1886
1986
|
HARM_SEVERITY_UNSPECIFIED = "HARM_SEVERITY_UNSPECIFIED",
|
|
1887
1987
|
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE",
|
|
@@ -1974,6 +2074,7 @@ declare interface Image_2 {
|
|
|
1974
2074
|
}
|
|
1975
2075
|
export { Image_2 as Image }
|
|
1976
2076
|
|
|
2077
|
+
/** Enum that specifies the language of the text in the prompt. */
|
|
1977
2078
|
export declare enum ImagePromptLanguage {
|
|
1978
2079
|
auto = "auto",
|
|
1979
2080
|
en = "en",
|
|
@@ -1982,6 +2083,7 @@ export declare enum ImagePromptLanguage {
|
|
|
1982
2083
|
hi = "hi"
|
|
1983
2084
|
}
|
|
1984
2085
|
|
|
2086
|
+
/** Required. Programming language of the `code`. */
|
|
1985
2087
|
export declare enum Language {
|
|
1986
2088
|
LANGUAGE_UNSPECIFIED = "LANGUAGE_UNSPECIFIED",
|
|
1987
2089
|
PYTHON = "PYTHON"
|
|
@@ -2049,17 +2151,20 @@ export declare class Live {
|
|
|
2049
2151
|
@experimental
|
|
2050
2152
|
|
|
2051
2153
|
@remarks
|
|
2052
|
-
If using the Gemini API, Live is currently only supported behind API
|
|
2053
|
-
version `v1alpha`. Ensure that the API version is set to `v1alpha` when
|
|
2054
|
-
initializing the SDK if relying on the Gemini API.
|
|
2055
2154
|
|
|
2056
2155
|
@param params - The parameters for establishing a connection to the model.
|
|
2057
2156
|
@return A live session.
|
|
2058
2157
|
|
|
2059
2158
|
@example
|
|
2060
2159
|
```ts
|
|
2160
|
+
let model: string;
|
|
2161
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
2162
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
2163
|
+
} else {
|
|
2164
|
+
model = 'gemini-2.0-flash-live-001';
|
|
2165
|
+
}
|
|
2061
2166
|
const session = await ai.live.connect({
|
|
2062
|
-
model:
|
|
2167
|
+
model: model,
|
|
2063
2168
|
config: {
|
|
2064
2169
|
responseModalities: [Modality.AUDIO],
|
|
2065
2170
|
},
|
|
@@ -2085,9 +2190,21 @@ export declare class Live {
|
|
|
2085
2190
|
|
|
2086
2191
|
/** Callbacks for the live API. */
|
|
2087
2192
|
export declare interface LiveCallbacks {
|
|
2193
|
+
/**
|
|
2194
|
+
* Called when the websocket connection is established.
|
|
2195
|
+
*/
|
|
2088
2196
|
onopen?: (() => void) | null;
|
|
2197
|
+
/**
|
|
2198
|
+
* Called when a message is received from the server.
|
|
2199
|
+
*/
|
|
2089
2200
|
onmessage: (e: LiveServerMessage) => void;
|
|
2201
|
+
/**
|
|
2202
|
+
* Called when an error occurs.
|
|
2203
|
+
*/
|
|
2090
2204
|
onerror?: ((e: ErrorEvent) => void) | null;
|
|
2205
|
+
/**
|
|
2206
|
+
* Called when the websocket connection is closed.
|
|
2207
|
+
*/
|
|
2091
2208
|
onclose?: ((e: CloseEvent) => void) | null;
|
|
2092
2209
|
}
|
|
2093
2210
|
|
|
@@ -2126,11 +2243,11 @@ export declare interface LiveClientMessage {
|
|
|
2126
2243
|
|
|
2127
2244
|
/** User input that is sent in real time.
|
|
2128
2245
|
|
|
2129
|
-
This is different from `
|
|
2246
|
+
This is different from `LiveClientContent` in a few ways:
|
|
2130
2247
|
|
|
2131
2248
|
- Can be sent continuously without interruption to model generation.
|
|
2132
2249
|
- If there is a need to mix data interleaved across the
|
|
2133
|
-
`
|
|
2250
|
+
`LiveClientContent` and the `LiveClientRealtimeInput`, server attempts to
|
|
2134
2251
|
optimize for best response, but there are no guarantees.
|
|
2135
2252
|
- End of turn is not explicitly specified, but is rather derived from user
|
|
2136
2253
|
activity (for example, end of speech).
|
|
@@ -2142,6 +2259,10 @@ export declare interface LiveClientMessage {
|
|
|
2142
2259
|
export declare interface LiveClientRealtimeInput {
|
|
2143
2260
|
/** Inlined bytes data for media input. */
|
|
2144
2261
|
mediaChunks?: Blob_2[];
|
|
2262
|
+
/** Marks the start of user activity. */
|
|
2263
|
+
activityStart?: ActivityStart;
|
|
2264
|
+
/** Marks the end of user activity. */
|
|
2265
|
+
activityEnd?: ActivityEnd;
|
|
2145
2266
|
}
|
|
2146
2267
|
|
|
2147
2268
|
/** Message contains configuration that will apply for the duration of the streaming session. */
|
|
@@ -2152,27 +2273,36 @@ export declare interface LiveClientSetup {
|
|
|
2152
2273
|
*/
|
|
2153
2274
|
model?: string;
|
|
2154
2275
|
/** The generation configuration for the session.
|
|
2155
|
-
|
|
2156
|
-
The following fields are supported:
|
|
2157
|
-
- `response_logprobs`
|
|
2158
|
-
- `response_mime_type`
|
|
2159
|
-
- `logprobs`
|
|
2160
|
-
- `response_schema`
|
|
2161
|
-
- `stop_sequence`
|
|
2162
|
-
- `routing_config`
|
|
2163
|
-
- `audio_timestamp`
|
|
2276
|
+
Note: only a subset of fields are supported.
|
|
2164
2277
|
*/
|
|
2165
2278
|
generationConfig?: GenerationConfig;
|
|
2166
2279
|
/** The user provided system instructions for the model.
|
|
2167
2280
|
Note: only text should be used in parts and content in each part will be
|
|
2168
2281
|
in a separate paragraph. */
|
|
2169
|
-
systemInstruction?:
|
|
2282
|
+
systemInstruction?: ContentUnion;
|
|
2170
2283
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2171
2284
|
|
|
2172
2285
|
A `Tool` is a piece of code that enables the system to interact with
|
|
2173
2286
|
external systems to perform an action, or set of actions, outside of
|
|
2174
2287
|
knowledge and scope of the model. */
|
|
2175
2288
|
tools?: ToolListUnion;
|
|
2289
|
+
/** Configures the realtime input behavior in BidiGenerateContent. */
|
|
2290
|
+
realtimeInputConfig?: RealtimeInputConfig;
|
|
2291
|
+
/** Configures session resumption mechanism.
|
|
2292
|
+
|
|
2293
|
+
If included server will send SessionResumptionUpdate messages. */
|
|
2294
|
+
sessionResumption?: SessionResumptionConfig;
|
|
2295
|
+
/** Configures context window compression mechanism.
|
|
2296
|
+
|
|
2297
|
+
If included, server will compress context window to fit into given length. */
|
|
2298
|
+
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2299
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2300
|
+
*/
|
|
2301
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2302
|
+
/** The transcription of the output aligns with the language code
|
|
2303
|
+
specified for the output audio.
|
|
2304
|
+
*/
|
|
2305
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2176
2306
|
}
|
|
2177
2307
|
|
|
2178
2308
|
/** Client generated response to a `ToolCall` received from the server.
|
|
@@ -2198,19 +2328,65 @@ export declare interface LiveConnectConfig {
|
|
|
2198
2328
|
modalities that the model can return. Defaults to AUDIO if not specified.
|
|
2199
2329
|
*/
|
|
2200
2330
|
responseModalities?: Modality[];
|
|
2331
|
+
/** Value that controls the degree of randomness in token selection.
|
|
2332
|
+
Lower temperatures are good for prompts that require a less open-ended or
|
|
2333
|
+
creative response, while higher temperatures can lead to more diverse or
|
|
2334
|
+
creative results.
|
|
2335
|
+
*/
|
|
2336
|
+
temperature?: number;
|
|
2337
|
+
/** Tokens are selected from the most to least probable until the sum
|
|
2338
|
+
of their probabilities equals this value. Use a lower value for less
|
|
2339
|
+
random responses and a higher value for more random responses.
|
|
2340
|
+
*/
|
|
2341
|
+
topP?: number;
|
|
2342
|
+
/** For each token selection step, the ``top_k`` tokens with the
|
|
2343
|
+
highest probabilities are sampled. Then tokens are further filtered based
|
|
2344
|
+
on ``top_p`` with the final token selected using temperature sampling. Use
|
|
2345
|
+
a lower number for less random responses and a higher number for more
|
|
2346
|
+
random responses.
|
|
2347
|
+
*/
|
|
2348
|
+
topK?: number;
|
|
2349
|
+
/** Maximum number of tokens that can be generated in the response.
|
|
2350
|
+
*/
|
|
2351
|
+
maxOutputTokens?: number;
|
|
2352
|
+
/** If specified, the media resolution specified will be used.
|
|
2353
|
+
*/
|
|
2354
|
+
mediaResolution?: MediaResolution;
|
|
2355
|
+
/** When ``seed`` is fixed to a specific number, the model makes a best
|
|
2356
|
+
effort to provide the same response for repeated requests. By default, a
|
|
2357
|
+
random number is used.
|
|
2358
|
+
*/
|
|
2359
|
+
seed?: number;
|
|
2201
2360
|
/** The speech generation configuration.
|
|
2202
2361
|
*/
|
|
2203
2362
|
speechConfig?: SpeechConfig;
|
|
2204
2363
|
/** The user provided system instructions for the model.
|
|
2205
2364
|
Note: only text should be used in parts and content in each part will be
|
|
2206
2365
|
in a separate paragraph. */
|
|
2207
|
-
systemInstruction?:
|
|
2366
|
+
systemInstruction?: ContentUnion;
|
|
2208
2367
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2209
2368
|
|
|
2210
2369
|
A `Tool` is a piece of code that enables the system to interact with
|
|
2211
2370
|
external systems to perform an action, or set of actions, outside of
|
|
2212
2371
|
knowledge and scope of the model. */
|
|
2213
2372
|
tools?: ToolListUnion;
|
|
2373
|
+
/** Configures session resumption mechanism.
|
|
2374
|
+
|
|
2375
|
+
If included the server will send SessionResumptionUpdate messages. */
|
|
2376
|
+
sessionResumption?: SessionResumptionConfig;
|
|
2377
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2378
|
+
*/
|
|
2379
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2380
|
+
/** The transcription of the output aligns with the language code
|
|
2381
|
+
specified for the output audio.
|
|
2382
|
+
*/
|
|
2383
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2384
|
+
/** Configures the realtime input behavior in BidiGenerateContent. */
|
|
2385
|
+
realtimeInputConfig?: RealtimeInputConfig;
|
|
2386
|
+
/** Configures context window compression mechanism.
|
|
2387
|
+
|
|
2388
|
+
If included, server will compress context window to fit into given length. */
|
|
2389
|
+
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2214
2390
|
}
|
|
2215
2391
|
|
|
2216
2392
|
/** Parameters for connecting to the live API. */
|
|
@@ -2239,6 +2415,10 @@ export declare interface LiveSendClientContentParameters {
|
|
|
2239
2415
|
export declare interface LiveSendRealtimeInputParameters {
|
|
2240
2416
|
/** Realtime input to send to the session. */
|
|
2241
2417
|
media: Blob_2;
|
|
2418
|
+
/** Marks the start of user activity. */
|
|
2419
|
+
activityStart?: ActivityStart;
|
|
2420
|
+
/** Marks the end of user activity. */
|
|
2421
|
+
activityEnd?: ActivityEnd;
|
|
2242
2422
|
}
|
|
2243
2423
|
|
|
2244
2424
|
/** Parameters for sending tool responses to the live API. */
|
|
@@ -2259,6 +2439,30 @@ export declare interface LiveServerContent {
|
|
|
2259
2439
|
turnComplete?: boolean;
|
|
2260
2440
|
/** 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. */
|
|
2261
2441
|
interrupted?: boolean;
|
|
2442
|
+
/** If true, indicates that the model is done generating. When model is
|
|
2443
|
+
interrupted while generating there will be no generation_complete message
|
|
2444
|
+
in interrupted turn, it will go through interrupted > turn_complete.
|
|
2445
|
+
When model assumes realtime playback there will be delay between
|
|
2446
|
+
generation_complete and turn_complete that is caused by model
|
|
2447
|
+
waiting for playback to finish. If true, indicates that the model
|
|
2448
|
+
has finished generating all content. This is a signal to the client
|
|
2449
|
+
that it can stop sending messages. */
|
|
2450
|
+
generationComplete?: boolean;
|
|
2451
|
+
/** Input transcription. The transcription is independent to the model
|
|
2452
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2453
|
+
model turn. */
|
|
2454
|
+
inputTranscription?: Transcription;
|
|
2455
|
+
/** Output transcription. The transcription is independent to the model
|
|
2456
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2457
|
+
model turn.
|
|
2458
|
+
*/
|
|
2459
|
+
outputTranscription?: Transcription;
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
/** Server will not be able to service client soon. */
|
|
2463
|
+
export declare interface LiveServerGoAway {
|
|
2464
|
+
/** 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. */
|
|
2465
|
+
timeLeft?: string;
|
|
2262
2466
|
}
|
|
2263
2467
|
|
|
2264
2468
|
/** Response message for API call. */
|
|
@@ -2271,6 +2475,29 @@ export declare interface LiveServerMessage {
|
|
|
2271
2475
|
toolCall?: LiveServerToolCall;
|
|
2272
2476
|
/** Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled. */
|
|
2273
2477
|
toolCallCancellation?: LiveServerToolCallCancellation;
|
|
2478
|
+
/** Usage metadata about model response(s). */
|
|
2479
|
+
usageMetadata?: UsageMetadata;
|
|
2480
|
+
/** Server will disconnect soon. */
|
|
2481
|
+
goAway?: LiveServerGoAway;
|
|
2482
|
+
/** Update of the session resumption state. */
|
|
2483
|
+
sessionResumptionUpdate?: LiveServerSessionResumptionUpdate;
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
/** Update of the session resumption state.
|
|
2487
|
+
|
|
2488
|
+
Only sent if `session_resumption` was set in the connection config.
|
|
2489
|
+
*/
|
|
2490
|
+
export declare interface LiveServerSessionResumptionUpdate {
|
|
2491
|
+
/** New handle that represents state that can be resumed. Empty if `resumable`=false. */
|
|
2492
|
+
newHandle?: string;
|
|
2493
|
+
/** 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. */
|
|
2494
|
+
resumable?: boolean;
|
|
2495
|
+
/** Index of last message sent by client that is included in state represented by this SessionResumptionToken. Only sent when `SessionResumptionConfig.transparent` is set.
|
|
2496
|
+
|
|
2497
|
+
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).
|
|
2498
|
+
|
|
2499
|
+
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. */
|
|
2500
|
+
lastConsumedClientMessageIndex?: string;
|
|
2274
2501
|
}
|
|
2275
2502
|
|
|
2276
2503
|
/** Sent in response to a `LiveGenerateContentSetup` message from the client. */
|
|
@@ -2352,6 +2579,7 @@ export declare interface MaskReferenceImage {
|
|
|
2352
2579
|
config?: MaskReferenceConfig;
|
|
2353
2580
|
}
|
|
2354
2581
|
|
|
2582
|
+
/** Enum representing the mask mode of a mask reference image. */
|
|
2355
2583
|
export declare enum MaskReferenceMode {
|
|
2356
2584
|
MASK_MODE_DEFAULT = "MASK_MODE_DEFAULT",
|
|
2357
2585
|
MASK_MODE_USER_PROVIDED = "MASK_MODE_USER_PROVIDED",
|
|
@@ -2360,6 +2588,7 @@ export declare enum MaskReferenceMode {
|
|
|
2360
2588
|
MASK_MODE_SEMANTIC = "MASK_MODE_SEMANTIC"
|
|
2361
2589
|
}
|
|
2362
2590
|
|
|
2591
|
+
/** Server content modalities. */
|
|
2363
2592
|
export declare enum MediaModality {
|
|
2364
2593
|
MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED",
|
|
2365
2594
|
TEXT = "TEXT",
|
|
@@ -2369,6 +2598,7 @@ export declare enum MediaModality {
|
|
|
2369
2598
|
DOCUMENT = "DOCUMENT"
|
|
2370
2599
|
}
|
|
2371
2600
|
|
|
2601
|
+
/** The media resolution to use. */
|
|
2372
2602
|
export declare enum MediaResolution {
|
|
2373
2603
|
MEDIA_RESOLUTION_UNSPECIFIED = "MEDIA_RESOLUTION_UNSPECIFIED",
|
|
2374
2604
|
MEDIA_RESOLUTION_LOW = "MEDIA_RESOLUTION_LOW",
|
|
@@ -2376,6 +2606,7 @@ export declare enum MediaResolution {
|
|
|
2376
2606
|
MEDIA_RESOLUTION_HIGH = "MEDIA_RESOLUTION_HIGH"
|
|
2377
2607
|
}
|
|
2378
2608
|
|
|
2609
|
+
/** Server content modalities. */
|
|
2379
2610
|
export declare enum Modality {
|
|
2380
2611
|
MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED",
|
|
2381
2612
|
TEXT = "TEXT",
|
|
@@ -2391,11 +2622,40 @@ export declare interface ModalityTokenCount {
|
|
|
2391
2622
|
tokenCount?: number;
|
|
2392
2623
|
}
|
|
2393
2624
|
|
|
2625
|
+
/** The mode of the predictor to be used in dynamic retrieval. */
|
|
2394
2626
|
export declare enum Mode {
|
|
2395
2627
|
MODE_UNSPECIFIED = "MODE_UNSPECIFIED",
|
|
2396
2628
|
MODE_DYNAMIC = "MODE_DYNAMIC"
|
|
2397
2629
|
}
|
|
2398
2630
|
|
|
2631
|
+
/** A trained machine learning model. */
|
|
2632
|
+
export declare interface Model {
|
|
2633
|
+
/** Resource name of the model. */
|
|
2634
|
+
name?: string;
|
|
2635
|
+
/** Display name of the model. */
|
|
2636
|
+
displayName?: string;
|
|
2637
|
+
/** Description of the model. */
|
|
2638
|
+
description?: string;
|
|
2639
|
+
/** Version ID of the model. A new version is committed when a new
|
|
2640
|
+
model version is uploaded or trained under an existing model ID. The
|
|
2641
|
+
version ID is an auto-incrementing decimal number in string
|
|
2642
|
+
representation. */
|
|
2643
|
+
version?: string;
|
|
2644
|
+
/** List of deployed models created from this base model. Note that a
|
|
2645
|
+
model could have been deployed to endpoints in different locations. */
|
|
2646
|
+
endpoints?: Endpoint[];
|
|
2647
|
+
/** Labels with user-defined metadata to organize your models. */
|
|
2648
|
+
labels?: Record<string, string>;
|
|
2649
|
+
/** Information about the tuned model from the base model. */
|
|
2650
|
+
tunedModelInfo?: TunedModelInfo;
|
|
2651
|
+
/** The maximum number of input tokens that the model can handle. */
|
|
2652
|
+
inputTokenLimit?: number;
|
|
2653
|
+
/** The maximum number of output tokens that the model can generate. */
|
|
2654
|
+
outputTokenLimit?: number;
|
|
2655
|
+
/** List of actions that are supported by the model. */
|
|
2656
|
+
supportedActions?: string[];
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2399
2659
|
export declare class Models extends BaseModule {
|
|
2400
2660
|
private readonly apiClient;
|
|
2401
2661
|
constructor(apiClient: ApiClient);
|
|
@@ -2546,6 +2806,15 @@ export declare class Models extends BaseModule {
|
|
|
2546
2806
|
* ```
|
|
2547
2807
|
*/
|
|
2548
2808
|
private generateImagesInternal;
|
|
2809
|
+
/**
|
|
2810
|
+
* Fetches information about a model by name.
|
|
2811
|
+
*
|
|
2812
|
+
* @example
|
|
2813
|
+
* ```ts
|
|
2814
|
+
* const modelInfo = await ai.models.get({model: 'gemini-2.0-flash'});
|
|
2815
|
+
* ```
|
|
2816
|
+
*/
|
|
2817
|
+
get(params: types.GetModelParameters): Promise<types.Model>;
|
|
2549
2818
|
/**
|
|
2550
2819
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
2551
2820
|
* supported for Gemini models.
|
|
@@ -2599,15 +2868,21 @@ export declare class Models extends BaseModule {
|
|
|
2599
2868
|
*
|
|
2600
2869
|
* while (!operation.done) {
|
|
2601
2870
|
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
2602
|
-
* operation = await ai.operations.
|
|
2871
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
2603
2872
|
* }
|
|
2604
2873
|
*
|
|
2605
|
-
* console.log(operation.
|
|
2874
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
2606
2875
|
* ```
|
|
2607
2876
|
*/
|
|
2608
2877
|
generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
|
|
2609
2878
|
}
|
|
2610
2879
|
|
|
2880
|
+
/** Config for model selection. */
|
|
2881
|
+
export declare interface ModelSelectionConfig {
|
|
2882
|
+
/** Options for feature selection preference. */
|
|
2883
|
+
featureSelectionPreference?: FeatureSelectionPreference;
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2611
2886
|
/** Parameters for the get method of the operations module. */
|
|
2612
2887
|
export declare interface OperationGetParameters {
|
|
2613
2888
|
/** The operation to be retrieved. */
|
|
@@ -2622,10 +2897,10 @@ export declare class Operations extends BaseModule {
|
|
|
2622
2897
|
/**
|
|
2623
2898
|
* Gets the status of a long-running operation.
|
|
2624
2899
|
*
|
|
2625
|
-
* @param
|
|
2900
|
+
* @param parameters The parameters for the get operation request.
|
|
2626
2901
|
* @return The updated Operation object, with the latest status or result.
|
|
2627
2902
|
*/
|
|
2628
|
-
|
|
2903
|
+
getVideosOperation(parameters: types.OperationGetParameters): Promise<types.GenerateVideosOperation>;
|
|
2629
2904
|
private getVideosOperationInternal;
|
|
2630
2905
|
private fetchPredictVideosOperationInternal;
|
|
2631
2906
|
}
|
|
@@ -2635,6 +2910,7 @@ export declare class Operations extends BaseModule {
|
|
|
2635
2910
|
* Copyright 2025 Google LLC
|
|
2636
2911
|
* SPDX-License-Identifier: Apache-2.0
|
|
2637
2912
|
*/
|
|
2913
|
+
/** Required. Outcome of the code execution. */
|
|
2638
2914
|
export declare enum Outcome {
|
|
2639
2915
|
OUTCOME_UNSPECIFIED = "OUTCOME_UNSPECIFIED",
|
|
2640
2916
|
OUTCOME_OK = "OUTCOME_OK",
|
|
@@ -2800,6 +3076,7 @@ export declare type PartListUnion = PartUnion[] | PartUnion;
|
|
|
2800
3076
|
|
|
2801
3077
|
export declare type PartUnion = Part | string;
|
|
2802
3078
|
|
|
3079
|
+
/** Enum that controls the generation of people. */
|
|
2803
3080
|
export declare enum PersonGeneration {
|
|
2804
3081
|
DONT_ALLOW = "DONT_ALLOW",
|
|
2805
3082
|
ALLOW_ADULT = "ALLOW_ADULT",
|
|
@@ -2813,6 +3090,54 @@ export declare interface PrebuiltVoiceConfig {
|
|
|
2813
3090
|
voiceName?: string;
|
|
2814
3091
|
}
|
|
2815
3092
|
|
|
3093
|
+
/** Specifies the context retrieval config. */
|
|
3094
|
+
export declare interface RagRetrievalConfig {
|
|
3095
|
+
/** Optional. Config for filters. */
|
|
3096
|
+
filter?: RagRetrievalConfigFilter;
|
|
3097
|
+
/** Optional. Config for Hybrid Search. */
|
|
3098
|
+
hybridSearch?: RagRetrievalConfigHybridSearch;
|
|
3099
|
+
/** Optional. Config for ranking and reranking. */
|
|
3100
|
+
ranking?: RagRetrievalConfigRanking;
|
|
3101
|
+
/** Optional. The number of contexts to retrieve. */
|
|
3102
|
+
topK?: number;
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
/** Config for filters. */
|
|
3106
|
+
export declare interface RagRetrievalConfigFilter {
|
|
3107
|
+
/** Optional. String for metadata filtering. */
|
|
3108
|
+
metadataFilter?: string;
|
|
3109
|
+
/** Optional. Only returns contexts with vector distance smaller than the threshold. */
|
|
3110
|
+
vectorDistanceThreshold?: number;
|
|
3111
|
+
/** Optional. Only returns contexts with vector similarity larger than the threshold. */
|
|
3112
|
+
vectorSimilarityThreshold?: number;
|
|
3113
|
+
}
|
|
3114
|
+
|
|
3115
|
+
/** Config for Hybrid Search. */
|
|
3116
|
+
export declare interface RagRetrievalConfigHybridSearch {
|
|
3117
|
+
/** 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. */
|
|
3118
|
+
alpha?: number;
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
/** Config for ranking and reranking. */
|
|
3122
|
+
export declare interface RagRetrievalConfigRanking {
|
|
3123
|
+
/** Optional. Config for LlmRanker. */
|
|
3124
|
+
llmRanker?: RagRetrievalConfigRankingLlmRanker;
|
|
3125
|
+
/** Optional. Config for Rank Service. */
|
|
3126
|
+
rankService?: RagRetrievalConfigRankingRankService;
|
|
3127
|
+
}
|
|
3128
|
+
|
|
3129
|
+
/** Config for LlmRanker. */
|
|
3130
|
+
export declare interface RagRetrievalConfigRankingLlmRanker {
|
|
3131
|
+
/** Optional. The model name used for ranking. Format: `gemini-1.5-pro` */
|
|
3132
|
+
modelName?: string;
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
/** Config for Rank Service. */
|
|
3136
|
+
export declare interface RagRetrievalConfigRankingRankService {
|
|
3137
|
+
/** Optional. The model name of the rank service. Format: `semantic-ranker-512@latest` */
|
|
3138
|
+
modelName?: string;
|
|
3139
|
+
}
|
|
3140
|
+
|
|
2816
3141
|
/** A raw reference image.
|
|
2817
3142
|
|
|
2818
3143
|
A raw reference image represents the base image to edit, provided by the user.
|
|
@@ -2828,6 +3153,20 @@ export declare interface RawReferenceImage {
|
|
|
2828
3153
|
referenceType?: string;
|
|
2829
3154
|
}
|
|
2830
3155
|
|
|
3156
|
+
/** Marks the end of user activity.
|
|
3157
|
+
|
|
3158
|
+
This can only be sent if automatic (i.e. server-side) activity detection is
|
|
3159
|
+
disabled.
|
|
3160
|
+
*/
|
|
3161
|
+
export declare interface RealtimeInputConfig {
|
|
3162
|
+
/** If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals. */
|
|
3163
|
+
automaticActivityDetection?: AutomaticActivityDetection;
|
|
3164
|
+
/** Defines what effect activity has. */
|
|
3165
|
+
activityHandling?: ActivityHandling;
|
|
3166
|
+
/** Defines which input is included in the user's turn. */
|
|
3167
|
+
turnCoverage?: TurnCoverage;
|
|
3168
|
+
}
|
|
3169
|
+
|
|
2831
3170
|
/** Represents a recorded session. */
|
|
2832
3171
|
export declare interface ReplayFile {
|
|
2833
3172
|
replayId?: string;
|
|
@@ -2885,6 +3224,7 @@ export declare interface SafetyAttributes {
|
|
|
2885
3224
|
contentType?: string;
|
|
2886
3225
|
}
|
|
2887
3226
|
|
|
3227
|
+
/** Enum that controls the safety filter level for objectionable content. */
|
|
2888
3228
|
export declare enum SafetyFilterLevel {
|
|
2889
3229
|
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
2890
3230
|
BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -3120,8 +3460,14 @@ export declare class Session {
|
|
|
3120
3460
|
|
|
3121
3461
|
@example
|
|
3122
3462
|
```ts
|
|
3463
|
+
let model: string;
|
|
3464
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
3465
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
3466
|
+
} else {
|
|
3467
|
+
model = 'gemini-2.0-flash-live-001';
|
|
3468
|
+
}
|
|
3123
3469
|
const session = await ai.live.connect({
|
|
3124
|
-
model:
|
|
3470
|
+
model: model,
|
|
3125
3471
|
config: {
|
|
3126
3472
|
responseModalities: [Modality.AUDIO],
|
|
3127
3473
|
}
|
|
@@ -3133,21 +3479,50 @@ export declare class Session {
|
|
|
3133
3479
|
close(): void;
|
|
3134
3480
|
}
|
|
3135
3481
|
|
|
3136
|
-
|
|
3482
|
+
/** Configuration of session resumption mechanism.
|
|
3483
|
+
|
|
3484
|
+
Included in `LiveConnectConfig.session_resumption`. If included server
|
|
3485
|
+
will send `LiveServerSessionResumptionUpdate` messages.
|
|
3486
|
+
*/
|
|
3487
|
+
export declare interface SessionResumptionConfig {
|
|
3488
|
+
/** Session resumption handle of previous session (session to restore).
|
|
3489
|
+
|
|
3490
|
+
If not present new session will be started. */
|
|
3491
|
+
handle?: string;
|
|
3492
|
+
/** If set the server will send `last_consumed_client_message_index` in the `session_resumption_update` messages to allow for transparent reconnections. */
|
|
3493
|
+
transparent?: boolean;
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
/** Context window will be truncated by keeping only suffix of it.
|
|
3497
|
+
|
|
3498
|
+
Context window will always be cut at start of USER role turn. System
|
|
3499
|
+
instructions and `BidiGenerateContentSetup.prefix_turns` will not be
|
|
3500
|
+
subject to the sliding window mechanism, they will always stay at the
|
|
3501
|
+
beginning of context window.
|
|
3502
|
+
*/
|
|
3503
|
+
export declare interface SlidingWindow {
|
|
3504
|
+
/** 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. */
|
|
3505
|
+
targetTokens?: string;
|
|
3506
|
+
}
|
|
3137
3507
|
|
|
3138
3508
|
/** The speech generation configuration. */
|
|
3139
3509
|
export declare interface SpeechConfig {
|
|
3140
3510
|
/** The configuration for the speaker to use.
|
|
3141
3511
|
*/
|
|
3142
3512
|
voiceConfig?: VoiceConfig;
|
|
3513
|
+
/** Language code (ISO 639. e.g. en-US) for the speech synthesization.
|
|
3514
|
+
Only available for Live API.
|
|
3515
|
+
*/
|
|
3516
|
+
languageCode?: string;
|
|
3143
3517
|
}
|
|
3144
3518
|
|
|
3145
3519
|
export declare type SpeechConfigUnion = SpeechConfig | string;
|
|
3146
3520
|
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3521
|
+
/** Start of speech sensitivity. */
|
|
3522
|
+
export declare enum StartSensitivity {
|
|
3523
|
+
START_SENSITIVITY_UNSPECIFIED = "START_SENSITIVITY_UNSPECIFIED",
|
|
3524
|
+
START_SENSITIVITY_HIGH = "START_SENSITIVITY_HIGH",
|
|
3525
|
+
START_SENSITIVITY_LOW = "START_SENSITIVITY_LOW"
|
|
3151
3526
|
}
|
|
3152
3527
|
|
|
3153
3528
|
/** Configuration for a Style reference image. */
|
|
@@ -3202,6 +3577,7 @@ export declare interface SubjectReferenceImage {
|
|
|
3202
3577
|
config?: SubjectReferenceConfig;
|
|
3203
3578
|
}
|
|
3204
3579
|
|
|
3580
|
+
/** Enum representing the subject type of a subject reference image. */
|
|
3205
3581
|
export declare enum SubjectReferenceType {
|
|
3206
3582
|
SUBJECT_TYPE_DEFAULT = "SUBJECT_TYPE_DEFAULT",
|
|
3207
3583
|
SUBJECT_TYPE_PERSON = "SUBJECT_TYPE_PERSON",
|
|
@@ -3240,6 +3616,9 @@ export declare interface ThinkingConfig {
|
|
|
3240
3616
|
/** Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.
|
|
3241
3617
|
*/
|
|
3242
3618
|
includeThoughts?: boolean;
|
|
3619
|
+
/** Indicates the thinking budget in tokens.
|
|
3620
|
+
*/
|
|
3621
|
+
thinkingBudget?: number;
|
|
3243
3622
|
}
|
|
3244
3623
|
|
|
3245
3624
|
/** Tokens info with a list of tokens and the corresponding list of token ids. */
|
|
@@ -3282,6 +3661,41 @@ export declare interface ToolConfig {
|
|
|
3282
3661
|
|
|
3283
3662
|
export declare type ToolListUnion = Tool[];
|
|
3284
3663
|
|
|
3664
|
+
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
3665
|
+
export declare enum TrafficType {
|
|
3666
|
+
TRAFFIC_TYPE_UNSPECIFIED = "TRAFFIC_TYPE_UNSPECIFIED",
|
|
3667
|
+
ON_DEMAND = "ON_DEMAND",
|
|
3668
|
+
PROVISIONED_THROUGHPUT = "PROVISIONED_THROUGHPUT"
|
|
3669
|
+
}
|
|
3670
|
+
|
|
3671
|
+
/** Audio transcription in Server Conent. */
|
|
3672
|
+
export declare interface Transcription {
|
|
3673
|
+
/** Transcription text.
|
|
3674
|
+
*/
|
|
3675
|
+
text?: string;
|
|
3676
|
+
/** The bool indicates the end of the transcription.
|
|
3677
|
+
*/
|
|
3678
|
+
finished?: boolean;
|
|
3679
|
+
}
|
|
3680
|
+
|
|
3681
|
+
/** A tuned machine learning model. */
|
|
3682
|
+
export declare interface TunedModelInfo {
|
|
3683
|
+
/** ID of the base model that you want to tune. */
|
|
3684
|
+
baseModel?: string;
|
|
3685
|
+
/** Date and time when the base model was created. */
|
|
3686
|
+
createTime?: string;
|
|
3687
|
+
/** Date and time when the base model was last updated. */
|
|
3688
|
+
updateTime?: string;
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3691
|
+
/** Options about which input is included in the user's turn. */
|
|
3692
|
+
export declare enum TurnCoverage {
|
|
3693
|
+
TURN_COVERAGE_UNSPECIFIED = "TURN_COVERAGE_UNSPECIFIED",
|
|
3694
|
+
TURN_INCLUDES_ONLY_ACTIVITY = "TURN_INCLUDES_ONLY_ACTIVITY",
|
|
3695
|
+
TURN_INCLUDES_ALL_INPUT = "TURN_INCLUDES_ALL_INPUT"
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
/** Optional. The type of the data. */
|
|
3285
3699
|
export declare enum Type {
|
|
3286
3700
|
TYPE_UNSPECIFIED = "TYPE_UNSPECIFIED",
|
|
3287
3701
|
STRING = "STRING",
|
|
@@ -3314,11 +3728,12 @@ declare namespace types {
|
|
|
3314
3728
|
HarmProbability,
|
|
3315
3729
|
HarmSeverity,
|
|
3316
3730
|
BlockedReason,
|
|
3731
|
+
TrafficType,
|
|
3317
3732
|
Modality,
|
|
3318
|
-
|
|
3733
|
+
MediaResolution,
|
|
3734
|
+
FeatureSelectionPreference,
|
|
3319
3735
|
DynamicRetrievalConfigMode,
|
|
3320
3736
|
FunctionCallingConfigMode,
|
|
3321
|
-
MediaResolution,
|
|
3322
3737
|
SafetyFilterLevel,
|
|
3323
3738
|
PersonGeneration,
|
|
3324
3739
|
ImagePromptLanguage,
|
|
@@ -3328,6 +3743,10 @@ declare namespace types {
|
|
|
3328
3743
|
ControlReferenceType,
|
|
3329
3744
|
SubjectReferenceType,
|
|
3330
3745
|
MediaModality,
|
|
3746
|
+
StartSensitivity,
|
|
3747
|
+
EndSensitivity,
|
|
3748
|
+
ActivityHandling,
|
|
3749
|
+
TurnCoverage,
|
|
3331
3750
|
VideoMetadata,
|
|
3332
3751
|
CodeExecutionResult,
|
|
3333
3752
|
ExecutableCode,
|
|
@@ -3339,6 +3758,7 @@ declare namespace types {
|
|
|
3339
3758
|
Content,
|
|
3340
3759
|
HttpOptions,
|
|
3341
3760
|
Schema,
|
|
3761
|
+
ModelSelectionConfig,
|
|
3342
3762
|
SafetySetting,
|
|
3343
3763
|
FunctionDeclaration,
|
|
3344
3764
|
GoogleSearch,
|
|
@@ -3346,6 +3766,12 @@ declare namespace types {
|
|
|
3346
3766
|
GoogleSearchRetrieval,
|
|
3347
3767
|
VertexAISearch,
|
|
3348
3768
|
VertexRagStoreRagResource,
|
|
3769
|
+
RagRetrievalConfigFilter,
|
|
3770
|
+
RagRetrievalConfigHybridSearch,
|
|
3771
|
+
RagRetrievalConfigRankingLlmRanker,
|
|
3772
|
+
RagRetrievalConfigRankingRankService,
|
|
3773
|
+
RagRetrievalConfigRanking,
|
|
3774
|
+
RagRetrievalConfig,
|
|
3349
3775
|
VertexRagStore,
|
|
3350
3776
|
Retrieval,
|
|
3351
3777
|
ToolCodeExecution,
|
|
@@ -3393,6 +3819,11 @@ declare namespace types {
|
|
|
3393
3819
|
SafetyAttributes,
|
|
3394
3820
|
GeneratedImage,
|
|
3395
3821
|
GenerateImagesResponse,
|
|
3822
|
+
GetModelConfig,
|
|
3823
|
+
GetModelParameters,
|
|
3824
|
+
Endpoint,
|
|
3825
|
+
TunedModelInfo,
|
|
3826
|
+
Model,
|
|
3396
3827
|
GenerationConfig,
|
|
3397
3828
|
CountTokensConfig,
|
|
3398
3829
|
CountTokensParameters,
|
|
@@ -3430,6 +3861,7 @@ declare namespace types {
|
|
|
3430
3861
|
CreateFileParameters,
|
|
3431
3862
|
HttpResponse,
|
|
3432
3863
|
LiveCallbacks,
|
|
3864
|
+
UploadFileParameters,
|
|
3433
3865
|
CreateFileResponse,
|
|
3434
3866
|
GetFileConfig,
|
|
3435
3867
|
GetFileParameters,
|
|
@@ -3460,12 +3892,24 @@ declare namespace types {
|
|
|
3460
3892
|
SubjectReferenceConfig,
|
|
3461
3893
|
SubjectReferenceImage,
|
|
3462
3894
|
LiveServerSetupComplete,
|
|
3895
|
+
Transcription,
|
|
3463
3896
|
LiveServerContent,
|
|
3464
3897
|
LiveServerToolCall,
|
|
3465
3898
|
LiveServerToolCallCancellation,
|
|
3899
|
+
UsageMetadata,
|
|
3900
|
+
LiveServerGoAway,
|
|
3901
|
+
LiveServerSessionResumptionUpdate,
|
|
3466
3902
|
LiveServerMessage,
|
|
3903
|
+
AutomaticActivityDetection,
|
|
3904
|
+
RealtimeInputConfig,
|
|
3905
|
+
SessionResumptionConfig,
|
|
3906
|
+
SlidingWindow,
|
|
3907
|
+
ContextWindowCompressionConfig,
|
|
3908
|
+
AudioTranscriptionConfig,
|
|
3467
3909
|
LiveClientSetup,
|
|
3468
3910
|
LiveClientContent,
|
|
3911
|
+
ActivityStart,
|
|
3912
|
+
ActivityEnd,
|
|
3469
3913
|
LiveClientRealtimeInput,
|
|
3470
3914
|
LiveClientToolResponse,
|
|
3471
3915
|
LiveClientMessage,
|
|
@@ -3542,9 +3986,9 @@ export declare interface UploadFileConfig {
|
|
|
3542
3986
|
}
|
|
3543
3987
|
|
|
3544
3988
|
/** Parameters for the upload file method. */
|
|
3545
|
-
declare interface UploadFileParameters {
|
|
3989
|
+
export declare interface UploadFileParameters {
|
|
3546
3990
|
/** The string path to the file to be uploaded or a Blob object. */
|
|
3547
|
-
file: string | Blob;
|
|
3991
|
+
file: string | globalThis.Blob;
|
|
3548
3992
|
/** Configuration that contains optional parameters. */
|
|
3549
3993
|
config?: UploadFileConfig;
|
|
3550
3994
|
}
|
|
@@ -3580,6 +4024,33 @@ export declare interface UpscaleImageParameters {
|
|
|
3580
4024
|
config?: UpscaleImageConfig;
|
|
3581
4025
|
}
|
|
3582
4026
|
|
|
4027
|
+
/** Usage metadata about response(s). */
|
|
4028
|
+
export declare interface UsageMetadata {
|
|
4029
|
+
/** 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. */
|
|
4030
|
+
promptTokenCount?: number;
|
|
4031
|
+
/** Number of tokens in the cached part of the prompt (the cached content). */
|
|
4032
|
+
cachedContentTokenCount?: number;
|
|
4033
|
+
/** Total number of tokens across all the generated response candidates. */
|
|
4034
|
+
responseTokenCount?: number;
|
|
4035
|
+
/** Number of tokens present in tool-use prompt(s). */
|
|
4036
|
+
toolUsePromptTokenCount?: number;
|
|
4037
|
+
/** Number of tokens of thoughts for thinking models. */
|
|
4038
|
+
thoughtsTokenCount?: number;
|
|
4039
|
+
/** Total token count for prompt, response candidates, and tool-use prompts(if present). */
|
|
4040
|
+
totalTokenCount?: number;
|
|
4041
|
+
/** List of modalities that were processed in the request input. */
|
|
4042
|
+
promptTokensDetails?: ModalityTokenCount[];
|
|
4043
|
+
/** List of modalities that were processed in the cache input. */
|
|
4044
|
+
cacheTokensDetails?: ModalityTokenCount[];
|
|
4045
|
+
/** List of modalities that were returned in the response. */
|
|
4046
|
+
responseTokensDetails?: ModalityTokenCount[];
|
|
4047
|
+
/** List of modalities that were processed in the tool-use prompt. */
|
|
4048
|
+
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
4049
|
+
/** Traffic type. This shows whether a request consumes Pay-As-You-Go
|
|
4050
|
+
or Provisioned Throughput quota. */
|
|
4051
|
+
trafficType?: TrafficType;
|
|
4052
|
+
}
|
|
4053
|
+
|
|
3583
4054
|
/** Retrieve from Vertex AI Search datastore or engine for grounding. datastore and engine are mutually exclusive. See https://cloud.google.com/products/agent-builder */
|
|
3584
4055
|
export declare interface VertexAISearch {
|
|
3585
4056
|
/** Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}` */
|
|
@@ -3594,6 +4065,8 @@ export declare interface VertexRagStore {
|
|
|
3594
4065
|
ragCorpora?: string[];
|
|
3595
4066
|
/** 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. */
|
|
3596
4067
|
ragResources?: VertexRagStoreRagResource[];
|
|
4068
|
+
/** Optional. The retrieval config for the Rag query. */
|
|
4069
|
+
ragRetrievalConfig?: RagRetrievalConfig;
|
|
3597
4070
|
/** Optional. Number of top k results to return from the selected corpora. */
|
|
3598
4071
|
similarityTopK?: number;
|
|
3599
4072
|
/** Optional. Only return results with vector distance smaller than the threshold. */
|