@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/web/web.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. */
|
|
@@ -2027,6 +2172,10 @@ declare interface HttpRequest {
|
|
|
2027
2172
|
* Optional set of customizable configuration for HTTP requests.
|
|
2028
2173
|
*/
|
|
2029
2174
|
httpOptions?: HttpOptions;
|
|
2175
|
+
/**
|
|
2176
|
+
* Optional abort signal which can be used to cancel the request.
|
|
2177
|
+
*/
|
|
2178
|
+
abortSignal?: AbortSignal;
|
|
2030
2179
|
}
|
|
2031
2180
|
|
|
2032
2181
|
/** A wrapper class for the http response. */
|
|
@@ -2075,6 +2224,13 @@ export declare enum Language {
|
|
|
2075
2224
|
export declare interface ListCachedContentsConfig {
|
|
2076
2225
|
/** Used to override HTTP request options. */
|
|
2077
2226
|
httpOptions?: HttpOptions;
|
|
2227
|
+
/** Abort signal which can be used to cancel the request.
|
|
2228
|
+
|
|
2229
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
2230
|
+
operation will not cancel the request in the service. You will still
|
|
2231
|
+
be charged usage for any applicable operations.
|
|
2232
|
+
*/
|
|
2233
|
+
abortSignal?: AbortSignal;
|
|
2078
2234
|
pageSize?: number;
|
|
2079
2235
|
pageToken?: string;
|
|
2080
2236
|
}
|
|
@@ -2097,6 +2253,13 @@ export declare class ListCachedContentsResponse {
|
|
|
2097
2253
|
export declare interface ListFilesConfig {
|
|
2098
2254
|
/** Used to override HTTP request options. */
|
|
2099
2255
|
httpOptions?: HttpOptions;
|
|
2256
|
+
/** Abort signal which can be used to cancel the request.
|
|
2257
|
+
|
|
2258
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
2259
|
+
operation will not cancel the request in the service. You will still
|
|
2260
|
+
be charged usage for any applicable operations.
|
|
2261
|
+
*/
|
|
2262
|
+
abortSignal?: AbortSignal;
|
|
2100
2263
|
pageSize?: number;
|
|
2101
2264
|
pageToken?: string;
|
|
2102
2265
|
}
|
|
@@ -2133,17 +2296,20 @@ export declare class Live {
|
|
|
2133
2296
|
@experimental
|
|
2134
2297
|
|
|
2135
2298
|
@remarks
|
|
2136
|
-
If using the Gemini API, Live is currently only supported behind API
|
|
2137
|
-
version `v1alpha`. Ensure that the API version is set to `v1alpha` when
|
|
2138
|
-
initializing the SDK if relying on the Gemini API.
|
|
2139
2299
|
|
|
2140
2300
|
@param params - The parameters for establishing a connection to the model.
|
|
2141
2301
|
@return A live session.
|
|
2142
2302
|
|
|
2143
2303
|
@example
|
|
2144
2304
|
```ts
|
|
2305
|
+
let model: string;
|
|
2306
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
2307
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
2308
|
+
} else {
|
|
2309
|
+
model = 'gemini-2.0-flash-live-001';
|
|
2310
|
+
}
|
|
2145
2311
|
const session = await ai.live.connect({
|
|
2146
|
-
model:
|
|
2312
|
+
model: model,
|
|
2147
2313
|
config: {
|
|
2148
2314
|
responseModalities: [Modality.AUDIO],
|
|
2149
2315
|
},
|
|
@@ -2238,6 +2404,22 @@ export declare interface LiveClientMessage {
|
|
|
2238
2404
|
export declare interface LiveClientRealtimeInput {
|
|
2239
2405
|
/** Inlined bytes data for media input. */
|
|
2240
2406
|
mediaChunks?: Blob_2[];
|
|
2407
|
+
/** The realtime audio input stream. */
|
|
2408
|
+
audio?: Blob_2;
|
|
2409
|
+
/**
|
|
2410
|
+
Indicates that the audio stream has ended, e.g. because the microphone was
|
|
2411
|
+
turned off.
|
|
2412
|
+
|
|
2413
|
+
This should only be sent when automatic activity detection is enabled
|
|
2414
|
+
(which is the default).
|
|
2415
|
+
|
|
2416
|
+
The client can reopen the stream by sending an audio message.
|
|
2417
|
+
*/
|
|
2418
|
+
audioStreamEnd?: boolean;
|
|
2419
|
+
/** The realtime video input stream. */
|
|
2420
|
+
video?: Blob_2;
|
|
2421
|
+
/** The realtime text input stream. */
|
|
2422
|
+
text?: string;
|
|
2241
2423
|
/** Marks the start of user activity. */
|
|
2242
2424
|
activityStart?: ActivityStart;
|
|
2243
2425
|
/** Marks the end of user activity. */
|
|
@@ -2258,7 +2440,7 @@ export declare interface LiveClientSetup {
|
|
|
2258
2440
|
/** The user provided system instructions for the model.
|
|
2259
2441
|
Note: only text should be used in parts and content in each part will be
|
|
2260
2442
|
in a separate paragraph. */
|
|
2261
|
-
systemInstruction?:
|
|
2443
|
+
systemInstruction?: ContentUnion;
|
|
2262
2444
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2263
2445
|
|
|
2264
2446
|
A `Tool` is a piece of code that enables the system to interact with
|
|
@@ -2275,6 +2457,13 @@ export declare interface LiveClientSetup {
|
|
|
2275
2457
|
|
|
2276
2458
|
If included, server will compress context window to fit into given length. */
|
|
2277
2459
|
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2460
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2461
|
+
*/
|
|
2462
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2463
|
+
/** The transcription of the output aligns with the language code
|
|
2464
|
+
specified for the output audio.
|
|
2465
|
+
*/
|
|
2466
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2278
2467
|
}
|
|
2279
2468
|
|
|
2280
2469
|
/** Client generated response to a `ToolCall` received from the server.
|
|
@@ -2300,13 +2489,42 @@ export declare interface LiveConnectConfig {
|
|
|
2300
2489
|
modalities that the model can return. Defaults to AUDIO if not specified.
|
|
2301
2490
|
*/
|
|
2302
2491
|
responseModalities?: Modality[];
|
|
2492
|
+
/** Value that controls the degree of randomness in token selection.
|
|
2493
|
+
Lower temperatures are good for prompts that require a less open-ended or
|
|
2494
|
+
creative response, while higher temperatures can lead to more diverse or
|
|
2495
|
+
creative results.
|
|
2496
|
+
*/
|
|
2497
|
+
temperature?: number;
|
|
2498
|
+
/** Tokens are selected from the most to least probable until the sum
|
|
2499
|
+
of their probabilities equals this value. Use a lower value for less
|
|
2500
|
+
random responses and a higher value for more random responses.
|
|
2501
|
+
*/
|
|
2502
|
+
topP?: number;
|
|
2503
|
+
/** For each token selection step, the ``top_k`` tokens with the
|
|
2504
|
+
highest probabilities are sampled. Then tokens are further filtered based
|
|
2505
|
+
on ``top_p`` with the final token selected using temperature sampling. Use
|
|
2506
|
+
a lower number for less random responses and a higher number for more
|
|
2507
|
+
random responses.
|
|
2508
|
+
*/
|
|
2509
|
+
topK?: number;
|
|
2510
|
+
/** Maximum number of tokens that can be generated in the response.
|
|
2511
|
+
*/
|
|
2512
|
+
maxOutputTokens?: number;
|
|
2513
|
+
/** If specified, the media resolution specified will be used.
|
|
2514
|
+
*/
|
|
2515
|
+
mediaResolution?: MediaResolution;
|
|
2516
|
+
/** When ``seed`` is fixed to a specific number, the model makes a best
|
|
2517
|
+
effort to provide the same response for repeated requests. By default, a
|
|
2518
|
+
random number is used.
|
|
2519
|
+
*/
|
|
2520
|
+
seed?: number;
|
|
2303
2521
|
/** The speech generation configuration.
|
|
2304
2522
|
*/
|
|
2305
2523
|
speechConfig?: SpeechConfig;
|
|
2306
2524
|
/** The user provided system instructions for the model.
|
|
2307
2525
|
Note: only text should be used in parts and content in each part will be
|
|
2308
2526
|
in a separate paragraph. */
|
|
2309
|
-
systemInstruction?:
|
|
2527
|
+
systemInstruction?: ContentUnion;
|
|
2310
2528
|
/** A list of `Tools` the model may use to generate the next response.
|
|
2311
2529
|
|
|
2312
2530
|
A `Tool` is a piece of code that enables the system to interact with
|
|
@@ -2317,6 +2535,13 @@ export declare interface LiveConnectConfig {
|
|
|
2317
2535
|
|
|
2318
2536
|
If included the server will send SessionResumptionUpdate messages. */
|
|
2319
2537
|
sessionResumption?: SessionResumptionConfig;
|
|
2538
|
+
/** The transcription of the input aligns with the input audio language.
|
|
2539
|
+
*/
|
|
2540
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2541
|
+
/** The transcription of the output aligns with the language code
|
|
2542
|
+
specified for the output audio.
|
|
2543
|
+
*/
|
|
2544
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2320
2545
|
/** Configures the realtime input behavior in BidiGenerateContent. */
|
|
2321
2546
|
realtimeInputConfig?: RealtimeInputConfig;
|
|
2322
2547
|
/** Configures context window compression mechanism.
|
|
@@ -2350,7 +2575,23 @@ export declare interface LiveSendClientContentParameters {
|
|
|
2350
2575
|
/** Parameters for sending realtime input to the live API. */
|
|
2351
2576
|
export declare interface LiveSendRealtimeInputParameters {
|
|
2352
2577
|
/** Realtime input to send to the session. */
|
|
2353
|
-
media
|
|
2578
|
+
media?: BlobImageUnion;
|
|
2579
|
+
/** The realtime audio input stream. */
|
|
2580
|
+
audio?: Blob_2;
|
|
2581
|
+
/**
|
|
2582
|
+
Indicates that the audio stream has ended, e.g. because the microphone was
|
|
2583
|
+
turned off.
|
|
2584
|
+
|
|
2585
|
+
This should only be sent when automatic activity detection is enabled
|
|
2586
|
+
(which is the default).
|
|
2587
|
+
|
|
2588
|
+
The client can reopen the stream by sending an audio message.
|
|
2589
|
+
*/
|
|
2590
|
+
audioStreamEnd?: boolean;
|
|
2591
|
+
/** The realtime video input stream. */
|
|
2592
|
+
video?: BlobImageUnion;
|
|
2593
|
+
/** The realtime text input stream. */
|
|
2594
|
+
text?: string;
|
|
2354
2595
|
/** Marks the start of user activity. */
|
|
2355
2596
|
activityStart?: ActivityStart;
|
|
2356
2597
|
/** Marks the end of user activity. */
|
|
@@ -2384,6 +2625,15 @@ export declare interface LiveServerContent {
|
|
|
2384
2625
|
has finished generating all content. This is a signal to the client
|
|
2385
2626
|
that it can stop sending messages. */
|
|
2386
2627
|
generationComplete?: boolean;
|
|
2628
|
+
/** Input transcription. The transcription is independent to the model
|
|
2629
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2630
|
+
model turn. */
|
|
2631
|
+
inputTranscription?: Transcription;
|
|
2632
|
+
/** Output transcription. The transcription is independent to the model
|
|
2633
|
+
turn which means it doesn’t imply any ordering between transcription and
|
|
2634
|
+
model turn.
|
|
2635
|
+
*/
|
|
2636
|
+
outputTranscription?: Transcription;
|
|
2387
2637
|
}
|
|
2388
2638
|
|
|
2389
2639
|
/** Server will not be able to service client soon. */
|
|
@@ -2804,6 +3054,12 @@ export declare class Models extends BaseModule {
|
|
|
2804
3054
|
generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
|
|
2805
3055
|
}
|
|
2806
3056
|
|
|
3057
|
+
/** Config for model selection. */
|
|
3058
|
+
export declare interface ModelSelectionConfig {
|
|
3059
|
+
/** Options for feature selection preference. */
|
|
3060
|
+
featureSelectionPreference?: FeatureSelectionPreference;
|
|
3061
|
+
}
|
|
3062
|
+
|
|
2807
3063
|
/** Parameters for the get method of the operations module. */
|
|
2808
3064
|
export declare interface OperationGetParameters {
|
|
2809
3065
|
/** The operation to be retrieved. */
|
|
@@ -3011,6 +3267,54 @@ export declare interface PrebuiltVoiceConfig {
|
|
|
3011
3267
|
voiceName?: string;
|
|
3012
3268
|
}
|
|
3013
3269
|
|
|
3270
|
+
/** Specifies the context retrieval config. */
|
|
3271
|
+
export declare interface RagRetrievalConfig {
|
|
3272
|
+
/** Optional. Config for filters. */
|
|
3273
|
+
filter?: RagRetrievalConfigFilter;
|
|
3274
|
+
/** Optional. Config for Hybrid Search. */
|
|
3275
|
+
hybridSearch?: RagRetrievalConfigHybridSearch;
|
|
3276
|
+
/** Optional. Config for ranking and reranking. */
|
|
3277
|
+
ranking?: RagRetrievalConfigRanking;
|
|
3278
|
+
/** Optional. The number of contexts to retrieve. */
|
|
3279
|
+
topK?: number;
|
|
3280
|
+
}
|
|
3281
|
+
|
|
3282
|
+
/** Config for filters. */
|
|
3283
|
+
export declare interface RagRetrievalConfigFilter {
|
|
3284
|
+
/** Optional. String for metadata filtering. */
|
|
3285
|
+
metadataFilter?: string;
|
|
3286
|
+
/** Optional. Only returns contexts with vector distance smaller than the threshold. */
|
|
3287
|
+
vectorDistanceThreshold?: number;
|
|
3288
|
+
/** Optional. Only returns contexts with vector similarity larger than the threshold. */
|
|
3289
|
+
vectorSimilarityThreshold?: number;
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
/** Config for Hybrid Search. */
|
|
3293
|
+
export declare interface RagRetrievalConfigHybridSearch {
|
|
3294
|
+
/** 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. */
|
|
3295
|
+
alpha?: number;
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
/** Config for ranking and reranking. */
|
|
3299
|
+
export declare interface RagRetrievalConfigRanking {
|
|
3300
|
+
/** Optional. Config for LlmRanker. */
|
|
3301
|
+
llmRanker?: RagRetrievalConfigRankingLlmRanker;
|
|
3302
|
+
/** Optional. Config for Rank Service. */
|
|
3303
|
+
rankService?: RagRetrievalConfigRankingRankService;
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
/** Config for LlmRanker. */
|
|
3307
|
+
export declare interface RagRetrievalConfigRankingLlmRanker {
|
|
3308
|
+
/** Optional. The model name used for ranking. Format: `gemini-1.5-pro` */
|
|
3309
|
+
modelName?: string;
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
/** Config for Rank Service. */
|
|
3313
|
+
export declare interface RagRetrievalConfigRankingRankService {
|
|
3314
|
+
/** Optional. The model name of the rank service. Format: `semantic-ranker-512@latest` */
|
|
3315
|
+
modelName?: string;
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3014
3318
|
/** A raw reference image.
|
|
3015
3319
|
|
|
3016
3320
|
A raw reference image represents the base image to edit, provided by the user.
|
|
@@ -3236,7 +3540,6 @@ export declare class Session {
|
|
|
3236
3540
|
private readonly apiClient;
|
|
3237
3541
|
constructor(conn: WebSocket_2, apiClient: ApiClient);
|
|
3238
3542
|
private tLiveClientContent;
|
|
3239
|
-
private tLiveClientRealtimeInput;
|
|
3240
3543
|
private tLiveClienttToolResponse;
|
|
3241
3544
|
/**
|
|
3242
3545
|
Send a message over the established connection.
|
|
@@ -3333,8 +3636,14 @@ export declare class Session {
|
|
|
3333
3636
|
|
|
3334
3637
|
@example
|
|
3335
3638
|
```ts
|
|
3639
|
+
let model: string;
|
|
3640
|
+
if (GOOGLE_GENAI_USE_VERTEXAI) {
|
|
3641
|
+
model = 'gemini-2.0-flash-live-preview-04-09';
|
|
3642
|
+
} else {
|
|
3643
|
+
model = 'gemini-2.0-flash-live-001';
|
|
3644
|
+
}
|
|
3336
3645
|
const session = await ai.live.connect({
|
|
3337
|
-
model:
|
|
3646
|
+
model: model,
|
|
3338
3647
|
config: {
|
|
3339
3648
|
responseModalities: [Modality.AUDIO],
|
|
3340
3649
|
}
|
|
@@ -3360,6 +3669,28 @@ export declare interface SessionResumptionConfig {
|
|
|
3360
3669
|
transparent?: boolean;
|
|
3361
3670
|
}
|
|
3362
3671
|
|
|
3672
|
+
/**
|
|
3673
|
+
* Overrides the base URLs for the Gemini API and Vertex AI API.
|
|
3674
|
+
*
|
|
3675
|
+
* @remarks This function should be called before initializing the SDK. If the
|
|
3676
|
+
* base URLs are set after initializing the SDK, the base URLs will not be
|
|
3677
|
+
* updated. Base URLs provided in the HttpOptions will also take precedence over
|
|
3678
|
+
* URLs set here.
|
|
3679
|
+
*
|
|
3680
|
+
* @example
|
|
3681
|
+
* ```ts
|
|
3682
|
+
* import {GoogleGenAI, setDefaultBaseUrls} from '@google/genai';
|
|
3683
|
+
* // Override the base URL for the Gemini API.
|
|
3684
|
+
* setDefaultBaseUrls({geminiUrl:'https://gemini.google.com'});
|
|
3685
|
+
*
|
|
3686
|
+
* // Override the base URL for the Vertex AI API.
|
|
3687
|
+
* setDefaultBaseUrls({vertexUrl: 'https://vertexai.googleapis.com'});
|
|
3688
|
+
*
|
|
3689
|
+
* const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
|
|
3690
|
+
* ```
|
|
3691
|
+
*/
|
|
3692
|
+
export declare function setDefaultBaseUrls(baseUrlParams: BaseUrlParameters): void;
|
|
3693
|
+
|
|
3363
3694
|
/** Context window will be truncated by keeping only suffix of it.
|
|
3364
3695
|
|
|
3365
3696
|
Context window will always be cut at start of USER role turn. System
|
|
@@ -3377,6 +3708,10 @@ export declare interface SpeechConfig {
|
|
|
3377
3708
|
/** The configuration for the speaker to use.
|
|
3378
3709
|
*/
|
|
3379
3710
|
voiceConfig?: VoiceConfig;
|
|
3711
|
+
/** Language code (ISO 639. e.g. en-US) for the speech synthesization.
|
|
3712
|
+
Only available for Live API.
|
|
3713
|
+
*/
|
|
3714
|
+
languageCode?: string;
|
|
3380
3715
|
}
|
|
3381
3716
|
|
|
3382
3717
|
export declare type SpeechConfigUnion = SpeechConfig | string;
|
|
@@ -3531,6 +3866,16 @@ export declare enum TrafficType {
|
|
|
3531
3866
|
PROVISIONED_THROUGHPUT = "PROVISIONED_THROUGHPUT"
|
|
3532
3867
|
}
|
|
3533
3868
|
|
|
3869
|
+
/** Audio transcription in Server Conent. */
|
|
3870
|
+
export declare interface Transcription {
|
|
3871
|
+
/** Transcription text.
|
|
3872
|
+
*/
|
|
3873
|
+
text?: string;
|
|
3874
|
+
/** The bool indicates the end of the transcription.
|
|
3875
|
+
*/
|
|
3876
|
+
finished?: boolean;
|
|
3877
|
+
}
|
|
3878
|
+
|
|
3534
3879
|
/** A tuned machine learning model. */
|
|
3535
3880
|
export declare interface TunedModelInfo {
|
|
3536
3881
|
/** ID of the base model that you want to tune. */
|
|
@@ -3584,6 +3929,7 @@ declare namespace types {
|
|
|
3584
3929
|
TrafficType,
|
|
3585
3930
|
Modality,
|
|
3586
3931
|
MediaResolution,
|
|
3932
|
+
FeatureSelectionPreference,
|
|
3587
3933
|
DynamicRetrievalConfigMode,
|
|
3588
3934
|
FunctionCallingConfigMode,
|
|
3589
3935
|
SafetyFilterLevel,
|
|
@@ -3610,6 +3956,7 @@ declare namespace types {
|
|
|
3610
3956
|
Content,
|
|
3611
3957
|
HttpOptions,
|
|
3612
3958
|
Schema,
|
|
3959
|
+
ModelSelectionConfig,
|
|
3613
3960
|
SafetySetting,
|
|
3614
3961
|
FunctionDeclaration,
|
|
3615
3962
|
GoogleSearch,
|
|
@@ -3617,6 +3964,12 @@ declare namespace types {
|
|
|
3617
3964
|
GoogleSearchRetrieval,
|
|
3618
3965
|
VertexAISearch,
|
|
3619
3966
|
VertexRagStoreRagResource,
|
|
3967
|
+
RagRetrievalConfigFilter,
|
|
3968
|
+
RagRetrievalConfigHybridSearch,
|
|
3969
|
+
RagRetrievalConfigRankingLlmRanker,
|
|
3970
|
+
RagRetrievalConfigRankingRankService,
|
|
3971
|
+
RagRetrievalConfigRanking,
|
|
3972
|
+
RagRetrievalConfig,
|
|
3620
3973
|
VertexRagStore,
|
|
3621
3974
|
Retrieval,
|
|
3622
3975
|
ToolCodeExecution,
|
|
@@ -3737,6 +4090,7 @@ declare namespace types {
|
|
|
3737
4090
|
SubjectReferenceConfig,
|
|
3738
4091
|
SubjectReferenceImage,
|
|
3739
4092
|
LiveServerSetupComplete,
|
|
4093
|
+
Transcription,
|
|
3740
4094
|
LiveServerContent,
|
|
3741
4095
|
LiveServerToolCall,
|
|
3742
4096
|
LiveServerToolCallCancellation,
|
|
@@ -3749,6 +4103,7 @@ declare namespace types {
|
|
|
3749
4103
|
SessionResumptionConfig,
|
|
3750
4104
|
SlidingWindow,
|
|
3751
4105
|
ContextWindowCompressionConfig,
|
|
4106
|
+
AudioTranscriptionConfig,
|
|
3752
4107
|
LiveClientSetup,
|
|
3753
4108
|
LiveClientContent,
|
|
3754
4109
|
ActivityStart,
|
|
@@ -3756,7 +4111,6 @@ declare namespace types {
|
|
|
3756
4111
|
LiveClientRealtimeInput,
|
|
3757
4112
|
LiveClientToolResponse,
|
|
3758
4113
|
LiveClientMessage,
|
|
3759
|
-
AudioTranscriptionConfig,
|
|
3760
4114
|
LiveConnectConfig,
|
|
3761
4115
|
LiveConnectParameters,
|
|
3762
4116
|
CreateChatParameters,
|
|
@@ -3765,6 +4119,7 @@ declare namespace types {
|
|
|
3765
4119
|
LiveSendRealtimeInputParameters,
|
|
3766
4120
|
LiveSendToolResponseParameters,
|
|
3767
4121
|
OperationGetParameters,
|
|
4122
|
+
BlobImageUnion,
|
|
3768
4123
|
PartUnion,
|
|
3769
4124
|
PartListUnion,
|
|
3770
4125
|
ContentUnion,
|
|
@@ -3779,6 +4134,13 @@ declare namespace types {
|
|
|
3779
4134
|
export declare interface UpdateCachedContentConfig {
|
|
3780
4135
|
/** Used to override HTTP request options. */
|
|
3781
4136
|
httpOptions?: HttpOptions;
|
|
4137
|
+
/** Abort signal which can be used to cancel the request.
|
|
4138
|
+
|
|
4139
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
4140
|
+
operation will not cancel the request in the service. You will still
|
|
4141
|
+
be charged usage for any applicable operations.
|
|
4142
|
+
*/
|
|
4143
|
+
abortSignal?: AbortSignal;
|
|
3782
4144
|
/** 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". */
|
|
3783
4145
|
ttl?: string;
|
|
3784
4146
|
/** Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z. */
|
|
@@ -3821,6 +4183,13 @@ declare interface Uploader {
|
|
|
3821
4183
|
export declare interface UploadFileConfig {
|
|
3822
4184
|
/** Used to override HTTP request options. */
|
|
3823
4185
|
httpOptions?: HttpOptions;
|
|
4186
|
+
/** Abort signal which can be used to cancel the request.
|
|
4187
|
+
|
|
4188
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
4189
|
+
operation will not cancel the request in the service. You will still
|
|
4190
|
+
be charged usage for any applicable operations.
|
|
4191
|
+
*/
|
|
4192
|
+
abortSignal?: AbortSignal;
|
|
3824
4193
|
/** The name of the file in the destination (e.g., 'files/sample-image'. If not provided one will be generated. */
|
|
3825
4194
|
name?: string;
|
|
3826
4195
|
/** mime_type: The MIME type of the file. If not provided, it will be inferred from the file extension. */
|
|
@@ -3846,6 +4215,13 @@ export declare interface UploadFileParameters {
|
|
|
3846
4215
|
export declare interface UpscaleImageConfig {
|
|
3847
4216
|
/** Used to override HTTP request options. */
|
|
3848
4217
|
httpOptions?: HttpOptions;
|
|
4218
|
+
/** Abort signal which can be used to cancel the request.
|
|
4219
|
+
|
|
4220
|
+
NOTE: AbortSignal is a client-only operation. Using it to cancel an
|
|
4221
|
+
operation will not cancel the request in the service. You will still
|
|
4222
|
+
be charged usage for any applicable operations.
|
|
4223
|
+
*/
|
|
4224
|
+
abortSignal?: AbortSignal;
|
|
3849
4225
|
/** Whether to include a reason for filtered-out images in the
|
|
3850
4226
|
response. */
|
|
3851
4227
|
includeRaiReason?: boolean;
|
|
@@ -3909,6 +4285,8 @@ export declare interface VertexRagStore {
|
|
|
3909
4285
|
ragCorpora?: string[];
|
|
3910
4286
|
/** 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. */
|
|
3911
4287
|
ragResources?: VertexRagStoreRagResource[];
|
|
4288
|
+
/** Optional. The retrieval config for the Rag query. */
|
|
4289
|
+
ragRetrievalConfig?: RagRetrievalConfig;
|
|
3912
4290
|
/** Optional. Number of top k results to return from the selected corpora. */
|
|
3913
4291
|
similarityTopK?: number;
|
|
3914
4292
|
/** Optional. Only return results with vector distance smaller than the threshold. */
|