@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.
@@ -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
  /**
@@ -4295,6 +4296,8 @@ export declare interface LiveMusicGenerationConfig {
4295
4296
  muteDrums?: boolean;
4296
4297
  /** Whether the audio output should contain only bass and drums. */
4297
4298
  onlyBassAndDrums?: boolean;
4299
+ /** The mode of music generation. Default mode is QUALITY. */
4300
+ musicGenerationMode?: MusicGenerationMode;
4298
4301
  }
4299
4302
 
4300
4303
  /** The playback control signal to apply to the music generation. */
@@ -5038,6 +5041,45 @@ export declare class Models extends BaseModule {
5038
5041
  private generateImagesInternal;
5039
5042
  private editImageInternal;
5040
5043
  private upscaleImageInternal;
5044
+ /**
5045
+ * Recontextualizes an image.
5046
+ *
5047
+ * There are two types of recontextualization currently supported:
5048
+ * 1) Imagen Product Recontext - Generate images of products in new scenes
5049
+ * and contexts.
5050
+ * 2) Virtual Try-On: Generate images of persons modeling fashion products.
5051
+ *
5052
+ * @param params - The parameters for recontextualizing an image.
5053
+ * @return The response from the API.
5054
+ *
5055
+ * @example
5056
+ * ```ts
5057
+ * const response1 = await ai.models.recontextImage({
5058
+ * model: 'imagen-product-recontext-preview-06-30',
5059
+ * source: {
5060
+ * prompt: 'In a modern kitchen setting.',
5061
+ * productImages: [productImage],
5062
+ * },
5063
+ * config: {
5064
+ * numberOfImages: 1,
5065
+ * },
5066
+ * });
5067
+ * console.log(response1?.generatedImages?.[0]?.image?.imageBytes);
5068
+ *
5069
+ * const response2 = await ai.models.recontextImage({
5070
+ * model: 'virtual-try-on-preview-08-04',
5071
+ * source: {
5072
+ * personImage: personImage,
5073
+ * productImages: [productImage],
5074
+ * },
5075
+ * config: {
5076
+ * numberOfImages: 1,
5077
+ * },
5078
+ * });
5079
+ * console.log(response2?.generatedImages?.[0]?.image?.imageBytes);
5080
+ * ```
5081
+ */
5082
+ recontextImage(params: types.RecontextImageParameters): Promise<types.RecontextImageResponse>;
5041
5083
  /**
5042
5084
  * Fetches information about a model by name.
5043
5085
  *
@@ -5152,6 +5194,29 @@ export declare interface MultiSpeakerVoiceConfig {
5152
5194
  speakerVoiceConfigs?: SpeakerVoiceConfig[];
5153
5195
  }
5154
5196
 
5197
+ /** The mode of music generation. */
5198
+ export declare enum MusicGenerationMode {
5199
+ /**
5200
+ * Rely on the server default generation mode.
5201
+ */
5202
+ MUSIC_GENERATION_MODE_UNSPECIFIED = "MUSIC_GENERATION_MODE_UNSPECIFIED",
5203
+ /**
5204
+ * Steer text prompts to regions of latent space with higher quality
5205
+ music.
5206
+ */
5207
+ QUALITY = "QUALITY",
5208
+ /**
5209
+ * Steer text prompts to regions of latent space with a larger
5210
+ diversity of music.
5211
+ */
5212
+ DIVERSITY = "DIVERSITY",
5213
+ /**
5214
+ * Steer text prompts to regions of latent space more likely to
5215
+ generate music with vocals.
5216
+ */
5217
+ VOCALIZATION = "VOCALIZATION"
5218
+ }
5219
+
5155
5220
  /** A long-running operation. */
5156
5221
  export declare interface Operation<T> {
5157
5222
  /** 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}`. */
@@ -5427,6 +5492,12 @@ export declare interface ProactivityConfig {
5427
5492
  proactiveAudio?: boolean;
5428
5493
  }
5429
5494
 
5495
+ /** An image of the product. */
5496
+ export declare interface ProductImage {
5497
+ /** An image of the product to be recontextualized. */
5498
+ productImage?: Image_2;
5499
+ }
5500
+
5430
5501
  /** A RagChunk includes the content of a chunk of a RagFile, and associated metadata. */
5431
5502
  export declare interface RagChunk {
5432
5503
  /** If populated, represents where the chunk starts and ends in the document. */
@@ -5522,6 +5593,69 @@ export declare interface RealtimeInputConfig {
5522
5593
  turnCoverage?: TurnCoverage;
5523
5594
  }
5524
5595
 
5596
+ /** Configuration for recontextualizing an image. */
5597
+ export declare interface RecontextImageConfig {
5598
+ /** Used to override HTTP request options. */
5599
+ httpOptions?: HttpOptions;
5600
+ /** Abort signal which can be used to cancel the request.
5601
+
5602
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
5603
+ operation will not cancel the request in the service. You will still
5604
+ be charged usage for any applicable operations.
5605
+ */
5606
+ abortSignal?: AbortSignal;
5607
+ /** Number of images to generate. */
5608
+ numberOfImages?: number;
5609
+ /** The number of sampling steps. A higher value has better image
5610
+ quality, while a lower value has better latency. */
5611
+ baseSteps?: number;
5612
+ /** Cloud Storage URI used to store the generated images. */
5613
+ outputGcsUri?: string;
5614
+ /** Random seed for image generation. */
5615
+ seed?: number;
5616
+ /** Filter level for safety filtering. */
5617
+ safetyFilterLevel?: SafetyFilterLevel;
5618
+ /** Whether allow to generate person images, and restrict to specific
5619
+ ages. */
5620
+ personGeneration?: PersonGeneration;
5621
+ /** MIME type of the generated image. */
5622
+ outputMimeType?: string;
5623
+ /** Compression quality of the generated image (for ``image/jpeg``
5624
+ only). */
5625
+ outputCompressionQuality?: number;
5626
+ /** Whether to use the prompt rewriting logic. */
5627
+ enhancePrompt?: boolean;
5628
+ }
5629
+
5630
+ /** The parameters for recontextualizing an image. */
5631
+ export declare interface RecontextImageParameters {
5632
+ /** ID of the model to use. For a list of models, see `Google models
5633
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
5634
+ model: string;
5635
+ /** A set of source input(s) for image recontextualization. */
5636
+ source: RecontextImageSource;
5637
+ /** Configuration for image recontextualization. */
5638
+ config?: RecontextImageConfig;
5639
+ }
5640
+
5641
+ /** The output images response. */
5642
+ export declare class RecontextImageResponse {
5643
+ /** List of generated images. */
5644
+ generatedImages?: GeneratedImage[];
5645
+ }
5646
+
5647
+ /** A set of source input(s) for image recontextualization. */
5648
+ export declare interface RecontextImageSource {
5649
+ /** A text prompt for guiding the model during image
5650
+ recontextualization. Not supported for Virtual Try-On. */
5651
+ prompt?: string;
5652
+ /** Image of the person or subject who will be wearing the
5653
+ product(s). */
5654
+ personImage?: Image_2;
5655
+ /** A list of product images. */
5656
+ productImages?: ProductImage[];
5657
+ }
5658
+
5525
5659
  export declare type ReferenceImage = RawReferenceImage | MaskReferenceImage | ControlReferenceImage | StyleReferenceImage | SubjectReferenceImage;
5526
5660
 
5527
5661
  /** Private class that represents a Reference image that is sent to API. */
@@ -6649,6 +6783,7 @@ declare namespace types {
6649
6783
  TurnCoverage,
6650
6784
  FunctionResponseScheduling,
6651
6785
  Scale,
6786
+ MusicGenerationMode,
6652
6787
  LiveMusicPlaybackControl,
6653
6788
  VideoMetadata,
6654
6789
  Blob_2 as Blob,
@@ -6759,6 +6894,11 @@ declare namespace types {
6759
6894
  EditImageConfig,
6760
6895
  EditImageResponse,
6761
6896
  UpscaleImageResponse,
6897
+ ProductImage,
6898
+ RecontextImageSource,
6899
+ RecontextImageConfig,
6900
+ RecontextImageParameters,
6901
+ RecontextImageResponse,
6762
6902
  GetModelConfig,
6763
6903
  GetModelParameters,
6764
6904
  Endpoint,
@@ -7135,7 +7275,15 @@ export declare enum UrlRetrievalStatus {
7135
7275
  /**
7136
7276
  * Url retrieval is failed due to error.
7137
7277
  */
7138
- URL_RETRIEVAL_STATUS_ERROR = "URL_RETRIEVAL_STATUS_ERROR"
7278
+ URL_RETRIEVAL_STATUS_ERROR = "URL_RETRIEVAL_STATUS_ERROR",
7279
+ /**
7280
+ * Url retrieval is failed because the content is behind paywall.
7281
+ */
7282
+ URL_RETRIEVAL_STATUS_PAYWALL = "URL_RETRIEVAL_STATUS_PAYWALL",
7283
+ /**
7284
+ * Url retrieval is failed because the content is unsafe.
7285
+ */
7286
+ URL_RETRIEVAL_STATUS_UNSAFE = "URL_RETRIEVAL_STATUS_UNSAFE"
7139
7287
  }
7140
7288
 
7141
7289
  /** Usage metadata about response(s). */
@@ -444,6 +444,14 @@ var UrlRetrievalStatus;
444
444
  * Url retrieval is failed due to error.
445
445
  */
446
446
  UrlRetrievalStatus["URL_RETRIEVAL_STATUS_ERROR"] = "URL_RETRIEVAL_STATUS_ERROR";
447
+ /**
448
+ * Url retrieval is failed because the content is behind paywall.
449
+ */
450
+ UrlRetrievalStatus["URL_RETRIEVAL_STATUS_PAYWALL"] = "URL_RETRIEVAL_STATUS_PAYWALL";
451
+ /**
452
+ * Url retrieval is failed because the content is unsafe.
453
+ */
454
+ UrlRetrievalStatus["URL_RETRIEVAL_STATUS_UNSAFE"] = "URL_RETRIEVAL_STATUS_UNSAFE";
447
455
  })(UrlRetrievalStatus || (UrlRetrievalStatus = {}));
448
456
  /** Output only. The reason why the model stopped generating tokens.
449
457
 
@@ -1070,6 +1078,29 @@ var Scale;
1070
1078
  */
1071
1079
  Scale["B_MAJOR_A_FLAT_MINOR"] = "B_MAJOR_A_FLAT_MINOR";
1072
1080
  })(Scale || (Scale = {}));
1081
+ /** The mode of music generation. */
1082
+ var MusicGenerationMode;
1083
+ (function (MusicGenerationMode) {
1084
+ /**
1085
+ * Rely on the server default generation mode.
1086
+ */
1087
+ MusicGenerationMode["MUSIC_GENERATION_MODE_UNSPECIFIED"] = "MUSIC_GENERATION_MODE_UNSPECIFIED";
1088
+ /**
1089
+ * Steer text prompts to regions of latent space with higher quality
1090
+ music.
1091
+ */
1092
+ MusicGenerationMode["QUALITY"] = "QUALITY";
1093
+ /**
1094
+ * Steer text prompts to regions of latent space with a larger
1095
+ diversity of music.
1096
+ */
1097
+ MusicGenerationMode["DIVERSITY"] = "DIVERSITY";
1098
+ /**
1099
+ * Steer text prompts to regions of latent space more likely to
1100
+ generate music with vocals.
1101
+ */
1102
+ MusicGenerationMode["VOCALIZATION"] = "VOCALIZATION";
1103
+ })(MusicGenerationMode || (MusicGenerationMode = {}));
1073
1104
  /** The playback control signal to apply to the music generation. */
1074
1105
  var LiveMusicPlaybackControl;
1075
1106
  (function (LiveMusicPlaybackControl) {
@@ -1493,6 +1524,9 @@ class EditImageResponse {
1493
1524
  }
1494
1525
  class UpscaleImageResponse {
1495
1526
  }
1527
+ /** The output images response. */
1528
+ class RecontextImageResponse {
1529
+ }
1496
1530
  class ListModelsResponse {
1497
1531
  }
1498
1532
  class DeleteModelResponse {
@@ -3698,6 +3732,10 @@ function generateContentResponseFromMldev$1(fromObject) {
3698
3732
  if (fromPromptFeedback != null) {
3699
3733
  setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
3700
3734
  }
3735
+ const fromResponseId = getValueByPath(fromObject, ['responseId']);
3736
+ if (fromResponseId != null) {
3737
+ setValueByPath(toObject, ['responseId'], fromResponseId);
3738
+ }
3701
3739
  const fromUsageMetadata = getValueByPath(fromObject, [
3702
3740
  'usageMetadata',
3703
3741
  ]);
@@ -3831,6 +3869,12 @@ function listBatchJobsResponseFromMldev(fromObject) {
3831
3869
  }
3832
3870
  function deleteResourceJobFromMldev(fromObject) {
3833
3871
  const toObject = {};
3872
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
3873
+ 'sdkHttpResponse',
3874
+ ]);
3875
+ if (fromSdkHttpResponse != null) {
3876
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
3877
+ }
3834
3878
  const fromName = getValueByPath(fromObject, ['name']);
3835
3879
  if (fromName != null) {
3836
3880
  setValueByPath(toObject, ['name'], fromName);
@@ -3980,6 +4024,12 @@ function listBatchJobsResponseFromVertex(fromObject) {
3980
4024
  }
3981
4025
  function deleteResourceJobFromVertex(fromObject) {
3982
4026
  const toObject = {};
4027
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
4028
+ 'sdkHttpResponse',
4029
+ ]);
4030
+ if (fromSdkHttpResponse != null) {
4031
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
4032
+ }
3983
4033
  const fromName = getValueByPath(fromObject, ['name']);
3984
4034
  if (fromName != null) {
3985
4035
  setValueByPath(toObject, ['name'], fromName);
@@ -4525,7 +4575,13 @@ class Batches extends BaseModule {
4525
4575
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
4526
4576
  })
4527
4577
  .then((httpResponse) => {
4528
- return httpResponse.json();
4578
+ return httpResponse.json().then((jsonResponse) => {
4579
+ const response = jsonResponse;
4580
+ response.sdkHttpResponse = {
4581
+ headers: httpResponse.headers,
4582
+ };
4583
+ return response;
4584
+ });
4529
4585
  });
4530
4586
  return response.then((apiResponse) => {
4531
4587
  const resp = deleteResourceJobFromVertex(apiResponse);
@@ -4549,7 +4605,13 @@ class Batches extends BaseModule {
4549
4605
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
4550
4606
  })
4551
4607
  .then((httpResponse) => {
4552
- return httpResponse.json();
4608
+ return httpResponse.json().then((jsonResponse) => {
4609
+ const response = jsonResponse;
4610
+ response.sdkHttpResponse = {
4611
+ headers: httpResponse.headers,
4612
+ };
4613
+ return response;
4614
+ });
4553
4615
  });
4554
4616
  return response.then((apiResponse) => {
4555
4617
  const resp = deleteResourceJobFromMldev(apiResponse);
@@ -7610,6 +7672,12 @@ function liveMusicGenerationConfigToMldev(fromObject) {
7610
7672
  if (fromOnlyBassAndDrums != null) {
7611
7673
  setValueByPath(toObject, ['onlyBassAndDrums'], fromOnlyBassAndDrums);
7612
7674
  }
7675
+ const fromMusicGenerationMode = getValueByPath(fromObject, [
7676
+ 'musicGenerationMode',
7677
+ ]);
7678
+ if (fromMusicGenerationMode != null) {
7679
+ setValueByPath(toObject, ['musicGenerationMode'], fromMusicGenerationMode);
7680
+ }
7613
7681
  return toObject;
7614
7682
  }
7615
7683
  function liveMusicSetConfigParametersToMldev(fromObject) {
@@ -8768,6 +8836,12 @@ function liveMusicGenerationConfigFromMldev(fromObject) {
8768
8836
  if (fromOnlyBassAndDrums != null) {
8769
8837
  setValueByPath(toObject, ['onlyBassAndDrums'], fromOnlyBassAndDrums);
8770
8838
  }
8839
+ const fromMusicGenerationMode = getValueByPath(fromObject, [
8840
+ 'musicGenerationMode',
8841
+ ]);
8842
+ if (fromMusicGenerationMode != null) {
8843
+ setValueByPath(toObject, ['musicGenerationMode'], fromMusicGenerationMode);
8844
+ }
8771
8845
  return toObject;
8772
8846
  }
8773
8847
  function liveMusicSourceMetadataFromMldev(fromObject) {
@@ -10034,8 +10108,9 @@ function generateImagesConfigToMldev(fromObject, parentObject) {
10034
10108
  if (getValueByPath(fromObject, ['addWatermark']) !== undefined) {
10035
10109
  throw new Error('addWatermark parameter is not supported in Gemini API.');
10036
10110
  }
10037
- if (getValueByPath(fromObject, ['imageSize']) !== undefined) {
10038
- throw new Error('imageSize parameter is not supported in Gemini API.');
10111
+ const fromImageSize = getValueByPath(fromObject, ['imageSize']);
10112
+ if (parentObject !== undefined && fromImageSize != null) {
10113
+ setValueByPath(parentObject, ['parameters', 'sampleImageSize'], fromImageSize);
10039
10114
  }
10040
10115
  if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
10041
10116
  throw new Error('enhancePrompt parameter is not supported in Gemini API.');
@@ -11437,6 +11512,106 @@ function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject) {
11437
11512
  }
11438
11513
  return toObject;
11439
11514
  }
11515
+ function productImageToVertex(fromObject) {
11516
+ const toObject = {};
11517
+ const fromProductImage = getValueByPath(fromObject, ['productImage']);
11518
+ if (fromProductImage != null) {
11519
+ setValueByPath(toObject, ['image'], imageToVertex(fromProductImage));
11520
+ }
11521
+ return toObject;
11522
+ }
11523
+ function recontextImageSourceToVertex(fromObject, parentObject) {
11524
+ const toObject = {};
11525
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
11526
+ if (parentObject !== undefined && fromPrompt != null) {
11527
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
11528
+ }
11529
+ const fromPersonImage = getValueByPath(fromObject, ['personImage']);
11530
+ if (parentObject !== undefined && fromPersonImage != null) {
11531
+ setValueByPath(parentObject, ['instances[0]', 'personImage', 'image'], imageToVertex(fromPersonImage));
11532
+ }
11533
+ const fromProductImages = getValueByPath(fromObject, [
11534
+ 'productImages',
11535
+ ]);
11536
+ if (parentObject !== undefined && fromProductImages != null) {
11537
+ let transformedList = fromProductImages;
11538
+ if (Array.isArray(transformedList)) {
11539
+ transformedList = transformedList.map((item) => {
11540
+ return productImageToVertex(item);
11541
+ });
11542
+ }
11543
+ setValueByPath(parentObject, ['instances[0]', 'productImages'], transformedList);
11544
+ }
11545
+ return toObject;
11546
+ }
11547
+ function recontextImageConfigToVertex(fromObject, parentObject) {
11548
+ const toObject = {};
11549
+ const fromNumberOfImages = getValueByPath(fromObject, [
11550
+ 'numberOfImages',
11551
+ ]);
11552
+ if (parentObject !== undefined && fromNumberOfImages != null) {
11553
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
11554
+ }
11555
+ const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
11556
+ if (parentObject !== undefined && fromBaseSteps != null) {
11557
+ setValueByPath(parentObject, ['parameters', 'editConfig', 'baseSteps'], fromBaseSteps);
11558
+ }
11559
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
11560
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
11561
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
11562
+ }
11563
+ const fromSeed = getValueByPath(fromObject, ['seed']);
11564
+ if (parentObject !== undefined && fromSeed != null) {
11565
+ setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
11566
+ }
11567
+ const fromSafetyFilterLevel = getValueByPath(fromObject, [
11568
+ 'safetyFilterLevel',
11569
+ ]);
11570
+ if (parentObject !== undefined && fromSafetyFilterLevel != null) {
11571
+ setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
11572
+ }
11573
+ const fromPersonGeneration = getValueByPath(fromObject, [
11574
+ 'personGeneration',
11575
+ ]);
11576
+ if (parentObject !== undefined && fromPersonGeneration != null) {
11577
+ setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
11578
+ }
11579
+ const fromOutputMimeType = getValueByPath(fromObject, [
11580
+ 'outputMimeType',
11581
+ ]);
11582
+ if (parentObject !== undefined && fromOutputMimeType != null) {
11583
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
11584
+ }
11585
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
11586
+ 'outputCompressionQuality',
11587
+ ]);
11588
+ if (parentObject !== undefined && fromOutputCompressionQuality != null) {
11589
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
11590
+ }
11591
+ const fromEnhancePrompt = getValueByPath(fromObject, [
11592
+ 'enhancePrompt',
11593
+ ]);
11594
+ if (parentObject !== undefined && fromEnhancePrompt != null) {
11595
+ setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
11596
+ }
11597
+ return toObject;
11598
+ }
11599
+ function recontextImageParametersToVertex(apiClient, fromObject) {
11600
+ const toObject = {};
11601
+ const fromModel = getValueByPath(fromObject, ['model']);
11602
+ if (fromModel != null) {
11603
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
11604
+ }
11605
+ const fromSource = getValueByPath(fromObject, ['source']);
11606
+ if (fromSource != null) {
11607
+ setValueByPath(toObject, ['config'], recontextImageSourceToVertex(fromSource, toObject));
11608
+ }
11609
+ const fromConfig = getValueByPath(fromObject, ['config']);
11610
+ if (fromConfig != null) {
11611
+ setValueByPath(toObject, ['config'], recontextImageConfigToVertex(fromConfig, toObject));
11612
+ }
11613
+ return toObject;
11614
+ }
11440
11615
  function getModelParametersToVertex(apiClient, fromObject) {
11441
11616
  const toObject = {};
11442
11617
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -11933,6 +12108,10 @@ function generateContentResponseFromMldev(fromObject) {
11933
12108
  if (fromPromptFeedback != null) {
11934
12109
  setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
11935
12110
  }
12111
+ const fromResponseId = getValueByPath(fromObject, ['responseId']);
12112
+ if (fromResponseId != null) {
12113
+ setValueByPath(toObject, ['responseId'], fromResponseId);
12114
+ }
11936
12115
  const fromUsageMetadata = getValueByPath(fromObject, [
11937
12116
  'usageMetadata',
11938
12117
  ]);
@@ -12483,10 +12662,6 @@ function generateContentResponseFromVertex(fromObject) {
12483
12662
  if (fromCreateTime != null) {
12484
12663
  setValueByPath(toObject, ['createTime'], fromCreateTime);
12485
12664
  }
12486
- const fromResponseId = getValueByPath(fromObject, ['responseId']);
12487
- if (fromResponseId != null) {
12488
- setValueByPath(toObject, ['responseId'], fromResponseId);
12489
- }
12490
12665
  const fromModelVersion = getValueByPath(fromObject, ['modelVersion']);
12491
12666
  if (fromModelVersion != null) {
12492
12667
  setValueByPath(toObject, ['modelVersion'], fromModelVersion);
@@ -12497,6 +12672,10 @@ function generateContentResponseFromVertex(fromObject) {
12497
12672
  if (fromPromptFeedback != null) {
12498
12673
  setValueByPath(toObject, ['promptFeedback'], fromPromptFeedback);
12499
12674
  }
12675
+ const fromResponseId = getValueByPath(fromObject, ['responseId']);
12676
+ if (fromResponseId != null) {
12677
+ setValueByPath(toObject, ['responseId'], fromResponseId);
12678
+ }
12500
12679
  const fromUsageMetadata = getValueByPath(fromObject, [
12501
12680
  'usageMetadata',
12502
12681
  ]);
@@ -12700,6 +12879,22 @@ function upscaleImageResponseFromVertex(fromObject) {
12700
12879
  }
12701
12880
  return toObject;
12702
12881
  }
12882
+ function recontextImageResponseFromVertex(fromObject) {
12883
+ const toObject = {};
12884
+ const fromGeneratedImages = getValueByPath(fromObject, [
12885
+ 'predictions',
12886
+ ]);
12887
+ if (fromGeneratedImages != null) {
12888
+ let transformedList = fromGeneratedImages;
12889
+ if (Array.isArray(transformedList)) {
12890
+ transformedList = transformedList.map((item) => {
12891
+ return generatedImageFromVertex(item);
12892
+ });
12893
+ }
12894
+ setValueByPath(toObject, ['generatedImages'], transformedList);
12895
+ }
12896
+ return toObject;
12897
+ }
12703
12898
  function endpointFromVertex(fromObject) {
12704
12899
  const toObject = {};
12705
12900
  const fromName = getValueByPath(fromObject, ['endpoint']);
@@ -12947,7 +13142,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
12947
13142
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
12948
13143
  const USER_AGENT_HEADER = 'User-Agent';
12949
13144
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
12950
- const SDK_VERSION = '1.12.0'; // x-release-please-version
13145
+ const SDK_VERSION = '1.13.0'; // x-release-please-version
12951
13146
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
12952
13147
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
12953
13148
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -15317,6 +15512,79 @@ class Models extends BaseModule {
15317
15512
  throw new Error('This method is only supported by the Vertex AI.');
15318
15513
  }
15319
15514
  }
15515
+ /**
15516
+ * Recontextualizes an image.
15517
+ *
15518
+ * There are two types of recontextualization currently supported:
15519
+ * 1) Imagen Product Recontext - Generate images of products in new scenes
15520
+ * and contexts.
15521
+ * 2) Virtual Try-On: Generate images of persons modeling fashion products.
15522
+ *
15523
+ * @param params - The parameters for recontextualizing an image.
15524
+ * @return The response from the API.
15525
+ *
15526
+ * @example
15527
+ * ```ts
15528
+ * const response1 = await ai.models.recontextImage({
15529
+ * model: 'imagen-product-recontext-preview-06-30',
15530
+ * source: {
15531
+ * prompt: 'In a modern kitchen setting.',
15532
+ * productImages: [productImage],
15533
+ * },
15534
+ * config: {
15535
+ * numberOfImages: 1,
15536
+ * },
15537
+ * });
15538
+ * console.log(response1?.generatedImages?.[0]?.image?.imageBytes);
15539
+ *
15540
+ * const response2 = await ai.models.recontextImage({
15541
+ * model: 'virtual-try-on-preview-08-04',
15542
+ * source: {
15543
+ * personImage: personImage,
15544
+ * productImages: [productImage],
15545
+ * },
15546
+ * config: {
15547
+ * numberOfImages: 1,
15548
+ * },
15549
+ * });
15550
+ * console.log(response2?.generatedImages?.[0]?.image?.imageBytes);
15551
+ * ```
15552
+ */
15553
+ async recontextImage(params) {
15554
+ var _a, _b;
15555
+ let response;
15556
+ let path = '';
15557
+ let queryParams = {};
15558
+ if (this.apiClient.isVertexAI()) {
15559
+ const body = recontextImageParametersToVertex(this.apiClient, params);
15560
+ path = formatMap('{model}:predict', body['_url']);
15561
+ queryParams = body['_query'];
15562
+ delete body['config'];
15563
+ delete body['_url'];
15564
+ delete body['_query'];
15565
+ response = this.apiClient
15566
+ .request({
15567
+ path: path,
15568
+ queryParams: queryParams,
15569
+ body: JSON.stringify(body),
15570
+ httpMethod: 'POST',
15571
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
15572
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
15573
+ })
15574
+ .then((httpResponse) => {
15575
+ return httpResponse.json();
15576
+ });
15577
+ return response.then((apiResponse) => {
15578
+ const resp = recontextImageResponseFromVertex(apiResponse);
15579
+ const typedResp = new RecontextImageResponse();
15580
+ Object.assign(typedResp, resp);
15581
+ return typedResp;
15582
+ });
15583
+ }
15584
+ else {
15585
+ throw new Error('This method is only supported by the Vertex AI.');
15586
+ }
15587
+ }
15320
15588
  /**
15321
15589
  * Fetches information about a model by name.
15322
15590
  *
@@ -18023,5 +18291,5 @@ class GoogleGenAI {
18023
18291
  }
18024
18292
  }
18025
18293
 
18026
- export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
18294
+ export { ActivityHandling, AdapterSize, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, Environment, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, RecontextImageResponse, ReplayResponse, SafetyFilterLevel, Scale, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
18027
18295
  //# sourceMappingURL=index.mjs.map