@google/genai 1.12.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/genai.d.ts CHANGED
@@ -1599,6 +1599,8 @@ export declare class DeleteModelResponse {
1599
1599
 
1600
1600
  /** The return value of delete operation. */
1601
1601
  export declare interface DeleteResourceJob {
1602
+ /** Used to retain the full HTTP response. */
1603
+ sdkHttpResponse?: HttpResponse;
1602
1604
  name?: string;
1603
1605
  done?: boolean;
1604
1606
  error?: JobError;
@@ -2501,9 +2503,6 @@ export declare class GenerateContentResponse {
2501
2503
  /** Timestamp when the request is made to the server.
2502
2504
  */
2503
2505
  createTime?: string;
2504
- /** Identifier for each response.
2505
- */
2506
- responseId?: string;
2507
2506
  /** The history of automatic function calling.
2508
2507
  */
2509
2508
  automaticFunctionCallingHistory?: Content[];
@@ -2511,6 +2510,8 @@ export declare class GenerateContentResponse {
2511
2510
  modelVersion?: string;
2512
2511
  /** Output only. Content filter results for a prompt sent in the request. Note: Sent only in the first stream chunk. Only happens when no candidates were generated due to content violations. */
2513
2512
  promptFeedback?: GenerateContentResponsePromptFeedback;
2513
+ /** Output only. response_id is used to identify each response. It is the encoding of the event_id. */
2514
+ responseId?: string;
2514
2515
  /** Usage metadata about the response(s). */
2515
2516
  usageMetadata?: GenerateContentResponseUsageMetadata;
2516
2517
  /**
@@ -4283,6 +4284,8 @@ export declare interface LiveMusicGenerationConfig {
4283
4284
  muteDrums?: boolean;
4284
4285
  /** Whether the audio output should contain only bass and drums. */
4285
4286
  onlyBassAndDrums?: boolean;
4287
+ /** The mode of music generation. Default mode is QUALITY. */
4288
+ musicGenerationMode?: MusicGenerationMode;
4286
4289
  }
4287
4290
 
4288
4291
  /** The playback control signal to apply to the music generation. */
@@ -5026,6 +5029,45 @@ export declare class Models extends BaseModule {
5026
5029
  private generateImagesInternal;
5027
5030
  private editImageInternal;
5028
5031
  private upscaleImageInternal;
5032
+ /**
5033
+ * Recontextualizes an image.
5034
+ *
5035
+ * There are two types of recontextualization currently supported:
5036
+ * 1) Imagen Product Recontext - Generate images of products in new scenes
5037
+ * and contexts.
5038
+ * 2) Virtual Try-On: Generate images of persons modeling fashion products.
5039
+ *
5040
+ * @param params - The parameters for recontextualizing an image.
5041
+ * @return The response from the API.
5042
+ *
5043
+ * @example
5044
+ * ```ts
5045
+ * const response1 = await ai.models.recontextImage({
5046
+ * model: 'imagen-product-recontext-preview-06-30',
5047
+ * source: {
5048
+ * prompt: 'In a modern kitchen setting.',
5049
+ * productImages: [productImage],
5050
+ * },
5051
+ * config: {
5052
+ * numberOfImages: 1,
5053
+ * },
5054
+ * });
5055
+ * console.log(response1?.generatedImages?.[0]?.image?.imageBytes);
5056
+ *
5057
+ * const response2 = await ai.models.recontextImage({
5058
+ * model: 'virtual-try-on-preview-08-04',
5059
+ * source: {
5060
+ * personImage: personImage,
5061
+ * productImages: [productImage],
5062
+ * },
5063
+ * config: {
5064
+ * numberOfImages: 1,
5065
+ * },
5066
+ * });
5067
+ * console.log(response2?.generatedImages?.[0]?.image?.imageBytes);
5068
+ * ```
5069
+ */
5070
+ recontextImage(params: types.RecontextImageParameters): Promise<types.RecontextImageResponse>;
5029
5071
  /**
5030
5072
  * Fetches information about a model by name.
5031
5073
  *
@@ -5140,6 +5182,29 @@ export declare interface MultiSpeakerVoiceConfig {
5140
5182
  speakerVoiceConfigs?: SpeakerVoiceConfig[];
5141
5183
  }
5142
5184
 
5185
+ /** The mode of music generation. */
5186
+ export declare enum MusicGenerationMode {
5187
+ /**
5188
+ * Rely on the server default generation mode.
5189
+ */
5190
+ MUSIC_GENERATION_MODE_UNSPECIFIED = "MUSIC_GENERATION_MODE_UNSPECIFIED",
5191
+ /**
5192
+ * Steer text prompts to regions of latent space with higher quality
5193
+ music.
5194
+ */
5195
+ QUALITY = "QUALITY",
5196
+ /**
5197
+ * Steer text prompts to regions of latent space with a larger
5198
+ diversity of music.
5199
+ */
5200
+ DIVERSITY = "DIVERSITY",
5201
+ /**
5202
+ * Steer text prompts to regions of latent space more likely to
5203
+ generate music with vocals.
5204
+ */
5205
+ VOCALIZATION = "VOCALIZATION"
5206
+ }
5207
+
5143
5208
  /** A long-running operation. */
5144
5209
  export declare interface Operation<T> {
5145
5210
  /** The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. */
@@ -5415,6 +5480,12 @@ export declare interface ProactivityConfig {
5415
5480
  proactiveAudio?: boolean;
5416
5481
  }
5417
5482
 
5483
+ /** An image of the product. */
5484
+ export declare interface ProductImage {
5485
+ /** An image of the product to be recontextualized. */
5486
+ productImage?: Image_2;
5487
+ }
5488
+
5418
5489
  /** A RagChunk includes the content of a chunk of a RagFile, and associated metadata. */
5419
5490
  export declare interface RagChunk {
5420
5491
  /** If populated, represents where the chunk starts and ends in the document. */
@@ -5510,6 +5581,69 @@ export declare interface RealtimeInputConfig {
5510
5581
  turnCoverage?: TurnCoverage;
5511
5582
  }
5512
5583
 
5584
+ /** Configuration for recontextualizing an image. */
5585
+ export declare interface RecontextImageConfig {
5586
+ /** Used to override HTTP request options. */
5587
+ httpOptions?: HttpOptions;
5588
+ /** Abort signal which can be used to cancel the request.
5589
+
5590
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
5591
+ operation will not cancel the request in the service. You will still
5592
+ be charged usage for any applicable operations.
5593
+ */
5594
+ abortSignal?: AbortSignal;
5595
+ /** Number of images to generate. */
5596
+ numberOfImages?: number;
5597
+ /** The number of sampling steps. A higher value has better image
5598
+ quality, while a lower value has better latency. */
5599
+ baseSteps?: number;
5600
+ /** Cloud Storage URI used to store the generated images. */
5601
+ outputGcsUri?: string;
5602
+ /** Random seed for image generation. */
5603
+ seed?: number;
5604
+ /** Filter level for safety filtering. */
5605
+ safetyFilterLevel?: SafetyFilterLevel;
5606
+ /** Whether allow to generate person images, and restrict to specific
5607
+ ages. */
5608
+ personGeneration?: PersonGeneration;
5609
+ /** MIME type of the generated image. */
5610
+ outputMimeType?: string;
5611
+ /** Compression quality of the generated image (for ``image/jpeg``
5612
+ only). */
5613
+ outputCompressionQuality?: number;
5614
+ /** Whether to use the prompt rewriting logic. */
5615
+ enhancePrompt?: boolean;
5616
+ }
5617
+
5618
+ /** The parameters for recontextualizing an image. */
5619
+ export declare interface RecontextImageParameters {
5620
+ /** ID of the model to use. For a list of models, see `Google models
5621
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
5622
+ model: string;
5623
+ /** A set of source input(s) for image recontextualization. */
5624
+ source: RecontextImageSource;
5625
+ /** Configuration for image recontextualization. */
5626
+ config?: RecontextImageConfig;
5627
+ }
5628
+
5629
+ /** The output images response. */
5630
+ export declare class RecontextImageResponse {
5631
+ /** List of generated images. */
5632
+ generatedImages?: GeneratedImage[];
5633
+ }
5634
+
5635
+ /** A set of source input(s) for image recontextualization. */
5636
+ export declare interface RecontextImageSource {
5637
+ /** A text prompt for guiding the model during image
5638
+ recontextualization. Not supported for Virtual Try-On. */
5639
+ prompt?: string;
5640
+ /** Image of the person or subject who will be wearing the
5641
+ product(s). */
5642
+ personImage?: Image_2;
5643
+ /** A list of product images. */
5644
+ productImages?: ProductImage[];
5645
+ }
5646
+
5513
5647
  export declare type ReferenceImage = RawReferenceImage | MaskReferenceImage | ControlReferenceImage | StyleReferenceImage | SubjectReferenceImage;
5514
5648
 
5515
5649
  /** Private class that represents a Reference image that is sent to API. */
@@ -6637,6 +6771,7 @@ declare namespace types {
6637
6771
  TurnCoverage,
6638
6772
  FunctionResponseScheduling,
6639
6773
  Scale,
6774
+ MusicGenerationMode,
6640
6775
  LiveMusicPlaybackControl,
6641
6776
  VideoMetadata,
6642
6777
  Blob_2 as Blob,
@@ -6747,6 +6882,11 @@ declare namespace types {
6747
6882
  EditImageConfig,
6748
6883
  EditImageResponse,
6749
6884
  UpscaleImageResponse,
6885
+ ProductImage,
6886
+ RecontextImageSource,
6887
+ RecontextImageConfig,
6888
+ RecontextImageParameters,
6889
+ RecontextImageResponse,
6750
6890
  GetModelConfig,
6751
6891
  GetModelParameters,
6752
6892
  Endpoint,
@@ -7123,7 +7263,15 @@ export declare enum UrlRetrievalStatus {
7123
7263
  /**
7124
7264
  * Url retrieval is failed due to error.
7125
7265
  */
7126
- URL_RETRIEVAL_STATUS_ERROR = "URL_RETRIEVAL_STATUS_ERROR"
7266
+ URL_RETRIEVAL_STATUS_ERROR = "URL_RETRIEVAL_STATUS_ERROR",
7267
+ /**
7268
+ * Url retrieval is failed because the content is behind paywall.
7269
+ */
7270
+ URL_RETRIEVAL_STATUS_PAYWALL = "URL_RETRIEVAL_STATUS_PAYWALL",
7271
+ /**
7272
+ * Url retrieval is failed because the content is unsafe.
7273
+ */
7274
+ URL_RETRIEVAL_STATUS_UNSAFE = "URL_RETRIEVAL_STATUS_UNSAFE"
7127
7275
  }
7128
7276
 
7129
7277
  /** Usage metadata about response(s). */
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 {
@@ -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.12.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
  ]);
@@ -13152,10 +13331,6 @@ function generateContentResponseFromVertex(fromObject) {
13152
13331
  if (fromCreateTime != null) {
13153
13332
  setValueByPath(toObject, ['createTime'], fromCreateTime);
13154
13333
  }
13155
- const fromResponseId = getValueByPath(fromObject, ['responseId']);
13156
- if (fromResponseId != null) {
13157
- setValueByPath(toObject, ['responseId'], fromResponseId);
13158
- }
13159
13334
  const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
13160
13335
  if (fromModelVersion != null) {
13161
13336
  setValueByPath(toObject, ['modelVersion'], fromModelVersion);
@@ -13166,6 +13341,10 @@ function generateContentResponseFromVertex(fromObject) {
13166
13341
  if (fromPromptFeedback != null) {
13167
13342
  setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
13168
13343
  }
13344
+ const fromResponseId = getValueByPath(fromObject, ['responseId']);
13345
+ if (fromResponseId != null) {
13346
+ setValueByPath(toObject, ['responseId'], fromResponseId);
13347
+ }
13169
13348
  const fromUsageMetadata = getValueByPath(fromObject, [
13170
13349
  'usageMetadata',
13171
13350
  ]);
@@ -13369,6 +13548,22 @@ function upscaleImageResponseFromVertex(fromObject) {
13369
13548
  }
13370
13549
  return toObject;
13371
13550
  }
13551
+ function recontextImageResponseFromVertex(fromObject) {
13552
+ const toObject = {};
13553
+ const fromGeneratedImages = getValueByPath(fromObject, [
13554
+ 'predictions',
13555
+ ]);
13556
+ if (fromGeneratedImages != null) {
13557
+ let transformedList = fromGeneratedImages;
13558
+ if (Array.isArray(transformedList)) {
13559
+ transformedList = transformedList.map((item) => {
13560
+ return generatedImageFromVertex(item);
13561
+ });
13562
+ }
13563
+ setValueByPath(toObject, ['generatedImages'], transformedList);
13564
+ }
13565
+ return toObject;
13566
+ }
13372
13567
  function endpointFromVertex(fromObject) {
13373
13568
  const toObject = {};
13374
13569
  const fromName = getValueByPath(fromObject, ['endpoint']);
@@ -15412,6 +15607,79 @@ class Models extends BaseModule {
15412
15607
  throw new Error('This method is only supported by the Vertex AI.');
15413
15608
  }
15414
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
+ }
15415
15683
  /**
15416
15684
  * Fetches information about a model by name.
15417
15685
  *
@@ -18005,6 +18273,7 @@ exports.Models = Models;
18005
18273
  exports.Operations = Operations;
18006
18274
  exports.Pager = Pager;
18007
18275
  exports.RawReferenceImage = RawReferenceImage;
18276
+ exports.RecontextImageResponse = RecontextImageResponse;
18008
18277
  exports.ReplayResponse = ReplayResponse;
18009
18278
  exports.Session = Session;
18010
18279
  exports.StyleReferenceImage = StyleReferenceImage;