@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.
@@ -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,7 +2785,7 @@ 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
  class Models extends BaseModule {
@@ -2791,14 +2815,12 @@ class Models extends BaseModule {
2791
2815
  *
2792
2816
  * Some models support multimodal input and output.
2793
2817
  *
2794
- * @param model - The model to use for generating content.
2795
- * @param contents - The input contents to use for generating content.
2796
- * @param [config] - The configuration for generating content.
2818
+ * @param params - The parameters for generating content.
2797
2819
  * @return The response from generating content.
2798
2820
  *
2799
2821
  * @example
2800
2822
  * ```ts
2801
- * const response = await client.models.generateContent({
2823
+ * const response = await ai.models.generateContent({
2802
2824
  * model: 'gemini-2.0-flash',
2803
2825
  * contents: 'why is the sky blue?',
2804
2826
  * config: {
@@ -2835,14 +2857,12 @@ class Models extends BaseModule {
2835
2857
  *
2836
2858
  * Some models support multimodal input and output.
2837
2859
  *
2838
- * @param model - The model to use for generating content.
2839
- * @param contents - The input contents to use for generating content.
2840
- * @param [config] - The configuration for generating content.
2860
+ * @param params - The parameters for generating content with streaming response.
2841
2861
  * @return The response from generating content.
2842
2862
  *
2843
2863
  * @example
2844
2864
  * ```ts
2845
- * const response = await client.models.generateContentStream({
2865
+ * const response = await ai.models.generateContentStream({
2846
2866
  * model: 'gemini-2.0-flash',
2847
2867
  * contents: 'why is the sky blue?',
2848
2868
  * config: {
@@ -3001,14 +3021,12 @@ class Models extends BaseModule {
3001
3021
  /**
3002
3022
  * Calculates embeddings for the given contents. Only text is supported.
3003
3023
  *
3004
- * @param model - The model to use.
3005
- * @param contents - The contents to embed.
3006
- * @param [config] - The config for embedding contents.
3024
+ * @param params - The parameters for embedding contents.
3007
3025
  * @return The response from the API.
3008
3026
  *
3009
3027
  * @example
3010
3028
  * ```ts
3011
- * const response = await client.models.embedContent({
3029
+ * const response = await ai.models.embedContent({
3012
3030
  * model: 'text-embedding-004',
3013
3031
  * contents: [
3014
3032
  * 'What is your name?',
@@ -3080,14 +3098,12 @@ class Models extends BaseModule {
3080
3098
  /**
3081
3099
  * Generates an image based on a text description and configuration.
3082
3100
  *
3083
- * @param model - The model to use.
3084
- * @param prompt - A text description of the image to generate.
3085
- * @param [config] - The config for image generation.
3101
+ * @param params - The parameters for generating images.
3086
3102
  * @return The response from the API.
3087
3103
  *
3088
3104
  * @example
3089
3105
  * ```ts
3090
- * const response = await client.models.generateImages({
3106
+ * const response = await ai.models.generateImages({
3091
3107
  * model: 'imagen-3.0-generate-002',
3092
3108
  * prompt: 'Robot holding a red skateboard',
3093
3109
  * config: {
@@ -3158,14 +3174,12 @@ class Models extends BaseModule {
3158
3174
  * Counts the number of tokens in the given contents. Multimodal input is
3159
3175
  * supported for Gemini models.
3160
3176
  *
3161
- * @param model - The model to use for counting tokens.
3162
- * @param contents - The contents to count tokens for.
3163
- * @param [config] - The config for counting tokens.
3177
+ * @param params - The parameters for counting tokens.
3164
3178
  * @return The response from the API.
3165
3179
  *
3166
3180
  * @example
3167
3181
  * ```ts
3168
- * const response = await client.models.countTokens({
3182
+ * const response = await ai.models.countTokens({
3169
3183
  * model: 'gemini-2.0-flash',
3170
3184
  * contents: 'The quick brown fox jumps over the lazy dog.'
3171
3185
  * });
@@ -3234,14 +3248,12 @@ class Models extends BaseModule {
3234
3248
  *
3235
3249
  * This method is not supported by the Gemini Developer API.
3236
3250
  *
3237
- * @param model - The model to use.
3238
- * @param contents - The content to compute tokens for.
3239
- * @param [config] - The config for computing tokens.
3251
+ * @param params - The parameters for computing tokens.
3240
3252
  * @return The response from the API.
3241
3253
  *
3242
3254
  * @example
3243
3255
  * ```ts
3244
- * const response = await client.models.computeTokens({
3256
+ * const response = await ai.models.computeTokens({
3245
3257
  * model: 'gemini-2.0-flash',
3246
3258
  * contents: 'What is your name?'
3247
3259
  * });
@@ -3249,7 +3261,7 @@ class Models extends BaseModule {
3249
3261
  * ```
3250
3262
  */
3251
3263
  async computeTokens(params) {
3252
- var _a, _b;
3264
+ var _a;
3253
3265
  let response;
3254
3266
  let path = '';
3255
3267
  let queryParams = {};
@@ -3279,29 +3291,7 @@ class Models extends BaseModule {
3279
3291
  });
3280
3292
  }
3281
3293
  else {
3282
- const body = computeTokensParametersToMldev(this.apiClient, params);
3283
- path = formatMap('None', body['_url']);
3284
- queryParams = body['_query'];
3285
- delete body['config'];
3286
- delete body['_url'];
3287
- delete body['_query'];
3288
- response = this.apiClient
3289
- .request({
3290
- path: path,
3291
- queryParams: queryParams,
3292
- body: JSON.stringify(body),
3293
- httpMethod: 'POST',
3294
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
3295
- })
3296
- .then((httpResponse) => {
3297
- return httpResponse.json();
3298
- });
3299
- return response.then((apiResponse) => {
3300
- const resp = computeTokensResponseFromMldev(this.apiClient, apiResponse);
3301
- const typedResp = new ComputeTokensResponse();
3302
- Object.assign(typedResp, resp);
3303
- return typedResp;
3304
- });
3294
+ throw new Error('This method is only supported by the Vertex AI.');
3305
3295
  }
3306
3296
  }
3307
3297
  }
@@ -3446,15 +3436,9 @@ function schemaToMldev(apiClient, fromObject) {
3446
3436
  if (getValueByPath(fromObject, ['pattern']) !== undefined) {
3447
3437
  throw new Error('pattern parameter is not supported in Gemini API.');
3448
3438
  }
3449
- if (getValueByPath(fromObject, ['minimum']) !== undefined) {
3450
- throw new Error('minimum parameter is not supported in Gemini API.');
3451
- }
3452
3439
  if (getValueByPath(fromObject, ['default']) !== undefined) {
3453
3440
  throw new Error('default parameter is not supported in Gemini API.');
3454
3441
  }
3455
- if (getValueByPath(fromObject, ['anyOf']) !== undefined) {
3456
- throw new Error('anyOf parameter is not supported in Gemini API.');
3457
- }
3458
3442
  if (getValueByPath(fromObject, ['maxLength']) !== undefined) {
3459
3443
  throw new Error('maxLength parameter is not supported in Gemini API.');
3460
3444
  }
@@ -3467,12 +3451,13 @@ function schemaToMldev(apiClient, fromObject) {
3467
3451
  if (getValueByPath(fromObject, ['minProperties']) !== undefined) {
3468
3452
  throw new Error('minProperties parameter is not supported in Gemini API.');
3469
3453
  }
3470
- if (getValueByPath(fromObject, ['maximum']) !== undefined) {
3471
- throw new Error('maximum parameter is not supported in Gemini API.');
3472
- }
3473
3454
  if (getValueByPath(fromObject, ['maxProperties']) !== undefined) {
3474
3455
  throw new Error('maxProperties parameter is not supported in Gemini API.');
3475
3456
  }
3457
+ const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
3458
+ if (fromAnyOf != null) {
3459
+ setValueByPath(toObject, ['anyOf'], fromAnyOf);
3460
+ }
3476
3461
  const fromDescription = getValueByPath(fromObject, ['description']);
3477
3462
  if (fromDescription != null) {
3478
3463
  setValueByPath(toObject, ['description'], fromDescription);
@@ -3493,10 +3478,18 @@ function schemaToMldev(apiClient, fromObject) {
3493
3478
  if (fromMaxItems != null) {
3494
3479
  setValueByPath(toObject, ['maxItems'], fromMaxItems);
3495
3480
  }
3481
+ const fromMaximum = getValueByPath(fromObject, ['maximum']);
3482
+ if (fromMaximum != null) {
3483
+ setValueByPath(toObject, ['maximum'], fromMaximum);
3484
+ }
3496
3485
  const fromMinItems = getValueByPath(fromObject, ['minItems']);
3497
3486
  if (fromMinItems != null) {
3498
3487
  setValueByPath(toObject, ['minItems'], fromMinItems);
3499
3488
  }
3489
+ const fromMinimum = getValueByPath(fromObject, ['minimum']);
3490
+ if (fromMinimum != null) {
3491
+ setValueByPath(toObject, ['minimum'], fromMinimum);
3492
+ }
3500
3493
  const fromNullable = getValueByPath(fromObject, ['nullable']);
3501
3494
  if (fromNullable != null) {
3502
3495
  setValueByPath(toObject, ['nullable'], fromNullable);
@@ -3531,18 +3524,10 @@ function schemaToVertex(apiClient, fromObject) {
3531
3524
  if (fromPattern != null) {
3532
3525
  setValueByPath(toObject, ['pattern'], fromPattern);
3533
3526
  }
3534
- const fromMinimum = getValueByPath(fromObject, ['minimum']);
3535
- if (fromMinimum != null) {
3536
- setValueByPath(toObject, ['minimum'], fromMinimum);
3537
- }
3538
3527
  const fromDefault = getValueByPath(fromObject, ['default']);
3539
3528
  if (fromDefault != null) {
3540
3529
  setValueByPath(toObject, ['default'], fromDefault);
3541
3530
  }
3542
- const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
3543
- if (fromAnyOf != null) {
3544
- setValueByPath(toObject, ['anyOf'], fromAnyOf);
3545
- }
3546
3531
  const fromMaxLength = getValueByPath(fromObject, ['maxLength']);
3547
3532
  if (fromMaxLength != null) {
3548
3533
  setValueByPath(toObject, ['maxLength'], fromMaxLength);
@@ -3561,16 +3546,16 @@ function schemaToVertex(apiClient, fromObject) {
3561
3546
  if (fromMinProperties != null) {
3562
3547
  setValueByPath(toObject, ['minProperties'], fromMinProperties);
3563
3548
  }
3564
- const fromMaximum = getValueByPath(fromObject, ['maximum']);
3565
- if (fromMaximum != null) {
3566
- setValueByPath(toObject, ['maximum'], fromMaximum);
3567
- }
3568
3549
  const fromMaxProperties = getValueByPath(fromObject, [
3569
3550
  'maxProperties',
3570
3551
  ]);
3571
3552
  if (fromMaxProperties != null) {
3572
3553
  setValueByPath(toObject, ['maxProperties'], fromMaxProperties);
3573
3554
  }
3555
+ const fromAnyOf = getValueByPath(fromObject, ['anyOf']);
3556
+ if (fromAnyOf != null) {
3557
+ setValueByPath(toObject, ['anyOf'], fromAnyOf);
3558
+ }
3574
3559
  const fromDescription = getValueByPath(fromObject, ['description']);
3575
3560
  if (fromDescription != null) {
3576
3561
  setValueByPath(toObject, ['description'], fromDescription);
@@ -3591,10 +3576,18 @@ function schemaToVertex(apiClient, fromObject) {
3591
3576
  if (fromMaxItems != null) {
3592
3577
  setValueByPath(toObject, ['maxItems'], fromMaxItems);
3593
3578
  }
3579
+ const fromMaximum = getValueByPath(fromObject, ['maximum']);
3580
+ if (fromMaximum != null) {
3581
+ setValueByPath(toObject, ['maximum'], fromMaximum);
3582
+ }
3594
3583
  const fromMinItems = getValueByPath(fromObject, ['minItems']);
3595
3584
  if (fromMinItems != null) {
3596
3585
  setValueByPath(toObject, ['minItems'], fromMinItems);
3597
3586
  }
3587
+ const fromMinimum = getValueByPath(fromObject, ['minimum']);
3588
+ if (fromMinimum != null) {
3589
+ setValueByPath(toObject, ['minimum'], fromMinimum);
3590
+ }
3598
3591
  const fromNullable = getValueByPath(fromObject, ['nullable']);
3599
3592
  if (fromNullable != null) {
3600
3593
  setValueByPath(toObject, ['nullable'], fromNullable);
@@ -3689,11 +3682,11 @@ function functionDeclarationToVertex(apiClient, fromObject) {
3689
3682
  }
3690
3683
  return toObject;
3691
3684
  }
3692
- function googleSearchToMldev(apiClient, fromObject) {
3685
+ function googleSearchToMldev() {
3693
3686
  const toObject = {};
3694
3687
  return toObject;
3695
3688
  }
3696
- function googleSearchToVertex(apiClient, fromObject) {
3689
+ function googleSearchToVertex() {
3697
3690
  const toObject = {};
3698
3691
  return toObject;
3699
3692
  }
@@ -4642,21 +4635,6 @@ function countTokensParametersToVertex(apiClient, fromObject) {
4642
4635
  }
4643
4636
  return toObject;
4644
4637
  }
4645
- function computeTokensParametersToMldev(apiClient, fromObject) {
4646
- const toObject = {};
4647
- const fromModel = getValueByPath(fromObject, ['model']);
4648
- if (fromModel != null) {
4649
- setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
4650
- }
4651
- if (getValueByPath(fromObject, ['contents']) !== undefined) {
4652
- throw new Error('contents parameter is not supported in Gemini API.');
4653
- }
4654
- const fromConfig = getValueByPath(fromObject, ['config']);
4655
- if (fromConfig != null) {
4656
- setValueByPath(toObject, ['config'], fromConfig);
4657
- }
4658
- return toObject;
4659
- }
4660
4638
  function computeTokensParametersToVertex(apiClient, fromObject) {
4661
4639
  const toObject = {};
4662
4640
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -5026,7 +5004,7 @@ function contentEmbeddingFromVertex(apiClient, fromObject) {
5026
5004
  }
5027
5005
  return toObject;
5028
5006
  }
5029
- function embedContentMetadataFromMldev(apiClient, fromObject) {
5007
+ function embedContentMetadataFromMldev() {
5030
5008
  const toObject = {};
5031
5009
  return toObject;
5032
5010
  }
@@ -5113,6 +5091,42 @@ function imageFromVertex(apiClient, fromObject) {
5113
5091
  }
5114
5092
  return toObject;
5115
5093
  }
5094
+ function safetyAttributesFromMldev(apiClient, fromObject) {
5095
+ const toObject = {};
5096
+ const fromCategories = getValueByPath(fromObject, [
5097
+ 'safetyAttributes',
5098
+ 'categories',
5099
+ ]);
5100
+ if (fromCategories != null) {
5101
+ setValueByPath(toObject, ['categories'], fromCategories);
5102
+ }
5103
+ const fromScores = getValueByPath(fromObject, [
5104
+ 'safetyAttributes',
5105
+ 'scores',
5106
+ ]);
5107
+ if (fromScores != null) {
5108
+ setValueByPath(toObject, ['scores'], fromScores);
5109
+ }
5110
+ return toObject;
5111
+ }
5112
+ function safetyAttributesFromVertex(apiClient, fromObject) {
5113
+ const toObject = {};
5114
+ const fromCategories = getValueByPath(fromObject, [
5115
+ 'safetyAttributes',
5116
+ 'categories',
5117
+ ]);
5118
+ if (fromCategories != null) {
5119
+ setValueByPath(toObject, ['categories'], fromCategories);
5120
+ }
5121
+ const fromScores = getValueByPath(fromObject, [
5122
+ 'safetyAttributes',
5123
+ 'scores',
5124
+ ]);
5125
+ if (fromScores != null) {
5126
+ setValueByPath(toObject, ['scores'], fromScores);
5127
+ }
5128
+ return toObject;
5129
+ }
5116
5130
  function generatedImageFromMldev(apiClient, fromObject) {
5117
5131
  const toObject = {};
5118
5132
  const fromImage = getValueByPath(fromObject, ['_self']);
@@ -5125,6 +5139,10 @@ function generatedImageFromMldev(apiClient, fromObject) {
5125
5139
  if (fromRaiFilteredReason != null) {
5126
5140
  setValueByPath(toObject, ['raiFilteredReason'], fromRaiFilteredReason);
5127
5141
  }
5142
+ const fromSafetyAttributes = getValueByPath(fromObject, ['_self']);
5143
+ if (fromSafetyAttributes != null) {
5144
+ setValueByPath(toObject, ['safetyAttributes'], safetyAttributesFromMldev(apiClient, fromSafetyAttributes));
5145
+ }
5128
5146
  return toObject;
5129
5147
  }
5130
5148
  function generatedImageFromVertex(apiClient, fromObject) {
@@ -5139,6 +5157,10 @@ function generatedImageFromVertex(apiClient, fromObject) {
5139
5157
  if (fromRaiFilteredReason != null) {
5140
5158
  setValueByPath(toObject, ['raiFilteredReason'], fromRaiFilteredReason);
5141
5159
  }
5160
+ const fromSafetyAttributes = getValueByPath(fromObject, ['_self']);
5161
+ if (fromSafetyAttributes != null) {
5162
+ setValueByPath(toObject, ['safetyAttributes'], safetyAttributesFromVertex(apiClient, fromSafetyAttributes));
5163
+ }
5142
5164
  const fromEnhancedPrompt = getValueByPath(fromObject, ['prompt']);
5143
5165
  if (fromEnhancedPrompt != null) {
5144
5166
  setValueByPath(toObject, ['enhancedPrompt'], fromEnhancedPrompt);
@@ -5201,14 +5223,6 @@ function countTokensResponseFromVertex(apiClient, fromObject) {
5201
5223
  }
5202
5224
  return toObject;
5203
5225
  }
5204
- function computeTokensResponseFromMldev(apiClient, fromObject) {
5205
- const toObject = {};
5206
- const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
5207
- if (fromTokensInfo != null) {
5208
- setValueByPath(toObject, ['tokensInfo'], fromTokensInfo);
5209
- }
5210
- return toObject;
5211
- }
5212
5226
  function computeTokensResponseFromVertex(apiClient, fromObject) {
5213
5227
  const toObject = {};
5214
5228
  const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
@@ -5220,7 +5234,7 @@ function computeTokensResponseFromVertex(apiClient, fromObject) {
5220
5234
 
5221
5235
  /**
5222
5236
  * @license
5223
- * Copyright 2024 Google LLC
5237
+ * Copyright 2025 Google LLC
5224
5238
  * SPDX-License-Identifier: Apache-2.0
5225
5239
  */
5226
5240
  const FUNCTION_RESPONSE_REQUIRES_ID = 'FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.';
@@ -5481,6 +5495,12 @@ function liveServerMessageFromVertex(apiClient, fromObject) {
5481
5495
  /**
5482
5496
  * Handles incoming messages from the WebSocket.
5483
5497
  *
5498
+ * @remarks
5499
+ * This function is responsible for parsing incoming messages, transforming them
5500
+ * into LiveServerMessages, and then calling the onmessage callback. Note that
5501
+ * the first message which is received from the server is a setupComplete
5502
+ * message.
5503
+ *
5484
5504
  * @param apiClient The ApiClient instance.
5485
5505
  * @param onmessage The user-provided onmessage callback (if any).
5486
5506
  * @param event The MessageEvent from the WebSocket.
@@ -5518,20 +5538,14 @@ class Live {
5518
5538
  Establishes a connection to the specified model with the given
5519
5539
  configuration and returns a Session object representing that connection.
5520
5540
 
5521
- > [!CAUTION] This SDK does not yet support the live API for **Google Vertex AI**.
5522
-
5523
5541
  @experimental
5524
5542
 
5525
- @param model - Model to use for the Live session.
5526
- @param config - Configuration parameters for the Live session.
5527
- @param callbacks - Optional callbacks for websocket events. If not
5528
- provided, default no-op callbacks will be used. Generally, prefer to
5529
- provide explicit callbacks to allow for proper handling of websocket
5530
- events (e.g. connection errors).
5543
+ @param params - The parameters for establishing a connection to the model.
5544
+ @return A live session.
5531
5545
 
5532
5546
  @example
5533
5547
  ```ts
5534
- const session = await client.live.connect({
5548
+ const session = await ai.live.connect({
5535
5549
  model: 'gemini-2.0-flash-exp',
5536
5550
  config: {
5537
5551
  responseModalities: [Modality.AUDIO],
@@ -5555,9 +5569,6 @@ class Live {
5555
5569
  */
5556
5570
  async connect(params) {
5557
5571
  var _a, _b;
5558
- if (this.apiClient.isVertexAI()) {
5559
- throw new Error('This SDK does not yet support the live API for **Google Vertex AI**.');
5560
- }
5561
5572
  const websocketBaseUrl = this.apiClient.getWebsocketBaseUrl();
5562
5573
  const apiVersion = this.apiClient.getApiVersion();
5563
5574
  let url;
@@ -5633,8 +5644,7 @@ class Session {
5633
5644
  if (params.turns !== null && params.turns !== undefined) {
5634
5645
  let contents = [];
5635
5646
  try {
5636
- contents =
5637
- tContents(apiClient, params.turns);
5647
+ contents = tContents(apiClient, params.turns);
5638
5648
  if (apiClient.isVertexAI()) {
5639
5649
  contents = contents.map((item) => contentToVertex(apiClient, item));
5640
5650
  }
@@ -5674,8 +5684,10 @@ class Session {
5674
5684
  throw new Error('functionResponses is required.');
5675
5685
  }
5676
5686
  for (const functionResponse of functionResponses) {
5677
- if (typeof functionResponse !== 'object' || functionResponse === null ||
5678
- !('name' in functionResponse) || !('response' in functionResponse)) {
5687
+ if (typeof functionResponse !== 'object' ||
5688
+ functionResponse === null ||
5689
+ !('name' in functionResponse) ||
5690
+ !('response' in functionResponse)) {
5679
5691
  throw new Error(`Could not parse function response, type '${typeof functionResponse}'.`);
5680
5692
  }
5681
5693
  if (!apiClient.isVertexAI() && !('id' in functionResponse)) {
@@ -5683,7 +5695,7 @@ class Session {
5683
5695
  }
5684
5696
  }
5685
5697
  const clientMessage = {
5686
- toolResponse: { functionResponses: functionResponses }
5698
+ toolResponse: { functionResponses: functionResponses },
5687
5699
  };
5688
5700
  return clientMessage;
5689
5701
  }
@@ -5801,7 +5813,7 @@ class Session {
5801
5813
 
5802
5814
  @example
5803
5815
  ```ts
5804
- const session = await client.live.connect({
5816
+ const session = await ai.live.connect({
5805
5817
  model: 'gemini-2.0-flash-exp',
5806
5818
  config: {
5807
5819
  responseModalities: [Modality.AUDIO],
@@ -5838,13 +5850,13 @@ function mapToHeaders(map) {
5838
5850
 
5839
5851
  /**
5840
5852
  * @license
5841
- * Copyright 2024 Google LLC
5853
+ * Copyright 2025 Google LLC
5842
5854
  * SPDX-License-Identifier: Apache-2.0
5843
5855
  */
5844
5856
  const CONTENT_TYPE_HEADER = 'Content-Type';
5845
5857
  const USER_AGENT_HEADER = 'User-Agent';
5846
5858
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
5847
- const SDK_VERSION = '0.2.0'; // x-release-please-version
5859
+ const SDK_VERSION = '0.4.0'; // x-release-please-version
5848
5860
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
5849
5861
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
5850
5862
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -6056,7 +6068,7 @@ class ApiClient {
6056
6068
  async unaryApiCall(url, requestInit, httpMethod) {
6057
6069
  return this.apiCall(url.toString(), Object.assign(Object.assign({}, requestInit), { method: httpMethod }))
6058
6070
  .then(async (response) => {
6059
- await throwErrorIfNotOK(response, url.toString());
6071
+ await throwErrorIfNotOK(response);
6060
6072
  return new HttpResponse(response);
6061
6073
  })
6062
6074
  .catch((e) => {
@@ -6071,7 +6083,7 @@ class ApiClient {
6071
6083
  async streamApiCall(url, requestInit, httpMethod) {
6072
6084
  return this.apiCall(url.toString(), Object.assign(Object.assign({}, requestInit), { method: httpMethod }))
6073
6085
  .then(async (response) => {
6074
- await throwErrorIfNotOK(response, url.toString());
6086
+ await throwErrorIfNotOK(response);
6075
6087
  return this.processStreamResponse(response);
6076
6088
  })
6077
6089
  .catch((e) => {
@@ -6216,7 +6228,7 @@ class ApiClient {
6216
6228
  return uploadUrl;
6217
6229
  }
6218
6230
  }
6219
- async function throwErrorIfNotOK(response, url, requestInit) {
6231
+ async function throwErrorIfNotOK(response) {
6220
6232
  var _a;
6221
6233
  if (response === undefined) {
6222
6234
  throw new ServerError('response is undefined');
@@ -6252,7 +6264,7 @@ async function throwErrorIfNotOK(response, url, requestInit) {
6252
6264
 
6253
6265
  /**
6254
6266
  * @license
6255
- * Copyright 2024 Google LLC
6267
+ * Copyright 2025 Google LLC
6256
6268
  * SPDX-License-Identifier: Apache-2.0
6257
6269
  */
6258
6270
  class Files extends BaseModule {
@@ -6270,7 +6282,7 @@ class Files extends BaseModule {
6270
6282
  * size of each page is 10.
6271
6283
  *
6272
6284
  * ```ts
6273
- * const listResponse = await client.files.list({config: {'pageSize': 10}});
6285
+ * const listResponse = await ai.files.list({config: {'pageSize': 10}});
6274
6286
  * for await (const file of listResponse) {
6275
6287
  * console.log(file.name);
6276
6288
  * }
@@ -6303,63 +6315,43 @@ class Files extends BaseModule {
6303
6315
  *
6304
6316
  * This section can contain multiple paragraphs and code examples.
6305
6317
  *
6306
- * @param file The string path to the file to be uploaded or a Blob object.
6307
- * @param config Optional parameters specified in the `types.UploadFileConfig`
6308
- * interface. Optional @see {@link types.UploadFileConfig}
6318
+ * @param params - Optional parameters specified in the
6319
+ * `common.UploadFileParameters` interface.
6320
+ * Optional @see {@link common.UploadFileParameters}
6309
6321
  * @return A promise that resolves to a `types.File` object.
6310
6322
  * @throws An error if called on a Vertex AI client.
6311
6323
  * @throws An error if the `mimeType` is not provided and can not be inferred,
6312
- * the `mimeType` can be provided in the `config` parameter.
6324
+ * the `mimeType` can be provided in the `params.config` parameter.
6313
6325
  * @throws An error occurs if a suitable upload location cannot be established.
6314
6326
  *
6315
6327
  * @example
6316
6328
  * The following code uploads a file to Gemini API.
6317
6329
  *
6318
6330
  * ```ts
6319
- * const file = await client.files.upload('file.txt', {
6331
+ * const file = await ai.files.upload({file: 'file.txt', config: {
6320
6332
  * mimeType: 'text/plain',
6321
- * });
6333
+ * }});
6322
6334
  * console.log(file.name);
6323
6335
  * ```
6324
6336
  */
6325
- async upload(file, config) {
6337
+ async upload(params) {
6326
6338
  if (this.apiClient.isVertexAI()) {
6327
6339
  throw new Error('Vertex AI does not support uploading files. You can share files through a GCS bucket.');
6328
6340
  }
6329
- return this.apiClient.uploadFile(file, config).then((response) => {
6341
+ return this.apiClient
6342
+ .uploadFile(params.file, params.config)
6343
+ .then((response) => {
6330
6344
  const file = fileFromMldev(this.apiClient, response);
6331
6345
  return file;
6332
6346
  });
6333
6347
  }
6334
6348
  async listInternal(params) {
6335
- var _a, _b;
6349
+ var _a;
6336
6350
  let response;
6337
6351
  let path = '';
6338
6352
  let queryParams = {};
6339
6353
  if (this.apiClient.isVertexAI()) {
6340
- const body = listFilesParametersToVertex(this.apiClient, params);
6341
- path = formatMap('None', body['_url']);
6342
- queryParams = body['_query'];
6343
- delete body['config'];
6344
- delete body['_url'];
6345
- delete body['_query'];
6346
- response = this.apiClient
6347
- .request({
6348
- path: path,
6349
- queryParams: queryParams,
6350
- body: JSON.stringify(body),
6351
- httpMethod: 'GET',
6352
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6353
- })
6354
- .then((httpResponse) => {
6355
- return httpResponse.json();
6356
- });
6357
- return response.then((apiResponse) => {
6358
- const resp = listFilesResponseFromVertex(this.apiClient);
6359
- const typedResp = new ListFilesResponse();
6360
- Object.assign(typedResp, resp);
6361
- return typedResp;
6362
- });
6354
+ throw new Error('This method is only supported by the Gemini Developer API.');
6363
6355
  }
6364
6356
  else {
6365
6357
  const body = listFilesParametersToMldev(this.apiClient, params);
@@ -6374,7 +6366,7 @@ class Files extends BaseModule {
6374
6366
  queryParams: queryParams,
6375
6367
  body: JSON.stringify(body),
6376
6368
  httpMethod: 'GET',
6377
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
6369
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6378
6370
  })
6379
6371
  .then((httpResponse) => {
6380
6372
  return httpResponse.json();
@@ -6388,34 +6380,12 @@ class Files extends BaseModule {
6388
6380
  }
6389
6381
  }
6390
6382
  async createInternal(params) {
6391
- var _a, _b;
6383
+ var _a;
6392
6384
  let response;
6393
6385
  let path = '';
6394
6386
  let queryParams = {};
6395
6387
  if (this.apiClient.isVertexAI()) {
6396
- const body = createFileParametersToVertex(this.apiClient, params);
6397
- path = formatMap('', body['_url']);
6398
- queryParams = body['_query'];
6399
- delete body['config'];
6400
- delete body['_url'];
6401
- delete body['_query'];
6402
- response = this.apiClient
6403
- .request({
6404
- path: path,
6405
- queryParams: queryParams,
6406
- body: JSON.stringify(body),
6407
- httpMethod: 'POST',
6408
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6409
- })
6410
- .then((httpResponse) => {
6411
- return httpResponse.json();
6412
- });
6413
- return response.then((apiResponse) => {
6414
- const resp = createFileResponseFromVertex(this.apiClient, apiResponse);
6415
- const typedResp = new CreateFileResponse();
6416
- Object.assign(typedResp, resp);
6417
- return typedResp;
6418
- });
6388
+ throw new Error('This method is only supported by the Gemini Developer API.');
6419
6389
  }
6420
6390
  else {
6421
6391
  const body = createFileParametersToMldev(this.apiClient, params);
@@ -6430,7 +6400,7 @@ class Files extends BaseModule {
6430
6400
  queryParams: queryParams,
6431
6401
  body: JSON.stringify(body),
6432
6402
  httpMethod: 'POST',
6433
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
6403
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6434
6404
  })
6435
6405
  .then((httpResponse) => {
6436
6406
  return httpResponse.json();
@@ -6454,37 +6424,17 @@ class Files extends BaseModule {
6454
6424
  * const config: GetFileParameters = {
6455
6425
  * name: fileName,
6456
6426
  * };
6457
- * file = await client.files.get(config);
6427
+ * file = await ai.files.get(config);
6458
6428
  * console.log(file.name);
6459
6429
  * ```
6460
6430
  */
6461
6431
  async get(params) {
6462
- var _a, _b;
6432
+ var _a;
6463
6433
  let response;
6464
6434
  let path = '';
6465
6435
  let queryParams = {};
6466
6436
  if (this.apiClient.isVertexAI()) {
6467
- const body = getFileParametersToVertex(this.apiClient, params);
6468
- path = formatMap('None', body['_url']);
6469
- queryParams = body['_query'];
6470
- delete body['config'];
6471
- delete body['_url'];
6472
- delete body['_query'];
6473
- response = this.apiClient
6474
- .request({
6475
- path: path,
6476
- queryParams: queryParams,
6477
- body: JSON.stringify(body),
6478
- httpMethod: 'GET',
6479
- httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6480
- })
6481
- .then((httpResponse) => {
6482
- return httpResponse.json();
6483
- });
6484
- return response.then((apiResponse) => {
6485
- const resp = fileFromVertex(this.apiClient);
6486
- return resp;
6487
- });
6437
+ throw new Error('This method is only supported by the Gemini Developer API.');
6488
6438
  }
6489
6439
  else {
6490
6440
  const body = getFileParametersToMldev(this.apiClient, params);
@@ -6499,7 +6449,7 @@ class Files extends BaseModule {
6499
6449
  queryParams: queryParams,
6500
6450
  body: JSON.stringify(body),
6501
6451
  httpMethod: 'GET',
6502
- httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
6452
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
6503
6453
  })
6504
6454
  .then((httpResponse) => {
6505
6455
  return httpResponse.json();
@@ -6531,13 +6481,6 @@ function listFilesParametersToMldev(apiClient, fromObject) {
6531
6481
  }
6532
6482
  return toObject;
6533
6483
  }
6534
- function listFilesParametersToVertex(apiClient, fromObject) {
6535
- const toObject = {};
6536
- if (getValueByPath(fromObject, ['config']) !== undefined) {
6537
- throw new Error('config parameter is not supported in Vertex AI.');
6538
- }
6539
- return toObject;
6540
- }
6541
6484
  function fileStatusToMldev(apiClient, fromObject) {
6542
6485
  const toObject = {};
6543
6486
  const fromDetails = getValueByPath(fromObject, ['details']);
@@ -6630,16 +6573,6 @@ function createFileParametersToMldev(apiClient, fromObject) {
6630
6573
  }
6631
6574
  return toObject;
6632
6575
  }
6633
- function createFileParametersToVertex(apiClient, fromObject) {
6634
- const toObject = {};
6635
- if (getValueByPath(fromObject, ['file']) !== undefined) {
6636
- throw new Error('file parameter is not supported in Vertex AI.');
6637
- }
6638
- if (getValueByPath(fromObject, ['config']) !== undefined) {
6639
- throw new Error('config parameter is not supported in Vertex AI.');
6640
- }
6641
- return toObject;
6642
- }
6643
6576
  function getFileParametersToMldev(apiClient, fromObject) {
6644
6577
  const toObject = {};
6645
6578
  const fromName = getValueByPath(fromObject, ['name']);
@@ -6652,16 +6585,6 @@ function getFileParametersToMldev(apiClient, fromObject) {
6652
6585
  }
6653
6586
  return toObject;
6654
6587
  }
6655
- function getFileParametersToVertex(apiClient, fromObject) {
6656
- const toObject = {};
6657
- if (getValueByPath(fromObject, ['name']) !== undefined) {
6658
- throw new Error('name parameter is not supported in Vertex AI.');
6659
- }
6660
- if (getValueByPath(fromObject, ['config']) !== undefined) {
6661
- throw new Error('config parameter is not supported in Vertex AI.');
6662
- }
6663
- return toObject;
6664
- }
6665
6588
  function fileStatusFromMldev(apiClient, fromObject) {
6666
6589
  const toObject = {};
6667
6590
  const fromDetails = getValueByPath(fromObject, ['details']);
@@ -6742,10 +6665,6 @@ function fileFromMldev(apiClient, fromObject) {
6742
6665
  }
6743
6666
  return toObject;
6744
6667
  }
6745
- function fileFromVertex(apiClient, fromObject) {
6746
- const toObject = {};
6747
- return toObject;
6748
- }
6749
6668
  function listFilesResponseFromMldev(apiClient, fromObject) {
6750
6669
  const toObject = {};
6751
6670
  const fromNextPageToken = getValueByPath(fromObject, [
@@ -6767,10 +6686,6 @@ function listFilesResponseFromMldev(apiClient, fromObject) {
6767
6686
  }
6768
6687
  return toObject;
6769
6688
  }
6770
- function listFilesResponseFromVertex(apiClient, fromObject) {
6771
- const toObject = {};
6772
- return toObject;
6773
- }
6774
6689
  function createFileResponseFromMldev(apiClient, fromObject) {
6775
6690
  const toObject = {};
6776
6691
  const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
@@ -6779,14 +6694,6 @@ function createFileResponseFromMldev(apiClient, fromObject) {
6779
6694
  }
6780
6695
  return toObject;
6781
6696
  }
6782
- function createFileResponseFromVertex(apiClient, fromObject) {
6783
- const toObject = {};
6784
- const fromHttpHeaders = getValueByPath(fromObject, ['httpHeaders']);
6785
- if (fromHttpHeaders != null) {
6786
- setValueByPath(toObject, ['httpHeaders'], fromHttpHeaders);
6787
- }
6788
- return toObject;
6789
- }
6790
6697
 
6791
6698
  /**
6792
6699
  * @license
@@ -6961,14 +6868,14 @@ const LANGUAGE_LABEL_PREFIX = 'gl-node/';
6961
6868
  * Initializing the SDK for using the Gemini API:
6962
6869
  * ```ts
6963
6870
  * import {GoogleGenAI} from '@google/genai';
6964
- * const ai = genai.GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
6871
+ * const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
6965
6872
  * ```
6966
6873
  *
6967
6874
  * @example
6968
6875
  * Initializing the SDK for using the Vertex AI API:
6969
6876
  * ```ts
6970
6877
  * import {GoogleGenAI} from '@google/genai';
6971
- * const ai = genai.GoogleGenAI({
6878
+ * const ai = new GoogleGenAI({
6972
6879
  * vertexai: true,
6973
6880
  * project: 'PROJECT_ID',
6974
6881
  * location: 'PROJECT_LOCATION'
@@ -6983,6 +6890,9 @@ class GoogleGenAI {
6983
6890
  throw new Error('An API Key must be set when running in a browser');
6984
6891
  }
6985
6892
  this.vertexai = (_a = options.vertexai) !== null && _a !== void 0 ? _a : false;
6893
+ if (this.vertexai) {
6894
+ throw new Error("VertexAI browser support is not yet implemented, it's coming soon!");
6895
+ }
6986
6896
  this.apiKey = options.apiKey;
6987
6897
  this.apiVersion = options.apiVersion;
6988
6898
  const auth = new WebAuth(this.apiKey);
@@ -7003,5 +6913,5 @@ class GoogleGenAI {
7003
6913
  }
7004
6914
  }
7005
6915
 
7006
- 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 };
6916
+ 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 };
7007
6917
  //# sourceMappingURL=index.mjs.map