@google/genai 0.8.0 → 0.10.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 +39 -39
- package/dist/genai.d.ts +393 -15
- package/dist/index.js +3018 -2160
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3018 -2161
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +3201 -2304
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +393 -15
- package/dist/web/index.mjs +3195 -2297
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +393 -15
- package/package.json +4 -2
package/dist/node/node.d.ts
CHANGED
|
@@ -46,11 +46,11 @@ declare class ApiClient {
|
|
|
46
46
|
private shouldPrependVertexProjectPath;
|
|
47
47
|
request(request: HttpRequest): Promise<HttpResponse>;
|
|
48
48
|
private patchHttpOptions;
|
|
49
|
-
requestStream(request: HttpRequest): Promise<
|
|
49
|
+
requestStream(request: HttpRequest): Promise<AsyncGenerator<HttpResponse>>;
|
|
50
50
|
private includeExtraHttpOptionsToRequestInit;
|
|
51
51
|
private unaryApiCall;
|
|
52
52
|
private streamApiCall;
|
|
53
|
-
processStreamResponse(response: Response): AsyncGenerator<
|
|
53
|
+
processStreamResponse(response: Response): AsyncGenerator<HttpResponse>;
|
|
54
54
|
private apiCall;
|
|
55
55
|
getDefaultHeaders(): Record<string, string>;
|
|
56
56
|
private getHeadersInternal;
|
|
@@ -164,6 +164,14 @@ export declare interface AutomaticActivityDetection {
|
|
|
164
164
|
declare class BaseModule {
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Parameters for setting the base URLs for the Gemini API and Vertex AI API.
|
|
169
|
+
*/
|
|
170
|
+
export declare interface BaseUrlParameters {
|
|
171
|
+
geminiUrl?: string;
|
|
172
|
+
vertexUrl?: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
167
175
|
/** Content blob. */
|
|
168
176
|
declare interface Blob_2 {
|
|
169
177
|
/** Required. Raw bytes. */
|
|
@@ -173,6 +181,8 @@ declare interface Blob_2 {
|
|
|
173
181
|
}
|
|
174
182
|
export { Blob_2 as Blob }
|
|
175
183
|
|
|
184
|
+
export declare type BlobImageUnion = Blob_2;
|
|
185
|
+
|
|
176
186
|
/** Output only. Blocked reason. */
|
|
177
187
|
export declare enum BlockedReason {
|
|
178
188
|
BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED",
|
|
@@ -237,8 +247,8 @@ export declare class Caches extends BaseModule {
|
|
|
237
247
|
*
|
|
238
248
|
* @remarks
|
|
239
249
|
* Context caching is only supported for specific models. See [Gemini
|
|
240
|
-
* Developer API reference]
|
|
241
|
-
* and [Vertex AI reference]
|
|
250
|
+
* Developer API reference](https://ai.google.dev/gemini-api/docs/caching?lang=node/context-cac)
|
|
251
|
+
* and [Vertex AI reference](https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-overview#supported_models)
|
|
242
252
|
* for more information.
|
|
243
253
|
*
|
|
244
254
|
* @param params - The parameters for the create request.
|
|
@@ -487,6 +497,13 @@ export declare interface CodeExecutionResult {
|
|
|
487
497
|
export declare interface ComputeTokensConfig {
|
|
488
498
|
/** Used to override HTTP request options. */
|
|
489
499
|
httpOptions?: HttpOptions;
|
|
500
|
+
/** Abort signal which can be used to cancel the request.
|
|
501
|
+
|
|
502
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
503
|
+
operation will not cancel the request in the service. You will still
|
|
504
|
+
be charged usage for any applicable operations.
|
|
505
|
+
*/
|
|
506
|
+
abortSignal?: AbortSignal;
|
|
490
507
|
}
|
|
491
508
|
|
|
492
509
|
/** Parameters for computing tokens. */
|
|
@@ -540,7 +557,7 @@ export declare interface ContentEmbeddingStatistics {
|
|
|
540
557
|
tokenCount?: number;
|
|
541
558
|
}
|
|
542
559
|
|
|
543
|
-
export declare type ContentListUnion =
|
|
560
|
+
export declare type ContentListUnion = Content | Content[] | PartUnion | PartUnion[];
|
|
544
561
|
|
|
545
562
|
export declare type ContentUnion = Content | PartUnion[] | PartUnion;
|
|
546
563
|
|
|
@@ -595,6 +612,13 @@ export declare enum ControlReferenceType {
|
|
|
595
612
|
export declare interface CountTokensConfig {
|
|
596
613
|
/** Used to override HTTP request options. */
|
|
597
614
|
httpOptions?: HttpOptions;
|
|
615
|
+
/** Abort signal which can be used to cancel the request.
|
|
616
|
+
|
|
617
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
618
|
+
operation will not cancel the request in the service. You will still
|
|
619
|
+
be charged usage for any applicable operations.
|
|
620
|
+
*/
|
|
621
|
+
abortSignal?: AbortSignal;
|
|
598
622
|
/** Instructions for the model to steer it toward better performance.
|
|
599
623
|
*/
|
|
600
624
|
systemInstruction?: ContentUnion;
|
|
@@ -631,6 +655,13 @@ export declare class CountTokensResponse {
|
|
|
631
655
|
export declare interface CreateCachedContentConfig {
|
|
632
656
|
/** Used to override HTTP request options. */
|
|
633
657
|
httpOptions?: HttpOptions;
|
|
658
|
+
/** Abort signal which can be used to cancel the request.
|
|
659
|
+
|
|
660
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
661
|
+
operation will not cancel the request in the service. You will still
|
|
662
|
+
be charged usage for any applicable operations.
|
|
663
|
+
*/
|
|
664
|
+
abortSignal?: AbortSignal;
|
|
634
665
|
/** The TTL for this resource. The expiration time is computed: now + TTL. It is a duration string, with up to nine fractional digits, terminated by 's'. Example: "3.5s". */
|
|
635
666
|
ttl?: string;
|
|
636
667
|
/** Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z. */
|
|
@@ -692,6 +723,13 @@ export declare interface CreateChatParameters {
|
|
|
692
723
|
export declare interface CreateFileConfig {
|
|
693
724
|
/** Used to override HTTP request options. */
|
|
694
725
|
httpOptions?: HttpOptions;
|
|
726
|
+
/** Abort signal which can be used to cancel the request.
|
|
727
|
+
|
|
728
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
729
|
+
operation will not cancel the request in the service. You will still
|
|
730
|
+
be charged usage for any applicable operations.
|
|
731
|
+
*/
|
|
732
|
+
abortSignal?: AbortSignal;
|
|
695
733
|
}
|
|
696
734
|
|
|
697
735
|
/** Generates the parameters for the private _create method. */
|
|
@@ -762,6 +800,13 @@ export declare function createUserContent(partOrString: PartListUnion | string):
|
|
|
762
800
|
export declare interface DeleteCachedContentConfig {
|
|
763
801
|
/** Used to override HTTP request options. */
|
|
764
802
|
httpOptions?: HttpOptions;
|
|
803
|
+
/** Abort signal which can be used to cancel the request.
|
|
804
|
+
|
|
805
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
806
|
+
operation will not cancel the request in the service. You will still
|
|
807
|
+
be charged usage for any applicable operations.
|
|
808
|
+
*/
|
|
809
|
+
abortSignal?: AbortSignal;
|
|
765
810
|
}
|
|
766
811
|
|
|
767
812
|
/** Parameters for caches.delete method. */
|
|
@@ -782,6 +827,13 @@ export declare class DeleteCachedContentResponse {
|
|
|
782
827
|
export declare interface DeleteFileConfig {
|
|
783
828
|
/** Used to override HTTP request options. */
|
|
784
829
|
httpOptions?: HttpOptions;
|
|
830
|
+
/** Abort signal which can be used to cancel the request.
|
|
831
|
+
|
|
832
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
833
|
+
operation will not cancel the request in the service. You will still
|
|
834
|
+
be charged usage for any applicable operations.
|
|
835
|
+
*/
|
|
836
|
+
abortSignal?: AbortSignal;
|
|
785
837
|
}
|
|
786
838
|
|
|
787
839
|
/** Generates the parameters for the get method. */
|
|
@@ -800,6 +852,13 @@ export declare class DeleteFileResponse {
|
|
|
800
852
|
export declare interface DownloadFileConfig {
|
|
801
853
|
/** Used to override HTTP request options. */
|
|
802
854
|
httpOptions?: HttpOptions;
|
|
855
|
+
/** Abort signal which can be used to cancel the request.
|
|
856
|
+
|
|
857
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
858
|
+
operation will not cancel the request in the service. You will still
|
|
859
|
+
be charged usage for any applicable operations.
|
|
860
|
+
*/
|
|
861
|
+
abortSignal?: AbortSignal;
|
|
803
862
|
}
|
|
804
863
|
|
|
805
864
|
/** Describes the options to customize dynamic retrieval. */
|
|
@@ -819,6 +878,13 @@ export declare enum DynamicRetrievalConfigMode {
|
|
|
819
878
|
export declare interface EmbedContentConfig {
|
|
820
879
|
/** Used to override HTTP request options. */
|
|
821
880
|
httpOptions?: HttpOptions;
|
|
881
|
+
/** Abort signal which can be used to cancel the request.
|
|
882
|
+
|
|
883
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
884
|
+
operation will not cancel the request in the service. You will still
|
|
885
|
+
be charged usage for any applicable operations.
|
|
886
|
+
*/
|
|
887
|
+
abortSignal?: AbortSignal;
|
|
822
888
|
/** Type of task for which the embedding will be used.
|
|
823
889
|
*/
|
|
824
890
|
taskType?: string;
|
|
@@ -897,9 +963,24 @@ export declare interface ExecutableCode {
|
|
|
897
963
|
language?: Language;
|
|
898
964
|
}
|
|
899
965
|
|
|
966
|
+
/** Options for feature selection preference. */
|
|
967
|
+
export declare enum FeatureSelectionPreference {
|
|
968
|
+
FEATURE_SELECTION_PREFERENCE_UNSPECIFIED = "FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",
|
|
969
|
+
PRIORITIZE_QUALITY = "PRIORITIZE_QUALITY",
|
|
970
|
+
BALANCED = "BALANCED",
|
|
971
|
+
PRIORITIZE_COST = "PRIORITIZE_COST"
|
|
972
|
+
}
|
|
973
|
+
|
|
900
974
|
export declare interface FetchPredictOperationConfig {
|
|
901
975
|
/** Used to override HTTP request options. */
|
|
902
976
|
httpOptions?: HttpOptions;
|
|
977
|
+
/** Abort signal which can be used to cancel the request.
|
|
978
|
+
|
|
979
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
980
|
+
operation will not cancel the request in the service. You will still
|
|
981
|
+
be charged usage for any applicable operations.
|
|
982
|
+
*/
|
|
983
|
+
abortSignal?: AbortSignal;
|
|
903
984
|
}
|
|
904
985
|
|
|
905
986
|
/** Parameters for the fetchPredictOperation method. */
|
|
@@ -1103,6 +1184,7 @@ export declare enum FinishReason {
|
|
|
1103
1184
|
MAX_TOKENS = "MAX_TOKENS",
|
|
1104
1185
|
SAFETY = "SAFETY",
|
|
1105
1186
|
RECITATION = "RECITATION",
|
|
1187
|
+
LANGUAGE = "LANGUAGE",
|
|
1106
1188
|
OTHER = "OTHER",
|
|
1107
1189
|
BLOCKLIST = "BLOCKLIST",
|
|
1108
1190
|
PROHIBITED_CONTENT = "PROHIBITED_CONTENT",
|
|
@@ -1174,6 +1256,13 @@ export declare class FunctionResponse {
|
|
|
1174
1256
|
export declare interface GenerateContentConfig {
|
|
1175
1257
|
/** Used to override HTTP request options. */
|
|
1176
1258
|
httpOptions?: HttpOptions;
|
|
1259
|
+
/** Abort signal which can be used to cancel the request.
|
|
1260
|
+
|
|
1261
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
1262
|
+
operation will not cancel the request in the service. You will still
|
|
1263
|
+
be charged usage for any applicable operations.
|
|
1264
|
+
*/
|
|
1265
|
+
abortSignal?: AbortSignal;
|
|
1177
1266
|
/** Instructions for the model to steer it toward better performance.
|
|
1178
1267
|
For example, "Answer as concisely as possible" or "Don't use technical
|
|
1179
1268
|
terms in your response".
|
|
@@ -1239,6 +1328,9 @@ export declare interface GenerateContentConfig {
|
|
|
1239
1328
|
/** Configuration for model router requests.
|
|
1240
1329
|
*/
|
|
1241
1330
|
routingConfig?: GenerationConfigRoutingConfig;
|
|
1331
|
+
/** Configuration for model selection.
|
|
1332
|
+
*/
|
|
1333
|
+
modelSelectionConfig?: ModelSelectionConfig;
|
|
1242
1334
|
/** Safety settings in the request to block unsafe content in the
|
|
1243
1335
|
response.
|
|
1244
1336
|
*/
|
|
@@ -1328,6 +1420,17 @@ export declare class GenerateContentResponse {
|
|
|
1328
1420
|
* ```
|
|
1329
1421
|
*/
|
|
1330
1422
|
get text(): string | undefined;
|
|
1423
|
+
/**
|
|
1424
|
+
* Returns the concatenation of all inline data parts from the first candidate
|
|
1425
|
+
* in the response.
|
|
1426
|
+
*
|
|
1427
|
+
* @remarks
|
|
1428
|
+
* If there are multiple candidates in the response, the inline data from the
|
|
1429
|
+
* first one will be returned. If there are non-inline data parts in the
|
|
1430
|
+
* response, the concatenation of all inline data parts will be returned, and
|
|
1431
|
+
* a warning will be logged.
|
|
1432
|
+
*/
|
|
1433
|
+
get data(): string | undefined;
|
|
1331
1434
|
/**
|
|
1332
1435
|
* Returns the function calls from the first candidate in the response.
|
|
1333
1436
|
*
|
|
@@ -1488,6 +1591,13 @@ export declare interface GeneratedVideo {
|
|
|
1488
1591
|
export declare interface GenerateImagesConfig {
|
|
1489
1592
|
/** Used to override HTTP request options. */
|
|
1490
1593
|
httpOptions?: HttpOptions;
|
|
1594
|
+
/** Abort signal which can be used to cancel the request.
|
|
1595
|
+
|
|
1596
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
1597
|
+
operation will not cancel the request in the service. You will still
|
|
1598
|
+
be charged usage for any applicable operations.
|
|
1599
|
+
*/
|
|
1600
|
+
abortSignal?: AbortSignal;
|
|
1491
1601
|
/** Cloud Storage URI used to store the generated images.
|
|
1492
1602
|
*/
|
|
1493
1603
|
outputGcsUri?: string;
|
|
@@ -1569,6 +1679,13 @@ export declare class GenerateImagesResponse {
|
|
|
1569
1679
|
export declare interface GenerateVideosConfig {
|
|
1570
1680
|
/** Used to override HTTP request options. */
|
|
1571
1681
|
httpOptions?: HttpOptions;
|
|
1682
|
+
/** Abort signal which can be used to cancel the request.
|
|
1683
|
+
|
|
1684
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
1685
|
+
operation will not cancel the request in the service. You will still
|
|
1686
|
+
be charged usage for any applicable operations.
|
|
1687
|
+
*/
|
|
1688
|
+
abortSignal?: AbortSignal;
|
|
1572
1689
|
/** Number of output videos. */
|
|
1573
1690
|
numberOfVideos?: number;
|
|
1574
1691
|
/** The gcs bucket where to save the generated videos. */
|
|
@@ -1691,6 +1808,13 @@ export declare interface GenerationConfigRoutingConfigManualRoutingMode {
|
|
|
1691
1808
|
export declare interface GetCachedContentConfig {
|
|
1692
1809
|
/** Used to override HTTP request options. */
|
|
1693
1810
|
httpOptions?: HttpOptions;
|
|
1811
|
+
/** Abort signal which can be used to cancel the request.
|
|
1812
|
+
|
|
1813
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
1814
|
+
operation will not cancel the request in the service. You will still
|
|
1815
|
+
be charged usage for any applicable operations.
|
|
1816
|
+
*/
|
|
1817
|
+
abortSignal?: AbortSignal;
|
|
1694
1818
|
}
|
|
1695
1819
|
|
|
1696
1820
|
/** Parameters for caches.get method. */
|
|
@@ -1707,6 +1831,13 @@ export declare interface GetCachedContentParameters {
|
|
|
1707
1831
|
export declare interface GetFileConfig {
|
|
1708
1832
|
/** Used to override HTTP request options. */
|
|
1709
1833
|
httpOptions?: HttpOptions;
|
|
1834
|
+
/** Abort signal which can be used to cancel the request.
|
|
1835
|
+
|
|
1836
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
1837
|
+
operation will not cancel the request in the service. You will still
|
|
1838
|
+
be charged usage for any applicable operations.
|
|
1839
|
+
*/
|
|
1840
|
+
abortSignal?: AbortSignal;
|
|
1710
1841
|
}
|
|
1711
1842
|
|
|
1712
1843
|
/** Generates the parameters for the get method. */
|
|
@@ -1721,6 +1852,13 @@ export declare interface GetFileParameters {
|
|
|
1721
1852
|
export declare interface GetModelConfig {
|
|
1722
1853
|
/** Used to override HTTP request options. */
|
|
1723
1854
|
httpOptions?: HttpOptions;
|
|
1855
|
+
/** Abort signal which can be used to cancel the request.
|
|
1856
|
+
|
|
1857
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
1858
|
+
operation will not cancel the request in the service. You will still
|
|
1859
|
+
be charged usage for any applicable operations.
|
|
1860
|
+
*/
|
|
1861
|
+
abortSignal?: AbortSignal;
|
|
1724
1862
|
}
|
|
1725
1863
|
|
|
1726
1864
|
export declare interface GetModelParameters {
|
|
@@ -1732,6 +1870,13 @@ export declare interface GetModelParameters {
|
|
|
1732
1870
|
export declare interface GetOperationConfig {
|
|
1733
1871
|
/** Used to override HTTP request options. */
|
|
1734
1872
|
httpOptions?: HttpOptions;
|
|
1873
|
+
/** Abort signal which can be used to cancel the request.
|
|
1874
|
+
|
|
1875
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
1876
|
+
operation will not cancel the request in the service. You will still
|
|
1877
|
+
be charged usage for any applicable operations.
|
|
1878
|
+
*/
|
|
1879
|
+
abortSignal?: AbortSignal;
|
|
1735
1880
|
}
|
|
1736
1881
|
|
|
1737
1882
|
/** Parameters for the GET method. */
|
|
@@ -2034,6 +2179,10 @@ declare interface HttpRequest {
|
|
|
2034
2179
|
* Optional set of customizable configuration for HTTP requests.
|
|
2035
2180
|
*/
|
|
2036
2181
|
httpOptions?: HttpOptions;
|
|
2182
|
+
/**
|
|
2183
|
+
* Optional abort signal which can be used to cancel the request.
|
|
2184
|
+
*/
|
|
2185
|
+
abortSignal?: AbortSignal;
|
|
2037
2186
|
}
|
|
2038
2187
|
|
|
2039
2188
|
/** A wrapper class for the http response. */
|
|
@@ -2082,6 +2231,13 @@ export declare enum Language {
|
|
|
2082
2231
|
export declare interface ListCachedContentsConfig {
|
|
2083
2232
|
/** Used to override HTTP request options. */
|
|
2084
2233
|
httpOptions?: HttpOptions;
|
|
2234
|
+
/** Abort signal which can be used to cancel the request.
|
|
2235
|
+
|
|
2236
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
2237
|
+
operation will not cancel the request in the service. You will still
|
|
2238
|
+
be charged usage for any applicable operations.
|
|
2239
|
+
*/
|
|
2240
|
+
abortSignal?: AbortSignal;
|
|
2085
2241
|
pageSize?: number;
|
|
2086
2242
|
pageToken?: string;
|
|
2087
2243
|
}
|
|
@@ -2104,6 +2260,13 @@ export declare class ListCachedContentsResponse {
|
|
|
2104
2260
|
export declare interface ListFilesConfig {
|
|
2105
2261
|
/** Used to override HTTP request options. */
|
|
2106
2262
|
httpOptions?: HttpOptions;
|
|
2263
|
+
/** Abort signal which can be used to cancel the request.
|
|
2264
|
+
|
|
2265
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
2266
|
+
operation will not cancel the request in the service. You will still
|
|
2267
|
+
be charged usage for any applicable operations.
|
|
2268
|
+
*/
|
|
2269
|
+
abortSignal?: AbortSignal;
|
|
2107
2270
|
pageSize?: number;
|
|
2108
2271
|
pageToken?: string;
|
|
2109
2272
|
}
|
|
@@ -2140,17 +2303,20 @@ export declare class Live {
|
|
|
2140
2303
|
@experimental
|
|
2141
2304
|
|
|
2142
2305
|
@remarks
|
|
2143
|
-
If using the Gemini API, Live is currently only supported behind API
|
|
2144
|
-
version `v1alpha`. Ensure that the API version is set to `v1alpha` when
|
|
2145
|
-
initializing the SDK if relying on the Gemini API.
|
|
2146
2306
|
|
|
2147
2307
|
@param params - The parameters for establishing a connection to the model.
|
|
2148
2308
|
@return A live session.
|
|
2149
2309
|
|
|
2150
2310
|
@example
|
|
2151
2311
|
```ts
|
|
2312
|
+
let model: string;
|
|
2313
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
2314
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
2315
|
+
} else {
|
|
2316
|
+
model = 'gemini-2.0-flash-live-001';
|
|
2317
|
+
}
|
|
2152
2318
|
const session = await ai.live.connect({
|
|
2153
|
-
model:
|
|
2319
|
+
model: model,
|
|
2154
2320
|
config: {
|
|
2155
2321
|
responseModalities: [Modality.AUDIO],
|
|
2156
2322
|
},
|
|
@@ -2245,6 +2411,22 @@ export declare interface LiveClientMessage {
|
|
|
2245
2411
|
export declare interface LiveClientRealtimeInput {
|
|
2246
2412
|
/** Inlined bytes data for media input. */
|
|
2247
2413
|
mediaChunks?: Blob_2[];
|
|
2414
|
+
/** The realtime audio input stream. */
|
|
2415
|
+
audio?: Blob_2;
|
|
2416
|
+
/**
|
|
2417
|
+
Indicates that the audio stream has ended, e.g. because the microphone was
|
|
2418
|
+
turned off.
|
|
2419
|
+
|
|
2420
|
+
This should only be sent when automatic activity detection is enabled
|
|
2421
|
+
(which is the default).
|
|
2422
|
+
|
|
2423
|
+
The client can reopen the stream by sending an audio message.
|
|
2424
|
+
*/
|
|
2425
|
+
audioStreamEnd?: boolean;
|
|
2426
|
+
/** The realtime video input stream. */
|
|
2427
|
+
video?: Blob_2;
|
|
2428
|
+
/** The realtime text input stream. */
|
|
2429
|
+
text?: string;
|
|
2248
2430
|
/** Marks the start of user activity. */
|
|
2249
2431
|
activityStart?: ActivityStart;
|
|
2250
2432
|
/** Marks the end of user activity. */
|
|
@@ -2265,7 +2447,7 @@ export declare interface LiveClientSetup {
|
|
|
2265
2447
|
/** The user provided system instructions for the model.
|
|
2266
2448
|
Note: only text should be used in parts and content in each part will be
|
|
2267
2449
|
in a separate paragraph. */
|
|
2268
|
-
systemInstruction?:
|
|
2450
|
+
systemInstruction?: ContentUnion;
|
|
2269
2451
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2270
2452
|
|
|
2271
2453
|
A `Tool` is a piece of code that enables the system to interact with
|
|
@@ -2282,6 +2464,13 @@ export declare interface LiveClientSetup {
|
|
|
2282
2464
|
|
|
2283
2465
|
If included, server will compress context window to fit into given length. */
|
|
2284
2466
|
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2467
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2468
|
+
*/
|
|
2469
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2470
|
+
/** The transcription of the output aligns with the language code
|
|
2471
|
+
specified for the output audio.
|
|
2472
|
+
*/
|
|
2473
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2285
2474
|
}
|
|
2286
2475
|
|
|
2287
2476
|
/** Client generated response to a `ToolCall` received from the server.
|
|
@@ -2307,13 +2496,42 @@ export declare interface LiveConnectConfig {
|
|
|
2307
2496
|
modalities that the model can return. Defaults to AUDIO if not specified.
|
|
2308
2497
|
*/
|
|
2309
2498
|
responseModalities?: Modality[];
|
|
2499
|
+
/** Value that controls the degree of randomness in token selection.
|
|
2500
|
+
Lower temperatures are good for prompts that require a less open-ended or
|
|
2501
|
+
creative response, while higher temperatures can lead to more diverse or
|
|
2502
|
+
creative results.
|
|
2503
|
+
*/
|
|
2504
|
+
temperature?: number;
|
|
2505
|
+
/** Tokens are selected from the most to least probable until the sum
|
|
2506
|
+
of their probabilities equals this value. Use a lower value for less
|
|
2507
|
+
random responses and a higher value for more random responses.
|
|
2508
|
+
*/
|
|
2509
|
+
topP?: number;
|
|
2510
|
+
/** For each token selection step, the ``top_k`` tokens with the
|
|
2511
|
+
highest probabilities are sampled. Then tokens are further filtered based
|
|
2512
|
+
on ``top_p`` with the final token selected using temperature sampling. Use
|
|
2513
|
+
a lower number for less random responses and a higher number for more
|
|
2514
|
+
random responses.
|
|
2515
|
+
*/
|
|
2516
|
+
topK?: number;
|
|
2517
|
+
/** Maximum number of tokens that can be generated in the response.
|
|
2518
|
+
*/
|
|
2519
|
+
maxOutputTokens?: number;
|
|
2520
|
+
/** If specified, the media resolution specified will be used.
|
|
2521
|
+
*/
|
|
2522
|
+
mediaResolution?: MediaResolution;
|
|
2523
|
+
/** When ``seed`` is fixed to a specific number, the model makes a best
|
|
2524
|
+
effort to provide the same response for repeated requests. By default, a
|
|
2525
|
+
random number is used.
|
|
2526
|
+
*/
|
|
2527
|
+
seed?: number;
|
|
2310
2528
|
/** The speech generation configuration.
|
|
2311
2529
|
*/
|
|
2312
2530
|
speechConfig?: SpeechConfig;
|
|
2313
2531
|
/** The user provided system instructions for the model.
|
|
2314
2532
|
Note: only text should be used in parts and content in each part will be
|
|
2315
2533
|
in a separate paragraph. */
|
|
2316
|
-
systemInstruction?:
|
|
2534
|
+
systemInstruction?: ContentUnion;
|
|
2317
2535
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2318
2536
|
|
|
2319
2537
|
A `Tool` is a piece of code that enables the system to interact with
|
|
@@ -2324,6 +2542,13 @@ export declare interface LiveConnectConfig {
|
|
|
2324
2542
|
|
|
2325
2543
|
If included the server will send SessionResumptionUpdate messages. */
|
|
2326
2544
|
sessionResumption?: SessionResumptionConfig;
|
|
2545
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2546
|
+
*/
|
|
2547
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2548
|
+
/** The transcription of the output aligns with the language code
|
|
2549
|
+
specified for the output audio.
|
|
2550
|
+
*/
|
|
2551
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2327
2552
|
/** Configures the realtime input behavior in BidiGenerateContent. */
|
|
2328
2553
|
realtimeInputConfig?: RealtimeInputConfig;
|
|
2329
2554
|
/** Configures context window compression mechanism.
|
|
@@ -2357,7 +2582,23 @@ export declare interface LiveSendClientContentParameters {
|
|
|
2357
2582
|
/** Parameters for sending realtime input to the live API. */
|
|
2358
2583
|
export declare interface LiveSendRealtimeInputParameters {
|
|
2359
2584
|
/** Realtime input to send to the session. */
|
|
2360
|
-
media
|
|
2585
|
+
media?: BlobImageUnion;
|
|
2586
|
+
/** The realtime audio input stream. */
|
|
2587
|
+
audio?: Blob_2;
|
|
2588
|
+
/**
|
|
2589
|
+
Indicates that the audio stream has ended, e.g. because the microphone was
|
|
2590
|
+
turned off.
|
|
2591
|
+
|
|
2592
|
+
This should only be sent when automatic activity detection is enabled
|
|
2593
|
+
(which is the default).
|
|
2594
|
+
|
|
2595
|
+
The client can reopen the stream by sending an audio message.
|
|
2596
|
+
*/
|
|
2597
|
+
audioStreamEnd?: boolean;
|
|
2598
|
+
/** The realtime video input stream. */
|
|
2599
|
+
video?: BlobImageUnion;
|
|
2600
|
+
/** The realtime text input stream. */
|
|
2601
|
+
text?: string;
|
|
2361
2602
|
/** Marks the start of user activity. */
|
|
2362
2603
|
activityStart?: ActivityStart;
|
|
2363
2604
|
/** Marks the end of user activity. */
|
|
@@ -2391,6 +2632,15 @@ export declare interface LiveServerContent {
|
|
|
2391
2632
|
has finished generating all content. This is a signal to the client
|
|
2392
2633
|
that it can stop sending messages. */
|
|
2393
2634
|
generationComplete?: boolean;
|
|
2635
|
+
/** Input transcription. The transcription is independent to the model
|
|
2636
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2637
|
+
model turn. */
|
|
2638
|
+
inputTranscription?: Transcription;
|
|
2639
|
+
/** Output transcription. The transcription is independent to the model
|
|
2640
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2641
|
+
model turn.
|
|
2642
|
+
*/
|
|
2643
|
+
outputTranscription?: Transcription;
|
|
2394
2644
|
}
|
|
2395
2645
|
|
|
2396
2646
|
/** Server will not be able to service client soon. */
|
|
@@ -2811,6 +3061,12 @@ export declare class Models extends BaseModule {
|
|
|
2811
3061
|
generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
|
|
2812
3062
|
}
|
|
2813
3063
|
|
|
3064
|
+
/** Config for model selection. */
|
|
3065
|
+
export declare interface ModelSelectionConfig {
|
|
3066
|
+
/** Options for feature selection preference. */
|
|
3067
|
+
featureSelectionPreference?: FeatureSelectionPreference;
|
|
3068
|
+
}
|
|
3069
|
+
|
|
2814
3070
|
/** Parameters for the get method of the operations module. */
|
|
2815
3071
|
export declare interface OperationGetParameters {
|
|
2816
3072
|
/** The operation to be retrieved. */
|
|
@@ -3018,6 +3274,54 @@ export declare interface PrebuiltVoiceConfig {
|
|
|
3018
3274
|
voiceName?: string;
|
|
3019
3275
|
}
|
|
3020
3276
|
|
|
3277
|
+
/** Specifies the context retrieval config. */
|
|
3278
|
+
export declare interface RagRetrievalConfig {
|
|
3279
|
+
/** Optional. Config for filters. */
|
|
3280
|
+
filter?: RagRetrievalConfigFilter;
|
|
3281
|
+
/** Optional. Config for Hybrid Search. */
|
|
3282
|
+
hybridSearch?: RagRetrievalConfigHybridSearch;
|
|
3283
|
+
/** Optional. Config for ranking and reranking. */
|
|
3284
|
+
ranking?: RagRetrievalConfigRanking;
|
|
3285
|
+
/** Optional. The number of contexts to retrieve. */
|
|
3286
|
+
topK?: number;
|
|
3287
|
+
}
|
|
3288
|
+
|
|
3289
|
+
/** Config for filters. */
|
|
3290
|
+
export declare interface RagRetrievalConfigFilter {
|
|
3291
|
+
/** Optional. String for metadata filtering. */
|
|
3292
|
+
metadataFilter?: string;
|
|
3293
|
+
/** Optional. Only returns contexts with vector distance smaller than the threshold. */
|
|
3294
|
+
vectorDistanceThreshold?: number;
|
|
3295
|
+
/** Optional. Only returns contexts with vector similarity larger than the threshold. */
|
|
3296
|
+
vectorSimilarityThreshold?: number;
|
|
3297
|
+
}
|
|
3298
|
+
|
|
3299
|
+
/** Config for Hybrid Search. */
|
|
3300
|
+
export declare interface RagRetrievalConfigHybridSearch {
|
|
3301
|
+
/** 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. */
|
|
3302
|
+
alpha?: number;
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
/** Config for ranking and reranking. */
|
|
3306
|
+
export declare interface RagRetrievalConfigRanking {
|
|
3307
|
+
/** Optional. Config for LlmRanker. */
|
|
3308
|
+
llmRanker?: RagRetrievalConfigRankingLlmRanker;
|
|
3309
|
+
/** Optional. Config for Rank Service. */
|
|
3310
|
+
rankService?: RagRetrievalConfigRankingRankService;
|
|
3311
|
+
}
|
|
3312
|
+
|
|
3313
|
+
/** Config for LlmRanker. */
|
|
3314
|
+
export declare interface RagRetrievalConfigRankingLlmRanker {
|
|
3315
|
+
/** Optional. The model name used for ranking. Format: `gemini-1.5-pro` */
|
|
3316
|
+
modelName?: string;
|
|
3317
|
+
}
|
|
3318
|
+
|
|
3319
|
+
/** Config for Rank Service. */
|
|
3320
|
+
export declare interface RagRetrievalConfigRankingRankService {
|
|
3321
|
+
/** Optional. The model name of the rank service. Format: `semantic-ranker-512@latest` */
|
|
3322
|
+
modelName?: string;
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3021
3325
|
/** A raw reference image.
|
|
3022
3326
|
|
|
3023
3327
|
A raw reference image represents the base image to edit, provided by the user.
|
|
@@ -3243,7 +3547,6 @@ export declare class Session {
|
|
|
3243
3547
|
private readonly apiClient;
|
|
3244
3548
|
constructor(conn: WebSocket_2, apiClient: ApiClient);
|
|
3245
3549
|
private tLiveClientContent;
|
|
3246
|
-
private tLiveClientRealtimeInput;
|
|
3247
3550
|
private tLiveClienttToolResponse;
|
|
3248
3551
|
/**
|
|
3249
3552
|
Send a message over the established connection.
|
|
@@ -3340,8 +3643,14 @@ export declare class Session {
|
|
|
3340
3643
|
|
|
3341
3644
|
@example
|
|
3342
3645
|
```ts
|
|
3646
|
+
let model: string;
|
|
3647
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
3648
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
3649
|
+
} else {
|
|
3650
|
+
model = 'gemini-2.0-flash-live-001';
|
|
3651
|
+
}
|
|
3343
3652
|
const session = await ai.live.connect({
|
|
3344
|
-
model:
|
|
3653
|
+
model: model,
|
|
3345
3654
|
config: {
|
|
3346
3655
|
responseModalities: [Modality.AUDIO],
|
|
3347
3656
|
}
|
|
@@ -3367,6 +3676,28 @@ export declare interface SessionResumptionConfig {
|
|
|
3367
3676
|
transparent?: boolean;
|
|
3368
3677
|
}
|
|
3369
3678
|
|
|
3679
|
+
/**
|
|
3680
|
+
* Overrides the base URLs for the Gemini API and Vertex AI API.
|
|
3681
|
+
*
|
|
3682
|
+
* @remarks This function should be called before initializing the SDK. If the
|
|
3683
|
+
* base URLs are set after initializing the SDK, the base URLs will not be
|
|
3684
|
+
* updated. Base URLs provided in the HttpOptions will also take precedence over
|
|
3685
|
+
* URLs set here.
|
|
3686
|
+
*
|
|
3687
|
+
* @example
|
|
3688
|
+
* ```ts
|
|
3689
|
+
* import {GoogleGenAI, setDefaultBaseUrls} from '@google/genai';
|
|
3690
|
+
* // Override the base URL for the Gemini API.
|
|
3691
|
+
* setDefaultBaseUrls({geminiUrl:'https://gemini.google.com'});
|
|
3692
|
+
*
|
|
3693
|
+
* // Override the base URL for the Vertex AI API.
|
|
3694
|
+
* setDefaultBaseUrls({vertexUrl: 'https://vertexai.googleapis.com'});
|
|
3695
|
+
*
|
|
3696
|
+
* const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
|
|
3697
|
+
* ```
|
|
3698
|
+
*/
|
|
3699
|
+
export declare function setDefaultBaseUrls(baseUrlParams: BaseUrlParameters): void;
|
|
3700
|
+
|
|
3370
3701
|
/** Context window will be truncated by keeping only suffix of it.
|
|
3371
3702
|
|
|
3372
3703
|
Context window will always be cut at start of USER role turn. System
|
|
@@ -3384,6 +3715,10 @@ export declare interface SpeechConfig {
|
|
|
3384
3715
|
/** The configuration for the speaker to use.
|
|
3385
3716
|
*/
|
|
3386
3717
|
voiceConfig?: VoiceConfig;
|
|
3718
|
+
/** Language code (ISO 639. e.g. en-US) for the speech synthesization.
|
|
3719
|
+
Only available for Live API.
|
|
3720
|
+
*/
|
|
3721
|
+
languageCode?: string;
|
|
3387
3722
|
}
|
|
3388
3723
|
|
|
3389
3724
|
export declare type SpeechConfigUnion = SpeechConfig | string;
|
|
@@ -3538,6 +3873,16 @@ export declare enum TrafficType {
|
|
|
3538
3873
|
PROVISIONED_THROUGHPUT = "PROVISIONED_THROUGHPUT"
|
|
3539
3874
|
}
|
|
3540
3875
|
|
|
3876
|
+
/** Audio transcription in Server Conent. */
|
|
3877
|
+
export declare interface Transcription {
|
|
3878
|
+
/** Transcription text.
|
|
3879
|
+
*/
|
|
3880
|
+
text?: string;
|
|
3881
|
+
/** The bool indicates the end of the transcription.
|
|
3882
|
+
*/
|
|
3883
|
+
finished?: boolean;
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3541
3886
|
/** A tuned machine learning model. */
|
|
3542
3887
|
export declare interface TunedModelInfo {
|
|
3543
3888
|
/** ID of the base model that you want to tune. */
|
|
@@ -3591,6 +3936,7 @@ declare namespace types {
|
|
|
3591
3936
|
TrafficType,
|
|
3592
3937
|
Modality,
|
|
3593
3938
|
MediaResolution,
|
|
3939
|
+
FeatureSelectionPreference,
|
|
3594
3940
|
DynamicRetrievalConfigMode,
|
|
3595
3941
|
FunctionCallingConfigMode,
|
|
3596
3942
|
SafetyFilterLevel,
|
|
@@ -3617,6 +3963,7 @@ declare namespace types {
|
|
|
3617
3963
|
Content,
|
|
3618
3964
|
HttpOptions,
|
|
3619
3965
|
Schema,
|
|
3966
|
+
ModelSelectionConfig,
|
|
3620
3967
|
SafetySetting,
|
|
3621
3968
|
FunctionDeclaration,
|
|
3622
3969
|
GoogleSearch,
|
|
@@ -3624,6 +3971,12 @@ declare namespace types {
|
|
|
3624
3971
|
GoogleSearchRetrieval,
|
|
3625
3972
|
VertexAISearch,
|
|
3626
3973
|
VertexRagStoreRagResource,
|
|
3974
|
+
RagRetrievalConfigFilter,
|
|
3975
|
+
RagRetrievalConfigHybridSearch,
|
|
3976
|
+
RagRetrievalConfigRankingLlmRanker,
|
|
3977
|
+
RagRetrievalConfigRankingRankService,
|
|
3978
|
+
RagRetrievalConfigRanking,
|
|
3979
|
+
RagRetrievalConfig,
|
|
3627
3980
|
VertexRagStore,
|
|
3628
3981
|
Retrieval,
|
|
3629
3982
|
ToolCodeExecution,
|
|
@@ -3744,6 +4097,7 @@ declare namespace types {
|
|
|
3744
4097
|
SubjectReferenceConfig,
|
|
3745
4098
|
SubjectReferenceImage,
|
|
3746
4099
|
LiveServerSetupComplete,
|
|
4100
|
+
Transcription,
|
|
3747
4101
|
LiveServerContent,
|
|
3748
4102
|
LiveServerToolCall,
|
|
3749
4103
|
LiveServerToolCallCancellation,
|
|
@@ -3756,6 +4110,7 @@ declare namespace types {
|
|
|
3756
4110
|
SessionResumptionConfig,
|
|
3757
4111
|
SlidingWindow,
|
|
3758
4112
|
ContextWindowCompressionConfig,
|
|
4113
|
+
AudioTranscriptionConfig,
|
|
3759
4114
|
LiveClientSetup,
|
|
3760
4115
|
LiveClientContent,
|
|
3761
4116
|
ActivityStart,
|
|
@@ -3763,7 +4118,6 @@ declare namespace types {
|
|
|
3763
4118
|
LiveClientRealtimeInput,
|
|
3764
4119
|
LiveClientToolResponse,
|
|
3765
4120
|
LiveClientMessage,
|
|
3766
|
-
AudioTranscriptionConfig,
|
|
3767
4121
|
LiveConnectConfig,
|
|
3768
4122
|
LiveConnectParameters,
|
|
3769
4123
|
CreateChatParameters,
|
|
@@ -3772,6 +4126,7 @@ declare namespace types {
|
|
|
3772
4126
|
LiveSendRealtimeInputParameters,
|
|
3773
4127
|
LiveSendToolResponseParameters,
|
|
3774
4128
|
OperationGetParameters,
|
|
4129
|
+
BlobImageUnion,
|
|
3775
4130
|
PartUnion,
|
|
3776
4131
|
PartListUnion,
|
|
3777
4132
|
ContentUnion,
|
|
@@ -3786,6 +4141,13 @@ declare namespace types {
|
|
|
3786
4141
|
export declare interface UpdateCachedContentConfig {
|
|
3787
4142
|
/** Used to override HTTP request options. */
|
|
3788
4143
|
httpOptions?: HttpOptions;
|
|
4144
|
+
/** Abort signal which can be used to cancel the request.
|
|
4145
|
+
|
|
4146
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
4147
|
+
operation will not cancel the request in the service. You will still
|
|
4148
|
+
be charged usage for any applicable operations.
|
|
4149
|
+
*/
|
|
4150
|
+
abortSignal?: AbortSignal;
|
|
3789
4151
|
/** The TTL for this resource. The expiration time is computed: now + TTL. It is a duration string, with up to nine fractional digits, terminated by 's'. Example: "3.5s". */
|
|
3790
4152
|
ttl?: string;
|
|
3791
4153
|
/** Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z. */
|
|
@@ -3828,6 +4190,13 @@ declare interface Uploader {
|
|
|
3828
4190
|
export declare interface UploadFileConfig {
|
|
3829
4191
|
/** Used to override HTTP request options. */
|
|
3830
4192
|
httpOptions?: HttpOptions;
|
|
4193
|
+
/** Abort signal which can be used to cancel the request.
|
|
4194
|
+
|
|
4195
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
4196
|
+
operation will not cancel the request in the service. You will still
|
|
4197
|
+
be charged usage for any applicable operations.
|
|
4198
|
+
*/
|
|
4199
|
+
abortSignal?: AbortSignal;
|
|
3831
4200
|
/** The name of the file in the destination (e.g., 'files/sample-image'. If not provided one will be generated. */
|
|
3832
4201
|
name?: string;
|
|
3833
4202
|
/** mime_type: The MIME type of the file. If not provided, it will be inferred from the file extension. */
|
|
@@ -3853,6 +4222,13 @@ export declare interface UploadFileParameters {
|
|
|
3853
4222
|
export declare interface UpscaleImageConfig {
|
|
3854
4223
|
/** Used to override HTTP request options. */
|
|
3855
4224
|
httpOptions?: HttpOptions;
|
|
4225
|
+
/** Abort signal which can be used to cancel the request.
|
|
4226
|
+
|
|
4227
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
4228
|
+
operation will not cancel the request in the service. You will still
|
|
4229
|
+
be charged usage for any applicable operations.
|
|
4230
|
+
*/
|
|
4231
|
+
abortSignal?: AbortSignal;
|
|
3856
4232
|
/** Whether to include a reason for filtered-out images in the
|
|
3857
4233
|
response. */
|
|
3858
4234
|
includeRaiReason?: boolean;
|
|
@@ -3916,6 +4292,8 @@ export declare interface VertexRagStore {
|
|
|
3916
4292
|
ragCorpora?: string[];
|
|
3917
4293
|
/** 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. */
|
|
3918
4294
|
ragResources?: VertexRagStoreRagResource[];
|
|
4295
|
+
/** Optional. The retrieval config for the Rag query. */
|
|
4296
|
+
ragRetrievalConfig?: RagRetrievalConfig;
|
|
3919
4297
|
/** Optional. Number of top k results to return from the selected corpora. */
|
|
3920
4298
|
similarityTopK?: number;
|
|
3921
4299
|
/** Optional. Only return results with vector distance smaller than the threshold. */
|