@google/genai 0.2.0 → 0.4.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 +1 -1
- package/dist/genai.d.ts +141 -83
- package/dist/index.js +201 -295
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +202 -295
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +209 -305
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +145 -89
- package/dist/web/index.mjs +207 -297
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +143 -85
- package/package.json +2 -1
package/dist/node/node.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ declare interface ApiClientInitOptions {
|
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* @license
|
|
102
|
-
* Copyright
|
|
102
|
+
* Copyright 2025 Google LLC
|
|
103
103
|
* SPDX-License-Identifier: Apache-2.0
|
|
104
104
|
*/
|
|
105
105
|
/**
|
|
@@ -114,11 +114,6 @@ declare interface Auth {
|
|
|
114
114
|
addAuthHeaders(headers: Headers): Promise<void>;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
/**
|
|
118
|
-
* @license
|
|
119
|
-
* Copyright 2024 Google LLC
|
|
120
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
121
|
-
*/
|
|
122
117
|
declare class BaseModule {
|
|
123
118
|
}
|
|
124
119
|
|
|
@@ -182,7 +177,7 @@ export declare class Caches extends BaseModule {
|
|
|
182
177
|
*
|
|
183
178
|
* @example
|
|
184
179
|
* ```ts
|
|
185
|
-
* const cachedContents = await
|
|
180
|
+
* const cachedContents = await ai.caches.list({config: {'pageSize': 2}});
|
|
186
181
|
* for (const cachedContent of cachedContents) {
|
|
187
182
|
* console.log(cachedContent);
|
|
188
183
|
* }
|
|
@@ -198,7 +193,7 @@ export declare class Caches extends BaseModule {
|
|
|
198
193
|
* @example
|
|
199
194
|
* ```ts
|
|
200
195
|
* const contents = ...; // Initialize the content to cache.
|
|
201
|
-
* const response = await
|
|
196
|
+
* const response = await ai.caches.create({
|
|
202
197
|
* model: 'gemini-2.0-flash',
|
|
203
198
|
* config: {
|
|
204
199
|
* 'contents': contents,
|
|
@@ -218,7 +213,7 @@ export declare class Caches extends BaseModule {
|
|
|
218
213
|
*
|
|
219
214
|
* @example
|
|
220
215
|
* ```ts
|
|
221
|
-
* await
|
|
216
|
+
* await ai.caches.get({name: 'gemini-1.5-flash'});
|
|
222
217
|
* ```
|
|
223
218
|
*/
|
|
224
219
|
get(params: types.GetCachedContentParameters): Promise<types.CachedContent>;
|
|
@@ -230,7 +225,7 @@ export declare class Caches extends BaseModule {
|
|
|
230
225
|
*
|
|
231
226
|
* @example
|
|
232
227
|
* ```ts
|
|
233
|
-
* await
|
|
228
|
+
* await ai.caches.delete({name: 'gemini-1.5-flash'});
|
|
234
229
|
* ```
|
|
235
230
|
*/
|
|
236
231
|
delete(params: types.DeleteCachedContentParameters): Promise<types.DeleteCachedContentResponse>;
|
|
@@ -242,7 +237,7 @@ export declare class Caches extends BaseModule {
|
|
|
242
237
|
*
|
|
243
238
|
* @example
|
|
244
239
|
* ```ts
|
|
245
|
-
* const response = await
|
|
240
|
+
* const response = await ai.caches.update({
|
|
246
241
|
* name: 'gemini-1.5-flash',
|
|
247
242
|
* config: {'ttl': '7600s'}
|
|
248
243
|
* });
|
|
@@ -281,8 +276,11 @@ export declare interface Candidate {
|
|
|
281
276
|
}
|
|
282
277
|
|
|
283
278
|
/**
|
|
284
|
-
* Chat session that enables sending messages
|
|
285
|
-
*
|
|
279
|
+
* Chat session that enables sending messages to the model with previous
|
|
280
|
+
* conversation context.
|
|
281
|
+
*
|
|
282
|
+
* @remarks
|
|
283
|
+
* The session maintains all the turns between user and model.
|
|
286
284
|
*/
|
|
287
285
|
export declare class Chat {
|
|
288
286
|
private readonly apiClient;
|
|
@@ -302,6 +300,15 @@ export declare class Chat {
|
|
|
302
300
|
* @see {@link Chat#sendMessageStream} for streaming method.
|
|
303
301
|
* @param params - parameters for sending messages within a chat session.
|
|
304
302
|
* @returns The model's response.
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```ts
|
|
306
|
+
* const chat = ai.chats.create({model: 'gemini-2.0-flash'});
|
|
307
|
+
* const response = await chat.sendMessage({
|
|
308
|
+
* message: 'Why is the sky blue?'
|
|
309
|
+
* });
|
|
310
|
+
* console.log(response.text);
|
|
311
|
+
* ```
|
|
305
312
|
*/
|
|
306
313
|
sendMessage(params: types.SendMessageParameters): Promise<types.GenerateContentResponse>;
|
|
307
314
|
/**
|
|
@@ -314,6 +321,17 @@ export declare class Chat {
|
|
|
314
321
|
* @see {@link Chat#sendMessage} for non-streaming method.
|
|
315
322
|
* @param params - parameters for sending the message.
|
|
316
323
|
* @return The model's response.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```ts
|
|
327
|
+
* const chat = ai.chats.create({model: 'gemini-2.0-flash'});
|
|
328
|
+
* const response = await chat.sendMessageStream({
|
|
329
|
+
* message: 'Why is the sky blue?'
|
|
330
|
+
* });
|
|
331
|
+
* for await (const chunk of response) {
|
|
332
|
+
* console.log(chunk.text);
|
|
333
|
+
* }
|
|
334
|
+
* ```
|
|
317
335
|
*/
|
|
318
336
|
sendMessageStream(params: types.SendMessageParameters): Promise<AsyncGenerator<types.GenerateContentResponse>>;
|
|
319
337
|
/**
|
|
@@ -354,8 +372,24 @@ export declare class Chats {
|
|
|
354
372
|
/**
|
|
355
373
|
* Creates a new chat session.
|
|
356
374
|
*
|
|
375
|
+
* @remarks
|
|
376
|
+
* The config in the params will be used for all requests within the chat
|
|
377
|
+
* session unless overridden by a per-request `config` in
|
|
378
|
+
* {@link ./types.SendMessageParameters}.
|
|
379
|
+
*
|
|
357
380
|
* @param params - Parameters for creating a chat session.
|
|
358
381
|
* @returns A new chat session.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```ts
|
|
385
|
+
* const chat = ai.chats.create({
|
|
386
|
+
* model: 'gemini-2.0-flash'
|
|
387
|
+
* config: {
|
|
388
|
+
* temperature: 0.5,
|
|
389
|
+
* maxOutputTokens: 1024,
|
|
390
|
+
* }
|
|
391
|
+
* });
|
|
392
|
+
* ```
|
|
359
393
|
*/
|
|
360
394
|
create(params: types.CreateChatParameters): Chat;
|
|
361
395
|
}
|
|
@@ -393,6 +427,16 @@ export declare interface CodeExecutionResult {
|
|
|
393
427
|
output?: string;
|
|
394
428
|
}
|
|
395
429
|
|
|
430
|
+
declare namespace common {
|
|
431
|
+
export {
|
|
432
|
+
formatMap,
|
|
433
|
+
setValueByPath,
|
|
434
|
+
getValueByPath,
|
|
435
|
+
BaseModule,
|
|
436
|
+
UploadFileParameters
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
396
440
|
/** Optional parameters for computing tokens. */
|
|
397
441
|
export declare interface ComputeTokensConfig {
|
|
398
442
|
/** Used to override HTTP request options. */
|
|
@@ -660,11 +704,6 @@ export declare function createPartFromText(text: string): Part;
|
|
|
660
704
|
*/
|
|
661
705
|
export declare function createPartFromUri(uri: string, mimeType: string): Part;
|
|
662
706
|
|
|
663
|
-
/**
|
|
664
|
-
* Creates a `Part` object from the `startOffset` and `endOffset` of a `VideoMetadata` object.
|
|
665
|
-
*/
|
|
666
|
-
export declare function createPartFromVideoMetadata(startOffset: string, endOffset: string): Part;
|
|
667
|
-
|
|
668
707
|
/**
|
|
669
708
|
* Creates a `Content` object with a user role from a `PartListUnion` object or `string`.
|
|
670
709
|
*/
|
|
@@ -830,7 +869,7 @@ declare class Files extends BaseModule {
|
|
|
830
869
|
* size of each page is 10.
|
|
831
870
|
*
|
|
832
871
|
* ```ts
|
|
833
|
-
* const listResponse = await
|
|
872
|
+
* const listResponse = await ai.files.list({config: {'pageSize': 10}});
|
|
834
873
|
* for await (const file of listResponse) {
|
|
835
874
|
* console.log(file.name);
|
|
836
875
|
* }
|
|
@@ -860,26 +899,26 @@ declare class Files extends BaseModule {
|
|
|
860
899
|
*
|
|
861
900
|
* This section can contain multiple paragraphs and code examples.
|
|
862
901
|
*
|
|
863
|
-
* @param
|
|
864
|
-
*
|
|
865
|
-
*
|
|
902
|
+
* @param params - Optional parameters specified in the
|
|
903
|
+
* `common.UploadFileParameters` interface.
|
|
904
|
+
* Optional @see {@link common.UploadFileParameters}
|
|
866
905
|
* @return A promise that resolves to a `types.File` object.
|
|
867
906
|
* @throws An error if called on a Vertex AI client.
|
|
868
907
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
869
|
-
* the `mimeType` can be provided in the `config` parameter.
|
|
908
|
+
* the `mimeType` can be provided in the `params.config` parameter.
|
|
870
909
|
* @throws An error occurs if a suitable upload location cannot be established.
|
|
871
910
|
*
|
|
872
911
|
* @example
|
|
873
912
|
* The following code uploads a file to Gemini API.
|
|
874
913
|
*
|
|
875
914
|
* ```ts
|
|
876
|
-
* const file = await
|
|
915
|
+
* const file = await ai.files.upload({file: 'file.txt', config: {
|
|
877
916
|
* mimeType: 'text/plain',
|
|
878
|
-
* });
|
|
917
|
+
* }});
|
|
879
918
|
* console.log(file.name);
|
|
880
919
|
* ```
|
|
881
920
|
*/
|
|
882
|
-
upload(
|
|
921
|
+
upload(params: common.UploadFileParameters): Promise<types.File>;
|
|
883
922
|
private listInternal;
|
|
884
923
|
private createInternal;
|
|
885
924
|
/**
|
|
@@ -893,7 +932,7 @@ declare class Files extends BaseModule {
|
|
|
893
932
|
* const config: GetFileParameters = {
|
|
894
933
|
* name: fileName,
|
|
895
934
|
* };
|
|
896
|
-
* file = await
|
|
935
|
+
* file = await ai.files.get(config);
|
|
897
936
|
* console.log(file.name);
|
|
898
937
|
* ```
|
|
899
938
|
*/
|
|
@@ -953,6 +992,8 @@ export declare enum FinishReason {
|
|
|
953
992
|
MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL"
|
|
954
993
|
}
|
|
955
994
|
|
|
995
|
+
declare function formatMap(templateString: string, valueMap: Record<string, unknown>): string;
|
|
996
|
+
|
|
956
997
|
/** A function call. */
|
|
957
998
|
export declare interface FunctionCall {
|
|
958
999
|
/** The unique id of the function call. If populated, the client to execute the
|
|
@@ -1295,6 +1336,10 @@ export declare interface GeneratedImage {
|
|
|
1295
1336
|
response.
|
|
1296
1337
|
*/
|
|
1297
1338
|
raiFilteredReason?: string;
|
|
1339
|
+
/** Safety attributes of the image. Lists of RAI categories and their
|
|
1340
|
+
scores of each content.
|
|
1341
|
+
*/
|
|
1342
|
+
safetyAttributes?: SafetyAttributes;
|
|
1298
1343
|
/** The rewritten prompt used for the image generation if the prompt
|
|
1299
1344
|
enhancer is enabled.
|
|
1300
1345
|
*/
|
|
@@ -1461,6 +1506,8 @@ export declare interface GetFileParameters {
|
|
|
1461
1506
|
config?: GetFileConfig;
|
|
1462
1507
|
}
|
|
1463
1508
|
|
|
1509
|
+
declare function getValueByPath(data: unknown, keys: string[]): unknown;
|
|
1510
|
+
|
|
1464
1511
|
/**
|
|
1465
1512
|
* The Google GenAI SDK.
|
|
1466
1513
|
*
|
|
@@ -1470,23 +1517,21 @@ export declare interface GetFileParameters {
|
|
|
1470
1517
|
*
|
|
1471
1518
|
* The {@link GoogleGenAIOptions.vertexai} value determines which of the API services to use.
|
|
1472
1519
|
*
|
|
1473
|
-
* When using the Gemini API, a {@link GoogleGenAIOptions.apiKey} must be set,
|
|
1474
|
-
* when using Vertex AI {@link GoogleGenAIOptions.project}
|
|
1475
|
-
* and {@link GoogleGenAIOptions.location} must be set,
|
|
1476
|
-
* and the {@link GoogleGenAIOptions.vertexai} must be set to `true`.
|
|
1520
|
+
* When using the Gemini API, a {@link GoogleGenAIOptions.apiKey} must also be set,
|
|
1521
|
+
* when using Vertex AI {@link GoogleGenAIOptions.project} and {@link GoogleGenAIOptions.location} must also be set.
|
|
1477
1522
|
*
|
|
1478
1523
|
* @example
|
|
1479
1524
|
* Initializing the SDK for using the Gemini API:
|
|
1480
1525
|
* ```ts
|
|
1481
1526
|
* import {GoogleGenAI} from '@google/genai';
|
|
1482
|
-
* const ai =
|
|
1527
|
+
* const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
|
|
1483
1528
|
* ```
|
|
1484
1529
|
*
|
|
1485
1530
|
* @example
|
|
1486
1531
|
* Initializing the SDK for using the Vertex AI API:
|
|
1487
1532
|
* ```ts
|
|
1488
1533
|
* import {GoogleGenAI} from '@google/genai';
|
|
1489
|
-
* const ai =
|
|
1534
|
+
* const ai = new GoogleGenAI({
|
|
1490
1535
|
* vertexai: true,
|
|
1491
1536
|
* project: 'PROJECT_ID',
|
|
1492
1537
|
* location: 'PROJECT_LOCATION'
|
|
@@ -1569,13 +1614,6 @@ export declare interface GoogleGenAIOptions {
|
|
|
1569
1614
|
* Optional. A set of customizable configuration for HTTP requests.
|
|
1570
1615
|
*/
|
|
1571
1616
|
httpOptions?: HttpOptions;
|
|
1572
|
-
/**
|
|
1573
|
-
* The object used for adding authentication headers to API requests.
|
|
1574
|
-
*
|
|
1575
|
-
* @remarks
|
|
1576
|
-
* Only used for internal testing, will be removed in the future.
|
|
1577
|
-
*/
|
|
1578
|
-
auth?: Auth;
|
|
1579
1617
|
}
|
|
1580
1618
|
|
|
1581
1619
|
/** Tool to support Google Search in Model. Powered by Google. */
|
|
@@ -1846,20 +1884,14 @@ export declare class Live {
|
|
|
1846
1884
|
Establishes a connection to the specified model with the given
|
|
1847
1885
|
configuration and returns a Session object representing that connection.
|
|
1848
1886
|
|
|
1849
|
-
> [!CAUTION] This SDK does not yet support the live API for **Google Vertex AI**.
|
|
1850
|
-
|
|
1851
1887
|
@experimental
|
|
1852
1888
|
|
|
1853
|
-
@param
|
|
1854
|
-
@
|
|
1855
|
-
@param callbacks - Optional callbacks for websocket events. If not
|
|
1856
|
-
provided, default no-op callbacks will be used. Generally, prefer to
|
|
1857
|
-
provide explicit callbacks to allow for proper handling of websocket
|
|
1858
|
-
events (e.g. connection errors).
|
|
1889
|
+
@param params - The parameters for establishing a connection to the model.
|
|
1890
|
+
@return A live session.
|
|
1859
1891
|
|
|
1860
1892
|
@example
|
|
1861
1893
|
```ts
|
|
1862
|
-
const session = await
|
|
1894
|
+
const session = await ai.live.connect({
|
|
1863
1895
|
model: 'gemini-2.0-flash-exp',
|
|
1864
1896
|
config: {
|
|
1865
1897
|
responseModalities: [Modality.AUDIO],
|
|
@@ -1886,10 +1918,10 @@ export declare class Live {
|
|
|
1886
1918
|
|
|
1887
1919
|
/** Callbacks for the live API. */
|
|
1888
1920
|
export declare interface LiveCallbacks {
|
|
1889
|
-
onopen
|
|
1921
|
+
onopen?: (() => void) | null;
|
|
1890
1922
|
onmessage: (e: LiveServerMessage) => void;
|
|
1891
|
-
onerror
|
|
1892
|
-
onclose
|
|
1923
|
+
onerror?: ((e: ErrorEvent) => void) | null;
|
|
1924
|
+
onclose?: ((e: CloseEvent) => void) | null;
|
|
1893
1925
|
}
|
|
1894
1926
|
|
|
1895
1927
|
/** Incremental update of the current conversation delivered from the client.
|
|
@@ -2184,14 +2216,12 @@ export declare class Models extends BaseModule {
|
|
|
2184
2216
|
*
|
|
2185
2217
|
* Some models support multimodal input and output.
|
|
2186
2218
|
*
|
|
2187
|
-
* @param
|
|
2188
|
-
* @param contents - The input contents to use for generating content.
|
|
2189
|
-
* @param [config] - The configuration for generating content.
|
|
2219
|
+
* @param params - The parameters for generating content.
|
|
2190
2220
|
* @return The response from generating content.
|
|
2191
2221
|
*
|
|
2192
2222
|
* @example
|
|
2193
2223
|
* ```ts
|
|
2194
|
-
* const response = await
|
|
2224
|
+
* const response = await ai.models.generateContent({
|
|
2195
2225
|
* model: 'gemini-2.0-flash',
|
|
2196
2226
|
* contents: 'why is the sky blue?',
|
|
2197
2227
|
* config: {
|
|
@@ -2226,14 +2256,12 @@ export declare class Models extends BaseModule {
|
|
|
2226
2256
|
*
|
|
2227
2257
|
* Some models support multimodal input and output.
|
|
2228
2258
|
*
|
|
2229
|
-
* @param
|
|
2230
|
-
* @param contents - The input contents to use for generating content.
|
|
2231
|
-
* @param [config] - The configuration for generating content.
|
|
2259
|
+
* @param params - The parameters for generating content with streaming response.
|
|
2232
2260
|
* @return The response from generating content.
|
|
2233
2261
|
*
|
|
2234
2262
|
* @example
|
|
2235
2263
|
* ```ts
|
|
2236
|
-
* const response = await
|
|
2264
|
+
* const response = await ai.models.generateContentStream({
|
|
2237
2265
|
* model: 'gemini-2.0-flash',
|
|
2238
2266
|
* contents: 'why is the sky blue?',
|
|
2239
2267
|
* config: {
|
|
@@ -2251,14 +2279,12 @@ export declare class Models extends BaseModule {
|
|
|
2251
2279
|
/**
|
|
2252
2280
|
* Calculates embeddings for the given contents. Only text is supported.
|
|
2253
2281
|
*
|
|
2254
|
-
* @param
|
|
2255
|
-
* @param contents - The contents to embed.
|
|
2256
|
-
* @param [config] - The config for embedding contents.
|
|
2282
|
+
* @param params - The parameters for embedding contents.
|
|
2257
2283
|
* @return The response from the API.
|
|
2258
2284
|
*
|
|
2259
2285
|
* @example
|
|
2260
2286
|
* ```ts
|
|
2261
|
-
* const response = await
|
|
2287
|
+
* const response = await ai.models.embedContent({
|
|
2262
2288
|
* model: 'text-embedding-004',
|
|
2263
2289
|
* contents: [
|
|
2264
2290
|
* 'What is your name?',
|
|
@@ -2275,14 +2301,12 @@ export declare class Models extends BaseModule {
|
|
|
2275
2301
|
/**
|
|
2276
2302
|
* Generates an image based on a text description and configuration.
|
|
2277
2303
|
*
|
|
2278
|
-
* @param
|
|
2279
|
-
* @param prompt - A text description of the image to generate.
|
|
2280
|
-
* @param [config] - The config for image generation.
|
|
2304
|
+
* @param params - The parameters for generating images.
|
|
2281
2305
|
* @return The response from the API.
|
|
2282
2306
|
*
|
|
2283
2307
|
* @example
|
|
2284
2308
|
* ```ts
|
|
2285
|
-
* const response = await
|
|
2309
|
+
* const response = await ai.models.generateImages({
|
|
2286
2310
|
* model: 'imagen-3.0-generate-002',
|
|
2287
2311
|
* prompt: 'Robot holding a red skateboard',
|
|
2288
2312
|
* config: {
|
|
@@ -2298,14 +2322,12 @@ export declare class Models extends BaseModule {
|
|
|
2298
2322
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
2299
2323
|
* supported for Gemini models.
|
|
2300
2324
|
*
|
|
2301
|
-
* @param
|
|
2302
|
-
* @param contents - The contents to count tokens for.
|
|
2303
|
-
* @param [config] - The config for counting tokens.
|
|
2325
|
+
* @param params - The parameters for counting tokens.
|
|
2304
2326
|
* @return The response from the API.
|
|
2305
2327
|
*
|
|
2306
2328
|
* @example
|
|
2307
2329
|
* ```ts
|
|
2308
|
-
* const response = await
|
|
2330
|
+
* const response = await ai.models.countTokens({
|
|
2309
2331
|
* model: 'gemini-2.0-flash',
|
|
2310
2332
|
* contents: 'The quick brown fox jumps over the lazy dog.'
|
|
2311
2333
|
* });
|
|
@@ -2319,14 +2341,12 @@ export declare class Models extends BaseModule {
|
|
|
2319
2341
|
*
|
|
2320
2342
|
* This method is not supported by the Gemini Developer API.
|
|
2321
2343
|
*
|
|
2322
|
-
* @param
|
|
2323
|
-
* @param contents - The content to compute tokens for.
|
|
2324
|
-
* @param [config] - The config for computing tokens.
|
|
2344
|
+
* @param params - The parameters for computing tokens.
|
|
2325
2345
|
* @return The response from the API.
|
|
2326
2346
|
*
|
|
2327
2347
|
* @example
|
|
2328
2348
|
* ```ts
|
|
2329
|
-
* const response = await
|
|
2349
|
+
* const response = await ai.models.computeTokens({
|
|
2330
2350
|
* model: 'gemini-2.0-flash',
|
|
2331
2351
|
* contents: 'What is your name?'
|
|
2332
2352
|
* });
|
|
@@ -2338,7 +2358,7 @@ export declare class Models extends BaseModule {
|
|
|
2338
2358
|
|
|
2339
2359
|
/**
|
|
2340
2360
|
* @license
|
|
2341
|
-
* Copyright
|
|
2361
|
+
* Copyright 2025 Google LLC
|
|
2342
2362
|
* SPDX-License-Identifier: Apache-2.0
|
|
2343
2363
|
*/
|
|
2344
2364
|
export declare enum Outcome {
|
|
@@ -2350,7 +2370,7 @@ export declare enum Outcome {
|
|
|
2350
2370
|
|
|
2351
2371
|
/**
|
|
2352
2372
|
* @license
|
|
2353
|
-
* Copyright
|
|
2373
|
+
* Copyright 2025 Google LLC
|
|
2354
2374
|
* SPDX-License-Identifier: Apache-2.0
|
|
2355
2375
|
*/
|
|
2356
2376
|
/**
|
|
@@ -2364,6 +2384,22 @@ declare enum PagedItem {
|
|
|
2364
2384
|
PAGED_ITEM_CACHED_CONTENTS = "cachedContents"
|
|
2365
2385
|
}
|
|
2366
2386
|
|
|
2387
|
+
declare interface PagedItemConfig {
|
|
2388
|
+
config?: {
|
|
2389
|
+
pageToken?: string;
|
|
2390
|
+
pageSize?: number;
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
declare interface PagedItemResponse<T> {
|
|
2395
|
+
nextPageToken?: string;
|
|
2396
|
+
batchJobs?: T[];
|
|
2397
|
+
models?: T[];
|
|
2398
|
+
tuningJobs?: T[];
|
|
2399
|
+
files?: T[];
|
|
2400
|
+
cachedContents?: T[];
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2367
2403
|
/**
|
|
2368
2404
|
* Pager class for iterating through paginated results.
|
|
2369
2405
|
*/
|
|
@@ -2372,9 +2408,9 @@ declare class Pager<T> implements AsyncIterable<T> {
|
|
|
2372
2408
|
private pageInternal;
|
|
2373
2409
|
private paramsInternal;
|
|
2374
2410
|
private pageInternalSize;
|
|
2375
|
-
protected requestInternal: (params:
|
|
2411
|
+
protected requestInternal: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>;
|
|
2376
2412
|
protected idxInternal: number;
|
|
2377
|
-
constructor(name: PagedItem, request: (params:
|
|
2413
|
+
constructor(name: PagedItem, request: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>, response: PagedItemResponse<T>, params: PagedItemConfig);
|
|
2378
2414
|
private init;
|
|
2379
2415
|
private initNextPage;
|
|
2380
2416
|
/**
|
|
@@ -2404,7 +2440,7 @@ declare class Pager<T> implements AsyncIterable<T> {
|
|
|
2404
2440
|
* used to customize the API request. For example, the `pageToken` parameter
|
|
2405
2441
|
* contains the token to request the next page.
|
|
2406
2442
|
*/
|
|
2407
|
-
get params():
|
|
2443
|
+
get params(): PagedItemConfig;
|
|
2408
2444
|
/**
|
|
2409
2445
|
* Returns the total number of items in the current page.
|
|
2410
2446
|
*/
|
|
@@ -2562,6 +2598,16 @@ export declare interface RetrievalMetadata {
|
|
|
2562
2598
|
googleSearchDynamicRetrievalScore?: number;
|
|
2563
2599
|
}
|
|
2564
2600
|
|
|
2601
|
+
/** Safety attributes of a GeneratedImage or the user-provided prompt. */
|
|
2602
|
+
export declare interface SafetyAttributes {
|
|
2603
|
+
/** List of RAI categories.
|
|
2604
|
+
*/
|
|
2605
|
+
categories?: string[];
|
|
2606
|
+
/** List of scores of each categories.
|
|
2607
|
+
*/
|
|
2608
|
+
scores?: number[];
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2565
2611
|
export declare enum SafetyFilterLevel {
|
|
2566
2612
|
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
2567
2613
|
BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -2605,12 +2651,8 @@ export declare interface Schema {
|
|
|
2605
2651
|
example?: unknown;
|
|
2606
2652
|
/** Optional. Pattern of the Type.STRING to restrict a string to a regular expression. */
|
|
2607
2653
|
pattern?: string;
|
|
2608
|
-
/** Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the Type.INTEGER and Type.NUMBER */
|
|
2609
|
-
minimum?: number;
|
|
2610
2654
|
/** Optional. Default value of the data. */
|
|
2611
2655
|
default?: unknown;
|
|
2612
|
-
/** Optional. The value should be validated against any (one or more) of the subschemas in the list. */
|
|
2613
|
-
anyOf?: Schema[];
|
|
2614
2656
|
/** Optional. Maximum length of the Type.STRING */
|
|
2615
2657
|
maxLength?: string;
|
|
2616
2658
|
/** Optional. The title of the Schema. */
|
|
@@ -2619,10 +2661,10 @@ export declare interface Schema {
|
|
|
2619
2661
|
minLength?: string;
|
|
2620
2662
|
/** Optional. Minimum number of the properties for Type.OBJECT. */
|
|
2621
2663
|
minProperties?: string;
|
|
2622
|
-
/** Optional. Maximum value of the Type.INTEGER and Type.NUMBER */
|
|
2623
|
-
maximum?: number;
|
|
2624
2664
|
/** Optional. Maximum number of the properties for Type.OBJECT. */
|
|
2625
2665
|
maxProperties?: string;
|
|
2666
|
+
/** Optional. The value should be validated against any (one or more) of the subschemas in the list. */
|
|
2667
|
+
anyOf?: Schema[];
|
|
2626
2668
|
/** Optional. The description of the data. */
|
|
2627
2669
|
description?: string;
|
|
2628
2670
|
/** Optional. Possible values of the element of primitive type with enum format. Examples: 1. We can define direction as : {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]} 2. We can define apartment number as : {type:INTEGER, format:enum, enum:["101", "201", "301"]} */
|
|
@@ -2633,8 +2675,12 @@ export declare interface Schema {
|
|
|
2633
2675
|
items?: Schema;
|
|
2634
2676
|
/** Optional. Maximum number of the elements for Type.ARRAY. */
|
|
2635
2677
|
maxItems?: string;
|
|
2678
|
+
/** Optional. Maximum value of the Type.INTEGER and Type.NUMBER */
|
|
2679
|
+
maximum?: number;
|
|
2636
2680
|
/** Optional. Minimum number of the elements for Type.ARRAY. */
|
|
2637
2681
|
minItems?: string;
|
|
2682
|
+
/** Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the Type.INTEGER and Type.NUMBER */
|
|
2683
|
+
minimum?: number;
|
|
2638
2684
|
/** Optional. Indicates if the value may be null. */
|
|
2639
2685
|
nullable?: boolean;
|
|
2640
2686
|
/** Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT. */
|
|
@@ -2796,7 +2842,7 @@ export declare class Session {
|
|
|
2796
2842
|
|
|
2797
2843
|
@example
|
|
2798
2844
|
```ts
|
|
2799
|
-
const session = await
|
|
2845
|
+
const session = await ai.live.connect({
|
|
2800
2846
|
model: 'gemini-2.0-flash-exp',
|
|
2801
2847
|
config: {
|
|
2802
2848
|
responseModalities: [Modality.AUDIO],
|
|
@@ -2831,6 +2877,8 @@ export declare class SessionSendToolResponseParameters {
|
|
|
2831
2877
|
functionResponses: FunctionResponse | FunctionResponse[];
|
|
2832
2878
|
}
|
|
2833
2879
|
|
|
2880
|
+
declare function setValueByPath(data: Record<string, unknown>, keys: string[], value: unknown): void;
|
|
2881
|
+
|
|
2834
2882
|
/** The speech generation configuration. */
|
|
2835
2883
|
export declare interface SpeechConfig {
|
|
2836
2884
|
/** The configuration for the speaker to use.
|
|
@@ -2999,7 +3047,6 @@ declare namespace types {
|
|
|
2999
3047
|
createPartFromFunctionCall,
|
|
3000
3048
|
createPartFromFunctionResponse,
|
|
3001
3049
|
createPartFromBase64,
|
|
3002
|
-
createPartFromVideoMetadata,
|
|
3003
3050
|
createPartFromCodeExecutionResult,
|
|
3004
3051
|
createPartFromExecutableCode,
|
|
3005
3052
|
createUserContent,
|
|
@@ -3089,6 +3136,7 @@ declare namespace types {
|
|
|
3089
3136
|
GenerateImagesConfig,
|
|
3090
3137
|
GenerateImagesParameters,
|
|
3091
3138
|
Image_2 as Image,
|
|
3139
|
+
SafetyAttributes,
|
|
3092
3140
|
GeneratedImage,
|
|
3093
3141
|
GenerateImagesResponse,
|
|
3094
3142
|
GenerationConfig,
|
|
@@ -3225,6 +3273,14 @@ export declare interface UploadFileConfig {
|
|
|
3225
3273
|
displayName?: string;
|
|
3226
3274
|
}
|
|
3227
3275
|
|
|
3276
|
+
/** Parameters for the upload file method. */
|
|
3277
|
+
declare interface UploadFileParameters {
|
|
3278
|
+
/** The string path to the file to be uploaded or a Blob object. */
|
|
3279
|
+
file: string | Blob;
|
|
3280
|
+
/** Configuration that contains optional parameters. */
|
|
3281
|
+
config?: UploadFileConfig;
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3228
3284
|
/** Configuration for upscaling an image.
|
|
3229
3285
|
|
|
3230
3286
|
For more information on this configuration, refer to
|