@google/genai 1.11.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -416,6 +416,14 @@ exports.UrlRetrievalStatus = void 0;
416
416
  * Url retrieval is failed due to error.
417
417
  */
418
418
  UrlRetrievalStatus["URL_RETRIEVAL_STATUS_ERROR"] = "URL_RETRIEVAL_STATUS_ERROR";
419
+ /**
420
+ * Url retrieval is failed because the content is behind paywall.
421
+ */
422
+ UrlRetrievalStatus["URL_RETRIEVAL_STATUS_PAYWALL"] = "URL_RETRIEVAL_STATUS_PAYWALL";
423
+ /**
424
+ * Url retrieval is failed because the content is unsafe.
425
+ */
426
+ UrlRetrievalStatus["URL_RETRIEVAL_STATUS_UNSAFE"] = "URL_RETRIEVAL_STATUS_UNSAFE";
419
427
  })(exports.UrlRetrievalStatus || (exports.UrlRetrievalStatus = {}));
420
428
  /** Output only. The reason why the model stopped generating tokens.
421
429
 
@@ -1042,6 +1050,29 @@ exports.Scale = void 0;
1042
1050
  */
1043
1051
  Scale["B_MAJOR_A_FLAT_MINOR"] = "B_MAJOR_A_FLAT_MINOR";
1044
1052
  })(exports.Scale || (exports.Scale = {}));
1053
+ /** The mode of music generation. */
1054
+ exports.MusicGenerationMode = void 0;
1055
+ (function (MusicGenerationMode) {
1056
+ /**
1057
+ * Rely on the server default generation mode.
1058
+ */
1059
+ MusicGenerationMode["MUSIC_GENERATION_MODE_UNSPECIFIED"] = "MUSIC_GENERATION_MODE_UNSPECIFIED";
1060
+ /**
1061
+ * Steer text prompts to regions of latent space with higher quality
1062
+ music.
1063
+ */
1064
+ MusicGenerationMode["QUALITY"] = "QUALITY";
1065
+ /**
1066
+ * Steer text prompts to regions of latent space with a larger
1067
+ diversity of music.
1068
+ */
1069
+ MusicGenerationMode["DIVERSITY"] = "DIVERSITY";
1070
+ /**
1071
+ * Steer text prompts to regions of latent space more likely to
1072
+ generate music with vocals.
1073
+ */
1074
+ MusicGenerationMode["VOCALIZATION"] = "VOCALIZATION";
1075
+ })(exports.MusicGenerationMode || (exports.MusicGenerationMode = {}));
1045
1076
  /** The playback control signal to apply to the music generation. */
1046
1077
  exports.LiveMusicPlaybackControl = void 0;
1047
1078
  (function (LiveMusicPlaybackControl) {
@@ -1465,6 +1496,9 @@ class EditImageResponse {
1465
1496
  }
1466
1497
  class UpscaleImageResponse {
1467
1498
  }
1499
+ /** The output images response. */
1500
+ class RecontextImageResponse {
1501
+ }
1468
1502
  class ListModelsResponse {
1469
1503
  }
1470
1504
  class DeleteModelResponse {
@@ -1720,8 +1754,8 @@ class GenerateVideosOperation {
1720
1754
  },
1721
1755
  };
1722
1756
  });
1723
- operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1724
- operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1757
+ operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1758
+ operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1725
1759
  operation.response = operationResponse;
1726
1760
  }
1727
1761
  }
@@ -3670,6 +3704,10 @@ function generateContentResponseFromMldev$1(fromObject) {
3670
3704
  if (fromPromptFeedback != null) {
3671
3705
  setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
3672
3706
  }
3707
+ const fromResponseId = getValueByPath(fromObject, ['responseId']);
3708
+ if (fromResponseId != null) {
3709
+ setValueByPath(toObject, ['responseId'], fromResponseId);
3710
+ }
3673
3711
  const fromUsageMetadata = getValueByPath(fromObject, [
3674
3712
  'usageMetadata',
3675
3713
  ]);
@@ -3803,6 +3841,12 @@ function listBatchJobsResponseFromMldev(fromObject) {
3803
3841
  }
3804
3842
  function deleteResourceJobFromMldev(fromObject) {
3805
3843
  const toObject = {};
3844
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
3845
+ 'sdkHttpResponse',
3846
+ ]);
3847
+ if (fromSdkHttpResponse != null) {
3848
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
3849
+ }
3806
3850
  const fromName = getValueByPath(fromObject, ['name']);
3807
3851
  if (fromName != null) {
3808
3852
  setValueByPath(toObject, ['name'], fromName);
@@ -3952,6 +3996,12 @@ function listBatchJobsResponseFromVertex(fromObject) {
3952
3996
  }
3953
3997
  function deleteResourceJobFromVertex(fromObject) {
3954
3998
  const toObject = {};
3999
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
4000
+ 'sdkHttpResponse',
4001
+ ]);
4002
+ if (fromSdkHttpResponse != null) {
4003
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
4004
+ }
3955
4005
  const fromName = getValueByPath(fromObject, ['name']);
3956
4006
  if (fromName != null) {
3957
4007
  setValueByPath(toObject, ['name'], fromName);
@@ -4497,7 +4547,13 @@ class Batches extends BaseModule {
4497
4547
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4498
4548
  })
4499
4549
  .then((httpResponse) => {
4500
- return httpResponse.json();
4550
+ return httpResponse.json().then((jsonResponse) => {
4551
+ const response = jsonResponse;
4552
+ response.sdkHttpResponse = {
4553
+ headers: httpResponse.headers,
4554
+ };
4555
+ return response;
4556
+ });
4501
4557
  });
4502
4558
  return response.then((apiResponse) => {
4503
4559
  const resp = deleteResourceJobFromVertex(apiResponse);
@@ -4521,7 +4577,13 @@ class Batches extends BaseModule {
4521
4577
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4522
4578
  })
4523
4579
  .then((httpResponse) => {
4524
- return httpResponse.json();
4580
+ return httpResponse.json().then((jsonResponse) => {
4581
+ const response = jsonResponse;
4582
+ response.sdkHttpResponse = {
4583
+ headers: httpResponse.headers,
4584
+ };
4585
+ return response;
4586
+ });
4525
4587
  });
4526
4588
  return response.then((apiResponse) => {
4527
4589
  const resp = deleteResourceJobFromMldev(apiResponse);
@@ -6392,7 +6454,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
6392
6454
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
6393
6455
  const USER_AGENT_HEADER = 'User-Agent';
6394
6456
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
6395
- const SDK_VERSION = '1.11.0'; // x-release-please-version
6457
+ const SDK_VERSION = '1.13.0'; // x-release-please-version
6396
6458
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
6397
6459
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
6398
6460
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -8279,6 +8341,12 @@ function liveMusicGenerationConfigToMldev(fromObject) {
8279
8341
  if (fromOnlyBassAndDrums != null) {
8280
8342
  setValueByPath(toObject, ['onlyBassAndDrums'], fromOnlyBassAndDrums);
8281
8343
  }
8344
+ const fromMusicGenerationMode = getValueByPath(fromObject, [
8345
+ 'musicGenerationMode',
8346
+ ]);
8347
+ if (fromMusicGenerationMode != null) {
8348
+ setValueByPath(toObject, ['musicGenerationMode'], fromMusicGenerationMode);
8349
+ }
8282
8350
  return toObject;
8283
8351
  }
8284
8352
  function liveMusicSetConfigParametersToMldev(fromObject) {
@@ -9437,6 +9505,12 @@ function liveMusicGenerationConfigFromMldev(fromObject) {
9437
9505
  if (fromOnlyBassAndDrums != null) {
9438
9506
  setValueByPath(toObject, ['onlyBassAndDrums'], fromOnlyBassAndDrums);
9439
9507
  }
9508
+ const fromMusicGenerationMode = getValueByPath(fromObject, [
9509
+ 'musicGenerationMode',
9510
+ ]);
9511
+ if (fromMusicGenerationMode != null) {
9512
+ setValueByPath(toObject, ['musicGenerationMode'], fromMusicGenerationMode);
9513
+ }
9440
9514
  return toObject;
9441
9515
  }
9442
9516
  function liveMusicSourceMetadataFromMldev(fromObject) {
@@ -10703,8 +10777,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
10703
10777
  if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
10704
10778
  throw new Error('addWatermark parameter is not supported in Gemini API.');
10705
10779
  }
10706
- if (getValueByPath(fromObject, ['imageSize']) !== undefined) {
10707
- throw new Error('imageSize parameter is not supported in Gemini API.');
10780
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
10781
+ if (parentObject !== undefined && fromImageSize != null) {
10782
+ setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
10708
10783
  }
10709
10784
  if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
10710
10785
  throw new Error('enhancePrompt parameter is not supported in Gemini API.');
@@ -12106,6 +12181,106 @@ function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject) {
12106
12181
  }
12107
12182
  return toObject;
12108
12183
  }
12184
+ function productImageToVertex(fromObject) {
12185
+ const toObject = {};
12186
+ const fromProductImage = getValueByPath(fromObject, ['productImage']);
12187
+ if (fromProductImage != null) {
12188
+ setValueByPath(toObject, ['image'], imageToVertex(fromProductImage));
12189
+ }
12190
+ return toObject;
12191
+ }
12192
+ function recontextImageSourceToVertex(fromObject, parentObject) {
12193
+ const toObject = {};
12194
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
12195
+ if (parentObject !== undefined && fromPrompt != null) {
12196
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
12197
+ }
12198
+ const fromPersonImage = getValueByPath(fromObject, ['personImage']);
12199
+ if (parentObject !== undefined && fromPersonImage != null) {
12200
+ setValueByPath(parentObject, ['instances[0]', 'personImage', 'image'], imageToVertex(fromPersonImage));
12201
+ }
12202
+ const fromProductImages = getValueByPath(fromObject, [
12203
+ 'productImages',
12204
+ ]);
12205
+ if (parentObject !== undefined && fromProductImages != null) {
12206
+ let transformedList = fromProductImages;
12207
+ if (Array.isArray(transformedList)) {
12208
+ transformedList = transformedList.map((item) => {
12209
+ return productImageToVertex(item);
12210
+ });
12211
+ }
12212
+ setValueByPath(parentObject, ['instances[0]', 'productImages'], transformedList);
12213
+ }
12214
+ return toObject;
12215
+ }
12216
+ function recontextImageConfigToVertex(fromObject, parentObject) {
12217
+ const toObject = {};
12218
+ const fromNumberOfImages = getValueByPath(fromObject, [
12219
+ 'numberOfImages',
12220
+ ]);
12221
+ if (parentObject !== undefined && fromNumberOfImages != null) {
12222
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
12223
+ }
12224
+ const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
12225
+ if (parentObject !== undefined && fromBaseSteps != null) {
12226
+ setValueByPath(parentObject, ['parameters', 'editConfig', 'baseSteps'], fromBaseSteps);
12227
+ }
12228
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
12229
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
12230
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
12231
+ }
12232
+ const fromSeed = getValueByPath(fromObject, ['seed']);
12233
+ if (parentObject !== undefined && fromSeed != null) {
12234
+ setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
12235
+ }
12236
+ const fromSafetyFilterLevel = getValueByPath(fromObject, [
12237
+ 'safetyFilterLevel',
12238
+ ]);
12239
+ if (parentObject !== undefined && fromSafetyFilterLevel != null) {
12240
+ setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
12241
+ }
12242
+ const fromPersonGeneration = getValueByPath(fromObject, [
12243
+ 'personGeneration',
12244
+ ]);
12245
+ if (parentObject !== undefined && fromPersonGeneration != null) {
12246
+ setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
12247
+ }
12248
+ const fromOutputMimeType = getValueByPath(fromObject, [
12249
+ 'outputMimeType',
12250
+ ]);
12251
+ if (parentObject !== undefined && fromOutputMimeType != null) {
12252
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
12253
+ }
12254
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
12255
+ 'outputCompressionQuality',
12256
+ ]);
12257
+ if (parentObject !== undefined && fromOutputCompressionQuality != null) {
12258
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
12259
+ }
12260
+ const fromEnhancePrompt = getValueByPath(fromObject, [
12261
+ 'enhancePrompt',
12262
+ ]);
12263
+ if (parentObject !== undefined && fromEnhancePrompt != null) {
12264
+ setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
12265
+ }
12266
+ return toObject;
12267
+ }
12268
+ function recontextImageParametersToVertex(apiClient, fromObject) {
12269
+ const toObject = {};
12270
+ const fromModel = getValueByPath(fromObject, ['model']);
12271
+ if (fromModel != null) {
12272
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
12273
+ }
12274
+ const fromSource = getValueByPath(fromObject, ['source']);
12275
+ if (fromSource != null) {
12276
+ setValueByPath(toObject, ['config'], recontextImageSourceToVertex(fromSource, toObject));
12277
+ }
12278
+ const fromConfig = getValueByPath(fromObject, ['config']);
12279
+ if (fromConfig != null) {
12280
+ setValueByPath(toObject, ['config'], recontextImageConfigToVertex(fromConfig, toObject));
12281
+ }
12282
+ return toObject;
12283
+ }
12109
12284
  function getModelParametersToVertex(apiClient, fromObject) {
12110
12285
  const toObject = {};
12111
12286
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -12602,6 +12777,10 @@ function generateContentResponseFromMldev(fromObject) {
12602
12777
  if (fromPromptFeedback != null) {
12603
12778
  setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
12604
12779
  }
12780
+ const fromResponseId = getValueByPath(fromObject, ['responseId']);
12781
+ if (fromResponseId != null) {
12782
+ setValueByPath(toObject, ['responseId'], fromResponseId);
12783
+ }
12605
12784
  const fromUsageMetadata = getValueByPath(fromObject, [
12606
12785
  'usageMetadata',
12607
12786
  ]);
@@ -12624,6 +12803,12 @@ function embedContentMetadataFromMldev() {
12624
12803
  }
12625
12804
  function embedContentResponseFromMldev(fromObject) {
12626
12805
  const toObject = {};
12806
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12807
+ 'sdkHttpResponse',
12808
+ ]);
12809
+ if (fromSdkHttpResponse != null) {
12810
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12811
+ }
12627
12812
  const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
12628
12813
  if (fromEmbeddings != null) {
12629
12814
  let transformedList = fromEmbeddings;
@@ -12696,6 +12881,12 @@ function generatedImageFromMldev(fromObject) {
12696
12881
  }
12697
12882
  function generateImagesResponseFromMldev(fromObject) {
12698
12883
  const toObject = {};
12884
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12885
+ 'sdkHttpResponse',
12886
+ ]);
12887
+ if (fromSdkHttpResponse != null) {
12888
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12889
+ }
12699
12890
  const fromGeneratedImages = getValueByPath(fromObject, [
12700
12891
  'predictions',
12701
12892
  ]);
@@ -12806,6 +12997,12 @@ function deleteModelResponseFromMldev() {
12806
12997
  }
12807
12998
  function countTokensResponseFromMldev(fromObject) {
12808
12999
  const toObject = {};
13000
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13001
+ 'sdkHttpResponse',
13002
+ ]);
13003
+ if (fromSdkHttpResponse != null) {
13004
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13005
+ }
12809
13006
  const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
12810
13007
  if (fromTotalTokens != null) {
12811
13008
  setValueByPath(toObject, ['totalTokens'], fromTotalTokens);
@@ -13134,10 +13331,6 @@ function generateContentResponseFromVertex(fromObject) {
13134
13331
  if (fromCreateTime != null) {
13135
13332
  setValueByPath(toObject, ['createTime'], fromCreateTime);
13136
13333
  }
13137
- const fromResponseId = getValueByPath(fromObject, ['responseId']);
13138
- if (fromResponseId != null) {
13139
- setValueByPath(toObject, ['responseId'], fromResponseId);
13140
- }
13141
13334
  const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
13142
13335
  if (fromModelVersion != null) {
13143
13336
  setValueByPath(toObject, ['modelVersion'], fromModelVersion);
@@ -13148,6 +13341,10 @@ function generateContentResponseFromVertex(fromObject) {
13148
13341
  if (fromPromptFeedback != null) {
13149
13342
  setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
13150
13343
  }
13344
+ const fromResponseId = getValueByPath(fromObject, ['responseId']);
13345
+ if (fromResponseId != null) {
13346
+ setValueByPath(toObject, ['responseId'], fromResponseId);
13347
+ }
13151
13348
  const fromUsageMetadata = getValueByPath(fromObject, [
13152
13349
  'usageMetadata',
13153
13350
  ]);
@@ -13192,6 +13389,12 @@ function embedContentMetadataFromVertex(fromObject) {
13192
13389
  }
13193
13390
  function embedContentResponseFromVertex(fromObject) {
13194
13391
  const toObject = {};
13392
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13393
+ 'sdkHttpResponse',
13394
+ ]);
13395
+ if (fromSdkHttpResponse != null) {
13396
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13397
+ }
13195
13398
  const fromEmbeddings = getValueByPath(fromObject, [
13196
13399
  'predictions[]',
13197
13400
  'embeddings',
@@ -13275,6 +13478,12 @@ function generatedImageFromVertex(fromObject) {
13275
13478
  }
13276
13479
  function generateImagesResponseFromVertex(fromObject) {
13277
13480
  const toObject = {};
13481
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13482
+ 'sdkHttpResponse',
13483
+ ]);
13484
+ if (fromSdkHttpResponse != null) {
13485
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13486
+ }
13278
13487
  const fromGeneratedImages = getValueByPath(fromObject, [
13279
13488
  'predictions',
13280
13489
  ]);
@@ -13297,6 +13506,12 @@ function generateImagesResponseFromVertex(fromObject) {
13297
13506
  }
13298
13507
  function editImageResponseFromVertex(fromObject) {
13299
13508
  const toObject = {};
13509
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13510
+ 'sdkHttpResponse',
13511
+ ]);
13512
+ if (fromSdkHttpResponse != null) {
13513
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13514
+ }
13300
13515
  const fromGeneratedImages = getValueByPath(fromObject, [
13301
13516
  'predictions',
13302
13517
  ]);
@@ -13312,6 +13527,28 @@ function editImageResponseFromVertex(fromObject) {
13312
13527
  return toObject;
13313
13528
  }
13314
13529
  function upscaleImageResponseFromVertex(fromObject) {
13530
+ const toObject = {};
13531
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13532
+ 'sdkHttpResponse',
13533
+ ]);
13534
+ if (fromSdkHttpResponse != null) {
13535
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13536
+ }
13537
+ const fromGeneratedImages = getValueByPath(fromObject, [
13538
+ 'predictions',
13539
+ ]);
13540
+ if (fromGeneratedImages != null) {
13541
+ let transformedList = fromGeneratedImages;
13542
+ if (Array.isArray(transformedList)) {
13543
+ transformedList = transformedList.map((item) => {
13544
+ return generatedImageFromVertex(item);
13545
+ });
13546
+ }
13547
+ setValueByPath(toObject, ['generatedImages'], transformedList);
13548
+ }
13549
+ return toObject;
13550
+ }
13551
+ function recontextImageResponseFromVertex(fromObject) {
13315
13552
  const toObject = {};
13316
13553
  const fromGeneratedImages = getValueByPath(fromObject, [
13317
13554
  'predictions',
@@ -13462,6 +13699,12 @@ function deleteModelResponseFromVertex() {
13462
13699
  }
13463
13700
  function countTokensResponseFromVertex(fromObject) {
13464
13701
  const toObject = {};
13702
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13703
+ 'sdkHttpResponse',
13704
+ ]);
13705
+ if (fromSdkHttpResponse != null) {
13706
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13707
+ }
13465
13708
  const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
13466
13709
  if (fromTotalTokens != null) {
13467
13710
  setValueByPath(toObject, ['totalTokens'], fromTotalTokens);
@@ -13470,6 +13713,12 @@ function countTokensResponseFromVertex(fromObject) {
13470
13713
  }
13471
13714
  function computeTokensResponseFromVertex(fromObject) {
13472
13715
  const toObject = {};
13716
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13717
+ 'sdkHttpResponse',
13718
+ ]);
13719
+ if (fromSdkHttpResponse != null) {
13720
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13721
+ }
13473
13722
  const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
13474
13723
  if (fromTokensInfo != null) {
13475
13724
  setValueByPath(toObject, ['tokensInfo'], fromTokensInfo);
@@ -14074,13 +14323,13 @@ class Live {
14074
14323
  const websocketBaseUrl = this.apiClient.getWebsocketBaseUrl();
14075
14324
  const apiVersion = this.apiClient.getApiVersion();
14076
14325
  let url;
14077
- const defaultHeaders = this.apiClient.getDefaultHeaders();
14326
+ const clientHeaders = this.apiClient.getHeaders();
14078
14327
  if (params.config &&
14079
14328
  params.config.tools &&
14080
14329
  hasMcpToolUsage(params.config.tools)) {
14081
- setMcpUsageHeader(defaultHeaders);
14330
+ setMcpUsageHeader(clientHeaders);
14082
14331
  }
14083
- const headers = mapToHeaders(defaultHeaders);
14332
+ const headers = mapToHeaders(clientHeaders);
14084
14333
  if (this.apiClient.isVertexAI()) {
14085
14334
  url = `${websocketBaseUrl}/ws/google.cloud.aiplatform.${apiVersion}.LlmBidiService/BidiGenerateContent`;
14086
14335
  await this.auth.addAuthHeaders(headers);
@@ -14647,11 +14896,13 @@ class Models extends BaseModule {
14647
14896
  response = {
14648
14897
  generatedImages: generatedImages,
14649
14898
  positivePromptSafetyAttributes: positivePromptSafetyAttributes,
14899
+ sdkHttpResponse: apiResponse.sdkHttpResponse,
14650
14900
  };
14651
14901
  }
14652
14902
  else {
14653
14903
  response = {
14654
14904
  generatedImages: generatedImages,
14905
+ sdkHttpResponse: apiResponse.sdkHttpResponse,
14655
14906
  };
14656
14907
  }
14657
14908
  return response;
@@ -15137,7 +15388,13 @@ class Models extends BaseModule {
15137
15388
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15138
15389
  })
15139
15390
  .then((httpResponse) => {
15140
- return httpResponse.json();
15391
+ return httpResponse.json().then((jsonResponse) => {
15392
+ const response = jsonResponse;
15393
+ response.sdkHttpResponse = {
15394
+ headers: httpResponse.headers,
15395
+ };
15396
+ return response;
15397
+ });
15141
15398
  });
15142
15399
  return response.then((apiResponse) => {
15143
15400
  const resp = embedContentResponseFromVertex(apiResponse);
@@ -15163,7 +15420,13 @@ class Models extends BaseModule {
15163
15420
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
15164
15421
  })
15165
15422
  .then((httpResponse) => {
15166
- return httpResponse.json();
15423
+ return httpResponse.json().then((jsonResponse) => {
15424
+ const response = jsonResponse;
15425
+ response.sdkHttpResponse = {
15426
+ headers: httpResponse.headers,
15427
+ };
15428
+ return response;
15429
+ });
15167
15430
  });
15168
15431
  return response.then((apiResponse) => {
15169
15432
  const resp = embedContentResponseFromMldev(apiResponse);
@@ -15214,7 +15477,13 @@ class Models extends BaseModule {
15214
15477
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15215
15478
  })
15216
15479
  .then((httpResponse) => {
15217
- return httpResponse.json();
15480
+ return httpResponse.json().then((jsonResponse) => {
15481
+ const response = jsonResponse;
15482
+ response.sdkHttpResponse = {
15483
+ headers: httpResponse.headers,
15484
+ };
15485
+ return response;
15486
+ });
15218
15487
  });
15219
15488
  return response.then((apiResponse) => {
15220
15489
  const resp = generateImagesResponseFromVertex(apiResponse);
@@ -15240,7 +15509,13 @@ class Models extends BaseModule {
15240
15509
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
15241
15510
  })
15242
15511
  .then((httpResponse) => {
15243
- return httpResponse.json();
15512
+ return httpResponse.json().then((jsonResponse) => {
15513
+ const response = jsonResponse;
15514
+ response.sdkHttpResponse = {
15515
+ headers: httpResponse.headers,
15516
+ };
15517
+ return response;
15518
+ });
15244
15519
  });
15245
15520
  return response.then((apiResponse) => {
15246
15521
  const resp = generateImagesResponseFromMldev(apiResponse);
@@ -15272,7 +15547,13 @@ class Models extends BaseModule {
15272
15547
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15273
15548
  })
15274
15549
  .then((httpResponse) => {
15275
- return httpResponse.json();
15550
+ return httpResponse.json().then((jsonResponse) => {
15551
+ const response = jsonResponse;
15552
+ response.sdkHttpResponse = {
15553
+ headers: httpResponse.headers,
15554
+ };
15555
+ return response;
15556
+ });
15276
15557
  });
15277
15558
  return response.then((apiResponse) => {
15278
15559
  const resp = editImageResponseFromVertex(apiResponse);
@@ -15307,7 +15588,13 @@ class Models extends BaseModule {
15307
15588
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15308
15589
  })
15309
15590
  .then((httpResponse) => {
15310
- return httpResponse.json();
15591
+ return httpResponse.json().then((jsonResponse) => {
15592
+ const response = jsonResponse;
15593
+ response.sdkHttpResponse = {
15594
+ headers: httpResponse.headers,
15595
+ };
15596
+ return response;
15597
+ });
15311
15598
  });
15312
15599
  return response.then((apiResponse) => {
15313
15600
  const resp = upscaleImageResponseFromVertex(apiResponse);
@@ -15320,6 +15607,79 @@ class Models extends BaseModule {
15320
15607
  throw new Error('This method is only supported by the Vertex AI.');
15321
15608
  }
15322
15609
  }
15610
+ /**
15611
+ * Recontextualizes an image.
15612
+ *
15613
+ * There are two types of recontextualization currently supported:
15614
+ * 1) Imagen Product Recontext - Generate images of products in new scenes
15615
+ * and contexts.
15616
+ * 2) Virtual Try-On: Generate images of persons modeling fashion products.
15617
+ *
15618
+ * @param params - The parameters for recontextualizing an image.
15619
+ * @return The response from the API.
15620
+ *
15621
+ * @example
15622
+ * ```ts
15623
+ * const response1 = await ai.models.recontextImage({
15624
+ * model: 'imagen-product-recontext-preview-06-30',
15625
+ * source: {
15626
+ * prompt: 'In a modern kitchen setting.',
15627
+ * productImages: [productImage],
15628
+ * },
15629
+ * config: {
15630
+ * numberOfImages: 1,
15631
+ * },
15632
+ * });
15633
+ * console.log(response1?.generatedImages?.[0]?.image?.imageBytes);
15634
+ *
15635
+ * const response2 = await ai.models.recontextImage({
15636
+ * model: 'virtual-try-on-preview-08-04',
15637
+ * source: {
15638
+ * personImage: personImage,
15639
+ * productImages: [productImage],
15640
+ * },
15641
+ * config: {
15642
+ * numberOfImages: 1,
15643
+ * },
15644
+ * });
15645
+ * console.log(response2?.generatedImages?.[0]?.image?.imageBytes);
15646
+ * ```
15647
+ */
15648
+ async recontextImage(params) {
15649
+ var _a, _b;
15650
+ let response;
15651
+ let path = '';
15652
+ let queryParams = {};
15653
+ if (this.apiClient.isVertexAI()) {
15654
+ const body = recontextImageParametersToVertex(this.apiClient, params);
15655
+ path = formatMap('{model}:predict', body['_url']);
15656
+ queryParams = body['_query'];
15657
+ delete body['config'];
15658
+ delete body['_url'];
15659
+ delete body['_query'];
15660
+ response = this.apiClient
15661
+ .request({
15662
+ path: path,
15663
+ queryParams: queryParams,
15664
+ body: JSON.stringify(body),
15665
+ httpMethod: 'POST',
15666
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
15667
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15668
+ })
15669
+ .then((httpResponse) => {
15670
+ return httpResponse.json();
15671
+ });
15672
+ return response.then((apiResponse) => {
15673
+ const resp = recontextImageResponseFromVertex(apiResponse);
15674
+ const typedResp = new RecontextImageResponse();
15675
+ Object.assign(typedResp, resp);
15676
+ return typedResp;
15677
+ });
15678
+ }
15679
+ else {
15680
+ throw new Error('This method is only supported by the Vertex AI.');
15681
+ }
15682
+ }
15323
15683
  /**
15324
15684
  * Fetches information about a model by name.
15325
15685
  *
@@ -15630,7 +15990,13 @@ class Models extends BaseModule {
15630
15990
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15631
15991
  })
15632
15992
  .then((httpResponse) => {
15633
- return httpResponse.json();
15993
+ return httpResponse.json().then((jsonResponse) => {
15994
+ const response = jsonResponse;
15995
+ response.sdkHttpResponse = {
15996
+ headers: httpResponse.headers,
15997
+ };
15998
+ return response;
15999
+ });
15634
16000
  });
15635
16001
  return response.then((apiResponse) => {
15636
16002
  const resp = countTokensResponseFromVertex(apiResponse);
@@ -15656,7 +16022,13 @@ class Models extends BaseModule {
15656
16022
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
15657
16023
  })
15658
16024
  .then((httpResponse) => {
15659
- return httpResponse.json();
16025
+ return httpResponse.json().then((jsonResponse) => {
16026
+ const response = jsonResponse;
16027
+ response.sdkHttpResponse = {
16028
+ headers: httpResponse.headers,
16029
+ };
16030
+ return response;
16031
+ });
15660
16032
  });
15661
16033
  return response.then((apiResponse) => {
15662
16034
  const resp = countTokensResponseFromMldev(apiResponse);
@@ -15706,7 +16078,13 @@ class Models extends BaseModule {
15706
16078
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15707
16079
  })
15708
16080
  .then((httpResponse) => {
15709
- return httpResponse.json();
16081
+ return httpResponse.json().then((jsonResponse) => {
16082
+ const response = jsonResponse;
16083
+ response.sdkHttpResponse = {
16084
+ headers: httpResponse.headers,
16085
+ };
16086
+ return response;
16087
+ });
15710
16088
  });
15711
16089
  return response.then((apiResponse) => {
15712
16090
  const resp = computeTokensResponseFromVertex(apiResponse);
@@ -17158,6 +17536,12 @@ function tunedModelFromMldev(fromObject) {
17158
17536
  }
17159
17537
  function tuningJobFromMldev(fromObject) {
17160
17538
  const toObject = {};
17539
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17540
+ 'sdkHttpResponse',
17541
+ ]);
17542
+ if (fromSdkHttpResponse != null) {
17543
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17544
+ }
17161
17545
  const fromName = getValueByPath(fromObject, ['name']);
17162
17546
  if (fromName != null) {
17163
17547
  setValueByPath(toObject, ['name'], fromName);
@@ -17268,6 +17652,12 @@ function listTuningJobsResponseFromMldev(fromObject) {
17268
17652
  }
17269
17653
  function tuningOperationFromMldev(fromObject) {
17270
17654
  const toObject = {};
17655
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17656
+ 'sdkHttpResponse',
17657
+ ]);
17658
+ if (fromSdkHttpResponse != null) {
17659
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17660
+ }
17271
17661
  const fromName = getValueByPath(fromObject, ['name']);
17272
17662
  if (fromName != null) {
17273
17663
  setValueByPath(toObject, ['name'], fromName);
@@ -17330,6 +17720,12 @@ function tunedModelFromVertex(fromObject) {
17330
17720
  }
17331
17721
  function tuningJobFromVertex(fromObject) {
17332
17722
  const toObject = {};
17723
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17724
+ 'sdkHttpResponse',
17725
+ ]);
17726
+ if (fromSdkHttpResponse != null) {
17727
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17728
+ }
17333
17729
  const fromName = getValueByPath(fromObject, ['name']);
17334
17730
  if (fromName != null) {
17335
17731
  setValueByPath(toObject, ['name'], fromName);
@@ -17548,7 +17944,13 @@ class Tunings extends BaseModule {
17548
17944
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
17549
17945
  })
17550
17946
  .then((httpResponse) => {
17551
- return httpResponse.json();
17947
+ return httpResponse.json().then((jsonResponse) => {
17948
+ const response = jsonResponse;
17949
+ response.sdkHttpResponse = {
17950
+ headers: httpResponse.headers,
17951
+ };
17952
+ return response;
17953
+ });
17552
17954
  });
17553
17955
  return response.then((apiResponse) => {
17554
17956
  const resp = tuningJobFromVertex(apiResponse);
@@ -17572,7 +17974,13 @@ class Tunings extends BaseModule {
17572
17974
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
17573
17975
  })
17574
17976
  .then((httpResponse) => {
17575
- return httpResponse.json();
17977
+ return httpResponse.json().then((jsonResponse) => {
17978
+ const response = jsonResponse;
17979
+ response.sdkHttpResponse = {
17980
+ headers: httpResponse.headers,
17981
+ };
17982
+ return response;
17983
+ });
17576
17984
  });
17577
17985
  return response.then((apiResponse) => {
17578
17986
  const resp = tuningJobFromMldev(apiResponse);
@@ -17672,7 +18080,13 @@ class Tunings extends BaseModule {
17672
18080
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
17673
18081
  })
17674
18082
  .then((httpResponse) => {
17675
- return httpResponse.json();
18083
+ return httpResponse.json().then((jsonResponse) => {
18084
+ const response = jsonResponse;
18085
+ response.sdkHttpResponse = {
18086
+ headers: httpResponse.headers,
18087
+ };
18088
+ return response;
18089
+ });
17676
18090
  });
17677
18091
  return response.then((apiResponse) => {
17678
18092
  const resp = tuningJobFromVertex(apiResponse);
@@ -17708,7 +18122,13 @@ class Tunings extends BaseModule {
17708
18122
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
17709
18123
  })
17710
18124
  .then((httpResponse) => {
17711
- return httpResponse.json();
18125
+ return httpResponse.json().then((jsonResponse) => {
18126
+ const response = jsonResponse;
18127
+ response.sdkHttpResponse = {
18128
+ headers: httpResponse.headers,
18129
+ };
18130
+ return response;
18131
+ });
17712
18132
  });
17713
18133
  return response.then((apiResponse) => {
17714
18134
  const resp = tuningOperationFromMldev(apiResponse);
@@ -17853,6 +18273,7 @@ exports.Models = Models;
17853
18273
  exports.Operations = Operations;
17854
18274
  exports.Pager = Pager;
17855
18275
  exports.RawReferenceImage = RawReferenceImage;
18276
+ exports.RecontextImageResponse = RecontextImageResponse;
17856
18277
  exports.ReplayResponse = ReplayResponse;
17857
18278
  exports.Session = Session;
17858
18279
  exports.StyleReferenceImage = StyleReferenceImage;