@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/genai.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. */
|
|
@@ -2022,6 +2167,10 @@ declare interface HttpRequest {
|
|
|
2022
2167
|
* Optional set of customizable configuration for HTTP requests.
|
|
2023
2168
|
*/
|
|
2024
2169
|
httpOptions?: HttpOptions;
|
|
2170
|
+
/**
|
|
2171
|
+
* Optional abort signal which can be used to cancel the request.
|
|
2172
|
+
*/
|
|
2173
|
+
abortSignal?: AbortSignal;
|
|
2025
2174
|
}
|
|
2026
2175
|
|
|
2027
2176
|
/** A wrapper class for the http response. */
|
|
@@ -2070,6 +2219,13 @@ export declare enum Language {
|
|
|
2070
2219
|
export declare interface ListCachedContentsConfig {
|
|
2071
2220
|
/** Used to override HTTP request options. */
|
|
2072
2221
|
httpOptions?: HttpOptions;
|
|
2222
|
+
/** Abort signal which can be used to cancel the request.
|
|
2223
|
+
|
|
2224
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
2225
|
+
operation will not cancel the request in the service. You will still
|
|
2226
|
+
be charged usage for any applicable operations.
|
|
2227
|
+
*/
|
|
2228
|
+
abortSignal?: AbortSignal;
|
|
2073
2229
|
pageSize?: number;
|
|
2074
2230
|
pageToken?: string;
|
|
2075
2231
|
}
|
|
@@ -2092,6 +2248,13 @@ export declare class ListCachedContentsResponse {
|
|
|
2092
2248
|
export declare interface ListFilesConfig {
|
|
2093
2249
|
/** Used to override HTTP request options. */
|
|
2094
2250
|
httpOptions?: HttpOptions;
|
|
2251
|
+
/** Abort signal which can be used to cancel the request.
|
|
2252
|
+
|
|
2253
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
2254
|
+
operation will not cancel the request in the service. You will still
|
|
2255
|
+
be charged usage for any applicable operations.
|
|
2256
|
+
*/
|
|
2257
|
+
abortSignal?: AbortSignal;
|
|
2095
2258
|
pageSize?: number;
|
|
2096
2259
|
pageToken?: string;
|
|
2097
2260
|
}
|
|
@@ -2128,17 +2291,20 @@ export declare class Live {
|
|
|
2128
2291
|
@experimental
|
|
2129
2292
|
|
|
2130
2293
|
@remarks
|
|
2131
|
-
If using the Gemini API, Live is currently only supported behind API
|
|
2132
|
-
version `v1alpha`. Ensure that the API version is set to `v1alpha` when
|
|
2133
|
-
initializing the SDK if relying on the Gemini API.
|
|
2134
2294
|
|
|
2135
2295
|
@param params - The parameters for establishing a connection to the model.
|
|
2136
2296
|
@return A live session.
|
|
2137
2297
|
|
|
2138
2298
|
@example
|
|
2139
2299
|
```ts
|
|
2300
|
+
let model: string;
|
|
2301
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
2302
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
2303
|
+
} else {
|
|
2304
|
+
model = 'gemini-2.0-flash-live-001';
|
|
2305
|
+
}
|
|
2140
2306
|
const session = await ai.live.connect({
|
|
2141
|
-
model:
|
|
2307
|
+
model: model,
|
|
2142
2308
|
config: {
|
|
2143
2309
|
responseModalities: [Modality.AUDIO],
|
|
2144
2310
|
},
|
|
@@ -2233,6 +2399,22 @@ export declare interface LiveClientMessage {
|
|
|
2233
2399
|
export declare interface LiveClientRealtimeInput {
|
|
2234
2400
|
/** Inlined bytes data for media input. */
|
|
2235
2401
|
mediaChunks?: Blob_2[];
|
|
2402
|
+
/** The realtime audio input stream. */
|
|
2403
|
+
audio?: Blob_2;
|
|
2404
|
+
/**
|
|
2405
|
+
Indicates that the audio stream has ended, e.g. because the microphone was
|
|
2406
|
+
turned off.
|
|
2407
|
+
|
|
2408
|
+
This should only be sent when automatic activity detection is enabled
|
|
2409
|
+
(which is the default).
|
|
2410
|
+
|
|
2411
|
+
The client can reopen the stream by sending an audio message.
|
|
2412
|
+
*/
|
|
2413
|
+
audioStreamEnd?: boolean;
|
|
2414
|
+
/** The realtime video input stream. */
|
|
2415
|
+
video?: Blob_2;
|
|
2416
|
+
/** The realtime text input stream. */
|
|
2417
|
+
text?: string;
|
|
2236
2418
|
/** Marks the start of user activity. */
|
|
2237
2419
|
activityStart?: ActivityStart;
|
|
2238
2420
|
/** Marks the end of user activity. */
|
|
@@ -2253,7 +2435,7 @@ export declare interface LiveClientSetup {
|
|
|
2253
2435
|
/** The user provided system instructions for the model.
|
|
2254
2436
|
Note: only text should be used in parts and content in each part will be
|
|
2255
2437
|
in a separate paragraph. */
|
|
2256
|
-
systemInstruction?:
|
|
2438
|
+
systemInstruction?: ContentUnion;
|
|
2257
2439
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2258
2440
|
|
|
2259
2441
|
A `Tool` is a piece of code that enables the system to interact with
|
|
@@ -2270,6 +2452,13 @@ export declare interface LiveClientSetup {
|
|
|
2270
2452
|
|
|
2271
2453
|
If included, server will compress context window to fit into given length. */
|
|
2272
2454
|
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2455
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2456
|
+
*/
|
|
2457
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2458
|
+
/** The transcription of the output aligns with the language code
|
|
2459
|
+
specified for the output audio.
|
|
2460
|
+
*/
|
|
2461
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2273
2462
|
}
|
|
2274
2463
|
|
|
2275
2464
|
/** Client generated response to a `ToolCall` received from the server.
|
|
@@ -2295,13 +2484,42 @@ export declare interface LiveConnectConfig {
|
|
|
2295
2484
|
modalities that the model can return. Defaults to AUDIO if not specified.
|
|
2296
2485
|
*/
|
|
2297
2486
|
responseModalities?: Modality[];
|
|
2487
|
+
/** Value that controls the degree of randomness in token selection.
|
|
2488
|
+
Lower temperatures are good for prompts that require a less open-ended or
|
|
2489
|
+
creative response, while higher temperatures can lead to more diverse or
|
|
2490
|
+
creative results.
|
|
2491
|
+
*/
|
|
2492
|
+
temperature?: number;
|
|
2493
|
+
/** Tokens are selected from the most to least probable until the sum
|
|
2494
|
+
of their probabilities equals this value. Use a lower value for less
|
|
2495
|
+
random responses and a higher value for more random responses.
|
|
2496
|
+
*/
|
|
2497
|
+
topP?: number;
|
|
2498
|
+
/** For each token selection step, the ``top_k`` tokens with the
|
|
2499
|
+
highest probabilities are sampled. Then tokens are further filtered based
|
|
2500
|
+
on ``top_p`` with the final token selected using temperature sampling. Use
|
|
2501
|
+
a lower number for less random responses and a higher number for more
|
|
2502
|
+
random responses.
|
|
2503
|
+
*/
|
|
2504
|
+
topK?: number;
|
|
2505
|
+
/** Maximum number of tokens that can be generated in the response.
|
|
2506
|
+
*/
|
|
2507
|
+
maxOutputTokens?: number;
|
|
2508
|
+
/** If specified, the media resolution specified will be used.
|
|
2509
|
+
*/
|
|
2510
|
+
mediaResolution?: MediaResolution;
|
|
2511
|
+
/** When ``seed`` is fixed to a specific number, the model makes a best
|
|
2512
|
+
effort to provide the same response for repeated requests. By default, a
|
|
2513
|
+
random number is used.
|
|
2514
|
+
*/
|
|
2515
|
+
seed?: number;
|
|
2298
2516
|
/** The speech generation configuration.
|
|
2299
2517
|
*/
|
|
2300
2518
|
speechConfig?: SpeechConfig;
|
|
2301
2519
|
/** The user provided system instructions for the model.
|
|
2302
2520
|
Note: only text should be used in parts and content in each part will be
|
|
2303
2521
|
in a separate paragraph. */
|
|
2304
|
-
systemInstruction?:
|
|
2522
|
+
systemInstruction?: ContentUnion;
|
|
2305
2523
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2306
2524
|
|
|
2307
2525
|
A `Tool` is a piece of code that enables the system to interact with
|
|
@@ -2312,6 +2530,13 @@ export declare interface LiveConnectConfig {
|
|
|
2312
2530
|
|
|
2313
2531
|
If included the server will send SessionResumptionUpdate messages. */
|
|
2314
2532
|
sessionResumption?: SessionResumptionConfig;
|
|
2533
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2534
|
+
*/
|
|
2535
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2536
|
+
/** The transcription of the output aligns with the language code
|
|
2537
|
+
specified for the output audio.
|
|
2538
|
+
*/
|
|
2539
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2315
2540
|
/** Configures the realtime input behavior in BidiGenerateContent. */
|
|
2316
2541
|
realtimeInputConfig?: RealtimeInputConfig;
|
|
2317
2542
|
/** Configures context window compression mechanism.
|
|
@@ -2345,7 +2570,23 @@ export declare interface LiveSendClientContentParameters {
|
|
|
2345
2570
|
/** Parameters for sending realtime input to the live API. */
|
|
2346
2571
|
export declare interface LiveSendRealtimeInputParameters {
|
|
2347
2572
|
/** Realtime input to send to the session. */
|
|
2348
|
-
media
|
|
2573
|
+
media?: BlobImageUnion;
|
|
2574
|
+
/** The realtime audio input stream. */
|
|
2575
|
+
audio?: Blob_2;
|
|
2576
|
+
/**
|
|
2577
|
+
Indicates that the audio stream has ended, e.g. because the microphone was
|
|
2578
|
+
turned off.
|
|
2579
|
+
|
|
2580
|
+
This should only be sent when automatic activity detection is enabled
|
|
2581
|
+
(which is the default).
|
|
2582
|
+
|
|
2583
|
+
The client can reopen the stream by sending an audio message.
|
|
2584
|
+
*/
|
|
2585
|
+
audioStreamEnd?: boolean;
|
|
2586
|
+
/** The realtime video input stream. */
|
|
2587
|
+
video?: BlobImageUnion;
|
|
2588
|
+
/** The realtime text input stream. */
|
|
2589
|
+
text?: string;
|
|
2349
2590
|
/** Marks the start of user activity. */
|
|
2350
2591
|
activityStart?: ActivityStart;
|
|
2351
2592
|
/** Marks the end of user activity. */
|
|
@@ -2379,6 +2620,15 @@ export declare interface LiveServerContent {
|
|
|
2379
2620
|
has finished generating all content. This is a signal to the client
|
|
2380
2621
|
that it can stop sending messages. */
|
|
2381
2622
|
generationComplete?: boolean;
|
|
2623
|
+
/** Input transcription. The transcription is independent to the model
|
|
2624
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2625
|
+
model turn. */
|
|
2626
|
+
inputTranscription?: Transcription;
|
|
2627
|
+
/** Output transcription. The transcription is independent to the model
|
|
2628
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2629
|
+
model turn.
|
|
2630
|
+
*/
|
|
2631
|
+
outputTranscription?: Transcription;
|
|
2382
2632
|
}
|
|
2383
2633
|
|
|
2384
2634
|
/** Server will not be able to service client soon. */
|
|
@@ -2799,6 +3049,12 @@ export declare class Models extends BaseModule {
|
|
|
2799
3049
|
generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
|
|
2800
3050
|
}
|
|
2801
3051
|
|
|
3052
|
+
/** Config for model selection. */
|
|
3053
|
+
export declare interface ModelSelectionConfig {
|
|
3054
|
+
/** Options for feature selection preference. */
|
|
3055
|
+
featureSelectionPreference?: FeatureSelectionPreference;
|
|
3056
|
+
}
|
|
3057
|
+
|
|
2802
3058
|
/** Parameters for the get method of the operations module. */
|
|
2803
3059
|
export declare interface OperationGetParameters {
|
|
2804
3060
|
/** The operation to be retrieved. */
|
|
@@ -3006,6 +3262,54 @@ export declare interface PrebuiltVoiceConfig {
|
|
|
3006
3262
|
voiceName?: string;
|
|
3007
3263
|
}
|
|
3008
3264
|
|
|
3265
|
+
/** Specifies the context retrieval config. */
|
|
3266
|
+
export declare interface RagRetrievalConfig {
|
|
3267
|
+
/** Optional. Config for filters. */
|
|
3268
|
+
filter?: RagRetrievalConfigFilter;
|
|
3269
|
+
/** Optional. Config for Hybrid Search. */
|
|
3270
|
+
hybridSearch?: RagRetrievalConfigHybridSearch;
|
|
3271
|
+
/** Optional. Config for ranking and reranking. */
|
|
3272
|
+
ranking?: RagRetrievalConfigRanking;
|
|
3273
|
+
/** Optional. The number of contexts to retrieve. */
|
|
3274
|
+
topK?: number;
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
/** Config for filters. */
|
|
3278
|
+
export declare interface RagRetrievalConfigFilter {
|
|
3279
|
+
/** Optional. String for metadata filtering. */
|
|
3280
|
+
metadataFilter?: string;
|
|
3281
|
+
/** Optional. Only returns contexts with vector distance smaller than the threshold. */
|
|
3282
|
+
vectorDistanceThreshold?: number;
|
|
3283
|
+
/** Optional. Only returns contexts with vector similarity larger than the threshold. */
|
|
3284
|
+
vectorSimilarityThreshold?: number;
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
/** Config for Hybrid Search. */
|
|
3288
|
+
export declare interface RagRetrievalConfigHybridSearch {
|
|
3289
|
+
/** 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. */
|
|
3290
|
+
alpha?: number;
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3293
|
+
/** Config for ranking and reranking. */
|
|
3294
|
+
export declare interface RagRetrievalConfigRanking {
|
|
3295
|
+
/** Optional. Config for LlmRanker. */
|
|
3296
|
+
llmRanker?: RagRetrievalConfigRankingLlmRanker;
|
|
3297
|
+
/** Optional. Config for Rank Service. */
|
|
3298
|
+
rankService?: RagRetrievalConfigRankingRankService;
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3301
|
+
/** Config for LlmRanker. */
|
|
3302
|
+
export declare interface RagRetrievalConfigRankingLlmRanker {
|
|
3303
|
+
/** Optional. The model name used for ranking. Format: `gemini-1.5-pro` */
|
|
3304
|
+
modelName?: string;
|
|
3305
|
+
}
|
|
3306
|
+
|
|
3307
|
+
/** Config for Rank Service. */
|
|
3308
|
+
export declare interface RagRetrievalConfigRankingRankService {
|
|
3309
|
+
/** Optional. The model name of the rank service. Format: `semantic-ranker-512@latest` */
|
|
3310
|
+
modelName?: string;
|
|
3311
|
+
}
|
|
3312
|
+
|
|
3009
3313
|
/** A raw reference image.
|
|
3010
3314
|
|
|
3011
3315
|
A raw reference image represents the base image to edit, provided by the user.
|
|
@@ -3231,7 +3535,6 @@ export declare class Session {
|
|
|
3231
3535
|
private readonly apiClient;
|
|
3232
3536
|
constructor(conn: WebSocket_2, apiClient: ApiClient);
|
|
3233
3537
|
private tLiveClientContent;
|
|
3234
|
-
private tLiveClientRealtimeInput;
|
|
3235
3538
|
private tLiveClienttToolResponse;
|
|
3236
3539
|
/**
|
|
3237
3540
|
Send a message over the established connection.
|
|
@@ -3328,8 +3631,14 @@ export declare class Session {
|
|
|
3328
3631
|
|
|
3329
3632
|
@example
|
|
3330
3633
|
```ts
|
|
3634
|
+
let model: string;
|
|
3635
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
3636
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
3637
|
+
} else {
|
|
3638
|
+
model = 'gemini-2.0-flash-live-001';
|
|
3639
|
+
}
|
|
3331
3640
|
const session = await ai.live.connect({
|
|
3332
|
-
model:
|
|
3641
|
+
model: model,
|
|
3333
3642
|
config: {
|
|
3334
3643
|
responseModalities: [Modality.AUDIO],
|
|
3335
3644
|
}
|
|
@@ -3355,6 +3664,28 @@ export declare interface SessionResumptionConfig {
|
|
|
3355
3664
|
transparent?: boolean;
|
|
3356
3665
|
}
|
|
3357
3666
|
|
|
3667
|
+
/**
|
|
3668
|
+
* Overrides the base URLs for the Gemini API and Vertex AI API.
|
|
3669
|
+
*
|
|
3670
|
+
* @remarks This function should be called before initializing the SDK. If the
|
|
3671
|
+
* base URLs are set after initializing the SDK, the base URLs will not be
|
|
3672
|
+
* updated. Base URLs provided in the HttpOptions will also take precedence over
|
|
3673
|
+
* URLs set here.
|
|
3674
|
+
*
|
|
3675
|
+
* @example
|
|
3676
|
+
* ```ts
|
|
3677
|
+
* import {GoogleGenAI, setDefaultBaseUrls} from '@google/genai';
|
|
3678
|
+
* // Override the base URL for the Gemini API.
|
|
3679
|
+
* setDefaultBaseUrls({geminiUrl:'https://gemini.google.com'});
|
|
3680
|
+
*
|
|
3681
|
+
* // Override the base URL for the Vertex AI API.
|
|
3682
|
+
* setDefaultBaseUrls({vertexUrl: 'https://vertexai.googleapis.com'});
|
|
3683
|
+
*
|
|
3684
|
+
* const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
|
|
3685
|
+
* ```
|
|
3686
|
+
*/
|
|
3687
|
+
export declare function setDefaultBaseUrls(baseUrlParams: BaseUrlParameters): void;
|
|
3688
|
+
|
|
3358
3689
|
/** Context window will be truncated by keeping only suffix of it.
|
|
3359
3690
|
|
|
3360
3691
|
Context window will always be cut at start of USER role turn. System
|
|
@@ -3372,6 +3703,10 @@ export declare interface SpeechConfig {
|
|
|
3372
3703
|
/** The configuration for the speaker to use.
|
|
3373
3704
|
*/
|
|
3374
3705
|
voiceConfig?: VoiceConfig;
|
|
3706
|
+
/** Language code (ISO 639. e.g. en-US) for the speech synthesization.
|
|
3707
|
+
Only available for Live API.
|
|
3708
|
+
*/
|
|
3709
|
+
languageCode?: string;
|
|
3375
3710
|
}
|
|
3376
3711
|
|
|
3377
3712
|
export declare type SpeechConfigUnion = SpeechConfig | string;
|
|
@@ -3526,6 +3861,16 @@ export declare enum TrafficType {
|
|
|
3526
3861
|
PROVISIONED_THROUGHPUT = "PROVISIONED_THROUGHPUT"
|
|
3527
3862
|
}
|
|
3528
3863
|
|
|
3864
|
+
/** Audio transcription in Server Conent. */
|
|
3865
|
+
export declare interface Transcription {
|
|
3866
|
+
/** Transcription text.
|
|
3867
|
+
*/
|
|
3868
|
+
text?: string;
|
|
3869
|
+
/** The bool indicates the end of the transcription.
|
|
3870
|
+
*/
|
|
3871
|
+
finished?: boolean;
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3529
3874
|
/** A tuned machine learning model. */
|
|
3530
3875
|
export declare interface TunedModelInfo {
|
|
3531
3876
|
/** ID of the base model that you want to tune. */
|
|
@@ -3579,6 +3924,7 @@ declare namespace types {
|
|
|
3579
3924
|
TrafficType,
|
|
3580
3925
|
Modality,
|
|
3581
3926
|
MediaResolution,
|
|
3927
|
+
FeatureSelectionPreference,
|
|
3582
3928
|
DynamicRetrievalConfigMode,
|
|
3583
3929
|
FunctionCallingConfigMode,
|
|
3584
3930
|
SafetyFilterLevel,
|
|
@@ -3605,6 +3951,7 @@ declare namespace types {
|
|
|
3605
3951
|
Content,
|
|
3606
3952
|
HttpOptions,
|
|
3607
3953
|
Schema,
|
|
3954
|
+
ModelSelectionConfig,
|
|
3608
3955
|
SafetySetting,
|
|
3609
3956
|
FunctionDeclaration,
|
|
3610
3957
|
GoogleSearch,
|
|
@@ -3612,6 +3959,12 @@ declare namespace types {
|
|
|
3612
3959
|
GoogleSearchRetrieval,
|
|
3613
3960
|
VertexAISearch,
|
|
3614
3961
|
VertexRagStoreRagResource,
|
|
3962
|
+
RagRetrievalConfigFilter,
|
|
3963
|
+
RagRetrievalConfigHybridSearch,
|
|
3964
|
+
RagRetrievalConfigRankingLlmRanker,
|
|
3965
|
+
RagRetrievalConfigRankingRankService,
|
|
3966
|
+
RagRetrievalConfigRanking,
|
|
3967
|
+
RagRetrievalConfig,
|
|
3615
3968
|
VertexRagStore,
|
|
3616
3969
|
Retrieval,
|
|
3617
3970
|
ToolCodeExecution,
|
|
@@ -3732,6 +4085,7 @@ declare namespace types {
|
|
|
3732
4085
|
SubjectReferenceConfig,
|
|
3733
4086
|
SubjectReferenceImage,
|
|
3734
4087
|
LiveServerSetupComplete,
|
|
4088
|
+
Transcription,
|
|
3735
4089
|
LiveServerContent,
|
|
3736
4090
|
LiveServerToolCall,
|
|
3737
4091
|
LiveServerToolCallCancellation,
|
|
@@ -3744,6 +4098,7 @@ declare namespace types {
|
|
|
3744
4098
|
SessionResumptionConfig,
|
|
3745
4099
|
SlidingWindow,
|
|
3746
4100
|
ContextWindowCompressionConfig,
|
|
4101
|
+
AudioTranscriptionConfig,
|
|
3747
4102
|
LiveClientSetup,
|
|
3748
4103
|
LiveClientContent,
|
|
3749
4104
|
ActivityStart,
|
|
@@ -3751,7 +4106,6 @@ declare namespace types {
|
|
|
3751
4106
|
LiveClientRealtimeInput,
|
|
3752
4107
|
LiveClientToolResponse,
|
|
3753
4108
|
LiveClientMessage,
|
|
3754
|
-
AudioTranscriptionConfig,
|
|
3755
4109
|
LiveConnectConfig,
|
|
3756
4110
|
LiveConnectParameters,
|
|
3757
4111
|
CreateChatParameters,
|
|
@@ -3760,6 +4114,7 @@ declare namespace types {
|
|
|
3760
4114
|
LiveSendRealtimeInputParameters,
|
|
3761
4115
|
LiveSendToolResponseParameters,
|
|
3762
4116
|
OperationGetParameters,
|
|
4117
|
+
BlobImageUnion,
|
|
3763
4118
|
PartUnion,
|
|
3764
4119
|
PartListUnion,
|
|
3765
4120
|
ContentUnion,
|
|
@@ -3774,6 +4129,13 @@ declare namespace types {
|
|
|
3774
4129
|
export declare interface UpdateCachedContentConfig {
|
|
3775
4130
|
/** Used to override HTTP request options. */
|
|
3776
4131
|
httpOptions?: HttpOptions;
|
|
4132
|
+
/** Abort signal which can be used to cancel the request.
|
|
4133
|
+
|
|
4134
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
4135
|
+
operation will not cancel the request in the service. You will still
|
|
4136
|
+
be charged usage for any applicable operations.
|
|
4137
|
+
*/
|
|
4138
|
+
abortSignal?: AbortSignal;
|
|
3777
4139
|
/** 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". */
|
|
3778
4140
|
ttl?: string;
|
|
3779
4141
|
/** Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z. */
|
|
@@ -3816,6 +4178,13 @@ declare interface Uploader {
|
|
|
3816
4178
|
export declare interface UploadFileConfig {
|
|
3817
4179
|
/** Used to override HTTP request options. */
|
|
3818
4180
|
httpOptions?: HttpOptions;
|
|
4181
|
+
/** Abort signal which can be used to cancel the request.
|
|
4182
|
+
|
|
4183
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
4184
|
+
operation will not cancel the request in the service. You will still
|
|
4185
|
+
be charged usage for any applicable operations.
|
|
4186
|
+
*/
|
|
4187
|
+
abortSignal?: AbortSignal;
|
|
3819
4188
|
/** The name of the file in the destination (e.g., 'files/sample-image'. If not provided one will be generated. */
|
|
3820
4189
|
name?: string;
|
|
3821
4190
|
/** mime_type: The MIME type of the file. If not provided, it will be inferred from the file extension. */
|
|
@@ -3841,6 +4210,13 @@ export declare interface UploadFileParameters {
|
|
|
3841
4210
|
export declare interface UpscaleImageConfig {
|
|
3842
4211
|
/** Used to override HTTP request options. */
|
|
3843
4212
|
httpOptions?: HttpOptions;
|
|
4213
|
+
/** Abort signal which can be used to cancel the request.
|
|
4214
|
+
|
|
4215
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
4216
|
+
operation will not cancel the request in the service. You will still
|
|
4217
|
+
be charged usage for any applicable operations.
|
|
4218
|
+
*/
|
|
4219
|
+
abortSignal?: AbortSignal;
|
|
3844
4220
|
/** Whether to include a reason for filtered-out images in the
|
|
3845
4221
|
response. */
|
|
3846
4222
|
includeRaiReason?: boolean;
|
|
@@ -3904,6 +4280,8 @@ export declare interface VertexRagStore {
|
|
|
3904
4280
|
ragCorpora?: string[];
|
|
3905
4281
|
/** 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. */
|
|
3906
4282
|
ragResources?: VertexRagStoreRagResource[];
|
|
4283
|
+
/** Optional. The retrieval config for the Rag query. */
|
|
4284
|
+
ragRetrievalConfig?: RagRetrievalConfig;
|
|
3907
4285
|
/** Optional. Number of top k results to return from the selected corpora. */
|
|
3908
4286
|
similarityTopK?: number;
|
|
3909
4287
|
/** Optional. Only return results with vector distance smaller than the threshold. */
|