@google/genai 1.37.0 → 1.39.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.
@@ -1355,6 +1355,18 @@ exports.PartMediaResolutionLevel = void 0;
1355
1355
  */
1356
1356
  PartMediaResolutionLevel["MEDIA_RESOLUTION_ULTRA_HIGH"] = "MEDIA_RESOLUTION_ULTRA_HIGH";
1357
1357
  })(exports.PartMediaResolutionLevel || (exports.PartMediaResolutionLevel = {}));
1358
+ /** Resource scope. */
1359
+ exports.ResourceScope = void 0;
1360
+ (function (ResourceScope) {
1361
+ /**
1362
+ * When setting base_url, this value configures resource scope to be the collection.
1363
+ The resource name will not include api version, project, or location.
1364
+ For example, if base_url is set to "https://aiplatform.googleapis.com",
1365
+ then the resource name for a Model would be
1366
+ "https://aiplatform.googleapis.com/publishers/google/models/gemini-3-pro-preview
1367
+ */
1368
+ ResourceScope["COLLECTION"] = "COLLECTION";
1369
+ })(exports.ResourceScope || (exports.ResourceScope = {}));
1358
1370
  /** Options for feature selection preference. */
1359
1371
  exports.FeatureSelectionPreference = void 0;
1360
1372
  (function (FeatureSelectionPreference) {
@@ -1548,6 +1560,10 @@ exports.TuningMethod = void 0;
1548
1560
  * Preference optimization tuning.
1549
1561
  */
1550
1562
  TuningMethod["PREFERENCE_TUNING"] = "PREFERENCE_TUNING";
1563
+ /**
1564
+ * Distillation tuning.
1565
+ */
1566
+ TuningMethod["DISTILLATION"] = "DISTILLATION";
1551
1567
  })(exports.TuningMethod || (exports.TuningMethod = {}));
1552
1568
  /** State for the lifecycle of a Document. */
1553
1569
  exports.DocumentState = void 0;
@@ -2339,6 +2355,9 @@ class CreateFileResponse {
2339
2355
  /** Response for the delete file method. */
2340
2356
  class DeleteFileResponse {
2341
2357
  }
2358
+ /** Response for the _register file method. */
2359
+ class RegisterFilesResponse {
2360
+ }
2342
2361
  /** Config for `inlined_responses` parameter. */
2343
2362
  class InlinedResponse {
2344
2363
  }
@@ -4191,6 +4210,9 @@ function generateContentConfigToMldev$1(apiClient, fromObject, parentObject) {
4191
4210
  if (fromEnableEnhancedCivicAnswers != null) {
4192
4211
  setValueByPath(toObject, ['enableEnhancedCivicAnswers'], fromEnableEnhancedCivicAnswers);
4193
4212
  }
4213
+ if (getValueByPath(fromObject, ['modelArmorConfig']) !== undefined) {
4214
+ throw new Error('modelArmorConfig parameter is not supported in Gemini API.');
4215
+ }
4194
4216
  return toObject;
4195
4217
  }
4196
4218
  function generateContentResponseFromMldev$1(fromObject) {
@@ -4330,6 +4352,10 @@ function inlinedResponseFromMldev(fromObject) {
4330
4352
  if (fromResponse != null) {
4331
4353
  setValueByPath(toObject, ['response'], generateContentResponseFromMldev$1(fromResponse));
4332
4354
  }
4355
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
4356
+ if (fromMetadata != null) {
4357
+ setValueByPath(toObject, ['metadata'], fromMetadata);
4358
+ }
4333
4359
  const fromError = getValueByPath(fromObject, ['error']);
4334
4360
  if (fromError != null) {
4335
4361
  setValueByPath(toObject, ['error'], fromError);
@@ -6770,6 +6796,14 @@ function getFileParametersToMldev(fromObject) {
6770
6796
  }
6771
6797
  return toObject;
6772
6798
  }
6799
+ function internalRegisterFilesParametersToMldev(fromObject) {
6800
+ const toObject = {};
6801
+ const fromUris = getValueByPath(fromObject, ['uris']);
6802
+ if (fromUris != null) {
6803
+ setValueByPath(toObject, ['uris'], fromUris);
6804
+ }
6805
+ return toObject;
6806
+ }
6773
6807
  function listFilesConfigToMldev(fromObject, parentObject) {
6774
6808
  const toObject = {};
6775
6809
  const fromPageSize = getValueByPath(fromObject, ['pageSize']);
@@ -6816,6 +6850,26 @@ function listFilesResponseFromMldev(fromObject) {
6816
6850
  }
6817
6851
  return toObject;
6818
6852
  }
6853
+ function registerFilesResponseFromMldev(fromObject) {
6854
+ const toObject = {};
6855
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
6856
+ 'sdkHttpResponse',
6857
+ ]);
6858
+ if (fromSdkHttpResponse != null) {
6859
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
6860
+ }
6861
+ const fromFiles = getValueByPath(fromObject, ['files']);
6862
+ if (fromFiles != null) {
6863
+ let transformedList = fromFiles;
6864
+ if (Array.isArray(transformedList)) {
6865
+ transformedList = transformedList.map((item) => {
6866
+ return item;
6867
+ });
6868
+ }
6869
+ setValueByPath(toObject, ['files'], transformedList);
6870
+ }
6871
+ return toObject;
6872
+ }
6819
6873
 
6820
6874
  /**
6821
6875
  * @license
@@ -6916,6 +6970,16 @@ class Files extends BaseModule {
6916
6970
  async download(params) {
6917
6971
  await this.apiClient.downloadFile(params);
6918
6972
  }
6973
+ /**
6974
+ * Registers Google Cloud Storage files for use with the API.
6975
+ * This method is only available in Node.js environments.
6976
+ */
6977
+ async registerFiles(params) {
6978
+ throw new Error('registerFiles is only supported in Node.js environments.');
6979
+ }
6980
+ async _registerFiles(params) {
6981
+ return this.registerFilesInternal(params);
6982
+ }
6919
6983
  async listInternal(params) {
6920
6984
  var _a, _b;
6921
6985
  let response;
@@ -7089,6 +7153,40 @@ class Files extends BaseModule {
7089
7153
  });
7090
7154
  }
7091
7155
  }
7156
+ async registerFilesInternal(params) {
7157
+ var _a, _b;
7158
+ let response;
7159
+ let path = '';
7160
+ let queryParams = {};
7161
+ if (this.apiClient.isVertexAI()) {
7162
+ throw new Error('This method is only supported by the Gemini Developer API.');
7163
+ }
7164
+ else {
7165
+ const body = internalRegisterFilesParametersToMldev(params);
7166
+ path = formatMap('files:register', body['_url']);
7167
+ queryParams = body['_query'];
7168
+ delete body['_url'];
7169
+ delete body['_query'];
7170
+ response = this.apiClient
7171
+ .request({
7172
+ path: path,
7173
+ queryParams: queryParams,
7174
+ body: JSON.stringify(body),
7175
+ httpMethod: 'POST',
7176
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
7177
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
7178
+ })
7179
+ .then((httpResponse) => {
7180
+ return httpResponse.json();
7181
+ });
7182
+ return response.then((apiResponse) => {
7183
+ const resp = registerFilesResponseFromMldev(apiResponse);
7184
+ const typedResp = new RegisterFilesResponse();
7185
+ Object.assign(typedResp, resp);
7186
+ return typedResp;
7187
+ });
7188
+ }
7189
+ }
7092
7190
  }
7093
7191
 
7094
7192
  /**
@@ -8061,7 +8159,7 @@ function voiceActivityFromVertex(fromObject) {
8061
8159
  * Copyright 2025 Google LLC
8062
8160
  * SPDX-License-Identifier: Apache-2.0
8063
8161
  */
8064
- function blobToMldev$1(fromObject) {
8162
+ function blobToMldev$1(fromObject, _rootObject) {
8065
8163
  const toObject = {};
8066
8164
  const fromData = getValueByPath(fromObject, ['data']);
8067
8165
  if (fromData != null) {
@@ -8076,7 +8174,7 @@ function blobToMldev$1(fromObject) {
8076
8174
  }
8077
8175
  return toObject;
8078
8176
  }
8079
- function candidateFromMldev(fromObject) {
8177
+ function candidateFromMldev(fromObject, rootObject) {
8080
8178
  const toObject = {};
8081
8179
  const fromContent = getValueByPath(fromObject, ['content']);
8082
8180
  if (fromContent != null) {
@@ -8136,7 +8234,7 @@ function candidateFromMldev(fromObject) {
8136
8234
  }
8137
8235
  return toObject;
8138
8236
  }
8139
- function citationMetadataFromMldev(fromObject) {
8237
+ function citationMetadataFromMldev(fromObject, _rootObject) {
8140
8238
  const toObject = {};
8141
8239
  const fromCitations = getValueByPath(fromObject, ['citationSources']);
8142
8240
  if (fromCitations != null) {
@@ -8150,7 +8248,7 @@ function citationMetadataFromMldev(fromObject) {
8150
8248
  }
8151
8249
  return toObject;
8152
8250
  }
8153
- function computeTokensParametersToVertex(apiClient, fromObject) {
8251
+ function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
8154
8252
  const toObject = {};
8155
8253
  const fromModel = getValueByPath(fromObject, ['model']);
8156
8254
  if (fromModel != null) {
@@ -8168,7 +8266,7 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
8168
8266
  }
8169
8267
  return toObject;
8170
8268
  }
8171
- function computeTokensResponseFromVertex(fromObject) {
8269
+ function computeTokensResponseFromVertex(fromObject, _rootObject) {
8172
8270
  const toObject = {};
8173
8271
  const fromSdkHttpResponse = getValueByPath(fromObject, [
8174
8272
  'sdkHttpResponse',
@@ -8188,7 +8286,7 @@ function computeTokensResponseFromVertex(fromObject) {
8188
8286
  }
8189
8287
  return toObject;
8190
8288
  }
8191
- function contentEmbeddingFromVertex(fromObject) {
8289
+ function contentEmbeddingFromVertex(fromObject, rootObject) {
8192
8290
  const toObject = {};
8193
8291
  const fromValues = getValueByPath(fromObject, ['values']);
8194
8292
  if (fromValues != null) {
@@ -8200,7 +8298,7 @@ function contentEmbeddingFromVertex(fromObject) {
8200
8298
  }
8201
8299
  return toObject;
8202
8300
  }
8203
- function contentEmbeddingStatisticsFromVertex(fromObject) {
8301
+ function contentEmbeddingStatisticsFromVertex(fromObject, _rootObject) {
8204
8302
  const toObject = {};
8205
8303
  const fromTruncated = getValueByPath(fromObject, ['truncated']);
8206
8304
  if (fromTruncated != null) {
@@ -8212,7 +8310,7 @@ function contentEmbeddingStatisticsFromVertex(fromObject) {
8212
8310
  }
8213
8311
  return toObject;
8214
8312
  }
8215
- function contentToMldev$1(fromObject) {
8313
+ function contentToMldev$1(fromObject, rootObject) {
8216
8314
  const toObject = {};
8217
8315
  const fromParts = getValueByPath(fromObject, ['parts']);
8218
8316
  if (fromParts != null) {
@@ -8230,7 +8328,7 @@ function contentToMldev$1(fromObject) {
8230
8328
  }
8231
8329
  return toObject;
8232
8330
  }
8233
- function controlReferenceConfigToVertex(fromObject) {
8331
+ function controlReferenceConfigToVertex(fromObject, _rootObject) {
8234
8332
  const toObject = {};
8235
8333
  const fromControlType = getValueByPath(fromObject, ['controlType']);
8236
8334
  if (fromControlType != null) {
@@ -8244,7 +8342,7 @@ function controlReferenceConfigToVertex(fromObject) {
8244
8342
  }
8245
8343
  return toObject;
8246
8344
  }
8247
- function countTokensConfigToMldev(fromObject) {
8345
+ function countTokensConfigToMldev(fromObject, _rootObject) {
8248
8346
  const toObject = {};
8249
8347
  if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
8250
8348
  throw new Error('systemInstruction parameter is not supported in Gemini API.');
@@ -8257,7 +8355,7 @@ function countTokensConfigToMldev(fromObject) {
8257
8355
  }
8258
8356
  return toObject;
8259
8357
  }
8260
- function countTokensConfigToVertex(fromObject, parentObject) {
8358
+ function countTokensConfigToVertex(fromObject, parentObject, rootObject) {
8261
8359
  const toObject = {};
8262
8360
  const fromSystemInstruction = getValueByPath(fromObject, [
8263
8361
  'systemInstruction',
@@ -8283,7 +8381,7 @@ function countTokensConfigToVertex(fromObject, parentObject) {
8283
8381
  }
8284
8382
  return toObject;
8285
8383
  }
8286
- function countTokensParametersToMldev(apiClient, fromObject) {
8384
+ function countTokensParametersToMldev(apiClient, fromObject, rootObject) {
8287
8385
  const toObject = {};
8288
8386
  const fromModel = getValueByPath(fromObject, ['model']);
8289
8387
  if (fromModel != null) {
@@ -8305,7 +8403,7 @@ function countTokensParametersToMldev(apiClient, fromObject) {
8305
8403
  }
8306
8404
  return toObject;
8307
8405
  }
8308
- function countTokensParametersToVertex(apiClient, fromObject) {
8406
+ function countTokensParametersToVertex(apiClient, fromObject, rootObject) {
8309
8407
  const toObject = {};
8310
8408
  const fromModel = getValueByPath(fromObject, ['model']);
8311
8409
  if (fromModel != null) {
@@ -8327,7 +8425,7 @@ function countTokensParametersToVertex(apiClient, fromObject) {
8327
8425
  }
8328
8426
  return toObject;
8329
8427
  }
8330
- function countTokensResponseFromMldev(fromObject) {
8428
+ function countTokensResponseFromMldev(fromObject, _rootObject) {
8331
8429
  const toObject = {};
8332
8430
  const fromSdkHttpResponse = getValueByPath(fromObject, [
8333
8431
  'sdkHttpResponse',
@@ -8347,7 +8445,7 @@ function countTokensResponseFromMldev(fromObject) {
8347
8445
  }
8348
8446
  return toObject;
8349
8447
  }
8350
- function countTokensResponseFromVertex(fromObject) {
8448
+ function countTokensResponseFromVertex(fromObject, _rootObject) {
8351
8449
  const toObject = {};
8352
8450
  const fromSdkHttpResponse = getValueByPath(fromObject, [
8353
8451
  'sdkHttpResponse',
@@ -8361,7 +8459,7 @@ function countTokensResponseFromVertex(fromObject) {
8361
8459
  }
8362
8460
  return toObject;
8363
8461
  }
8364
- function deleteModelParametersToMldev(apiClient, fromObject) {
8462
+ function deleteModelParametersToMldev(apiClient, fromObject, _rootObject) {
8365
8463
  const toObject = {};
8366
8464
  const fromModel = getValueByPath(fromObject, ['model']);
8367
8465
  if (fromModel != null) {
@@ -8369,7 +8467,7 @@ function deleteModelParametersToMldev(apiClient, fromObject) {
8369
8467
  }
8370
8468
  return toObject;
8371
8469
  }
8372
- function deleteModelParametersToVertex(apiClient, fromObject) {
8470
+ function deleteModelParametersToVertex(apiClient, fromObject, _rootObject) {
8373
8471
  const toObject = {};
8374
8472
  const fromModel = getValueByPath(fromObject, ['model']);
8375
8473
  if (fromModel != null) {
@@ -8377,7 +8475,7 @@ function deleteModelParametersToVertex(apiClient, fromObject) {
8377
8475
  }
8378
8476
  return toObject;
8379
8477
  }
8380
- function deleteModelResponseFromMldev(fromObject) {
8478
+ function deleteModelResponseFromMldev(fromObject, _rootObject) {
8381
8479
  const toObject = {};
8382
8480
  const fromSdkHttpResponse = getValueByPath(fromObject, [
8383
8481
  'sdkHttpResponse',
@@ -8387,7 +8485,7 @@ function deleteModelResponseFromMldev(fromObject) {
8387
8485
  }
8388
8486
  return toObject;
8389
8487
  }
8390
- function deleteModelResponseFromVertex(fromObject) {
8488
+ function deleteModelResponseFromVertex(fromObject, _rootObject) {
8391
8489
  const toObject = {};
8392
8490
  const fromSdkHttpResponse = getValueByPath(fromObject, [
8393
8491
  'sdkHttpResponse',
@@ -8397,7 +8495,7 @@ function deleteModelResponseFromVertex(fromObject) {
8397
8495
  }
8398
8496
  return toObject;
8399
8497
  }
8400
- function editImageConfigToVertex(fromObject, parentObject) {
8498
+ function editImageConfigToVertex(fromObject, parentObject, _rootObject) {
8401
8499
  const toObject = {};
8402
8500
  const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
8403
8501
  if (parentObject !== undefined && fromOutputGcsUri != null) {
@@ -8487,7 +8585,7 @@ function editImageConfigToVertex(fromObject, parentObject) {
8487
8585
  }
8488
8586
  return toObject;
8489
8587
  }
8490
- function editImageParametersInternalToVertex(apiClient, fromObject) {
8588
+ function editImageParametersInternalToVertex(apiClient, fromObject, rootObject) {
8491
8589
  const toObject = {};
8492
8590
  const fromModel = getValueByPath(fromObject, ['model']);
8493
8591
  if (fromModel != null) {
@@ -8515,7 +8613,7 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
8515
8613
  }
8516
8614
  return toObject;
8517
8615
  }
8518
- function editImageResponseFromVertex(fromObject) {
8616
+ function editImageResponseFromVertex(fromObject, rootObject) {
8519
8617
  const toObject = {};
8520
8618
  const fromSdkHttpResponse = getValueByPath(fromObject, [
8521
8619
  'sdkHttpResponse',
@@ -8537,7 +8635,7 @@ function editImageResponseFromVertex(fromObject) {
8537
8635
  }
8538
8636
  return toObject;
8539
8637
  }
8540
- function embedContentConfigToMldev(fromObject, parentObject) {
8638
+ function embedContentConfigToMldev(fromObject, parentObject, _rootObject) {
8541
8639
  const toObject = {};
8542
8640
  const fromTaskType = getValueByPath(fromObject, ['taskType']);
8543
8641
  if (parentObject !== undefined && fromTaskType != null) {
@@ -8561,7 +8659,7 @@ function embedContentConfigToMldev(fromObject, parentObject) {
8561
8659
  }
8562
8660
  return toObject;
8563
8661
  }
8564
- function embedContentConfigToVertex(fromObject, parentObject) {
8662
+ function embedContentConfigToVertex(fromObject, parentObject, _rootObject) {
8565
8663
  const toObject = {};
8566
8664
  const fromTaskType = getValueByPath(fromObject, ['taskType']);
8567
8665
  if (parentObject !== undefined && fromTaskType != null) {
@@ -8587,7 +8685,7 @@ function embedContentConfigToVertex(fromObject, parentObject) {
8587
8685
  }
8588
8686
  return toObject;
8589
8687
  }
8590
- function embedContentParametersToMldev(apiClient, fromObject) {
8688
+ function embedContentParametersToMldev(apiClient, fromObject, rootObject) {
8591
8689
  const toObject = {};
8592
8690
  const fromModel = getValueByPath(fromObject, ['model']);
8593
8691
  if (fromModel != null) {
@@ -8613,7 +8711,7 @@ function embedContentParametersToMldev(apiClient, fromObject) {
8613
8711
  }
8614
8712
  return toObject;
8615
8713
  }
8616
- function embedContentParametersToVertex(apiClient, fromObject) {
8714
+ function embedContentParametersToVertex(apiClient, fromObject, rootObject) {
8617
8715
  const toObject = {};
8618
8716
  const fromModel = getValueByPath(fromObject, ['model']);
8619
8717
  if (fromModel != null) {
@@ -8635,7 +8733,7 @@ function embedContentParametersToVertex(apiClient, fromObject) {
8635
8733
  }
8636
8734
  return toObject;
8637
8735
  }
8638
- function embedContentResponseFromMldev(fromObject) {
8736
+ function embedContentResponseFromMldev(fromObject, _rootObject) {
8639
8737
  const toObject = {};
8640
8738
  const fromSdkHttpResponse = getValueByPath(fromObject, [
8641
8739
  'sdkHttpResponse',
@@ -8659,7 +8757,7 @@ function embedContentResponseFromMldev(fromObject) {
8659
8757
  }
8660
8758
  return toObject;
8661
8759
  }
8662
- function embedContentResponseFromVertex(fromObject) {
8760
+ function embedContentResponseFromVertex(fromObject, rootObject) {
8663
8761
  const toObject = {};
8664
8762
  const fromSdkHttpResponse = getValueByPath(fromObject, [
8665
8763
  'sdkHttpResponse',
@@ -8686,7 +8784,7 @@ function embedContentResponseFromVertex(fromObject) {
8686
8784
  }
8687
8785
  return toObject;
8688
8786
  }
8689
- function endpointFromVertex(fromObject) {
8787
+ function endpointFromVertex(fromObject, _rootObject) {
8690
8788
  const toObject = {};
8691
8789
  const fromName = getValueByPath(fromObject, ['endpoint']);
8692
8790
  if (fromName != null) {
@@ -8700,7 +8798,7 @@ function endpointFromVertex(fromObject) {
8700
8798
  }
8701
8799
  return toObject;
8702
8800
  }
8703
- function fileDataToMldev$1(fromObject) {
8801
+ function fileDataToMldev$1(fromObject, _rootObject) {
8704
8802
  const toObject = {};
8705
8803
  if (getValueByPath(fromObject, ['displayName']) !== undefined) {
8706
8804
  throw new Error('displayName parameter is not supported in Gemini API.');
@@ -8715,7 +8813,7 @@ function fileDataToMldev$1(fromObject) {
8715
8813
  }
8716
8814
  return toObject;
8717
8815
  }
8718
- function functionCallToMldev$1(fromObject) {
8816
+ function functionCallToMldev$1(fromObject, _rootObject) {
8719
8817
  const toObject = {};
8720
8818
  const fromId = getValueByPath(fromObject, ['id']);
8721
8819
  if (fromId != null) {
@@ -8737,7 +8835,7 @@ function functionCallToMldev$1(fromObject) {
8737
8835
  }
8738
8836
  return toObject;
8739
8837
  }
8740
- function functionCallingConfigToMldev(fromObject) {
8838
+ function functionCallingConfigToMldev(fromObject, _rootObject) {
8741
8839
  const toObject = {};
8742
8840
  const fromAllowedFunctionNames = getValueByPath(fromObject, [
8743
8841
  'allowedFunctionNames',
@@ -8755,7 +8853,7 @@ function functionCallingConfigToMldev(fromObject) {
8755
8853
  }
8756
8854
  return toObject;
8757
8855
  }
8758
- function functionDeclarationToVertex(fromObject) {
8856
+ function functionDeclarationToVertex(fromObject, _rootObject) {
8759
8857
  const toObject = {};
8760
8858
  const fromDescription = getValueByPath(fromObject, ['description']);
8761
8859
  if (fromDescription != null) {
@@ -8790,7 +8888,7 @@ function functionDeclarationToVertex(fromObject) {
8790
8888
  }
8791
8889
  return toObject;
8792
8890
  }
8793
- function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
8891
+ function generateContentConfigToMldev(apiClient, fromObject, parentObject, rootObject) {
8794
8892
  const toObject = {};
8795
8893
  const fromSystemInstruction = getValueByPath(fromObject, [
8796
8894
  'systemInstruction',
@@ -8948,9 +9046,12 @@ function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
8948
9046
  if (fromEnableEnhancedCivicAnswers != null) {
8949
9047
  setValueByPath(toObject, ['enableEnhancedCivicAnswers'], fromEnableEnhancedCivicAnswers);
8950
9048
  }
9049
+ if (getValueByPath(fromObject, ['modelArmorConfig']) !== undefined) {
9050
+ throw new Error('modelArmorConfig parameter is not supported in Gemini API.');
9051
+ }
8951
9052
  return toObject;
8952
9053
  }
8953
- function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
9054
+ function generateContentConfigToVertex(apiClient, fromObject, parentObject, rootObject) {
8954
9055
  const toObject = {};
8955
9056
  const fromSystemInstruction = getValueByPath(fromObject, [
8956
9057
  'systemInstruction',
@@ -9116,9 +9217,15 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
9116
9217
  undefined) {
9117
9218
  throw new Error('enableEnhancedCivicAnswers parameter is not supported in Vertex AI.');
9118
9219
  }
9220
+ const fromModelArmorConfig = getValueByPath(fromObject, [
9221
+ 'modelArmorConfig',
9222
+ ]);
9223
+ if (parentObject !== undefined && fromModelArmorConfig != null) {
9224
+ setValueByPath(parentObject, ['modelArmorConfig'], fromModelArmorConfig);
9225
+ }
9119
9226
  return toObject;
9120
9227
  }
9121
- function generateContentParametersToMldev(apiClient, fromObject) {
9228
+ function generateContentParametersToMldev(apiClient, fromObject, rootObject) {
9122
9229
  const toObject = {};
9123
9230
  const fromModel = getValueByPath(fromObject, ['model']);
9124
9231
  if (fromModel != null) {
@@ -9140,7 +9247,7 @@ function generateContentParametersToMldev(apiClient, fromObject) {
9140
9247
  }
9141
9248
  return toObject;
9142
9249
  }
9143
- function generateContentParametersToVertex(apiClient, fromObject) {
9250
+ function generateContentParametersToVertex(apiClient, fromObject, rootObject) {
9144
9251
  const toObject = {};
9145
9252
  const fromModel = getValueByPath(fromObject, ['model']);
9146
9253
  if (fromModel != null) {
@@ -9162,7 +9269,7 @@ function generateContentParametersToVertex(apiClient, fromObject) {
9162
9269
  }
9163
9270
  return toObject;
9164
9271
  }
9165
- function generateContentResponseFromMldev(fromObject) {
9272
+ function generateContentResponseFromMldev(fromObject, rootObject) {
9166
9273
  const toObject = {};
9167
9274
  const fromSdkHttpResponse = getValueByPath(fromObject, [
9168
9275
  'sdkHttpResponse',
@@ -9202,7 +9309,7 @@ function generateContentResponseFromMldev(fromObject) {
9202
9309
  }
9203
9310
  return toObject;
9204
9311
  }
9205
- function generateContentResponseFromVertex(fromObject) {
9312
+ function generateContentResponseFromVertex(fromObject, _rootObject) {
9206
9313
  const toObject = {};
9207
9314
  const fromSdkHttpResponse = getValueByPath(fromObject, [
9208
9315
  'sdkHttpResponse',
@@ -9246,7 +9353,7 @@ function generateContentResponseFromVertex(fromObject) {
9246
9353
  }
9247
9354
  return toObject;
9248
9355
  }
9249
- function generateImagesConfigToMldev(fromObject, parentObject) {
9356
+ function generateImagesConfigToMldev(fromObject, parentObject, _rootObject) {
9250
9357
  const toObject = {};
9251
9358
  if (getValueByPath(fromObject, ['outputGcsUri']) !== undefined) {
9252
9359
  throw new Error('outputGcsUri parameter is not supported in Gemini API.');
@@ -9328,7 +9435,7 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
9328
9435
  }
9329
9436
  return toObject;
9330
9437
  }
9331
- function generateImagesConfigToVertex(fromObject, parentObject) {
9438
+ function generateImagesConfigToVertex(fromObject, parentObject, _rootObject) {
9332
9439
  const toObject = {};
9333
9440
  const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
9334
9441
  if (parentObject !== undefined && fromOutputGcsUri != null) {
@@ -9420,7 +9527,7 @@ function generateImagesConfigToVertex(fromObject, parentObject) {
9420
9527
  }
9421
9528
  return toObject;
9422
9529
  }
9423
- function generateImagesParametersToMldev(apiClient, fromObject) {
9530
+ function generateImagesParametersToMldev(apiClient, fromObject, rootObject) {
9424
9531
  const toObject = {};
9425
9532
  const fromModel = getValueByPath(fromObject, ['model']);
9426
9533
  if (fromModel != null) {
@@ -9436,7 +9543,7 @@ function generateImagesParametersToMldev(apiClient, fromObject) {
9436
9543
  }
9437
9544
  return toObject;
9438
9545
  }
9439
- function generateImagesParametersToVertex(apiClient, fromObject) {
9546
+ function generateImagesParametersToVertex(apiClient, fromObject, rootObject) {
9440
9547
  const toObject = {};
9441
9548
  const fromModel = getValueByPath(fromObject, ['model']);
9442
9549
  if (fromModel != null) {
@@ -9452,7 +9559,7 @@ function generateImagesParametersToVertex(apiClient, fromObject) {
9452
9559
  }
9453
9560
  return toObject;
9454
9561
  }
9455
- function generateImagesResponseFromMldev(fromObject) {
9562
+ function generateImagesResponseFromMldev(fromObject, rootObject) {
9456
9563
  const toObject = {};
9457
9564
  const fromSdkHttpResponse = getValueByPath(fromObject, [
9458
9565
  'sdkHttpResponse',
@@ -9480,7 +9587,7 @@ function generateImagesResponseFromMldev(fromObject) {
9480
9587
  }
9481
9588
  return toObject;
9482
9589
  }
9483
- function generateImagesResponseFromVertex(fromObject) {
9590
+ function generateImagesResponseFromVertex(fromObject, rootObject) {
9484
9591
  const toObject = {};
9485
9592
  const fromSdkHttpResponse = getValueByPath(fromObject, [
9486
9593
  'sdkHttpResponse',
@@ -9508,7 +9615,7 @@ function generateImagesResponseFromVertex(fromObject) {
9508
9615
  }
9509
9616
  return toObject;
9510
9617
  }
9511
- function generateVideosConfigToMldev(fromObject, parentObject) {
9618
+ function generateVideosConfigToMldev(fromObject, parentObject, rootObject) {
9512
9619
  const toObject = {};
9513
9620
  const fromNumberOfVideos = getValueByPath(fromObject, [
9514
9621
  'numberOfVideos',
@@ -9587,7 +9694,7 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
9587
9694
  }
9588
9695
  return toObject;
9589
9696
  }
9590
- function generateVideosConfigToVertex(fromObject, parentObject) {
9697
+ function generateVideosConfigToVertex(fromObject, parentObject, rootObject) {
9591
9698
  const toObject = {};
9592
9699
  const fromNumberOfVideos = getValueByPath(fromObject, [
9593
9700
  'numberOfVideos',
@@ -9677,7 +9784,7 @@ function generateVideosConfigToVertex(fromObject, parentObject) {
9677
9784
  }
9678
9785
  return toObject;
9679
9786
  }
9680
- function generateVideosOperationFromMldev(fromObject) {
9787
+ function generateVideosOperationFromMldev(fromObject, rootObject) {
9681
9788
  const toObject = {};
9682
9789
  const fromName = getValueByPath(fromObject, ['name']);
9683
9790
  if (fromName != null) {
@@ -9704,7 +9811,7 @@ function generateVideosOperationFromMldev(fromObject) {
9704
9811
  }
9705
9812
  return toObject;
9706
9813
  }
9707
- function generateVideosOperationFromVertex(fromObject) {
9814
+ function generateVideosOperationFromVertex(fromObject, rootObject) {
9708
9815
  const toObject = {};
9709
9816
  const fromName = getValueByPath(fromObject, ['name']);
9710
9817
  if (fromName != null) {
@@ -9728,7 +9835,7 @@ function generateVideosOperationFromVertex(fromObject) {
9728
9835
  }
9729
9836
  return toObject;
9730
9837
  }
9731
- function generateVideosParametersToMldev(apiClient, fromObject) {
9838
+ function generateVideosParametersToMldev(apiClient, fromObject, rootObject) {
9732
9839
  const toObject = {};
9733
9840
  const fromModel = getValueByPath(fromObject, ['model']);
9734
9841
  if (fromModel != null) {
@@ -9756,7 +9863,7 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
9756
9863
  }
9757
9864
  return toObject;
9758
9865
  }
9759
- function generateVideosParametersToVertex(apiClient, fromObject) {
9866
+ function generateVideosParametersToVertex(apiClient, fromObject, rootObject) {
9760
9867
  const toObject = {};
9761
9868
  const fromModel = getValueByPath(fromObject, ['model']);
9762
9869
  if (fromModel != null) {
@@ -9784,7 +9891,7 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
9784
9891
  }
9785
9892
  return toObject;
9786
9893
  }
9787
- function generateVideosResponseFromMldev(fromObject) {
9894
+ function generateVideosResponseFromMldev(fromObject, rootObject) {
9788
9895
  const toObject = {};
9789
9896
  const fromGeneratedVideos = getValueByPath(fromObject, [
9790
9897
  'generatedSamples',
@@ -9812,7 +9919,7 @@ function generateVideosResponseFromMldev(fromObject) {
9812
9919
  }
9813
9920
  return toObject;
9814
9921
  }
9815
- function generateVideosResponseFromVertex(fromObject) {
9922
+ function generateVideosResponseFromVertex(fromObject, rootObject) {
9816
9923
  const toObject = {};
9817
9924
  const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
9818
9925
  if (fromGeneratedVideos != null) {
@@ -9838,7 +9945,7 @@ function generateVideosResponseFromVertex(fromObject) {
9838
9945
  }
9839
9946
  return toObject;
9840
9947
  }
9841
- function generateVideosSourceToMldev(fromObject, parentObject) {
9948
+ function generateVideosSourceToMldev(fromObject, parentObject, rootObject) {
9842
9949
  const toObject = {};
9843
9950
  const fromPrompt = getValueByPath(fromObject, ['prompt']);
9844
9951
  if (parentObject !== undefined && fromPrompt != null) {
@@ -9854,7 +9961,7 @@ function generateVideosSourceToMldev(fromObject, parentObject) {
9854
9961
  }
9855
9962
  return toObject;
9856
9963
  }
9857
- function generateVideosSourceToVertex(fromObject, parentObject) {
9964
+ function generateVideosSourceToVertex(fromObject, parentObject, rootObject) {
9858
9965
  const toObject = {};
9859
9966
  const fromPrompt = getValueByPath(fromObject, ['prompt']);
9860
9967
  if (parentObject !== undefined && fromPrompt != null) {
@@ -9870,7 +9977,7 @@ function generateVideosSourceToVertex(fromObject, parentObject) {
9870
9977
  }
9871
9978
  return toObject;
9872
9979
  }
9873
- function generatedImageFromMldev(fromObject) {
9980
+ function generatedImageFromMldev(fromObject, rootObject) {
9874
9981
  const toObject = {};
9875
9982
  const fromImage = getValueByPath(fromObject, ['_self']);
9876
9983
  if (fromImage != null) {
@@ -9888,7 +9995,7 @@ function generatedImageFromMldev(fromObject) {
9888
9995
  }
9889
9996
  return toObject;
9890
9997
  }
9891
- function generatedImageFromVertex(fromObject) {
9998
+ function generatedImageFromVertex(fromObject, rootObject) {
9892
9999
  const toObject = {};
9893
10000
  const fromImage = getValueByPath(fromObject, ['_self']);
9894
10001
  if (fromImage != null) {
@@ -9910,7 +10017,7 @@ function generatedImageFromVertex(fromObject) {
9910
10017
  }
9911
10018
  return toObject;
9912
10019
  }
9913
- function generatedImageMaskFromVertex(fromObject) {
10020
+ function generatedImageMaskFromVertex(fromObject, rootObject) {
9914
10021
  const toObject = {};
9915
10022
  const fromMask = getValueByPath(fromObject, ['_self']);
9916
10023
  if (fromMask != null) {
@@ -9928,7 +10035,7 @@ function generatedImageMaskFromVertex(fromObject) {
9928
10035
  }
9929
10036
  return toObject;
9930
10037
  }
9931
- function generatedVideoFromMldev(fromObject) {
10038
+ function generatedVideoFromMldev(fromObject, rootObject) {
9932
10039
  const toObject = {};
9933
10040
  const fromVideo = getValueByPath(fromObject, ['video']);
9934
10041
  if (fromVideo != null) {
@@ -9936,7 +10043,7 @@ function generatedVideoFromMldev(fromObject) {
9936
10043
  }
9937
10044
  return toObject;
9938
10045
  }
9939
- function generatedVideoFromVertex(fromObject) {
10046
+ function generatedVideoFromVertex(fromObject, rootObject) {
9940
10047
  const toObject = {};
9941
10048
  const fromVideo = getValueByPath(fromObject, ['_self']);
9942
10049
  if (fromVideo != null) {
@@ -9944,7 +10051,7 @@ function generatedVideoFromVertex(fromObject) {
9944
10051
  }
9945
10052
  return toObject;
9946
10053
  }
9947
- function generationConfigToVertex(fromObject) {
10054
+ function generationConfigToVertex(fromObject, _rootObject) {
9948
10055
  const toObject = {};
9949
10056
  const fromModelSelectionConfig = getValueByPath(fromObject, [
9950
10057
  'modelSelectionConfig',
@@ -10072,7 +10179,7 @@ function generationConfigToVertex(fromObject) {
10072
10179
  }
10073
10180
  return toObject;
10074
10181
  }
10075
- function getModelParametersToMldev(apiClient, fromObject) {
10182
+ function getModelParametersToMldev(apiClient, fromObject, _rootObject) {
10076
10183
  const toObject = {};
10077
10184
  const fromModel = getValueByPath(fromObject, ['model']);
10078
10185
  if (fromModel != null) {
@@ -10080,7 +10187,7 @@ function getModelParametersToMldev(apiClient, fromObject) {
10080
10187
  }
10081
10188
  return toObject;
10082
10189
  }
10083
- function getModelParametersToVertex(apiClient, fromObject) {
10190
+ function getModelParametersToVertex(apiClient, fromObject, _rootObject) {
10084
10191
  const toObject = {};
10085
10192
  const fromModel = getValueByPath(fromObject, ['model']);
10086
10193
  if (fromModel != null) {
@@ -10088,7 +10195,7 @@ function getModelParametersToVertex(apiClient, fromObject) {
10088
10195
  }
10089
10196
  return toObject;
10090
10197
  }
10091
- function googleMapsToMldev$1(fromObject) {
10198
+ function googleMapsToMldev$1(fromObject, _rootObject) {
10092
10199
  const toObject = {};
10093
10200
  if (getValueByPath(fromObject, ['authConfig']) !== undefined) {
10094
10201
  throw new Error('authConfig parameter is not supported in Gemini API.');
@@ -10099,7 +10206,7 @@ function googleMapsToMldev$1(fromObject) {
10099
10206
  }
10100
10207
  return toObject;
10101
10208
  }
10102
- function googleSearchToMldev$1(fromObject) {
10209
+ function googleSearchToMldev$1(fromObject, _rootObject) {
10103
10210
  const toObject = {};
10104
10211
  if (getValueByPath(fromObject, ['excludeDomains']) !== undefined) {
10105
10212
  throw new Error('excludeDomains parameter is not supported in Gemini API.');
@@ -10115,7 +10222,7 @@ function googleSearchToMldev$1(fromObject) {
10115
10222
  }
10116
10223
  return toObject;
10117
10224
  }
10118
- function imageConfigToMldev(fromObject) {
10225
+ function imageConfigToMldev(fromObject, _rootObject) {
10119
10226
  const toObject = {};
10120
10227
  const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
10121
10228
  if (fromAspectRatio != null) {
@@ -10137,7 +10244,7 @@ function imageConfigToMldev(fromObject) {
10137
10244
  }
10138
10245
  return toObject;
10139
10246
  }
10140
- function imageConfigToVertex(fromObject) {
10247
+ function imageConfigToVertex(fromObject, _rootObject) {
10141
10248
  const toObject = {};
10142
10249
  const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
10143
10250
  if (fromAspectRatio != null) {
@@ -10167,7 +10274,7 @@ function imageConfigToVertex(fromObject) {
10167
10274
  }
10168
10275
  return toObject;
10169
10276
  }
10170
- function imageFromMldev(fromObject) {
10277
+ function imageFromMldev(fromObject, _rootObject) {
10171
10278
  const toObject = {};
10172
10279
  const fromImageBytes = getValueByPath(fromObject, [
10173
10280
  'bytesBase64Encoded',
@@ -10181,7 +10288,7 @@ function imageFromMldev(fromObject) {
10181
10288
  }
10182
10289
  return toObject;
10183
10290
  }
10184
- function imageFromVertex(fromObject) {
10291
+ function imageFromVertex(fromObject, _rootObject) {
10185
10292
  const toObject = {};
10186
10293
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
10187
10294
  if (fromGcsUri != null) {
@@ -10199,7 +10306,7 @@ function imageFromVertex(fromObject) {
10199
10306
  }
10200
10307
  return toObject;
10201
10308
  }
10202
- function imageToMldev(fromObject) {
10309
+ function imageToMldev(fromObject, _rootObject) {
10203
10310
  const toObject = {};
10204
10311
  if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
10205
10312
  throw new Error('gcsUri parameter is not supported in Gemini API.');
@@ -10214,7 +10321,7 @@ function imageToMldev(fromObject) {
10214
10321
  }
10215
10322
  return toObject;
10216
10323
  }
10217
- function imageToVertex(fromObject) {
10324
+ function imageToVertex(fromObject, _rootObject) {
10218
10325
  const toObject = {};
10219
10326
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
10220
10327
  if (fromGcsUri != null) {
@@ -10230,7 +10337,7 @@ function imageToVertex(fromObject) {
10230
10337
  }
10231
10338
  return toObject;
10232
10339
  }
10233
- function listModelsConfigToMldev(apiClient, fromObject, parentObject) {
10340
+ function listModelsConfigToMldev(apiClient, fromObject, parentObject, _rootObject) {
10234
10341
  const toObject = {};
10235
10342
  const fromPageSize = getValueByPath(fromObject, ['pageSize']);
10236
10343
  if (parentObject !== undefined && fromPageSize != null) {
@@ -10250,7 +10357,7 @@ function listModelsConfigToMldev(apiClient, fromObject, parentObject) {
10250
10357
  }
10251
10358
  return toObject;
10252
10359
  }
10253
- function listModelsConfigToVertex(apiClient, fromObject, parentObject) {
10360
+ function listModelsConfigToVertex(apiClient, fromObject, parentObject, _rootObject) {
10254
10361
  const toObject = {};
10255
10362
  const fromPageSize = getValueByPath(fromObject, ['pageSize']);
10256
10363
  if (parentObject !== undefined && fromPageSize != null) {
@@ -10270,7 +10377,7 @@ function listModelsConfigToVertex(apiClient, fromObject, parentObject) {
10270
10377
  }
10271
10378
  return toObject;
10272
10379
  }
10273
- function listModelsParametersToMldev(apiClient, fromObject) {
10380
+ function listModelsParametersToMldev(apiClient, fromObject, rootObject) {
10274
10381
  const toObject = {};
10275
10382
  const fromConfig = getValueByPath(fromObject, ['config']);
10276
10383
  if (fromConfig != null) {
@@ -10278,7 +10385,7 @@ function listModelsParametersToMldev(apiClient, fromObject) {
10278
10385
  }
10279
10386
  return toObject;
10280
10387
  }
10281
- function listModelsParametersToVertex(apiClient, fromObject) {
10388
+ function listModelsParametersToVertex(apiClient, fromObject, rootObject) {
10282
10389
  const toObject = {};
10283
10390
  const fromConfig = getValueByPath(fromObject, ['config']);
10284
10391
  if (fromConfig != null) {
@@ -10286,7 +10393,7 @@ function listModelsParametersToVertex(apiClient, fromObject) {
10286
10393
  }
10287
10394
  return toObject;
10288
10395
  }
10289
- function listModelsResponseFromMldev(fromObject) {
10396
+ function listModelsResponseFromMldev(fromObject, rootObject) {
10290
10397
  const toObject = {};
10291
10398
  const fromSdkHttpResponse = getValueByPath(fromObject, [
10292
10399
  'sdkHttpResponse',
@@ -10312,7 +10419,7 @@ function listModelsResponseFromMldev(fromObject) {
10312
10419
  }
10313
10420
  return toObject;
10314
10421
  }
10315
- function listModelsResponseFromVertex(fromObject) {
10422
+ function listModelsResponseFromVertex(fromObject, rootObject) {
10316
10423
  const toObject = {};
10317
10424
  const fromSdkHttpResponse = getValueByPath(fromObject, [
10318
10425
  'sdkHttpResponse',
@@ -10338,7 +10445,7 @@ function listModelsResponseFromVertex(fromObject) {
10338
10445
  }
10339
10446
  return toObject;
10340
10447
  }
10341
- function maskReferenceConfigToVertex(fromObject) {
10448
+ function maskReferenceConfigToVertex(fromObject, _rootObject) {
10342
10449
  const toObject = {};
10343
10450
  const fromMaskMode = getValueByPath(fromObject, ['maskMode']);
10344
10451
  if (fromMaskMode != null) {
@@ -10356,7 +10463,7 @@ function maskReferenceConfigToVertex(fromObject) {
10356
10463
  }
10357
10464
  return toObject;
10358
10465
  }
10359
- function modelFromMldev(fromObject) {
10466
+ function modelFromMldev(fromObject, rootObject) {
10360
10467
  const toObject = {};
10361
10468
  const fromName = getValueByPath(fromObject, ['name']);
10362
10469
  if (fromName != null) {
@@ -10420,7 +10527,7 @@ function modelFromMldev(fromObject) {
10420
10527
  }
10421
10528
  return toObject;
10422
10529
  }
10423
- function modelFromVertex(fromObject) {
10530
+ function modelFromVertex(fromObject, rootObject) {
10424
10531
  const toObject = {};
10425
10532
  const fromName = getValueByPath(fromObject, ['name']);
10426
10533
  if (fromName != null) {
@@ -10474,7 +10581,7 @@ function modelFromVertex(fromObject) {
10474
10581
  }
10475
10582
  return toObject;
10476
10583
  }
10477
- function partToMldev$1(fromObject) {
10584
+ function partToMldev$1(fromObject, rootObject) {
10478
10585
  const toObject = {};
10479
10586
  const fromMediaResolution = getValueByPath(fromObject, [
10480
10587
  'mediaResolution',
@@ -10534,7 +10641,7 @@ function partToMldev$1(fromObject) {
10534
10641
  }
10535
10642
  return toObject;
10536
10643
  }
10537
- function productImageToVertex(fromObject) {
10644
+ function productImageToVertex(fromObject, rootObject) {
10538
10645
  const toObject = {};
10539
10646
  const fromProductImage = getValueByPath(fromObject, ['productImage']);
10540
10647
  if (fromProductImage != null) {
@@ -10542,7 +10649,7 @@ function productImageToVertex(fromObject) {
10542
10649
  }
10543
10650
  return toObject;
10544
10651
  }
10545
- function recontextImageConfigToVertex(fromObject, parentObject) {
10652
+ function recontextImageConfigToVertex(fromObject, parentObject, _rootObject) {
10546
10653
  const toObject = {};
10547
10654
  const fromNumberOfImages = getValueByPath(fromObject, [
10548
10655
  'numberOfImages',
@@ -10602,7 +10709,7 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
10602
10709
  }
10603
10710
  return toObject;
10604
10711
  }
10605
- function recontextImageParametersToVertex(apiClient, fromObject) {
10712
+ function recontextImageParametersToVertex(apiClient, fromObject, rootObject) {
10606
10713
  const toObject = {};
10607
10714
  const fromModel = getValueByPath(fromObject, ['model']);
10608
10715
  if (fromModel != null) {
@@ -10618,7 +10725,7 @@ function recontextImageParametersToVertex(apiClient, fromObject) {
10618
10725
  }
10619
10726
  return toObject;
10620
10727
  }
10621
- function recontextImageResponseFromVertex(fromObject) {
10728
+ function recontextImageResponseFromVertex(fromObject, rootObject) {
10622
10729
  const toObject = {};
10623
10730
  const fromGeneratedImages = getValueByPath(fromObject, [
10624
10731
  'predictions',
@@ -10634,7 +10741,7 @@ function recontextImageResponseFromVertex(fromObject) {
10634
10741
  }
10635
10742
  return toObject;
10636
10743
  }
10637
- function recontextImageSourceToVertex(fromObject, parentObject) {
10744
+ function recontextImageSourceToVertex(fromObject, parentObject, rootObject) {
10638
10745
  const toObject = {};
10639
10746
  const fromPrompt = getValueByPath(fromObject, ['prompt']);
10640
10747
  if (parentObject !== undefined && fromPrompt != null) {
@@ -10658,7 +10765,7 @@ function recontextImageSourceToVertex(fromObject, parentObject) {
10658
10765
  }
10659
10766
  return toObject;
10660
10767
  }
10661
- function referenceImageAPIInternalToVertex(fromObject) {
10768
+ function referenceImageAPIInternalToVertex(fromObject, rootObject) {
10662
10769
  const toObject = {};
10663
10770
  const fromReferenceImage = getValueByPath(fromObject, [
10664
10771
  'referenceImage',
@@ -10702,7 +10809,7 @@ function referenceImageAPIInternalToVertex(fromObject) {
10702
10809
  }
10703
10810
  return toObject;
10704
10811
  }
10705
- function safetyAttributesFromMldev(fromObject) {
10812
+ function safetyAttributesFromMldev(fromObject, _rootObject) {
10706
10813
  const toObject = {};
10707
10814
  const fromCategories = getValueByPath(fromObject, [
10708
10815
  'safetyAttributes',
@@ -10724,7 +10831,7 @@ function safetyAttributesFromMldev(fromObject) {
10724
10831
  }
10725
10832
  return toObject;
10726
10833
  }
10727
- function safetyAttributesFromVertex(fromObject) {
10834
+ function safetyAttributesFromVertex(fromObject, _rootObject) {
10728
10835
  const toObject = {};
10729
10836
  const fromCategories = getValueByPath(fromObject, [
10730
10837
  'safetyAttributes',
@@ -10746,7 +10853,7 @@ function safetyAttributesFromVertex(fromObject) {
10746
10853
  }
10747
10854
  return toObject;
10748
10855
  }
10749
- function safetySettingToMldev(fromObject) {
10856
+ function safetySettingToMldev(fromObject, _rootObject) {
10750
10857
  const toObject = {};
10751
10858
  const fromCategory = getValueByPath(fromObject, ['category']);
10752
10859
  if (fromCategory != null) {
@@ -10761,7 +10868,7 @@ function safetySettingToMldev(fromObject) {
10761
10868
  }
10762
10869
  return toObject;
10763
10870
  }
10764
- function scribbleImageToVertex(fromObject) {
10871
+ function scribbleImageToVertex(fromObject, rootObject) {
10765
10872
  const toObject = {};
10766
10873
  const fromImage = getValueByPath(fromObject, ['image']);
10767
10874
  if (fromImage != null) {
@@ -10769,7 +10876,7 @@ function scribbleImageToVertex(fromObject) {
10769
10876
  }
10770
10877
  return toObject;
10771
10878
  }
10772
- function segmentImageConfigToVertex(fromObject, parentObject) {
10879
+ function segmentImageConfigToVertex(fromObject, parentObject, _rootObject) {
10773
10880
  const toObject = {};
10774
10881
  const fromMode = getValueByPath(fromObject, ['mode']);
10775
10882
  if (parentObject !== undefined && fromMode != null) {
@@ -10803,7 +10910,7 @@ function segmentImageConfigToVertex(fromObject, parentObject) {
10803
10910
  }
10804
10911
  return toObject;
10805
10912
  }
10806
- function segmentImageParametersToVertex(apiClient, fromObject) {
10913
+ function segmentImageParametersToVertex(apiClient, fromObject, rootObject) {
10807
10914
  const toObject = {};
10808
10915
  const fromModel = getValueByPath(fromObject, ['model']);
10809
10916
  if (fromModel != null) {
@@ -10819,7 +10926,7 @@ function segmentImageParametersToVertex(apiClient, fromObject) {
10819
10926
  }
10820
10927
  return toObject;
10821
10928
  }
10822
- function segmentImageResponseFromVertex(fromObject) {
10929
+ function segmentImageResponseFromVertex(fromObject, rootObject) {
10823
10930
  const toObject = {};
10824
10931
  const fromGeneratedMasks = getValueByPath(fromObject, ['predictions']);
10825
10932
  if (fromGeneratedMasks != null) {
@@ -10833,7 +10940,7 @@ function segmentImageResponseFromVertex(fromObject) {
10833
10940
  }
10834
10941
  return toObject;
10835
10942
  }
10836
- function segmentImageSourceToVertex(fromObject, parentObject) {
10943
+ function segmentImageSourceToVertex(fromObject, parentObject, rootObject) {
10837
10944
  const toObject = {};
10838
10945
  const fromPrompt = getValueByPath(fromObject, ['prompt']);
10839
10946
  if (parentObject !== undefined && fromPrompt != null) {
@@ -10851,7 +10958,7 @@ function segmentImageSourceToVertex(fromObject, parentObject) {
10851
10958
  }
10852
10959
  return toObject;
10853
10960
  }
10854
- function toolConfigToMldev(fromObject) {
10961
+ function toolConfigToMldev(fromObject, rootObject) {
10855
10962
  const toObject = {};
10856
10963
  const fromRetrievalConfig = getValueByPath(fromObject, [
10857
10964
  'retrievalConfig',
@@ -10867,7 +10974,7 @@ function toolConfigToMldev(fromObject) {
10867
10974
  }
10868
10975
  return toObject;
10869
10976
  }
10870
- function toolToMldev$1(fromObject) {
10977
+ function toolToMldev$1(fromObject, rootObject) {
10871
10978
  const toObject = {};
10872
10979
  if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
10873
10980
  throw new Error('retrieval parameter is not supported in Gemini API.');
@@ -10921,7 +11028,7 @@ function toolToMldev$1(fromObject) {
10921
11028
  }
10922
11029
  return toObject;
10923
11030
  }
10924
- function toolToVertex(fromObject) {
11031
+ function toolToVertex(fromObject, rootObject) {
10925
11032
  const toObject = {};
10926
11033
  const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
10927
11034
  if (fromRetrieval != null) {
@@ -10978,7 +11085,7 @@ function toolToVertex(fromObject) {
10978
11085
  }
10979
11086
  return toObject;
10980
11087
  }
10981
- function tunedModelInfoFromMldev(fromObject) {
11088
+ function tunedModelInfoFromMldev(fromObject, _rootObject) {
10982
11089
  const toObject = {};
10983
11090
  const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
10984
11091
  if (fromBaseModel != null) {
@@ -10994,7 +11101,7 @@ function tunedModelInfoFromMldev(fromObject) {
10994
11101
  }
10995
11102
  return toObject;
10996
11103
  }
10997
- function tunedModelInfoFromVertex(fromObject) {
11104
+ function tunedModelInfoFromVertex(fromObject, _rootObject) {
10998
11105
  const toObject = {};
10999
11106
  const fromBaseModel = getValueByPath(fromObject, [
11000
11107
  'labels',
@@ -11013,7 +11120,7 @@ function tunedModelInfoFromVertex(fromObject) {
11013
11120
  }
11014
11121
  return toObject;
11015
11122
  }
11016
- function updateModelConfigToMldev(fromObject, parentObject) {
11123
+ function updateModelConfigToMldev(fromObject, parentObject, _rootObject) {
11017
11124
  const toObject = {};
11018
11125
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
11019
11126
  if (parentObject !== undefined && fromDisplayName != null) {
@@ -11031,7 +11138,7 @@ function updateModelConfigToMldev(fromObject, parentObject) {
11031
11138
  }
11032
11139
  return toObject;
11033
11140
  }
11034
- function updateModelConfigToVertex(fromObject, parentObject) {
11141
+ function updateModelConfigToVertex(fromObject, parentObject, _rootObject) {
11035
11142
  const toObject = {};
11036
11143
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
11037
11144
  if (parentObject !== undefined && fromDisplayName != null) {
@@ -11049,7 +11156,7 @@ function updateModelConfigToVertex(fromObject, parentObject) {
11049
11156
  }
11050
11157
  return toObject;
11051
11158
  }
11052
- function updateModelParametersToMldev(apiClient, fromObject) {
11159
+ function updateModelParametersToMldev(apiClient, fromObject, rootObject) {
11053
11160
  const toObject = {};
11054
11161
  const fromModel = getValueByPath(fromObject, ['model']);
11055
11162
  if (fromModel != null) {
@@ -11061,7 +11168,7 @@ function updateModelParametersToMldev(apiClient, fromObject) {
11061
11168
  }
11062
11169
  return toObject;
11063
11170
  }
11064
- function updateModelParametersToVertex(apiClient, fromObject) {
11171
+ function updateModelParametersToVertex(apiClient, fromObject, rootObject) {
11065
11172
  const toObject = {};
11066
11173
  const fromModel = getValueByPath(fromObject, ['model']);
11067
11174
  if (fromModel != null) {
@@ -11073,7 +11180,7 @@ function updateModelParametersToVertex(apiClient, fromObject) {
11073
11180
  }
11074
11181
  return toObject;
11075
11182
  }
11076
- function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
11183
+ function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject, _rootObject) {
11077
11184
  const toObject = {};
11078
11185
  const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
11079
11186
  if (parentObject !== undefined && fromOutputGcsUri != null) {
@@ -11137,7 +11244,7 @@ function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
11137
11244
  }
11138
11245
  return toObject;
11139
11246
  }
11140
- function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject) {
11247
+ function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject, rootObject) {
11141
11248
  const toObject = {};
11142
11249
  const fromModel = getValueByPath(fromObject, ['model']);
11143
11250
  if (fromModel != null) {
@@ -11159,7 +11266,7 @@ function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject) {
11159
11266
  }
11160
11267
  return toObject;
11161
11268
  }
11162
- function upscaleImageResponseFromVertex(fromObject) {
11269
+ function upscaleImageResponseFromVertex(fromObject, rootObject) {
11163
11270
  const toObject = {};
11164
11271
  const fromSdkHttpResponse = getValueByPath(fromObject, [
11165
11272
  'sdkHttpResponse',
@@ -11181,7 +11288,7 @@ function upscaleImageResponseFromVertex(fromObject) {
11181
11288
  }
11182
11289
  return toObject;
11183
11290
  }
11184
- function videoFromMldev(fromObject) {
11291
+ function videoFromMldev(fromObject, _rootObject) {
11185
11292
  const toObject = {};
11186
11293
  const fromUri = getValueByPath(fromObject, ['uri']);
11187
11294
  if (fromUri != null) {
@@ -11197,7 +11304,7 @@ function videoFromMldev(fromObject) {
11197
11304
  }
11198
11305
  return toObject;
11199
11306
  }
11200
- function videoFromVertex(fromObject) {
11307
+ function videoFromVertex(fromObject, _rootObject) {
11201
11308
  const toObject = {};
11202
11309
  const fromUri = getValueByPath(fromObject, ['gcsUri']);
11203
11310
  if (fromUri != null) {
@@ -11215,7 +11322,7 @@ function videoFromVertex(fromObject) {
11215
11322
  }
11216
11323
  return toObject;
11217
11324
  }
11218
- function videoGenerationMaskToVertex(fromObject) {
11325
+ function videoGenerationMaskToVertex(fromObject, rootObject) {
11219
11326
  const toObject = {};
11220
11327
  const fromImage = getValueByPath(fromObject, ['image']);
11221
11328
  if (fromImage != null) {
@@ -11227,7 +11334,7 @@ function videoGenerationMaskToVertex(fromObject) {
11227
11334
  }
11228
11335
  return toObject;
11229
11336
  }
11230
- function videoGenerationReferenceImageToMldev(fromObject) {
11337
+ function videoGenerationReferenceImageToMldev(fromObject, rootObject) {
11231
11338
  const toObject = {};
11232
11339
  const fromImage = getValueByPath(fromObject, ['image']);
11233
11340
  if (fromImage != null) {
@@ -11241,7 +11348,7 @@ function videoGenerationReferenceImageToMldev(fromObject) {
11241
11348
  }
11242
11349
  return toObject;
11243
11350
  }
11244
- function videoGenerationReferenceImageToVertex(fromObject) {
11351
+ function videoGenerationReferenceImageToVertex(fromObject, rootObject) {
11245
11352
  const toObject = {};
11246
11353
  const fromImage = getValueByPath(fromObject, ['image']);
11247
11354
  if (fromImage != null) {
@@ -11255,7 +11362,7 @@ function videoGenerationReferenceImageToVertex(fromObject) {
11255
11362
  }
11256
11363
  return toObject;
11257
11364
  }
11258
- function videoToMldev(fromObject) {
11365
+ function videoToMldev(fromObject, _rootObject) {
11259
11366
  const toObject = {};
11260
11367
  const fromUri = getValueByPath(fromObject, ['uri']);
11261
11368
  if (fromUri != null) {
@@ -11271,7 +11378,7 @@ function videoToMldev(fromObject) {
11271
11378
  }
11272
11379
  return toObject;
11273
11380
  }
11274
- function videoToVertex(fromObject) {
11381
+ function videoToVertex(fromObject, _rootObject) {
11275
11382
  const toObject = {};
11276
11383
  const fromUri = getValueByPath(fromObject, ['uri']);
11277
11384
  if (fromUri != null) {
@@ -11532,7 +11639,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
11532
11639
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
11533
11640
  const USER_AGENT_HEADER = 'User-Agent';
11534
11641
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
11535
- const SDK_VERSION = '1.37.0'; // x-release-please-version
11642
+ const SDK_VERSION = '1.39.0'; // x-release-please-version
11536
11643
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
11537
11644
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
11538
11645
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -11542,19 +11649,57 @@ const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
11542
11649
  */
11543
11650
  class ApiClient {
11544
11651
  constructor(opts) {
11545
- var _a, _b;
11546
- this.clientOptions = Object.assign(Object.assign({}, opts), { project: opts.project, location: opts.location, apiKey: opts.apiKey, vertexai: opts.vertexai });
11652
+ var _a, _b, _c;
11653
+ this.clientOptions = Object.assign({}, opts);
11654
+ this.customBaseUrl = (_a = opts.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl;
11655
+ if (this.clientOptions.vertexai) {
11656
+ if (this.clientOptions.project && this.clientOptions.location) {
11657
+ this.clientOptions.apiKey = undefined;
11658
+ }
11659
+ else if (this.clientOptions.apiKey) {
11660
+ this.clientOptions.project = undefined;
11661
+ this.clientOptions.location = undefined;
11662
+ }
11663
+ }
11547
11664
  const initHttpOptions = {};
11548
11665
  if (this.clientOptions.vertexai) {
11666
+ if (!this.clientOptions.location &&
11667
+ !this.clientOptions.apiKey &&
11668
+ !this.customBaseUrl) {
11669
+ this.clientOptions.location = 'global';
11670
+ }
11671
+ const hasSufficientAuth = (this.clientOptions.project && this.clientOptions.location) ||
11672
+ this.clientOptions.apiKey;
11673
+ if (!hasSufficientAuth && !this.customBaseUrl) {
11674
+ throw new Error('Authentication is not set up. Please provide either a project and location, or an API key, or a custom base URL.');
11675
+ }
11676
+ const hasConstructorAuth = (opts.project && opts.location) || !!opts.apiKey;
11677
+ if (this.customBaseUrl && !hasConstructorAuth) {
11678
+ initHttpOptions.baseUrl = this.customBaseUrl;
11679
+ this.clientOptions.project = undefined;
11680
+ this.clientOptions.location = undefined;
11681
+ }
11682
+ else if (this.clientOptions.apiKey ||
11683
+ this.clientOptions.location === 'global') {
11684
+ // Vertex Express or global endpoint case.
11685
+ initHttpOptions.baseUrl = 'https://aiplatform.googleapis.com/';
11686
+ }
11687
+ else if (this.clientOptions.project && this.clientOptions.location) {
11688
+ initHttpOptions.baseUrl = `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
11689
+ }
11549
11690
  initHttpOptions.apiVersion =
11550
- (_a = this.clientOptions.apiVersion) !== null && _a !== void 0 ? _a : VERTEX_AI_API_DEFAULT_VERSION;
11551
- initHttpOptions.baseUrl = this.baseUrlFromProjectLocation();
11552
- this.normalizeAuthParameters();
11691
+ (_b = this.clientOptions.apiVersion) !== null && _b !== void 0 ? _b : VERTEX_AI_API_DEFAULT_VERSION;
11553
11692
  }
11554
11693
  else {
11555
11694
  // Gemini API
11695
+ if (!this.clientOptions.apiKey) {
11696
+ throw new ApiError({
11697
+ message: 'API key must be set when using the Gemini API.',
11698
+ status: 403,
11699
+ });
11700
+ }
11556
11701
  initHttpOptions.apiVersion =
11557
- (_b = this.clientOptions.apiVersion) !== null && _b !== void 0 ? _b : GOOGLE_AI_API_DEFAULT_VERSION;
11702
+ (_c = this.clientOptions.apiVersion) !== null && _c !== void 0 ? _c : GOOGLE_AI_API_DEFAULT_VERSION;
11558
11703
  initHttpOptions.baseUrl = `https://generativelanguage.googleapis.com/`;
11559
11704
  }
11560
11705
  initHttpOptions.headers = this.getDefaultHeaders();
@@ -11563,39 +11708,6 @@ class ApiClient {
11563
11708
  this.clientOptions.httpOptions = this.patchHttpOptions(initHttpOptions, opts.httpOptions);
11564
11709
  }
11565
11710
  }
11566
- /**
11567
- * Determines the base URL for Vertex AI based on project and location.
11568
- * Uses the global endpoint if location is 'global' or if project/location
11569
- * are not specified (implying API key usage).
11570
- * @private
11571
- */
11572
- baseUrlFromProjectLocation() {
11573
- if (this.clientOptions.project &&
11574
- this.clientOptions.location &&
11575
- this.clientOptions.location !== 'global') {
11576
- // Regional endpoint
11577
- return `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
11578
- }
11579
- // Global endpoint (covers 'global' location and API key usage)
11580
- return `https://aiplatform.googleapis.com/`;
11581
- }
11582
- /**
11583
- * Normalizes authentication parameters for Vertex AI.
11584
- * If project and location are provided, API key is cleared.
11585
- * If project and location are not provided (implying API key usage),
11586
- * project and location are cleared.
11587
- * @private
11588
- */
11589
- normalizeAuthParameters() {
11590
- if (this.clientOptions.project && this.clientOptions.location) {
11591
- // Using project/location for auth, clear potential API key
11592
- this.clientOptions.apiKey = undefined;
11593
- return;
11594
- }
11595
- // Using API key for auth (or no auth provided yet), clear project/location
11596
- this.clientOptions.project = undefined;
11597
- this.clientOptions.location = undefined;
11598
- }
11599
11711
  isVertexAI() {
11600
11712
  var _a;
11601
11713
  return (_a = this.clientOptions.vertexai) !== null && _a !== void 0 ? _a : false;
@@ -11606,6 +11718,9 @@ class ApiClient {
11606
11718
  getLocation() {
11607
11719
  return this.clientOptions.location;
11608
11720
  }
11721
+ getCustomBaseUrl() {
11722
+ return this.customBaseUrl;
11723
+ }
11609
11724
  async getAuthHeaders() {
11610
11725
  const headers = new Headers();
11611
11726
  await this.clientOptions.auth.addAuthHeaders(headers);
@@ -11683,7 +11798,11 @@ class ApiClient {
11683
11798
  const url = new URL(`${urlElement.join('/')}`);
11684
11799
  return url;
11685
11800
  }
11686
- shouldPrependVertexProjectPath(request) {
11801
+ shouldPrependVertexProjectPath(request, httpOptions) {
11802
+ if (httpOptions.baseUrl &&
11803
+ httpOptions.baseUrlResourceScope === exports.ResourceScope.COLLECTION) {
11804
+ return false;
11805
+ }
11687
11806
  if (this.clientOptions.apiKey) {
11688
11807
  return false;
11689
11808
  }
@@ -11709,7 +11828,7 @@ class ApiClient {
11709
11828
  if (request.httpOptions) {
11710
11829
  patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
11711
11830
  }
11712
- const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
11831
+ const prependProjectLocation = this.shouldPrependVertexProjectPath(request, patchedHttpOptions);
11713
11832
  const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
11714
11833
  if (request.queryParams) {
11715
11834
  for (const [key, value] of Object.entries(request.queryParams)) {
@@ -11752,7 +11871,7 @@ class ApiClient {
11752
11871
  if (request.httpOptions) {
11753
11872
  patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
11754
11873
  }
11755
- const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
11874
+ const prependProjectLocation = this.shouldPrependVertexProjectPath(request, patchedHttpOptions);
11756
11875
  const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
11757
11876
  if (!url.searchParams.has('alt') || url.searchParams.get('alt') !== 'sse') {
11758
11877
  url.searchParams.set('alt', 'sse');
@@ -12679,8 +12798,19 @@ class Live {
12679
12798
  }
12680
12799
  const headers = mapToHeaders(clientHeaders);
12681
12800
  if (this.apiClient.isVertexAI()) {
12682
- url = `${websocketBaseUrl}/ws/google.cloud.aiplatform.${apiVersion}.LlmBidiService/BidiGenerateContent`;
12683
- await this.auth.addAuthHeaders(headers, url);
12801
+ const project = this.apiClient.getProject();
12802
+ const location = this.apiClient.getLocation();
12803
+ const apiKey = this.apiClient.getApiKey();
12804
+ const hasStandardAuth = (!!project && !!location) || !!apiKey;
12805
+ if (this.apiClient.getCustomBaseUrl() && !hasStandardAuth) {
12806
+ // Custom base URL without standard auth (e.g., proxy).
12807
+ url = websocketBaseUrl;
12808
+ // Auth headers are assumed to be in `clientHeaders` from httpOptions.
12809
+ }
12810
+ else {
12811
+ url = `${websocketBaseUrl}/ws/google.cloud.aiplatform.${apiVersion}.LlmBidiService/BidiGenerateContent`;
12812
+ await this.auth.addAuthHeaders(headers, url);
12813
+ }
12684
12814
  }
12685
12815
  else {
12686
12816
  const apiKey = this.apiClient.getApiKey();
@@ -12726,8 +12856,10 @@ class Live {
12726
12856
  transformedModel.startsWith('publishers/')) {
12727
12857
  const project = this.apiClient.getProject();
12728
12858
  const location = this.apiClient.getLocation();
12729
- transformedModel =
12730
- `projects/${project}/locations/${location}/` + transformedModel;
12859
+ if (project && location) {
12860
+ transformedModel =
12861
+ `projects/${project}/locations/${location}/` + transformedModel;
12862
+ }
12731
12863
  }
12732
12864
  let clientMessage = {};
12733
12865
  if (this.apiClient.isVertexAI() &&
@@ -13683,7 +13815,7 @@ class Models extends BaseModule {
13683
13815
  _c = apiResponse_1_1.value;
13684
13816
  _d = false;
13685
13817
  const chunk = _c;
13686
- const resp = generateContentResponseFromVertex((yield __await(chunk.json())));
13818
+ const resp = generateContentResponseFromVertex((yield __await(chunk.json())), params);
13687
13819
  resp['sdkHttpResponse'] = {
13688
13820
  headers: chunk.headers,
13689
13821
  };
@@ -13725,7 +13857,7 @@ class Models extends BaseModule {
13725
13857
  _c = apiResponse_2_1.value;
13726
13858
  _d = false;
13727
13859
  const chunk = _c;
13728
- const resp = generateContentResponseFromMldev((yield __await(chunk.json())));
13860
+ const resp = generateContentResponseFromMldev((yield __await(chunk.json())), params);
13729
13861
  resp['sdkHttpResponse'] = {
13730
13862
  headers: chunk.headers,
13731
13863
  };
@@ -16658,7 +16790,9 @@ class BaseInteractions extends APIResource {
16658
16790
  *
16659
16791
  * @example
16660
16792
  * ```ts
16661
- * const interaction = await client.interactions.delete('id');
16793
+ * const interaction = await client.interactions.delete('id', {
16794
+ * api_version: 'api_version',
16795
+ * });
16662
16796
  * ```
16663
16797
  */
16664
16798
  delete(id, params = {}, options) {
@@ -16670,7 +16804,9 @@ class BaseInteractions extends APIResource {
16670
16804
  *
16671
16805
  * @example
16672
16806
  * ```ts
16673
- * const interaction = await client.interactions.cancel('id');
16807
+ * const interaction = await client.interactions.cancel('id', {
16808
+ * api_version: 'api_version',
16809
+ * });
16674
16810
  * ```
16675
16811
  */
16676
16812
  cancel(id, params = {}, options) {
@@ -18167,6 +18303,12 @@ function createTuningJobConfigToMldev(fromObject, parentObject, _rootObject) {
18167
18303
  if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
18168
18304
  throw new Error('adapterSize parameter is not supported in Gemini API.');
18169
18305
  }
18306
+ if (getValueByPath(fromObject, ['tuningMode']) !== undefined) {
18307
+ throw new Error('tuningMode parameter is not supported in Gemini API.');
18308
+ }
18309
+ if (getValueByPath(fromObject, ['customBaseModel']) !== undefined) {
18310
+ throw new Error('customBaseModel parameter is not supported in Gemini API.');
18311
+ }
18170
18312
  const fromBatchSize = getValueByPath(fromObject, ['batchSize']);
18171
18313
  if (parentObject !== undefined && fromBatchSize != null) {
18172
18314
  setValueByPath(parentObject, ['tuningTask', 'hyperparameters', 'batchSize'], fromBatchSize);
@@ -18181,6 +18323,18 @@ function createTuningJobConfigToMldev(fromObject, parentObject, _rootObject) {
18181
18323
  if (getValueByPath(fromObject, ['beta']) !== undefined) {
18182
18324
  throw new Error('beta parameter is not supported in Gemini API.');
18183
18325
  }
18326
+ if (getValueByPath(fromObject, ['baseTeacherModel']) !== undefined) {
18327
+ throw new Error('baseTeacherModel parameter is not supported in Gemini API.');
18328
+ }
18329
+ if (getValueByPath(fromObject, ['tunedTeacherModelSource']) !== undefined) {
18330
+ throw new Error('tunedTeacherModelSource parameter is not supported in Gemini API.');
18331
+ }
18332
+ if (getValueByPath(fromObject, ['sftLossWeightMultiplier']) !== undefined) {
18333
+ throw new Error('sftLossWeightMultiplier parameter is not supported in Gemini API.');
18334
+ }
18335
+ if (getValueByPath(fromObject, ['outputUri']) !== undefined) {
18336
+ throw new Error('outputUri parameter is not supported in Gemini API.');
18337
+ }
18184
18338
  return toObject;
18185
18339
  }
18186
18340
  function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
@@ -18208,6 +18362,14 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
18208
18362
  setValueByPath(parentObject, ['preferenceOptimizationSpec'], tuningValidationDatasetToVertex(fromValidationDataset));
18209
18363
  }
18210
18364
  }
18365
+ else if (discriminatorValidationDataset === 'DISTILLATION') {
18366
+ const fromValidationDataset = getValueByPath(fromObject, [
18367
+ 'validationDataset',
18368
+ ]);
18369
+ if (parentObject !== undefined && fromValidationDataset != null) {
18370
+ setValueByPath(parentObject, ['distillationSpec'], tuningValidationDatasetToVertex(fromValidationDataset));
18371
+ }
18372
+ }
18211
18373
  const fromTunedModelDisplayName = getValueByPath(fromObject, [
18212
18374
  'tunedModelDisplayName',
18213
18375
  ]);
@@ -18237,6 +18399,12 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
18237
18399
  setValueByPath(parentObject, ['preferenceOptimizationSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
18238
18400
  }
18239
18401
  }
18402
+ else if (discriminatorEpochCount === 'DISTILLATION') {
18403
+ const fromEpochCount = getValueByPath(fromObject, ['epochCount']);
18404
+ if (parentObject !== undefined && fromEpochCount != null) {
18405
+ setValueByPath(parentObject, ['distillationSpec', 'hyperParameters', 'epochCount'], fromEpochCount);
18406
+ }
18407
+ }
18240
18408
  let discriminatorLearningRateMultiplier = getValueByPath(rootObject, [
18241
18409
  'config',
18242
18410
  'method',
@@ -18264,6 +18432,14 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
18264
18432
  ], fromLearningRateMultiplier);
18265
18433
  }
18266
18434
  }
18435
+ else if (discriminatorLearningRateMultiplier === 'DISTILLATION') {
18436
+ const fromLearningRateMultiplier = getValueByPath(fromObject, [
18437
+ 'learningRateMultiplier',
18438
+ ]);
18439
+ if (parentObject !== undefined && fromLearningRateMultiplier != null) {
18440
+ setValueByPath(parentObject, ['distillationSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
18441
+ }
18442
+ }
18267
18443
  let discriminatorExportLastCheckpointOnly = getValueByPath(rootObject, ['config', 'method']);
18268
18444
  if (discriminatorExportLastCheckpointOnly === undefined) {
18269
18445
  discriminatorExportLastCheckpointOnly = 'SUPERVISED_FINE_TUNING';
@@ -18284,6 +18460,14 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
18284
18460
  setValueByPath(parentObject, ['preferenceOptimizationSpec', 'exportLastCheckpointOnly'], fromExportLastCheckpointOnly);
18285
18461
  }
18286
18462
  }
18463
+ else if (discriminatorExportLastCheckpointOnly === 'DISTILLATION') {
18464
+ const fromExportLastCheckpointOnly = getValueByPath(fromObject, [
18465
+ 'exportLastCheckpointOnly',
18466
+ ]);
18467
+ if (parentObject !== undefined && fromExportLastCheckpointOnly != null) {
18468
+ setValueByPath(parentObject, ['distillationSpec', 'exportLastCheckpointOnly'], fromExportLastCheckpointOnly);
18469
+ }
18470
+ }
18287
18471
  let discriminatorAdapterSize = getValueByPath(rootObject, [
18288
18472
  'config',
18289
18473
  'method',
@@ -18303,11 +18487,58 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
18303
18487
  setValueByPath(parentObject, ['preferenceOptimizationSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
18304
18488
  }
18305
18489
  }
18306
- if (getValueByPath(fromObject, ['batchSize']) !== undefined) {
18307
- throw new Error('batchSize parameter is not supported in Vertex AI.');
18490
+ else if (discriminatorAdapterSize === 'DISTILLATION') {
18491
+ const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
18492
+ if (parentObject !== undefined && fromAdapterSize != null) {
18493
+ setValueByPath(parentObject, ['distillationSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
18494
+ }
18495
+ }
18496
+ let discriminatorTuningMode = getValueByPath(rootObject, [
18497
+ 'config',
18498
+ 'method',
18499
+ ]);
18500
+ if (discriminatorTuningMode === undefined) {
18501
+ discriminatorTuningMode = 'SUPERVISED_FINE_TUNING';
18502
+ }
18503
+ if (discriminatorTuningMode === 'SUPERVISED_FINE_TUNING') {
18504
+ const fromTuningMode = getValueByPath(fromObject, ['tuningMode']);
18505
+ if (parentObject !== undefined && fromTuningMode != null) {
18506
+ setValueByPath(parentObject, ['supervisedTuningSpec', 'tuningMode'], fromTuningMode);
18507
+ }
18308
18508
  }
18309
- if (getValueByPath(fromObject, ['learningRate']) !== undefined) {
18310
- throw new Error('learningRate parameter is not supported in Vertex AI.');
18509
+ const fromCustomBaseModel = getValueByPath(fromObject, [
18510
+ 'customBaseModel',
18511
+ ]);
18512
+ if (parentObject !== undefined && fromCustomBaseModel != null) {
18513
+ setValueByPath(parentObject, ['customBaseModel'], fromCustomBaseModel);
18514
+ }
18515
+ let discriminatorBatchSize = getValueByPath(rootObject, [
18516
+ 'config',
18517
+ 'method',
18518
+ ]);
18519
+ if (discriminatorBatchSize === undefined) {
18520
+ discriminatorBatchSize = 'SUPERVISED_FINE_TUNING';
18521
+ }
18522
+ if (discriminatorBatchSize === 'SUPERVISED_FINE_TUNING') {
18523
+ const fromBatchSize = getValueByPath(fromObject, ['batchSize']);
18524
+ if (parentObject !== undefined && fromBatchSize != null) {
18525
+ setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'batchSize'], fromBatchSize);
18526
+ }
18527
+ }
18528
+ let discriminatorLearningRate = getValueByPath(rootObject, [
18529
+ 'config',
18530
+ 'method',
18531
+ ]);
18532
+ if (discriminatorLearningRate === undefined) {
18533
+ discriminatorLearningRate = 'SUPERVISED_FINE_TUNING';
18534
+ }
18535
+ if (discriminatorLearningRate === 'SUPERVISED_FINE_TUNING') {
18536
+ const fromLearningRate = getValueByPath(fromObject, [
18537
+ 'learningRate',
18538
+ ]);
18539
+ if (parentObject !== undefined && fromLearningRate != null) {
18540
+ setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRate'], fromLearningRate);
18541
+ }
18311
18542
  }
18312
18543
  const fromLabels = getValueByPath(fromObject, ['labels']);
18313
18544
  if (parentObject !== undefined && fromLabels != null) {
@@ -18317,6 +18548,28 @@ function createTuningJobConfigToVertex(fromObject, parentObject, rootObject) {
18317
18548
  if (parentObject !== undefined && fromBeta != null) {
18318
18549
  setValueByPath(parentObject, ['preferenceOptimizationSpec', 'hyperParameters', 'beta'], fromBeta);
18319
18550
  }
18551
+ const fromBaseTeacherModel = getValueByPath(fromObject, [
18552
+ 'baseTeacherModel',
18553
+ ]);
18554
+ if (parentObject !== undefined && fromBaseTeacherModel != null) {
18555
+ setValueByPath(parentObject, ['distillationSpec', 'baseTeacherModel'], fromBaseTeacherModel);
18556
+ }
18557
+ const fromTunedTeacherModelSource = getValueByPath(fromObject, [
18558
+ 'tunedTeacherModelSource',
18559
+ ]);
18560
+ if (parentObject !== undefined && fromTunedTeacherModelSource != null) {
18561
+ setValueByPath(parentObject, ['distillationSpec', 'tunedTeacherModelSource'], fromTunedTeacherModelSource);
18562
+ }
18563
+ const fromSftLossWeightMultiplier = getValueByPath(fromObject, [
18564
+ 'sftLossWeightMultiplier',
18565
+ ]);
18566
+ if (parentObject !== undefined && fromSftLossWeightMultiplier != null) {
18567
+ setValueByPath(parentObject, ['distillationSpec', 'hyperParameters', 'sftLossWeightMultiplier'], fromSftLossWeightMultiplier);
18568
+ }
18569
+ const fromOutputUri = getValueByPath(fromObject, ['outputUri']);
18570
+ if (parentObject !== undefined && fromOutputUri != null) {
18571
+ setValueByPath(parentObject, ['outputUri'], fromOutputUri);
18572
+ }
18320
18573
  return toObject;
18321
18574
  }
18322
18575
  function createTuningJobParametersPrivateToMldev(fromObject, rootObject) {
@@ -18536,6 +18789,12 @@ function tuningDatasetToVertex(fromObject, parentObject, rootObject) {
18536
18789
  setValueByPath(parentObject, ['preferenceOptimizationSpec', 'trainingDatasetUri'], fromGcsUri);
18537
18790
  }
18538
18791
  }
18792
+ else if (discriminatorGcsUri === 'DISTILLATION') {
18793
+ const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
18794
+ if (parentObject !== undefined && fromGcsUri != null) {
18795
+ setValueByPath(parentObject, ['distillationSpec', 'promptDatasetUri'], fromGcsUri);
18796
+ }
18797
+ }
18539
18798
  let discriminatorVertexDatasetResource = getValueByPath(rootObject, [
18540
18799
  'config',
18541
18800
  'method',
@@ -18559,6 +18818,14 @@ function tuningDatasetToVertex(fromObject, parentObject, rootObject) {
18559
18818
  setValueByPath(parentObject, ['preferenceOptimizationSpec', 'trainingDatasetUri'], fromVertexDatasetResource);
18560
18819
  }
18561
18820
  }
18821
+ else if (discriminatorVertexDatasetResource === 'DISTILLATION') {
18822
+ const fromVertexDatasetResource = getValueByPath(fromObject, [
18823
+ 'vertexDatasetResource',
18824
+ ]);
18825
+ if (parentObject !== undefined && fromVertexDatasetResource != null) {
18826
+ setValueByPath(parentObject, ['distillationSpec', 'promptDatasetUri'], fromVertexDatasetResource);
18827
+ }
18828
+ }
18562
18829
  if (getValueByPath(fromObject, ['examples']) !== undefined) {
18563
18830
  throw new Error('examples parameter is not supported in Vertex AI.');
18564
18831
  }
@@ -18682,6 +18949,12 @@ function tuningJobFromVertex(fromObject, _rootObject) {
18682
18949
  if (fromPreferenceOptimizationSpec != null) {
18683
18950
  setValueByPath(toObject, ['preferenceOptimizationSpec'], fromPreferenceOptimizationSpec);
18684
18951
  }
18952
+ const fromDistillationSpec = getValueByPath(fromObject, [
18953
+ 'distillationSpec',
18954
+ ]);
18955
+ if (fromDistillationSpec != null) {
18956
+ setValueByPath(toObject, ['distillationSpec'], fromDistillationSpec);
18957
+ }
18685
18958
  const fromTuningDataStats = getValueByPath(fromObject, [
18686
18959
  'tuningDataStats',
18687
18960
  ]);
@@ -19459,6 +19732,48 @@ class NodeUploader {
19459
19732
  }
19460
19733
  }
19461
19734
 
19735
+ /**
19736
+ * @license
19737
+ * Copyright 2025 Google LLC
19738
+ * SPDX-License-Identifier: Apache-2.0
19739
+ */
19740
+ class NodeFiles extends Files {
19741
+ /**
19742
+ * Registers Google Cloud Storage files for use with the API.
19743
+ * This method is only available in Node.js environments.
19744
+ */
19745
+ async registerFiles(params) {
19746
+ if (typeof process === 'undefined' ||
19747
+ !process.versions ||
19748
+ !process.versions.node) {
19749
+ throw new Error('registerFiles is only supported in Node.js environments.');
19750
+ }
19751
+ const googleAuth = params.auth;
19752
+ const authHeaders = await googleAuth.getRequestHeaders();
19753
+ const config = params.config || {};
19754
+ const httpOptions = config.httpOptions || {};
19755
+ const headers = Object.assign({}, (httpOptions.headers || {}));
19756
+ if (authHeaders) {
19757
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19758
+ if (typeof authHeaders[Symbol.iterator] === 'function') {
19759
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19760
+ for (const [key, value] of authHeaders) {
19761
+ headers[key] = value;
19762
+ }
19763
+ }
19764
+ else {
19765
+ for (const [key, value] of Object.entries(authHeaders)) {
19766
+ headers[key] = value;
19767
+ }
19768
+ }
19769
+ }
19770
+ return this._registerFiles({
19771
+ uris: params.uris,
19772
+ config: Object.assign(Object.assign({}, config), { httpOptions: Object.assign(Object.assign({}, httpOptions), { headers }) }),
19773
+ });
19774
+ }
19775
+ }
19776
+
19462
19777
  /**
19463
19778
  * @license
19464
19779
  * Copyright 2025 Google LLC
@@ -19541,6 +19856,9 @@ class GoogleGenAI {
19541
19856
  this.apiKey = (_c = options.apiKey) !== null && _c !== void 0 ? _c : envApiKey;
19542
19857
  this.project = (_d = options.project) !== null && _d !== void 0 ? _d : envProject;
19543
19858
  this.location = (_e = options.location) !== null && _e !== void 0 ? _e : envLocation;
19859
+ if (!this.vertexai && !this.apiKey) {
19860
+ throw new Error('API key must be set when using the Gemini API.');
19861
+ }
19544
19862
  // Handle when to use Vertex AI in express mode (api key)
19545
19863
  if (options.vertexai) {
19546
19864
  if ((_f = options.googleAuthOptions) === null || _f === void 0 ? void 0 : _f.credentials) {
@@ -19605,7 +19923,7 @@ class GoogleGenAI {
19605
19923
  this.batches = new Batches(this.apiClient);
19606
19924
  this.chats = new Chats(this.models, this.apiClient);
19607
19925
  this.caches = new Caches(this.apiClient);
19608
- this.files = new Files(this.apiClient);
19926
+ this.files = new NodeFiles(this.apiClient);
19609
19927
  this.operations = new Operations(this.apiClient);
19610
19928
  this.authTokens = new Tokens(this.apiClient);
19611
19929
  this.tunings = new Tunings(this.apiClient);
@@ -19685,6 +20003,7 @@ exports.Operations = Operations;
19685
20003
  exports.Pager = Pager;
19686
20004
  exports.RawReferenceImage = RawReferenceImage;
19687
20005
  exports.RecontextImageResponse = RecontextImageResponse;
20006
+ exports.RegisterFilesResponse = RegisterFilesResponse;
19688
20007
  exports.ReplayResponse = ReplayResponse;
19689
20008
  exports.SegmentImageResponse = SegmentImageResponse;
19690
20009
  exports.Session = Session;