@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/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2024 Google LLC
3
+ * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  class BaseModule {
@@ -127,7 +127,7 @@ function getValueByPath(data, keys) {
127
127
 
128
128
  /**
129
129
  * @license
130
- * Copyright 2024 Google LLC
130
+ * Copyright 2025 Google LLC
131
131
  * SPDX-License-Identifier: Apache-2.0
132
132
  */
133
133
  function tModel(apiClient, model) {
@@ -352,9 +352,6 @@ function processSchema(apiClient, schema) {
352
352
  }
353
353
  }
354
354
  if ('anyOf' in schema) {
355
- if (!apiClient.isVertexAI()) {
356
- throw new Error('AnyOf is not supported in the response schema for the Gemini API.');
357
- }
358
355
  if (schema['anyOf'] !== undefined) {
359
356
  for (const subSchema of schema['anyOf']) {
360
357
  processSchema(apiClient, subSchema);
@@ -495,14 +492,12 @@ function tFileName(apiClient, fromName) {
495
492
 
496
493
  /**
497
494
  * @license
498
- * Copyright 2024 Google LLC
495
+ * Copyright 2025 Google LLC
499
496
  * SPDX-License-Identifier: Apache-2.0
500
497
  */
501
498
  /**
502
499
  * @fileoverview Pagers for the GenAI List APIs.
503
500
  */
504
- // TODO(b/401555348): Re-enable linting after enforcing strong types.
505
- /* eslint-disable @typescript-eslint/no-explicit-any */
506
501
  var PagedItem;
507
502
  (function (PagedItem) {
508
503
  PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
@@ -517,6 +512,7 @@ var PagedItem;
517
512
  class Pager {
518
513
  constructor(name, request, response, params) {
519
514
  this.pageInternal = [];
515
+ this.paramsInternal = {};
520
516
  this.requestInternal = request;
521
517
  this.init(name, response, params);
522
518
  }
@@ -673,7 +669,7 @@ class Pager {
673
669
 
674
670
  /**
675
671
  * @license
676
- * Copyright 2024 Google LLC
672
+ * Copyright 2025 Google LLC
677
673
  * SPDX-License-Identifier: Apache-2.0
678
674
  */
679
675
  // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
@@ -909,17 +905,6 @@ function createPartFromBase64(data, mimeType) {
909
905
  },
910
906
  };
911
907
  }
912
- /**
913
- * Creates a `Part` object from the `startOffset` and `endOffset` of a `VideoMetadata` object.
914
- */
915
- function createPartFromVideoMetadata(startOffset, endOffset) {
916
- return {
917
- videoMetadata: {
918
- startOffset: startOffset,
919
- endOffset: endOffset,
920
- },
921
- };
922
- }
923
908
  /**
924
909
  * Creates a `Part` object from the `outcome` and `output` of a `CodeExecutionResult` object.
925
910
  */
@@ -1262,7 +1247,7 @@ class SessionSendToolResponseParameters {
1262
1247
 
1263
1248
  /**
1264
1249
  * @license
1265
- * Copyright 2024 Google LLC
1250
+ * Copyright 2025 Google LLC
1266
1251
  * SPDX-License-Identifier: Apache-2.0
1267
1252
  */
1268
1253
  class Caches extends BaseModule {
@@ -1277,7 +1262,7 @@ class Caches extends BaseModule {
1277
1262
  *
1278
1263
  * @example
1279
1264
  * ```ts
1280
- * const cachedContents = await client.caches.list({config: {'pageSize': 2}});
1265
+ * const cachedContents = await ai.caches.list({config: {'pageSize': 2}});
1281
1266
  * for (const cachedContent of cachedContents) {
1282
1267
  * console.log(cachedContent);
1283
1268
  * }
@@ -1296,7 +1281,7 @@ class Caches extends BaseModule {
1296
1281
  * @example
1297
1282
  * ```ts
1298
1283
  * const contents = ...; // Initialize the content to cache.
1299
- * const response = await client.caches.create({
1284
+ * const response = await ai.caches.create({
1300
1285
  * model: 'gemini-2.0-flash',
1301
1286
  * config: {
1302
1287
  * 'contents': contents,
@@ -1367,7 +1352,7 @@ class Caches extends BaseModule {
1367
1352
  *
1368
1353
  * @example
1369
1354
  * ```ts
1370
- * await client.caches.get({name: 'gemini-1.5-flash'});
1355
+ * await ai.caches.get({name: 'gemini-1.5-flash'});
1371
1356
  * ```
1372
1357
  */
1373
1358
  async get(params) {
@@ -1430,7 +1415,7 @@ class Caches extends BaseModule {
1430
1415
  *
1431
1416
  * @example
1432
1417
  * ```ts
1433
- * await client.caches.delete({name: 'gemini-1.5-flash'});
1418
+ * await ai.caches.delete({name: 'gemini-1.5-flash'});
1434
1419
  * ```
1435
1420
  */
1436
1421
  async delete(params) {
@@ -1457,7 +1442,7 @@ class Caches extends BaseModule {
1457
1442
  return httpResponse.json();
1458
1443
  });
1459
1444
  return response.then((apiResponse) => {
1460
- const resp = deleteCachedContentResponseFromVertex(this.apiClient);
1445
+ const resp = deleteCachedContentResponseFromVertex();
1461
1446
  const typedResp = new DeleteCachedContentResponse();
1462
1447
  Object.assign(typedResp, resp);
1463
1448
  return typedResp;
@@ -1482,7 +1467,7 @@ class Caches extends BaseModule {
1482
1467
  return httpResponse.json();
1483
1468
  });
1484
1469
  return response.then((apiResponse) => {
1485
- const resp = deleteCachedContentResponseFromMldev(this.apiClient);
1470
+ const resp = deleteCachedContentResponseFromMldev();
1486
1471
  const typedResp = new DeleteCachedContentResponse();
1487
1472
  Object.assign(typedResp, resp);
1488
1473
  return typedResp;
@@ -1497,7 +1482,7 @@ class Caches extends BaseModule {
1497
1482
  *
1498
1483
  * @example
1499
1484
  * ```ts
1500
- * const response = await client.caches.update({
1485
+ * const response = await ai.caches.update({
1501
1486
  * name: 'gemini-1.5-flash',
1502
1487
  * config: {'ttl': '7600s'}
1503
1488
  * });
@@ -1755,18 +1740,10 @@ function schemaToVertex$1(apiClient, fromObject) {
1755
1740
  if (fromPattern != null) {
1756
1741
  setValueByPath(toObject, ['pattern'], fromPattern);
1757
1742
  }
1758
- const fromMinimum = getValueByPath(fromObject, ['minimum']);
1759
- if (fromMinimum != null) {
1760
- setValueByPath(toObject, ['minimum'], fromMinimum);
1761
- }
1762
1743
  const fromDefault = getValueByPath(fromObject, ['default']);
1763
1744
  if (fromDefault != null) {
1764
1745
  setValueByPath(toObject, ['default'], fromDefault);
1765
1746
  }
1766
- const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
1767
- if (fromAnyOf != null) {
1768
- setValueByPath(toObject, ['anyOf'], fromAnyOf);
1769
- }
1770
1747
  const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
1771
1748
  if (fromMaxLength != null) {
1772
1749
  setValueByPath(toObject, ['maxLength'], fromMaxLength);
@@ -1785,16 +1762,16 @@ function schemaToVertex$1(apiClient, fromObject) {
1785
1762
  if (fromMinProperties != null) {
1786
1763
  setValueByPath(toObject, ['minProperties'], fromMinProperties);
1787
1764
  }
1788
- const fromMaximum = getValueByPath(fromObject, ['maximum']);
1789
- if (fromMaximum != null) {
1790
- setValueByPath(toObject, ['maximum'], fromMaximum);
1791
- }
1792
1765
  const fromMaxProperties = getValueByPath(fromObject, [
1793
1766
  'maxProperties',
1794
1767
  ]);
1795
1768
  if (fromMaxProperties != null) {
1796
1769
  setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
1797
1770
  }
1771
+ const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
1772
+ if (fromAnyOf != null) {
1773
+ setValueByPath(toObject, ['anyOf'], fromAnyOf);
1774
+ }
1798
1775
  const fromDescription = getValueByPath(fromObject, ['description']);
1799
1776
  if (fromDescription != null) {
1800
1777
  setValueByPath(toObject, ['description'], fromDescription);
@@ -1815,10 +1792,18 @@ function schemaToVertex$1(apiClient, fromObject) {
1815
1792
  if (fromMaxItems != null) {
1816
1793
  setValueByPath(toObject, ['maxItems'], fromMaxItems);
1817
1794
  }
1795
+ const fromMaximum = getValueByPath(fromObject, ['maximum']);
1796
+ if (fromMaximum != null) {
1797
+ setValueByPath(toObject, ['maximum'], fromMaximum);
1798
+ }
1818
1799
  const fromMinItems = getValueByPath(fromObject, ['minItems']);
1819
1800
  if (fromMinItems != null) {
1820
1801
  setValueByPath(toObject, ['minItems'], fromMinItems);
1821
1802
  }
1803
+ const fromMinimum = getValueByPath(fromObject, ['minimum']);
1804
+ if (fromMinimum != null) {
1805
+ setValueByPath(toObject, ['minimum'], fromMinimum);
1806
+ }
1822
1807
  const fromNullable = getValueByPath(fromObject, ['nullable']);
1823
1808
  if (fromNullable != null) {
1824
1809
  setValueByPath(toObject, ['nullable'], fromNullable);
@@ -1882,11 +1867,11 @@ function functionDeclarationToVertex$1(apiClient, fromObject) {
1882
1867
  }
1883
1868
  return toObject;
1884
1869
  }
1885
- function googleSearchToMldev$1(apiClient, fromObject) {
1870
+ function googleSearchToMldev$1() {
1886
1871
  const toObject = {};
1887
1872
  return toObject;
1888
1873
  }
1889
- function googleSearchToVertex$1(apiClient, fromObject) {
1874
+ function googleSearchToVertex$1() {
1890
1875
  const toObject = {};
1891
1876
  return toObject;
1892
1877
  }
@@ -2385,11 +2370,11 @@ function cachedContentFromVertex(apiClient, fromObject) {
2385
2370
  }
2386
2371
  return toObject;
2387
2372
  }
2388
- function deleteCachedContentResponseFromMldev(apiClient, fromObject) {
2373
+ function deleteCachedContentResponseFromMldev() {
2389
2374
  const toObject = {};
2390
2375
  return toObject;
2391
2376
  }
2392
- function deleteCachedContentResponseFromVertex(apiClient, fromObject) {
2377
+ function deleteCachedContentResponseFromVertex() {
2393
2378
  const toObject = {};
2394
2379
  return toObject;
2395
2380
  }
@@ -2501,7 +2486,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
2501
2486
 
2502
2487
  /**
2503
2488
  * @license
2504
- * Copyright 2024 Google LLC
2489
+ * Copyright 2025 Google LLC
2505
2490
  * SPDX-License-Identifier: Apache-2.0
2506
2491
  */
2507
2492
  /**
@@ -2606,16 +2591,35 @@ class Chats {
2606
2591
  /**
2607
2592
  * Creates a new chat session.
2608
2593
  *
2594
+ * @remarks
2595
+ * The config in the params will be used for all requests within the chat
2596
+ * session unless overridden by a per-request `config` in
2597
+ * {@link ./types.SendMessageParameters}.
2598
+ *
2609
2599
  * @param params - Parameters for creating a chat session.
2610
2600
  * @returns A new chat session.
2601
+ *
2602
+ * @example
2603
+ * ```ts
2604
+ * const chat = ai.chats.create({
2605
+ * model: 'gemini-2.0-flash'
2606
+ * config: {
2607
+ * temperature: 0.5,
2608
+ * maxOutputTokens: 1024,
2609
+ * }
2610
+ * });
2611
+ * ```
2611
2612
  */
2612
2613
  create(params) {
2613
2614
  return new Chat(this.apiClient, this.modelsModule, params.model, params.config, params.history);
2614
2615
  }
2615
2616
  }
2616
2617
  /**
2617
- * Chat session that enables sending messages and stores the chat history so
2618
- * far.
2618
+ * Chat session that enables sending messages to the model with previous
2619
+ * conversation context.
2620
+ *
2621
+ * @remarks
2622
+ * The session maintains all the turns between user and model.
2619
2623
  */
2620
2624
  class Chat {
2621
2625
  constructor(apiClient, modelsModule, model, config = {}, history = []) {
@@ -2639,6 +2643,15 @@ class Chat {
2639
2643
  * @see {@link Chat#sendMessageStream} for streaming method.
2640
2644
  * @param params - parameters for sending messages within a chat session.
2641
2645
  * @returns The model's response.
2646
+ *
2647
+ * @example
2648
+ * ```ts
2649
+ * const chat = ai.chats.create({model: 'gemini-2.0-flash'});
2650
+ * const response = await chat.sendMessage({
2651
+ * message: 'Why is the sky blue?'
2652
+ * });
2653
+ * console.log(response.text);
2654
+ * ```
2642
2655
  */
2643
2656
  async sendMessage(params) {
2644
2657
  var _a;
@@ -2670,6 +2683,17 @@ class Chat {
2670
2683
  * @see {@link Chat#sendMessage} for non-streaming method.
2671
2684
  * @param params - parameters for sending the message.
2672
2685
  * @return The model's response.
2686
+ *
2687
+ * @example
2688
+ * ```ts
2689
+ * const chat = ai.chats.create({model: 'gemini-2.0-flash'});
2690
+ * const response = await chat.sendMessageStream({
2691
+ * message: 'Why is the sky blue?'
2692
+ * });
2693
+ * for await (const chunk of response) {
2694
+ * console.log(chunk.text);
2695
+ * }
2696
+ * ```
2673
2697
  */
2674
2698
  async sendMessageStream(params) {
2675
2699
  var _a;
@@ -2761,13 +2785,13 @@ class Chat {
2761
2785
 
2762
2786
  /**
2763
2787
  * @license
2764
- * Copyright 2024 Google LLC
2788
+ * Copyright 2025 Google LLC
2765
2789
  * SPDX-License-Identifier: Apache-2.0
2766
2790
  */
2767
2791
  const CONTENT_TYPE_HEADER = 'Content-Type';
2768
2792
  const USER_AGENT_HEADER = 'User-Agent';
2769
2793
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
2770
- const SDK_VERSION = '0.2.0'; // x-release-please-version
2794
+ const SDK_VERSION = '0.4.0'; // x-release-please-version
2771
2795
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
2772
2796
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
2773
2797
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -2979,7 +3003,7 @@ class ApiClient {
2979
3003
  async unaryApiCall(url, requestInit, httpMethod) {
2980
3004
  return this.apiCall(url.toString(), Object.assign(Object.assign({}, requestInit), { method: httpMethod }))
2981
3005
  .then(async (response) => {
2982
- await throwErrorIfNotOK(response, url.toString());
3006
+ await throwErrorIfNotOK(response);
2983
3007
  return new HttpResponse(response);
2984
3008
  })
2985
3009
  .catch((e) => {
@@ -2994,7 +3018,7 @@ class ApiClient {
2994
3018
  async streamApiCall(url, requestInit, httpMethod) {
2995
3019
  return this.apiCall(url.toString(), Object.assign(Object.assign({}, requestInit), { method: httpMethod }))
2996
3020
  .then(async (response) => {
2997
- await throwErrorIfNotOK(response, url.toString());
3021
+ await throwErrorIfNotOK(response);
2998
3022
  return this.processStreamResponse(response);
2999
3023
  })
3000
3024
  .catch((e) => {
@@ -3139,7 +3163,7 @@ class ApiClient {
3139
3163
  return uploadUrl;
3140
3164
  }
3141
3165
  }
3142
- async function throwErrorIfNotOK(response, url, requestInit) {
3166
+ async function throwErrorIfNotOK(response) {
3143
3167
  var _a;
3144
3168
  if (response === undefined) {
3145
3169
  throw new ServerError('response is undefined');
@@ -3261,7 +3285,7 @@ class CrossWebSocketFactory {
3261
3285
 
3262
3286
  /**
3263
3287
  * @license
3264
- * Copyright 2024 Google LLC
3288
+ * Copyright 2025 Google LLC
3265
3289
  * SPDX-License-Identifier: Apache-2.0
3266
3290
  */
3267
3291
  class Files extends BaseModule {
@@ -3279,7 +3303,7 @@ class Files extends BaseModule {
3279
3303
  * size of each page is 10.
3280
3304
  *
3281
3305
  * ```ts
3282
- * const listResponse = await client.files.list({config: {'pageSize': 10}});
3306
+ * const listResponse = await ai.files.list({config: {'pageSize': 10}});
3283
3307
  * for await (const file of listResponse) {
3284
3308
  * console.log(file.name);
3285
3309
  * }
@@ -3312,63 +3336,43 @@ class Files extends BaseModule {
3312
3336
  *
3313
3337
  * This section can contain multiple paragraphs and code examples.
3314
3338
  *
3315
- * @param file The string path to the file to be uploaded or a Blob object.
3316
- * @param config Optional parameters specified in the `types.UploadFileConfig`
3317
- * interface. Optional @see {@link types.UploadFileConfig}
3339
+ * @param params - Optional parameters specified in the
3340
+ * `common.UploadFileParameters` interface.
3341
+ * Optional @see {@link common.UploadFileParameters}
3318
3342
  * @return A promise that resolves to a `types.File` object.
3319
3343
  * @throws An error if called on a Vertex AI client.
3320
3344
  * @throws An error if the `mimeType` is not provided and can not be inferred,
3321
- * the `mimeType` can be provided in the `config` parameter.
3345
+ * the `mimeType` can be provided in the `params.config` parameter.
3322
3346
  * @throws An error occurs if a suitable upload location cannot be established.
3323
3347
  *
3324
3348
  * @example
3325
3349
  * The following code uploads a file to Gemini API.
3326
3350
  *
3327
3351
  * ```ts
3328
- * const file = await client.files.upload('file.txt', {
3352
+ * const file = await ai.files.upload({file: 'file.txt', config: {
3329
3353
  * mimeType: 'text/plain',
3330
- * });
3354
+ * }});
3331
3355
  * console.log(file.name);
3332
3356
  * ```
3333
3357
  */
3334
- async upload(file, config) {
3358
+ async upload(params) {
3335
3359
  if (this.apiClient.isVertexAI()) {
3336
3360
  throw new Error('Vertex AI does not support uploading files. You can share files through a GCS bucket.');
3337
3361
  }
3338
- return this.apiClient.uploadFile(file, config).then((response) => {
3362
+ return this.apiClient
3363
+ .uploadFile(params.file, params.config)
3364
+ .then((response) => {
3339
3365
  const file = fileFromMldev(this.apiClient, response);
3340
3366
  return file;
3341
3367
  });
3342
3368
  }
3343
3369
  async listInternal(params) {
3344
- var _a, _b;
3370
+ var _a;
3345
3371
  let response;
3346
3372
  let path = '';
3347
3373
  let queryParams = {};
3348
3374
  if (this.apiClient.isVertexAI()) {
3349
- const body = listFilesParametersToVertex(this.apiClient, params);
3350
- path = formatMap('None', body['_url']);
3351
- queryParams = body['_query'];
3352
- delete body['config'];
3353
- delete body['_url'];
3354
- delete body['_query'];
3355
- response = this.apiClient
3356
- .request({
3357
- path: path,
3358
- queryParams: queryParams,
3359
- body: JSON.stringify(body),
3360
- httpMethod: 'GET',
3361
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3362
- })
3363
- .then((httpResponse) => {
3364
- return httpResponse.json();
3365
- });
3366
- return response.then((apiResponse) => {
3367
- const resp = listFilesResponseFromVertex(this.apiClient);
3368
- const typedResp = new ListFilesResponse();
3369
- Object.assign(typedResp, resp);
3370
- return typedResp;
3371
- });
3375
+ throw new Error('This method is only supported by the Gemini Developer API.');
3372
3376
  }
3373
3377
  else {
3374
3378
  const body = listFilesParametersToMldev(this.apiClient, params);
@@ -3383,7 +3387,7 @@ class Files extends BaseModule {
3383
3387
  queryParams: queryParams,
3384
3388
  body: JSON.stringify(body),
3385
3389
  httpMethod: 'GET',
3386
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
3390
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3387
3391
  })
3388
3392
  .then((httpResponse) => {
3389
3393
  return httpResponse.json();
@@ -3397,34 +3401,12 @@ class Files extends BaseModule {
3397
3401
  }
3398
3402
  }
3399
3403
  async createInternal(params) {
3400
- var _a, _b;
3404
+ var _a;
3401
3405
  let response;
3402
3406
  let path = '';
3403
3407
  let queryParams = {};
3404
3408
  if (this.apiClient.isVertexAI()) {
3405
- const body = createFileParametersToVertex(this.apiClient, params);
3406
- path = formatMap('', body['_url']);
3407
- queryParams = body['_query'];
3408
- delete body['config'];
3409
- delete body['_url'];
3410
- delete body['_query'];
3411
- response = this.apiClient
3412
- .request({
3413
- path: path,
3414
- queryParams: queryParams,
3415
- body: JSON.stringify(body),
3416
- httpMethod: 'POST',
3417
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3418
- })
3419
- .then((httpResponse) => {
3420
- return httpResponse.json();
3421
- });
3422
- return response.then((apiResponse) => {
3423
- const resp = createFileResponseFromVertex(this.apiClient, apiResponse);
3424
- const typedResp = new CreateFileResponse();
3425
- Object.assign(typedResp, resp);
3426
- return typedResp;
3427
- });
3409
+ throw new Error('This method is only supported by the Gemini Developer API.');
3428
3410
  }
3429
3411
  else {
3430
3412
  const body = createFileParametersToMldev(this.apiClient, params);
@@ -3439,7 +3421,7 @@ class Files extends BaseModule {
3439
3421
  queryParams: queryParams,
3440
3422
  body: JSON.stringify(body),
3441
3423
  httpMethod: 'POST',
3442
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
3424
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3443
3425
  })
3444
3426
  .then((httpResponse) => {
3445
3427
  return httpResponse.json();
@@ -3463,37 +3445,17 @@ class Files extends BaseModule {
3463
3445
  * const config: GetFileParameters = {
3464
3446
  * name: fileName,
3465
3447
  * };
3466
- * file = await client.files.get(config);
3448
+ * file = await ai.files.get(config);
3467
3449
  * console.log(file.name);
3468
3450
  * ```
3469
3451
  */
3470
3452
  async get(params) {
3471
- var _a, _b;
3453
+ var _a;
3472
3454
  let response;
3473
3455
  let path = '';
3474
3456
  let queryParams = {};
3475
3457
  if (this.apiClient.isVertexAI()) {
3476
- const body = getFileParametersToVertex(this.apiClient, params);
3477
- path = formatMap('None', body['_url']);
3478
- queryParams = body['_query'];
3479
- delete body['config'];
3480
- delete body['_url'];
3481
- delete body['_query'];
3482
- response = this.apiClient
3483
- .request({
3484
- path: path,
3485
- queryParams: queryParams,
3486
- body: JSON.stringify(body),
3487
- httpMethod: 'GET',
3488
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3489
- })
3490
- .then((httpResponse) => {
3491
- return httpResponse.json();
3492
- });
3493
- return response.then((apiResponse) => {
3494
- const resp = fileFromVertex(this.apiClient);
3495
- return resp;
3496
- });
3458
+ throw new Error('This method is only supported by the Gemini Developer API.');
3497
3459
  }
3498
3460
  else {
3499
3461
  const body = getFileParametersToMldev(this.apiClient, params);
@@ -3508,7 +3470,7 @@ class Files extends BaseModule {
3508
3470
  queryParams: queryParams,
3509
3471
  body: JSON.stringify(body),
3510
3472
  httpMethod: 'GET',
3511
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
3473
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
3512
3474
  })
3513
3475
  .then((httpResponse) => {
3514
3476
  return httpResponse.json();
@@ -3540,13 +3502,6 @@ function listFilesParametersToMldev(apiClient, fromObject) {
3540
3502
  }
3541
3503
  return toObject;
3542
3504
  }
3543
- function listFilesParametersToVertex(apiClient, fromObject) {
3544
- const toObject = {};
3545
- if (getValueByPath(fromObject, ['config']) !== undefined) {
3546
- throw new Error('config parameter is not supported in Vertex AI.');
3547
- }
3548
- return toObject;
3549
- }
3550
3505
  function fileStatusToMldev(apiClient, fromObject) {
3551
3506
  const toObject = {};
3552
3507
  const fromDetails = getValueByPath(fromObject, ['details']);
@@ -3639,16 +3594,6 @@ function createFileParametersToMldev(apiClient, fromObject) {
3639
3594
  }
3640
3595
  return toObject;
3641
3596
  }
3642
- function createFileParametersToVertex(apiClient, fromObject) {
3643
- const toObject = {};
3644
- if (getValueByPath(fromObject, ['file']) !== undefined) {
3645
- throw new Error('file parameter is not supported in Vertex AI.');
3646
- }
3647
- if (getValueByPath(fromObject, ['config']) !== undefined) {
3648
- throw new Error('config parameter is not supported in Vertex AI.');
3649
- }
3650
- return toObject;
3651
- }
3652
3597
  function getFileParametersToMldev(apiClient, fromObject) {
3653
3598
  const toObject = {};
3654
3599
  const fromName = getValueByPath(fromObject, ['name']);
@@ -3661,16 +3606,6 @@ function getFileParametersToMldev(apiClient, fromObject) {
3661
3606
  }
3662
3607
  return toObject;
3663
3608
  }
3664
- function getFileParametersToVertex(apiClient, fromObject) {
3665
- const toObject = {};
3666
- if (getValueByPath(fromObject, ['name']) !== undefined) {
3667
- throw new Error('name parameter is not supported in Vertex AI.');
3668
- }
3669
- if (getValueByPath(fromObject, ['config']) !== undefined) {
3670
- throw new Error('config parameter is not supported in Vertex AI.');
3671
- }
3672
- return toObject;
3673
- }
3674
3609
  function fileStatusFromMldev(apiClient, fromObject) {
3675
3610
  const toObject = {};
3676
3611
  const fromDetails = getValueByPath(fromObject, ['details']);
@@ -3751,10 +3686,6 @@ function fileFromMldev(apiClient, fromObject) {
3751
3686
  }
3752
3687
  return toObject;
3753
3688
  }
3754
- function fileFromVertex(apiClient, fromObject) {
3755
- const toObject = {};
3756
- return toObject;
3757
- }
3758
3689
  function listFilesResponseFromMldev(apiClient, fromObject) {
3759
3690
  const toObject = {};
3760
3691
  const fromNextPageToken = getValueByPath(fromObject, [
@@ -3776,10 +3707,6 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
3776
3707
  }
3777
3708
  return toObject;
3778
3709
  }
3779
- function listFilesResponseFromVertex(apiClient, fromObject) {
3780
- const toObject = {};
3781
- return toObject;
3782
- }
3783
3710
  function createFileResponseFromMldev(apiClient, fromObject) {
3784
3711
  const toObject = {};
3785
3712
  const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
@@ -3788,18 +3715,10 @@ function createFileResponseFromMldev(apiClient, fromObject) {
3788
3715
  }
3789
3716
  return toObject;
3790
3717
  }
3791
- function createFileResponseFromVertex(apiClient, fromObject) {
3792
- const toObject = {};
3793
- const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
3794
- if (fromHttpHeaders != null) {
3795
- setValueByPath(toObject, ['httpHeaders'], fromHttpHeaders);
3796
- }
3797
- return toObject;
3798
- }
3799
3718
 
3800
3719
  /**
3801
3720
  * @license
3802
- * Copyright 2024 Google LLC
3721
+ * Copyright 2025 Google LLC
3803
3722
  * SPDX-License-Identifier: Apache-2.0
3804
3723
  */
3805
3724
  class Models extends BaseModule {
@@ -3829,14 +3748,12 @@ class Models extends BaseModule {
3829
3748
  *
3830
3749
  * Some models support multimodal input and output.
3831
3750
  *
3832
- * @param model - The model to use for generating content.
3833
- * @param contents - The input contents to use for generating content.
3834
- * @param [config] - The configuration for generating content.
3751
+ * @param params - The parameters for generating content.
3835
3752
  * @return The response from generating content.
3836
3753
  *
3837
3754
  * @example
3838
3755
  * ```ts
3839
- * const response = await client.models.generateContent({
3756
+ * const response = await ai.models.generateContent({
3840
3757
  * model: 'gemini-2.0-flash',
3841
3758
  * contents: 'why is the sky blue?',
3842
3759
  * config: {
@@ -3873,14 +3790,12 @@ class Models extends BaseModule {
3873
3790
  *
3874
3791
  * Some models support multimodal input and output.
3875
3792
  *
3876
- * @param model - The model to use for generating content.
3877
- * @param contents - The input contents to use for generating content.
3878
- * @param [config] - The configuration for generating content.
3793
+ * @param params - The parameters for generating content with streaming response.
3879
3794
  * @return The response from generating content.
3880
3795
  *
3881
3796
  * @example
3882
3797
  * ```ts
3883
- * const response = await client.models.generateContentStream({
3798
+ * const response = await ai.models.generateContentStream({
3884
3799
  * model: 'gemini-2.0-flash',
3885
3800
  * contents: 'why is the sky blue?',
3886
3801
  * config: {
@@ -4039,14 +3954,12 @@ class Models extends BaseModule {
4039
3954
  /**
4040
3955
  * Calculates embeddings for the given contents. Only text is supported.
4041
3956
  *
4042
- * @param model - The model to use.
4043
- * @param contents - The contents to embed.
4044
- * @param [config] - The config for embedding contents.
3957
+ * @param params - The parameters for embedding contents.
4045
3958
  * @return The response from the API.
4046
3959
  *
4047
3960
  * @example
4048
3961
  * ```ts
4049
- * const response = await client.models.embedContent({
3962
+ * const response = await ai.models.embedContent({
4050
3963
  * model: 'text-embedding-004',
4051
3964
  * contents: [
4052
3965
  * 'What is your name?',
@@ -4118,14 +4031,12 @@ class Models extends BaseModule {
4118
4031
  /**
4119
4032
  * Generates an image based on a text description and configuration.
4120
4033
  *
4121
- * @param model - The model to use.
4122
- * @param prompt - A text description of the image to generate.
4123
- * @param [config] - The config for image generation.
4034
+ * @param params - The parameters for generating images.
4124
4035
  * @return The response from the API.
4125
4036
  *
4126
4037
  * @example
4127
4038
  * ```ts
4128
- * const response = await client.models.generateImages({
4039
+ * const response = await ai.models.generateImages({
4129
4040
  * model: 'imagen-3.0-generate-002',
4130
4041
  * prompt: 'Robot holding a red skateboard',
4131
4042
  * config: {
@@ -4196,14 +4107,12 @@ class Models extends BaseModule {
4196
4107
  * Counts the number of tokens in the given contents. Multimodal input is
4197
4108
  * supported for Gemini models.
4198
4109
  *
4199
- * @param model - The model to use for counting tokens.
4200
- * @param contents - The contents to count tokens for.
4201
- * @param [config] - The config for counting tokens.
4110
+ * @param params - The parameters for counting tokens.
4202
4111
  * @return The response from the API.
4203
4112
  *
4204
4113
  * @example
4205
4114
  * ```ts
4206
- * const response = await client.models.countTokens({
4115
+ * const response = await ai.models.countTokens({
4207
4116
  * model: 'gemini-2.0-flash',
4208
4117
  * contents: 'The quick brown fox jumps over the lazy dog.'
4209
4118
  * });
@@ -4272,14 +4181,12 @@ class Models extends BaseModule {
4272
4181
  *
4273
4182
  * This method is not supported by the Gemini Developer API.
4274
4183
  *
4275
- * @param model - The model to use.
4276
- * @param contents - The content to compute tokens for.
4277
- * @param [config] - The config for computing tokens.
4184
+ * @param params - The parameters for computing tokens.
4278
4185
  * @return The response from the API.
4279
4186
  *
4280
4187
  * @example
4281
4188
  * ```ts
4282
- * const response = await client.models.computeTokens({
4189
+ * const response = await ai.models.computeTokens({
4283
4190
  * model: 'gemini-2.0-flash',
4284
4191
  * contents: 'What is your name?'
4285
4192
  * });
@@ -4287,7 +4194,7 @@ class Models extends BaseModule {
4287
4194
  * ```
4288
4195
  */
4289
4196
  async computeTokens(params) {
4290
- var _a, _b;
4197
+ var _a;
4291
4198
  let response;
4292
4199
  let path = '';
4293
4200
  let queryParams = {};
@@ -4317,29 +4224,7 @@ class Models extends BaseModule {
4317
4224
  });
4318
4225
  }
4319
4226
  else {
4320
- const body = computeTokensParametersToMldev(this.apiClient, params);
4321
- path = formatMap('None', body['_url']);
4322
- queryParams = body['_query'];
4323
- delete body['config'];
4324
- delete body['_url'];
4325
- delete body['_query'];
4326
- response = this.apiClient
4327
- .request({
4328
- path: path,
4329
- queryParams: queryParams,
4330
- body: JSON.stringify(body),
4331
- httpMethod: 'POST',
4332
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
4333
- })
4334
- .then((httpResponse) => {
4335
- return httpResponse.json();
4336
- });
4337
- return response.then((apiResponse) => {
4338
- const resp = computeTokensResponseFromMldev(this.apiClient, apiResponse);
4339
- const typedResp = new ComputeTokensResponse();
4340
- Object.assign(typedResp, resp);
4341
- return typedResp;
4342
- });
4227
+ throw new Error('This method is only supported by the Vertex AI.');
4343
4228
  }
4344
4229
  }
4345
4230
  }
@@ -4484,15 +4369,9 @@ function schemaToMldev(apiClient, fromObject) {
4484
4369
  if (getValueByPath(fromObject, ['pattern']) !== undefined) {
4485
4370
  throw new Error('pattern parameter is not supported in Gemini API.');
4486
4371
  }
4487
- if (getValueByPath(fromObject, ['minimum']) !== undefined) {
4488
- throw new Error('minimum parameter is not supported in Gemini API.');
4489
- }
4490
4372
  if (getValueByPath(fromObject, ['default']) !== undefined) {
4491
4373
  throw new Error('default parameter is not supported in Gemini API.');
4492
4374
  }
4493
- if (getValueByPath(fromObject, ['anyOf']) !== undefined) {
4494
- throw new Error('anyOf parameter is not supported in Gemini API.');
4495
- }
4496
4375
  if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
4497
4376
  throw new Error('maxLength parameter is not supported in Gemini API.');
4498
4377
  }
@@ -4505,12 +4384,13 @@ function schemaToMldev(apiClient, fromObject) {
4505
4384
  if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
4506
4385
  throw new Error('minProperties parameter is not supported in Gemini API.');
4507
4386
  }
4508
- if (getValueByPath(fromObject, ['maximum']) !== undefined) {
4509
- throw new Error('maximum parameter is not supported in Gemini API.');
4510
- }
4511
4387
  if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
4512
4388
  throw new Error('maxProperties parameter is not supported in Gemini API.');
4513
4389
  }
4390
+ const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
4391
+ if (fromAnyOf != null) {
4392
+ setValueByPath(toObject, ['anyOf'], fromAnyOf);
4393
+ }
4514
4394
  const fromDescription = getValueByPath(fromObject, ['description']);
4515
4395
  if (fromDescription != null) {
4516
4396
  setValueByPath(toObject, ['description'], fromDescription);
@@ -4531,10 +4411,18 @@ function schemaToMldev(apiClient, fromObject) {
4531
4411
  if (fromMaxItems != null) {
4532
4412
  setValueByPath(toObject, ['maxItems'], fromMaxItems);
4533
4413
  }
4414
+ const fromMaximum = getValueByPath(fromObject, ['maximum']);
4415
+ if (fromMaximum != null) {
4416
+ setValueByPath(toObject, ['maximum'], fromMaximum);
4417
+ }
4534
4418
  const fromMinItems = getValueByPath(fromObject, ['minItems']);
4535
4419
  if (fromMinItems != null) {
4536
4420
  setValueByPath(toObject, ['minItems'], fromMinItems);
4537
4421
  }
4422
+ const fromMinimum = getValueByPath(fromObject, ['minimum']);
4423
+ if (fromMinimum != null) {
4424
+ setValueByPath(toObject, ['minimum'], fromMinimum);
4425
+ }
4538
4426
  const fromNullable = getValueByPath(fromObject, ['nullable']);
4539
4427
  if (fromNullable != null) {
4540
4428
  setValueByPath(toObject, ['nullable'], fromNullable);
@@ -4569,18 +4457,10 @@ function schemaToVertex(apiClient, fromObject) {
4569
4457
  if (fromPattern != null) {
4570
4458
  setValueByPath(toObject, ['pattern'], fromPattern);
4571
4459
  }
4572
- const fromMinimum = getValueByPath(fromObject, ['minimum']);
4573
- if (fromMinimum != null) {
4574
- setValueByPath(toObject, ['minimum'], fromMinimum);
4575
- }
4576
4460
  const fromDefault = getValueByPath(fromObject, ['default']);
4577
4461
  if (fromDefault != null) {
4578
4462
  setValueByPath(toObject, ['default'], fromDefault);
4579
4463
  }
4580
- const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
4581
- if (fromAnyOf != null) {
4582
- setValueByPath(toObject, ['anyOf'], fromAnyOf);
4583
- }
4584
4464
  const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
4585
4465
  if (fromMaxLength != null) {
4586
4466
  setValueByPath(toObject, ['maxLength'], fromMaxLength);
@@ -4599,16 +4479,16 @@ function schemaToVertex(apiClient, fromObject) {
4599
4479
  if (fromMinProperties != null) {
4600
4480
  setValueByPath(toObject, ['minProperties'], fromMinProperties);
4601
4481
  }
4602
- const fromMaximum = getValueByPath(fromObject, ['maximum']);
4603
- if (fromMaximum != null) {
4604
- setValueByPath(toObject, ['maximum'], fromMaximum);
4605
- }
4606
4482
  const fromMaxProperties = getValueByPath(fromObject, [
4607
4483
  'maxProperties',
4608
4484
  ]);
4609
4485
  if (fromMaxProperties != null) {
4610
4486
  setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
4611
4487
  }
4488
+ const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
4489
+ if (fromAnyOf != null) {
4490
+ setValueByPath(toObject, ['anyOf'], fromAnyOf);
4491
+ }
4612
4492
  const fromDescription = getValueByPath(fromObject, ['description']);
4613
4493
  if (fromDescription != null) {
4614
4494
  setValueByPath(toObject, ['description'], fromDescription);
@@ -4629,10 +4509,18 @@ function schemaToVertex(apiClient, fromObject) {
4629
4509
  if (fromMaxItems != null) {
4630
4510
  setValueByPath(toObject, ['maxItems'], fromMaxItems);
4631
4511
  }
4512
+ const fromMaximum = getValueByPath(fromObject, ['maximum']);
4513
+ if (fromMaximum != null) {
4514
+ setValueByPath(toObject, ['maximum'], fromMaximum);
4515
+ }
4632
4516
  const fromMinItems = getValueByPath(fromObject, ['minItems']);
4633
4517
  if (fromMinItems != null) {
4634
4518
  setValueByPath(toObject, ['minItems'], fromMinItems);
4635
4519
  }
4520
+ const fromMinimum = getValueByPath(fromObject, ['minimum']);
4521
+ if (fromMinimum != null) {
4522
+ setValueByPath(toObject, ['minimum'], fromMinimum);
4523
+ }
4636
4524
  const fromNullable = getValueByPath(fromObject, ['nullable']);
4637
4525
  if (fromNullable != null) {
4638
4526
  setValueByPath(toObject, ['nullable'], fromNullable);
@@ -4727,11 +4615,11 @@ function functionDeclarationToVertex(apiClient, fromObject) {
4727
4615
  }
4728
4616
  return toObject;
4729
4617
  }
4730
- function googleSearchToMldev(apiClient, fromObject) {
4618
+ function googleSearchToMldev() {
4731
4619
  const toObject = {};
4732
4620
  return toObject;
4733
4621
  }
4734
- function googleSearchToVertex(apiClient, fromObject) {
4622
+ function googleSearchToVertex() {
4735
4623
  const toObject = {};
4736
4624
  return toObject;
4737
4625
  }
@@ -5680,21 +5568,6 @@ function countTokensParametersToVertex(apiClient, fromObject) {
5680
5568
  }
5681
5569
  return toObject;
5682
5570
  }
5683
- function computeTokensParametersToMldev(apiClient, fromObject) {
5684
- const toObject = {};
5685
- const fromModel = getValueByPath(fromObject, ['model']);
5686
- if (fromModel != null) {
5687
- setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
5688
- }
5689
- if (getValueByPath(fromObject, ['contents']) !== undefined) {
5690
- throw new Error('contents parameter is not supported in Gemini API.');
5691
- }
5692
- const fromConfig = getValueByPath(fromObject, ['config']);
5693
- if (fromConfig != null) {
5694
- setValueByPath(toObject, ['config'], fromConfig);
5695
- }
5696
- return toObject;
5697
- }
5698
5571
  function computeTokensParametersToVertex(apiClient, fromObject) {
5699
5572
  const toObject = {};
5700
5573
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -6064,7 +5937,7 @@ function contentEmbeddingFromVertex(apiClient, fromObject) {
6064
5937
  }
6065
5938
  return toObject;
6066
5939
  }
6067
- function embedContentMetadataFromMldev(apiClient, fromObject) {
5940
+ function embedContentMetadataFromMldev() {
6068
5941
  const toObject = {};
6069
5942
  return toObject;
6070
5943
  }
@@ -6151,6 +6024,42 @@ function imageFromVertex(apiClient, fromObject) {
6151
6024
  }
6152
6025
  return toObject;
6153
6026
  }
6027
+ function safetyAttributesFromMldev(apiClient, fromObject) {
6028
+ const toObject = {};
6029
+ const fromCategories = getValueByPath(fromObject, [
6030
+ 'safetyAttributes',
6031
+ 'categories',
6032
+ ]);
6033
+ if (fromCategories != null) {
6034
+ setValueByPath(toObject, ['categories'], fromCategories);
6035
+ }
6036
+ const fromScores = getValueByPath(fromObject, [
6037
+ 'safetyAttributes',
6038
+ 'scores',
6039
+ ]);
6040
+ if (fromScores != null) {
6041
+ setValueByPath(toObject, ['scores'], fromScores);
6042
+ }
6043
+ return toObject;
6044
+ }
6045
+ function safetyAttributesFromVertex(apiClient, fromObject) {
6046
+ const toObject = {};
6047
+ const fromCategories = getValueByPath(fromObject, [
6048
+ 'safetyAttributes',
6049
+ 'categories',
6050
+ ]);
6051
+ if (fromCategories != null) {
6052
+ setValueByPath(toObject, ['categories'], fromCategories);
6053
+ }
6054
+ const fromScores = getValueByPath(fromObject, [
6055
+ 'safetyAttributes',
6056
+ 'scores',
6057
+ ]);
6058
+ if (fromScores != null) {
6059
+ setValueByPath(toObject, ['scores'], fromScores);
6060
+ }
6061
+ return toObject;
6062
+ }
6154
6063
  function generatedImageFromMldev(apiClient, fromObject) {
6155
6064
  const toObject = {};
6156
6065
  const fromImage = getValueByPath(fromObject, ['_self']);
@@ -6163,6 +6072,10 @@ function generatedImageFromMldev(apiClient, fromObject) {
6163
6072
  if (fromRaiFilteredReason != null) {
6164
6073
  setValueByPath(toObject, ['raiFilteredReason'], fromRaiFilteredReason);
6165
6074
  }
6075
+ const fromSafetyAttributes = getValueByPath(fromObject, ['_self']);
6076
+ if (fromSafetyAttributes != null) {
6077
+ setValueByPath(toObject, ['safetyAttributes'], safetyAttributesFromMldev(apiClient, fromSafetyAttributes));
6078
+ }
6166
6079
  return toObject;
6167
6080
  }
6168
6081
  function generatedImageFromVertex(apiClient, fromObject) {
@@ -6177,6 +6090,10 @@ function generatedImageFromVertex(apiClient, fromObject) {
6177
6090
  if (fromRaiFilteredReason != null) {
6178
6091
  setValueByPath(toObject, ['raiFilteredReason'], fromRaiFilteredReason);
6179
6092
  }
6093
+ const fromSafetyAttributes = getValueByPath(fromObject, ['_self']);
6094
+ if (fromSafetyAttributes != null) {
6095
+ setValueByPath(toObject, ['safetyAttributes'], safetyAttributesFromVertex(apiClient, fromSafetyAttributes));
6096
+ }
6180
6097
  const fromEnhancedPrompt = getValueByPath(fromObject, ['prompt']);
6181
6098
  if (fromEnhancedPrompt != null) {
6182
6099
  setValueByPath(toObject, ['enhancedPrompt'], fromEnhancedPrompt);
@@ -6239,14 +6156,6 @@ function countTokensResponseFromVertex(apiClient, fromObject) {
6239
6156
  }
6240
6157
  return toObject;
6241
6158
  }
6242
- function computeTokensResponseFromMldev(apiClient, fromObject) {
6243
- const toObject = {};
6244
- const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
6245
- if (fromTokensInfo != null) {
6246
- setValueByPath(toObject, ['tokensInfo'], fromTokensInfo);
6247
- }
6248
- return toObject;
6249
- }
6250
6159
  function computeTokensResponseFromVertex(apiClient, fromObject) {
6251
6160
  const toObject = {};
6252
6161
  const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
@@ -6258,7 +6167,7 @@ function computeTokensResponseFromVertex(apiClient, fromObject) {
6258
6167
 
6259
6168
  /**
6260
6169
  * @license
6261
- * Copyright 2024 Google LLC
6170
+ * Copyright 2025 Google LLC
6262
6171
  * SPDX-License-Identifier: Apache-2.0
6263
6172
  */
6264
6173
  const FUNCTION_RESPONSE_REQUIRES_ID = 'FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.';
@@ -6519,6 +6428,12 @@ function liveServerMessageFromVertex(apiClient, fromObject) {
6519
6428
  /**
6520
6429
  * Handles incoming messages from the WebSocket.
6521
6430
  *
6431
+ * @remarks
6432
+ * This function is responsible for parsing incoming messages, transforming them
6433
+ * into LiveServerMessages, and then calling the onmessage callback. Note that
6434
+ * the first message which is received from the server is a setupComplete
6435
+ * message.
6436
+ *
6522
6437
  * @param apiClient The ApiClient instance.
6523
6438
  * @param onmessage The user-provided onmessage callback (if any).
6524
6439
  * @param event The MessageEvent from the WebSocket.
@@ -6556,20 +6471,14 @@ class Live {
6556
6471
  Establishes a connection to the specified model with the given
6557
6472
  configuration and returns a Session object representing that connection.
6558
6473
 
6559
- > [!CAUTION] This SDK does not yet support the live API for **Google Vertex AI**.
6560
-
6561
6474
  @experimental
6562
6475
 
6563
- @param model - Model to use for the Live session.
6564
- @param config - Configuration parameters for the Live session.
6565
- @param callbacks - Optional callbacks for websocket events. If not
6566
- provided, default no-op callbacks will be used. Generally, prefer to
6567
- provide explicit callbacks to allow for proper handling of websocket
6568
- events (e.g. connection errors).
6476
+ @param params - The parameters for establishing a connection to the model.
6477
+ @return A live session.
6569
6478
 
6570
6479
  @example
6571
6480
  ```ts
6572
- const session = await client.live.connect({
6481
+ const session = await ai.live.connect({
6573
6482
  model: 'gemini-2.0-flash-exp',
6574
6483
  config: {
6575
6484
  responseModalities: [Modality.AUDIO],
@@ -6593,9 +6502,6 @@ class Live {
6593
6502
  */
6594
6503
  async connect(params) {
6595
6504
  var _a, _b;
6596
- if (this.apiClient.isVertexAI()) {
6597
- throw new Error('This SDK does not yet support the live API for **Google Vertex AI**.');
6598
- }
6599
6505
  const websocketBaseUrl = this.apiClient.getWebsocketBaseUrl();
6600
6506
  const apiVersion = this.apiClient.getApiVersion();
6601
6507
  let url;
@@ -6671,8 +6577,7 @@ class Session {
6671
6577
  if (params.turns !== null && params.turns !== undefined) {
6672
6578
  let contents = [];
6673
6579
  try {
6674
- contents =
6675
- tContents(apiClient, params.turns);
6580
+ contents = tContents(apiClient, params.turns);
6676
6581
  if (apiClient.isVertexAI()) {
6677
6582
  contents = contents.map((item) => contentToVertex(apiClient, item));
6678
6583
  }
@@ -6712,8 +6617,10 @@ class Session {
6712
6617
  throw new Error('functionResponses is required.');
6713
6618
  }
6714
6619
  for (const functionResponse of functionResponses) {
6715
- if (typeof functionResponse !== 'object' || functionResponse === null ||
6716
- !('name' in functionResponse) || !('response' in functionResponse)) {
6620
+ if (typeof functionResponse !== 'object' ||
6621
+ functionResponse === null ||
6622
+ !('name' in functionResponse) ||
6623
+ !('response' in functionResponse)) {
6717
6624
  throw new Error(`Could not parse function response, type '${typeof functionResponse}'.`);
6718
6625
  }
6719
6626
  if (!apiClient.isVertexAI() && !('id' in functionResponse)) {
@@ -6721,7 +6628,7 @@ class Session {
6721
6628
  }
6722
6629
  }
6723
6630
  const clientMessage = {
6724
- toolResponse: { functionResponses: functionResponses }
6631
+ toolResponse: { functionResponses: functionResponses },
6725
6632
  };
6726
6633
  return clientMessage;
6727
6634
  }
@@ -6839,7 +6746,7 @@ class Session {
6839
6746
 
6840
6747
  @example
6841
6748
  ```ts
6842
- const session = await client.live.connect({
6749
+ const session = await ai.live.connect({
6843
6750
  model: 'gemini-2.0-flash-exp',
6844
6751
  config: {
6845
6752
  responseModalities: [Modality.AUDIO],
@@ -6957,5 +6864,5 @@ class GoogleGenAI {
6957
6864
  }
6958
6865
  }
6959
6866
 
6960
- export { BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DynamicRetrievalConfigMode, EmbedContentResponse, FileSource, FileState, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, MaskReferenceMode, MediaResolution, Modality, Mode, Models, Outcome, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, SessionSendToolResponseParameters, State, SubjectReferenceType, Type, contentToMldev$1 as contentToMldev, contentToVertex$1 as contentToVertex, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createPartFromVideoMetadata, createUserContent, toolToMldev$1 as toolToMldev, toolToVertex$1 as toolToVertex };
6867
+ export { BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DynamicRetrievalConfigMode, EmbedContentResponse, FileSource, FileState, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, MaskReferenceMode, MediaResolution, Modality, Mode, Models, Outcome, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, SessionSendToolResponseParameters, State, SubjectReferenceType, Type, contentToMldev$1 as contentToMldev, contentToVertex$1 as contentToVertex, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, toolToMldev$1 as toolToMldev, toolToVertex$1 as toolToVertex };
6961
6868
  //# sourceMappingURL=index.mjs.map