@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.
@@ -472,6 +472,14 @@ exports.UrlRetrievalStatus = void 0;
472
472
  * Url retrieval is failed due to error.
473
473
  */
474
474
  UrlRetrievalStatus["URL_RETRIEVAL_STATUS_ERROR"] = "URL_RETRIEVAL_STATUS_ERROR";
475
+ /**
476
+ * Url retrieval is failed because the content is behind paywall.
477
+ */
478
+ UrlRetrievalStatus["URL_RETRIEVAL_STATUS_PAYWALL"] = "URL_RETRIEVAL_STATUS_PAYWALL";
479
+ /**
480
+ * Url retrieval is failed because the content is unsafe.
481
+ */
482
+ UrlRetrievalStatus["URL_RETRIEVAL_STATUS_UNSAFE"] = "URL_RETRIEVAL_STATUS_UNSAFE";
475
483
  })(exports.UrlRetrievalStatus || (exports.UrlRetrievalStatus = {}));
476
484
  /** Output only. The reason why the model stopped generating tokens.
477
485
 
@@ -1098,6 +1106,29 @@ exports.Scale = void 0;
1098
1106
  */
1099
1107
  Scale["B_MAJOR_A_FLAT_MINOR"] = "B_MAJOR_A_FLAT_MINOR";
1100
1108
  })(exports.Scale || (exports.Scale = {}));
1109
+ /** The mode of music generation. */
1110
+ exports.MusicGenerationMode = void 0;
1111
+ (function (MusicGenerationMode) {
1112
+ /**
1113
+ * Rely on the server default generation mode.
1114
+ */
1115
+ MusicGenerationMode["MUSIC_GENERATION_MODE_UNSPECIFIED"] = "MUSIC_GENERATION_MODE_UNSPECIFIED";
1116
+ /**
1117
+ * Steer text prompts to regions of latent space with higher quality
1118
+ music.
1119
+ */
1120
+ MusicGenerationMode["QUALITY"] = "QUALITY";
1121
+ /**
1122
+ * Steer text prompts to regions of latent space with a larger
1123
+ diversity of music.
1124
+ */
1125
+ MusicGenerationMode["DIVERSITY"] = "DIVERSITY";
1126
+ /**
1127
+ * Steer text prompts to regions of latent space more likely to
1128
+ generate music with vocals.
1129
+ */
1130
+ MusicGenerationMode["VOCALIZATION"] = "VOCALIZATION";
1131
+ })(exports.MusicGenerationMode || (exports.MusicGenerationMode = {}));
1101
1132
  /** The playback control signal to apply to the music generation. */
1102
1133
  exports.LiveMusicPlaybackControl = void 0;
1103
1134
  (function (LiveMusicPlaybackControl) {
@@ -1521,6 +1552,9 @@ class EditImageResponse {
1521
1552
  }
1522
1553
  class UpscaleImageResponse {
1523
1554
  }
1555
+ /** The output images response. */
1556
+ class RecontextImageResponse {
1557
+ }
1524
1558
  class ListModelsResponse {
1525
1559
  }
1526
1560
  class DeleteModelResponse {
@@ -1776,8 +1810,8 @@ class GenerateVideosOperation {
1776
1810
  },
1777
1811
  };
1778
1812
  });
1779
- operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1780
- operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1813
+ operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1814
+ operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1781
1815
  operation.response = operationResponse;
1782
1816
  }
1783
1817
  }
@@ -3726,6 +3760,10 @@ function generateContentResponseFromMldev$1(fromObject) {
3726
3760
  if (fromPromptFeedback != null) {
3727
3761
  setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
3728
3762
  }
3763
+ const fromResponseId = getValueByPath(fromObject, ['responseId']);
3764
+ if (fromResponseId != null) {
3765
+ setValueByPath(toObject, ['responseId'], fromResponseId);
3766
+ }
3729
3767
  const fromUsageMetadata = getValueByPath(fromObject, [
3730
3768
  'usageMetadata',
3731
3769
  ]);
@@ -3859,6 +3897,12 @@ function listBatchJobsResponseFromMldev(fromObject) {
3859
3897
  }
3860
3898
  function deleteResourceJobFromMldev(fromObject) {
3861
3899
  const toObject = {};
3900
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
3901
+ 'sdkHttpResponse',
3902
+ ]);
3903
+ if (fromSdkHttpResponse != null) {
3904
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
3905
+ }
3862
3906
  const fromName = getValueByPath(fromObject, ['name']);
3863
3907
  if (fromName != null) {
3864
3908
  setValueByPath(toObject, ['name'], fromName);
@@ -4008,6 +4052,12 @@ function listBatchJobsResponseFromVertex(fromObject) {
4008
4052
  }
4009
4053
  function deleteResourceJobFromVertex(fromObject) {
4010
4054
  const toObject = {};
4055
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
4056
+ 'sdkHttpResponse',
4057
+ ]);
4058
+ if (fromSdkHttpResponse != null) {
4059
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
4060
+ }
4011
4061
  const fromName = getValueByPath(fromObject, ['name']);
4012
4062
  if (fromName != null) {
4013
4063
  setValueByPath(toObject, ['name'], fromName);
@@ -4553,7 +4603,13 @@ class Batches extends BaseModule {
4553
4603
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4554
4604
  })
4555
4605
  .then((httpResponse) => {
4556
- return httpResponse.json();
4606
+ return httpResponse.json().then((jsonResponse) => {
4607
+ const response = jsonResponse;
4608
+ response.sdkHttpResponse = {
4609
+ headers: httpResponse.headers,
4610
+ };
4611
+ return response;
4612
+ });
4557
4613
  });
4558
4614
  return response.then((apiResponse) => {
4559
4615
  const resp = deleteResourceJobFromVertex(apiResponse);
@@ -4577,7 +4633,13 @@ class Batches extends BaseModule {
4577
4633
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4578
4634
  })
4579
4635
  .then((httpResponse) => {
4580
- return httpResponse.json();
4636
+ return httpResponse.json().then((jsonResponse) => {
4637
+ const response = jsonResponse;
4638
+ response.sdkHttpResponse = {
4639
+ headers: httpResponse.headers,
4640
+ };
4641
+ return response;
4642
+ });
4581
4643
  });
4582
4644
  return response.then((apiResponse) => {
4583
4645
  const resp = deleteResourceJobFromMldev(apiResponse);
@@ -7638,6 +7700,12 @@ function liveMusicGenerationConfigToMldev(fromObject) {
7638
7700
  if (fromOnlyBassAndDrums != null) {
7639
7701
  setValueByPath(toObject, ['onlyBassAndDrums'], fromOnlyBassAndDrums);
7640
7702
  }
7703
+ const fromMusicGenerationMode = getValueByPath(fromObject, [
7704
+ 'musicGenerationMode',
7705
+ ]);
7706
+ if (fromMusicGenerationMode != null) {
7707
+ setValueByPath(toObject, ['musicGenerationMode'], fromMusicGenerationMode);
7708
+ }
7641
7709
  return toObject;
7642
7710
  }
7643
7711
  function liveMusicSetConfigParametersToMldev(fromObject) {
@@ -8796,6 +8864,12 @@ function liveMusicGenerationConfigFromMldev(fromObject) {
8796
8864
  if (fromOnlyBassAndDrums != null) {
8797
8865
  setValueByPath(toObject, ['onlyBassAndDrums'], fromOnlyBassAndDrums);
8798
8866
  }
8867
+ const fromMusicGenerationMode = getValueByPath(fromObject, [
8868
+ 'musicGenerationMode',
8869
+ ]);
8870
+ if (fromMusicGenerationMode != null) {
8871
+ setValueByPath(toObject, ['musicGenerationMode'], fromMusicGenerationMode);
8872
+ }
8799
8873
  return toObject;
8800
8874
  }
8801
8875
  function liveMusicSourceMetadataFromMldev(fromObject) {
@@ -10062,8 +10136,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
10062
10136
  if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
10063
10137
  throw new Error('addWatermark parameter is not supported in Gemini API.');
10064
10138
  }
10065
- if (getValueByPath(fromObject, ['imageSize']) !== undefined) {
10066
- throw new Error('imageSize parameter is not supported in Gemini API.');
10139
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
10140
+ if (parentObject !== undefined && fromImageSize != null) {
10141
+ setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
10067
10142
  }
10068
10143
  if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
10069
10144
  throw new Error('enhancePrompt parameter is not supported in Gemini API.');
@@ -11465,6 +11540,106 @@ function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject) {
11465
11540
  }
11466
11541
  return toObject;
11467
11542
  }
11543
+ function productImageToVertex(fromObject) {
11544
+ const toObject = {};
11545
+ const fromProductImage = getValueByPath(fromObject, ['productImage']);
11546
+ if (fromProductImage != null) {
11547
+ setValueByPath(toObject, ['image'], imageToVertex(fromProductImage));
11548
+ }
11549
+ return toObject;
11550
+ }
11551
+ function recontextImageSourceToVertex(fromObject, parentObject) {
11552
+ const toObject = {};
11553
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
11554
+ if (parentObject !== undefined && fromPrompt != null) {
11555
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
11556
+ }
11557
+ const fromPersonImage = getValueByPath(fromObject, ['personImage']);
11558
+ if (parentObject !== undefined && fromPersonImage != null) {
11559
+ setValueByPath(parentObject, ['instances[0]', 'personImage', 'image'], imageToVertex(fromPersonImage));
11560
+ }
11561
+ const fromProductImages = getValueByPath(fromObject, [
11562
+ 'productImages',
11563
+ ]);
11564
+ if (parentObject !== undefined && fromProductImages != null) {
11565
+ let transformedList = fromProductImages;
11566
+ if (Array.isArray(transformedList)) {
11567
+ transformedList = transformedList.map((item) => {
11568
+ return productImageToVertex(item);
11569
+ });
11570
+ }
11571
+ setValueByPath(parentObject, ['instances[0]', 'productImages'], transformedList);
11572
+ }
11573
+ return toObject;
11574
+ }
11575
+ function recontextImageConfigToVertex(fromObject, parentObject) {
11576
+ const toObject = {};
11577
+ const fromNumberOfImages = getValueByPath(fromObject, [
11578
+ 'numberOfImages',
11579
+ ]);
11580
+ if (parentObject !== undefined && fromNumberOfImages != null) {
11581
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
11582
+ }
11583
+ const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
11584
+ if (parentObject !== undefined && fromBaseSteps != null) {
11585
+ setValueByPath(parentObject, ['parameters', 'editConfig', 'baseSteps'], fromBaseSteps);
11586
+ }
11587
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
11588
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
11589
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
11590
+ }
11591
+ const fromSeed = getValueByPath(fromObject, ['seed']);
11592
+ if (parentObject !== undefined && fromSeed != null) {
11593
+ setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
11594
+ }
11595
+ const fromSafetyFilterLevel = getValueByPath(fromObject, [
11596
+ 'safetyFilterLevel',
11597
+ ]);
11598
+ if (parentObject !== undefined && fromSafetyFilterLevel != null) {
11599
+ setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
11600
+ }
11601
+ const fromPersonGeneration = getValueByPath(fromObject, [
11602
+ 'personGeneration',
11603
+ ]);
11604
+ if (parentObject !== undefined && fromPersonGeneration != null) {
11605
+ setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
11606
+ }
11607
+ const fromOutputMimeType = getValueByPath(fromObject, [
11608
+ 'outputMimeType',
11609
+ ]);
11610
+ if (parentObject !== undefined && fromOutputMimeType != null) {
11611
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
11612
+ }
11613
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
11614
+ 'outputCompressionQuality',
11615
+ ]);
11616
+ if (parentObject !== undefined && fromOutputCompressionQuality != null) {
11617
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
11618
+ }
11619
+ const fromEnhancePrompt = getValueByPath(fromObject, [
11620
+ 'enhancePrompt',
11621
+ ]);
11622
+ if (parentObject !== undefined && fromEnhancePrompt != null) {
11623
+ setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
11624
+ }
11625
+ return toObject;
11626
+ }
11627
+ function recontextImageParametersToVertex(apiClient, fromObject) {
11628
+ const toObject = {};
11629
+ const fromModel = getValueByPath(fromObject, ['model']);
11630
+ if (fromModel != null) {
11631
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
11632
+ }
11633
+ const fromSource = getValueByPath(fromObject, ['source']);
11634
+ if (fromSource != null) {
11635
+ setValueByPath(toObject, ['config'], recontextImageSourceToVertex(fromSource, toObject));
11636
+ }
11637
+ const fromConfig = getValueByPath(fromObject, ['config']);
11638
+ if (fromConfig != null) {
11639
+ setValueByPath(toObject, ['config'], recontextImageConfigToVertex(fromConfig, toObject));
11640
+ }
11641
+ return toObject;
11642
+ }
11468
11643
  function getModelParametersToVertex(apiClient, fromObject) {
11469
11644
  const toObject = {};
11470
11645
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -11961,6 +12136,10 @@ function generateContentResponseFromMldev(fromObject) {
11961
12136
  if (fromPromptFeedback != null) {
11962
12137
  setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
11963
12138
  }
12139
+ const fromResponseId = getValueByPath(fromObject, ['responseId']);
12140
+ if (fromResponseId != null) {
12141
+ setValueByPath(toObject, ['responseId'], fromResponseId);
12142
+ }
11964
12143
  const fromUsageMetadata = getValueByPath(fromObject, [
11965
12144
  'usageMetadata',
11966
12145
  ]);
@@ -11983,6 +12162,12 @@ function embedContentMetadataFromMldev() {
11983
12162
  }
11984
12163
  function embedContentResponseFromMldev(fromObject) {
11985
12164
  const toObject = {};
12165
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12166
+ 'sdkHttpResponse',
12167
+ ]);
12168
+ if (fromSdkHttpResponse != null) {
12169
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12170
+ }
11986
12171
  const fromEmbeddings = getValueByPath(fromObject, ['embeddings']);
11987
12172
  if (fromEmbeddings != null) {
11988
12173
  let transformedList = fromEmbeddings;
@@ -12055,6 +12240,12 @@ function generatedImageFromMldev(fromObject) {
12055
12240
  }
12056
12241
  function generateImagesResponseFromMldev(fromObject) {
12057
12242
  const toObject = {};
12243
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12244
+ 'sdkHttpResponse',
12245
+ ]);
12246
+ if (fromSdkHttpResponse != null) {
12247
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12248
+ }
12058
12249
  const fromGeneratedImages = getValueByPath(fromObject, [
12059
12250
  'predictions',
12060
12251
  ]);
@@ -12165,6 +12356,12 @@ function deleteModelResponseFromMldev() {
12165
12356
  }
12166
12357
  function countTokensResponseFromMldev(fromObject) {
12167
12358
  const toObject = {};
12359
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12360
+ 'sdkHttpResponse',
12361
+ ]);
12362
+ if (fromSdkHttpResponse != null) {
12363
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12364
+ }
12168
12365
  const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
12169
12366
  if (fromTotalTokens != null) {
12170
12367
  setValueByPath(toObject, ['totalTokens'], fromTotalTokens);
@@ -12493,10 +12690,6 @@ function generateContentResponseFromVertex(fromObject) {
12493
12690
  if (fromCreateTime != null) {
12494
12691
  setValueByPath(toObject, ['createTime'], fromCreateTime);
12495
12692
  }
12496
- const fromResponseId = getValueByPath(fromObject, ['responseId']);
12497
- if (fromResponseId != null) {
12498
- setValueByPath(toObject, ['responseId'], fromResponseId);
12499
- }
12500
12693
  const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
12501
12694
  if (fromModelVersion != null) {
12502
12695
  setValueByPath(toObject, ['modelVersion'], fromModelVersion);
@@ -12507,6 +12700,10 @@ function generateContentResponseFromVertex(fromObject) {
12507
12700
  if (fromPromptFeedback != null) {
12508
12701
  setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
12509
12702
  }
12703
+ const fromResponseId = getValueByPath(fromObject, ['responseId']);
12704
+ if (fromResponseId != null) {
12705
+ setValueByPath(toObject, ['responseId'], fromResponseId);
12706
+ }
12510
12707
  const fromUsageMetadata = getValueByPath(fromObject, [
12511
12708
  'usageMetadata',
12512
12709
  ]);
@@ -12551,6 +12748,12 @@ function embedContentMetadataFromVertex(fromObject) {
12551
12748
  }
12552
12749
  function embedContentResponseFromVertex(fromObject) {
12553
12750
  const toObject = {};
12751
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12752
+ 'sdkHttpResponse',
12753
+ ]);
12754
+ if (fromSdkHttpResponse != null) {
12755
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12756
+ }
12554
12757
  const fromEmbeddings = getValueByPath(fromObject, [
12555
12758
  'predictions[]',
12556
12759
  'embeddings',
@@ -12634,6 +12837,12 @@ function generatedImageFromVertex(fromObject) {
12634
12837
  }
12635
12838
  function generateImagesResponseFromVertex(fromObject) {
12636
12839
  const toObject = {};
12840
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12841
+ 'sdkHttpResponse',
12842
+ ]);
12843
+ if (fromSdkHttpResponse != null) {
12844
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12845
+ }
12637
12846
  const fromGeneratedImages = getValueByPath(fromObject, [
12638
12847
  'predictions',
12639
12848
  ]);
@@ -12656,6 +12865,12 @@ function generateImagesResponseFromVertex(fromObject) {
12656
12865
  }
12657
12866
  function editImageResponseFromVertex(fromObject) {
12658
12867
  const toObject = {};
12868
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12869
+ 'sdkHttpResponse',
12870
+ ]);
12871
+ if (fromSdkHttpResponse != null) {
12872
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12873
+ }
12659
12874
  const fromGeneratedImages = getValueByPath(fromObject, [
12660
12875
  'predictions',
12661
12876
  ]);
@@ -12671,6 +12886,28 @@ function editImageResponseFromVertex(fromObject) {
12671
12886
  return toObject;
12672
12887
  }
12673
12888
  function upscaleImageResponseFromVertex(fromObject) {
12889
+ const toObject = {};
12890
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12891
+ 'sdkHttpResponse',
12892
+ ]);
12893
+ if (fromSdkHttpResponse != null) {
12894
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12895
+ }
12896
+ const fromGeneratedImages = getValueByPath(fromObject, [
12897
+ 'predictions',
12898
+ ]);
12899
+ if (fromGeneratedImages != null) {
12900
+ let transformedList = fromGeneratedImages;
12901
+ if (Array.isArray(transformedList)) {
12902
+ transformedList = transformedList.map((item) => {
12903
+ return generatedImageFromVertex(item);
12904
+ });
12905
+ }
12906
+ setValueByPath(toObject, ['generatedImages'], transformedList);
12907
+ }
12908
+ return toObject;
12909
+ }
12910
+ function recontextImageResponseFromVertex(fromObject) {
12674
12911
  const toObject = {};
12675
12912
  const fromGeneratedImages = getValueByPath(fromObject, [
12676
12913
  'predictions',
@@ -12821,6 +13058,12 @@ function deleteModelResponseFromVertex() {
12821
13058
  }
12822
13059
  function countTokensResponseFromVertex(fromObject) {
12823
13060
  const toObject = {};
13061
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13062
+ 'sdkHttpResponse',
13063
+ ]);
13064
+ if (fromSdkHttpResponse != null) {
13065
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13066
+ }
12824
13067
  const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
12825
13068
  if (fromTotalTokens != null) {
12826
13069
  setValueByPath(toObject, ['totalTokens'], fromTotalTokens);
@@ -12829,6 +13072,12 @@ function countTokensResponseFromVertex(fromObject) {
12829
13072
  }
12830
13073
  function computeTokensResponseFromVertex(fromObject) {
12831
13074
  const toObject = {};
13075
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13076
+ 'sdkHttpResponse',
13077
+ ]);
13078
+ if (fromSdkHttpResponse != null) {
13079
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13080
+ }
12832
13081
  const fromTokensInfo = getValueByPath(fromObject, ['tokensInfo']);
12833
13082
  if (fromTokensInfo != null) {
12834
13083
  setValueByPath(toObject, ['tokensInfo'], fromTokensInfo);
@@ -12921,7 +13170,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
12921
13170
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
12922
13171
  const USER_AGENT_HEADER = 'User-Agent';
12923
13172
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
12924
- const SDK_VERSION = '1.11.0'; // x-release-please-version
13173
+ const SDK_VERSION = '1.13.0'; // x-release-please-version
12925
13174
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
12926
13175
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
12927
13176
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -14007,13 +14256,13 @@ class Live {
14007
14256
  const websocketBaseUrl = this.apiClient.getWebsocketBaseUrl();
14008
14257
  const apiVersion = this.apiClient.getApiVersion();
14009
14258
  let url;
14010
- const defaultHeaders = this.apiClient.getDefaultHeaders();
14259
+ const clientHeaders = this.apiClient.getHeaders();
14011
14260
  if (params.config &&
14012
14261
  params.config.tools &&
14013
14262
  hasMcpToolUsage(params.config.tools)) {
14014
- setMcpUsageHeader(defaultHeaders);
14263
+ setMcpUsageHeader(clientHeaders);
14015
14264
  }
14016
- const headers = mapToHeaders(defaultHeaders);
14265
+ const headers = mapToHeaders(clientHeaders);
14017
14266
  if (this.apiClient.isVertexAI()) {
14018
14267
  url = `${websocketBaseUrl}/ws/google.cloud.aiplatform.${apiVersion}.LlmBidiService/BidiGenerateContent`;
14019
14268
  await this.auth.addAuthHeaders(headers);
@@ -14580,11 +14829,13 @@ class Models extends BaseModule {
14580
14829
  response = {
14581
14830
  generatedImages: generatedImages,
14582
14831
  positivePromptSafetyAttributes: positivePromptSafetyAttributes,
14832
+ sdkHttpResponse: apiResponse.sdkHttpResponse,
14583
14833
  };
14584
14834
  }
14585
14835
  else {
14586
14836
  response = {
14587
14837
  generatedImages: generatedImages,
14838
+ sdkHttpResponse: apiResponse.sdkHttpResponse,
14588
14839
  };
14589
14840
  }
14590
14841
  return response;
@@ -15070,7 +15321,13 @@ class Models extends BaseModule {
15070
15321
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15071
15322
  })
15072
15323
  .then((httpResponse) => {
15073
- return httpResponse.json();
15324
+ return httpResponse.json().then((jsonResponse) => {
15325
+ const response = jsonResponse;
15326
+ response.sdkHttpResponse = {
15327
+ headers: httpResponse.headers,
15328
+ };
15329
+ return response;
15330
+ });
15074
15331
  });
15075
15332
  return response.then((apiResponse) => {
15076
15333
  const resp = embedContentResponseFromVertex(apiResponse);
@@ -15096,7 +15353,13 @@ class Models extends BaseModule {
15096
15353
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
15097
15354
  })
15098
15355
  .then((httpResponse) => {
15099
- return httpResponse.json();
15356
+ return httpResponse.json().then((jsonResponse) => {
15357
+ const response = jsonResponse;
15358
+ response.sdkHttpResponse = {
15359
+ headers: httpResponse.headers,
15360
+ };
15361
+ return response;
15362
+ });
15100
15363
  });
15101
15364
  return response.then((apiResponse) => {
15102
15365
  const resp = embedContentResponseFromMldev(apiResponse);
@@ -15147,7 +15410,13 @@ class Models extends BaseModule {
15147
15410
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15148
15411
  })
15149
15412
  .then((httpResponse) => {
15150
- return httpResponse.json();
15413
+ return httpResponse.json().then((jsonResponse) => {
15414
+ const response = jsonResponse;
15415
+ response.sdkHttpResponse = {
15416
+ headers: httpResponse.headers,
15417
+ };
15418
+ return response;
15419
+ });
15151
15420
  });
15152
15421
  return response.then((apiResponse) => {
15153
15422
  const resp = generateImagesResponseFromVertex(apiResponse);
@@ -15173,7 +15442,13 @@ class Models extends BaseModule {
15173
15442
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
15174
15443
  })
15175
15444
  .then((httpResponse) => {
15176
- return httpResponse.json();
15445
+ return httpResponse.json().then((jsonResponse) => {
15446
+ const response = jsonResponse;
15447
+ response.sdkHttpResponse = {
15448
+ headers: httpResponse.headers,
15449
+ };
15450
+ return response;
15451
+ });
15177
15452
  });
15178
15453
  return response.then((apiResponse) => {
15179
15454
  const resp = generateImagesResponseFromMldev(apiResponse);
@@ -15205,7 +15480,13 @@ class Models extends BaseModule {
15205
15480
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15206
15481
  })
15207
15482
  .then((httpResponse) => {
15208
- return httpResponse.json();
15483
+ return httpResponse.json().then((jsonResponse) => {
15484
+ const response = jsonResponse;
15485
+ response.sdkHttpResponse = {
15486
+ headers: httpResponse.headers,
15487
+ };
15488
+ return response;
15489
+ });
15209
15490
  });
15210
15491
  return response.then((apiResponse) => {
15211
15492
  const resp = editImageResponseFromVertex(apiResponse);
@@ -15240,7 +15521,13 @@ class Models extends BaseModule {
15240
15521
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15241
15522
  })
15242
15523
  .then((httpResponse) => {
15243
- return httpResponse.json();
15524
+ return httpResponse.json().then((jsonResponse) => {
15525
+ const response = jsonResponse;
15526
+ response.sdkHttpResponse = {
15527
+ headers: httpResponse.headers,
15528
+ };
15529
+ return response;
15530
+ });
15244
15531
  });
15245
15532
  return response.then((apiResponse) => {
15246
15533
  const resp = upscaleImageResponseFromVertex(apiResponse);
@@ -15253,6 +15540,79 @@ class Models extends BaseModule {
15253
15540
  throw new Error('This method is only supported by the Vertex AI.');
15254
15541
  }
15255
15542
  }
15543
+ /**
15544
+ * Recontextualizes an image.
15545
+ *
15546
+ * There are two types of recontextualization currently supported:
15547
+ * 1) Imagen Product Recontext - Generate images of products in new scenes
15548
+ * and contexts.
15549
+ * 2) Virtual Try-On: Generate images of persons modeling fashion products.
15550
+ *
15551
+ * @param params - The parameters for recontextualizing an image.
15552
+ * @return The response from the API.
15553
+ *
15554
+ * @example
15555
+ * ```ts
15556
+ * const response1 = await ai.models.recontextImage({
15557
+ * model: 'imagen-product-recontext-preview-06-30',
15558
+ * source: {
15559
+ * prompt: 'In a modern kitchen setting.',
15560
+ * productImages: [productImage],
15561
+ * },
15562
+ * config: {
15563
+ * numberOfImages: 1,
15564
+ * },
15565
+ * });
15566
+ * console.log(response1?.generatedImages?.[0]?.image?.imageBytes);
15567
+ *
15568
+ * const response2 = await ai.models.recontextImage({
15569
+ * model: 'virtual-try-on-preview-08-04',
15570
+ * source: {
15571
+ * personImage: personImage,
15572
+ * productImages: [productImage],
15573
+ * },
15574
+ * config: {
15575
+ * numberOfImages: 1,
15576
+ * },
15577
+ * });
15578
+ * console.log(response2?.generatedImages?.[0]?.image?.imageBytes);
15579
+ * ```
15580
+ */
15581
+ async recontextImage(params) {
15582
+ var _a, _b;
15583
+ let response;
15584
+ let path = '';
15585
+ let queryParams = {};
15586
+ if (this.apiClient.isVertexAI()) {
15587
+ const body = recontextImageParametersToVertex(this.apiClient, params);
15588
+ path = formatMap('{model}:predict', body['_url']);
15589
+ queryParams = body['_query'];
15590
+ delete body['config'];
15591
+ delete body['_url'];
15592
+ delete body['_query'];
15593
+ response = this.apiClient
15594
+ .request({
15595
+ path: path,
15596
+ queryParams: queryParams,
15597
+ body: JSON.stringify(body),
15598
+ httpMethod: 'POST',
15599
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
15600
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15601
+ })
15602
+ .then((httpResponse) => {
15603
+ return httpResponse.json();
15604
+ });
15605
+ return response.then((apiResponse) => {
15606
+ const resp = recontextImageResponseFromVertex(apiResponse);
15607
+ const typedResp = new RecontextImageResponse();
15608
+ Object.assign(typedResp, resp);
15609
+ return typedResp;
15610
+ });
15611
+ }
15612
+ else {
15613
+ throw new Error('This method is only supported by the Vertex AI.');
15614
+ }
15615
+ }
15256
15616
  /**
15257
15617
  * Fetches information about a model by name.
15258
15618
  *
@@ -15563,7 +15923,13 @@ class Models extends BaseModule {
15563
15923
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15564
15924
  })
15565
15925
  .then((httpResponse) => {
15566
- return httpResponse.json();
15926
+ return httpResponse.json().then((jsonResponse) => {
15927
+ const response = jsonResponse;
15928
+ response.sdkHttpResponse = {
15929
+ headers: httpResponse.headers,
15930
+ };
15931
+ return response;
15932
+ });
15567
15933
  });
15568
15934
  return response.then((apiResponse) => {
15569
15935
  const resp = countTokensResponseFromVertex(apiResponse);
@@ -15589,7 +15955,13 @@ class Models extends BaseModule {
15589
15955
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
15590
15956
  })
15591
15957
  .then((httpResponse) => {
15592
- return httpResponse.json();
15958
+ return httpResponse.json().then((jsonResponse) => {
15959
+ const response = jsonResponse;
15960
+ response.sdkHttpResponse = {
15961
+ headers: httpResponse.headers,
15962
+ };
15963
+ return response;
15964
+ });
15593
15965
  });
15594
15966
  return response.then((apiResponse) => {
15595
15967
  const resp = countTokensResponseFromMldev(apiResponse);
@@ -15639,7 +16011,13 @@ class Models extends BaseModule {
15639
16011
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15640
16012
  })
15641
16013
  .then((httpResponse) => {
15642
- return httpResponse.json();
16014
+ return httpResponse.json().then((jsonResponse) => {
16015
+ const response = jsonResponse;
16016
+ response.sdkHttpResponse = {
16017
+ headers: httpResponse.headers,
16018
+ };
16019
+ return response;
16020
+ });
15643
16021
  });
15644
16022
  return response.then((apiResponse) => {
15645
16023
  const resp = computeTokensResponseFromVertex(apiResponse);
@@ -17265,6 +17643,12 @@ function tunedModelFromMldev(fromObject) {
17265
17643
  }
17266
17644
  function tuningJobFromMldev(fromObject) {
17267
17645
  const toObject = {};
17646
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17647
+ 'sdkHttpResponse',
17648
+ ]);
17649
+ if (fromSdkHttpResponse != null) {
17650
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17651
+ }
17268
17652
  const fromName = getValueByPath(fromObject, ['name']);
17269
17653
  if (fromName != null) {
17270
17654
  setValueByPath(toObject, ['name'], fromName);
@@ -17375,6 +17759,12 @@ function listTuningJobsResponseFromMldev(fromObject) {
17375
17759
  }
17376
17760
  function tuningOperationFromMldev(fromObject) {
17377
17761
  const toObject = {};
17762
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17763
+ 'sdkHttpResponse',
17764
+ ]);
17765
+ if (fromSdkHttpResponse != null) {
17766
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17767
+ }
17378
17768
  const fromName = getValueByPath(fromObject, ['name']);
17379
17769
  if (fromName != null) {
17380
17770
  setValueByPath(toObject, ['name'], fromName);
@@ -17437,6 +17827,12 @@ function tunedModelFromVertex(fromObject) {
17437
17827
  }
17438
17828
  function tuningJobFromVertex(fromObject) {
17439
17829
  const toObject = {};
17830
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
17831
+ 'sdkHttpResponse',
17832
+ ]);
17833
+ if (fromSdkHttpResponse != null) {
17834
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
17835
+ }
17440
17836
  const fromName = getValueByPath(fromObject, ['name']);
17441
17837
  if (fromName != null) {
17442
17838
  setValueByPath(toObject, ['name'], fromName);
@@ -17655,7 +18051,13 @@ class Tunings extends BaseModule {
17655
18051
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
17656
18052
  })
17657
18053
  .then((httpResponse) => {
17658
- return httpResponse.json();
18054
+ return httpResponse.json().then((jsonResponse) => {
18055
+ const response = jsonResponse;
18056
+ response.sdkHttpResponse = {
18057
+ headers: httpResponse.headers,
18058
+ };
18059
+ return response;
18060
+ });
17659
18061
  });
17660
18062
  return response.then((apiResponse) => {
17661
18063
  const resp = tuningJobFromVertex(apiResponse);
@@ -17679,7 +18081,13 @@ class Tunings extends BaseModule {
17679
18081
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
17680
18082
  })
17681
18083
  .then((httpResponse) => {
17682
- return httpResponse.json();
18084
+ return httpResponse.json().then((jsonResponse) => {
18085
+ const response = jsonResponse;
18086
+ response.sdkHttpResponse = {
18087
+ headers: httpResponse.headers,
18088
+ };
18089
+ return response;
18090
+ });
17683
18091
  });
17684
18092
  return response.then((apiResponse) => {
17685
18093
  const resp = tuningJobFromMldev(apiResponse);
@@ -17779,7 +18187,13 @@ class Tunings extends BaseModule {
17779
18187
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
17780
18188
  })
17781
18189
  .then((httpResponse) => {
17782
- return httpResponse.json();
18190
+ return httpResponse.json().then((jsonResponse) => {
18191
+ const response = jsonResponse;
18192
+ response.sdkHttpResponse = {
18193
+ headers: httpResponse.headers,
18194
+ };
18195
+ return response;
18196
+ });
17783
18197
  });
17784
18198
  return response.then((apiResponse) => {
17785
18199
  const resp = tuningJobFromVertex(apiResponse);
@@ -17815,7 +18229,13 @@ class Tunings extends BaseModule {
17815
18229
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
17816
18230
  })
17817
18231
  .then((httpResponse) => {
17818
- return httpResponse.json();
18232
+ return httpResponse.json().then((jsonResponse) => {
18233
+ const response = jsonResponse;
18234
+ response.sdkHttpResponse = {
18235
+ headers: httpResponse.headers,
18236
+ };
18237
+ return response;
18238
+ });
17819
18239
  });
17820
18240
  return response.then((apiResponse) => {
17821
18241
  const resp = tuningOperationFromMldev(apiResponse);
@@ -18271,6 +18691,7 @@ exports.Models = Models;
18271
18691
  exports.Operations = Operations;
18272
18692
  exports.Pager = Pager;
18273
18693
  exports.RawReferenceImage = RawReferenceImage;
18694
+ exports.RecontextImageResponse = RecontextImageResponse;
18274
18695
  exports.ReplayResponse = ReplayResponse;
18275
18696
  exports.Session = Session;
18276
18697
  exports.StyleReferenceImage = StyleReferenceImage;