@google/genai 1.15.0 → 1.17.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.
@@ -799,6 +799,10 @@ var FunctionCallingConfigMode;
799
799
  * Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
800
800
  */
801
801
  FunctionCallingConfigMode["NONE"] = "NONE";
802
+ /**
803
+ * Model decides to predict either a function call or a natural language response, but will validate function calls with constrained decoding. If "allowed_function_names" are set, the predicted function call will be limited to any one of "allowed_function_names", else the predicted function call will be any one of the provided "function_declarations".
804
+ */
805
+ FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
802
806
  })(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
803
807
  /** Enum that controls the safety filter level for objectionable content. */
804
808
  var SafetyFilterLevel;
@@ -885,7 +889,7 @@ var SubjectReferenceType;
885
889
  SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
886
890
  SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
887
891
  })(SubjectReferenceType || (SubjectReferenceType = {}));
888
- /** Enum representing the Imagen 3 Edit mode. */
892
+ /** Enum representing the editing mode. */
889
893
  var EditMode;
890
894
  (function (EditMode) {
891
895
  EditMode["EDIT_MODE_DEFAULT"] = "EDIT_MODE_DEFAULT";
@@ -906,6 +910,21 @@ var SegmentMode;
906
910
  SegmentMode["SEMANTIC"] = "SEMANTIC";
907
911
  SegmentMode["INTERACTIVE"] = "INTERACTIVE";
908
912
  })(SegmentMode || (SegmentMode = {}));
913
+ /** Enum for the reference type of a video generation reference image. */
914
+ var VideoGenerationReferenceType;
915
+ (function (VideoGenerationReferenceType) {
916
+ /**
917
+ * A reference image that provides assets to the generated video,
918
+ such as the scene, an object, a character, etc.
919
+ */
920
+ VideoGenerationReferenceType["ASSET"] = "ASSET";
921
+ /**
922
+ * A reference image that provides aesthetics including colors,
923
+ lighting, texture, etc., to be used as the style of the generated video,
924
+ such as 'anime', 'photography', 'origami', etc.
925
+ */
926
+ VideoGenerationReferenceType["STYLE"] = "STYLE";
927
+ })(VideoGenerationReferenceType || (VideoGenerationReferenceType = {}));
909
928
  /** Enum that controls the compression quality of the generated videos. */
910
929
  var VideoCompressionQuality;
911
930
  (function (VideoCompressionQuality) {
@@ -1568,6 +1587,65 @@ class ComputeTokensResponse {
1568
1587
  /** Response with generated videos. */
1569
1588
  class GenerateVideosResponse {
1570
1589
  }
1590
+ /** A video generation operation. */
1591
+ class GenerateVideosOperation {
1592
+ /**
1593
+ * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
1594
+ * @internal
1595
+ */
1596
+ _fromAPIResponse({ apiResponse, isVertexAI, }) {
1597
+ const operation = new GenerateVideosOperation();
1598
+ operation.name = apiResponse['name'];
1599
+ operation.metadata = apiResponse['metadata'];
1600
+ operation.done = apiResponse['done'];
1601
+ operation.error = apiResponse['error'];
1602
+ if (isVertexAI) {
1603
+ const response = apiResponse['response'];
1604
+ if (response) {
1605
+ const operationResponse = new GenerateVideosResponse();
1606
+ const responseVideos = response['videos'];
1607
+ operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1608
+ return {
1609
+ video: {
1610
+ uri: generatedVideo['gcsUri'],
1611
+ videoBytes: generatedVideo['bytesBase64Encoded']
1612
+ ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1613
+ : undefined,
1614
+ mimeType: generatedVideo['mimeType'],
1615
+ },
1616
+ };
1617
+ });
1618
+ operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1619
+ operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1620
+ operation.response = operationResponse;
1621
+ }
1622
+ }
1623
+ else {
1624
+ const response = apiResponse['response'];
1625
+ if (response) {
1626
+ const operationResponse = new GenerateVideosResponse();
1627
+ const generatedVideoResponse = response['generateVideoResponse'];
1628
+ const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1629
+ operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1630
+ const video = generatedVideo['video'];
1631
+ return {
1632
+ video: {
1633
+ uri: video === null || video === void 0 ? void 0 : video['uri'],
1634
+ videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1635
+ ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1636
+ : undefined,
1637
+ mimeType: generatedVideo['encoding'],
1638
+ },
1639
+ };
1640
+ });
1641
+ operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1642
+ operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1643
+ operation.response = operationResponse;
1644
+ }
1645
+ }
1646
+ return operation;
1647
+ }
1648
+ }
1571
1649
  /** Response for the list tuning jobs method. */
1572
1650
  class ListTuningJobsResponse {
1573
1651
  }
@@ -1759,65 +1837,6 @@ class LiveServerMessage {
1759
1837
  return data.length > 0 ? btoa(data) : undefined;
1760
1838
  }
1761
1839
  }
1762
- /** A video generation long-running operation. */
1763
- class GenerateVideosOperation {
1764
- /**
1765
- * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
1766
- * @internal
1767
- */
1768
- _fromAPIResponse({ apiResponse, isVertexAI, }) {
1769
- const operation = new GenerateVideosOperation();
1770
- operation.name = apiResponse['name'];
1771
- operation.metadata = apiResponse['metadata'];
1772
- operation.done = apiResponse['done'];
1773
- operation.error = apiResponse['error'];
1774
- if (isVertexAI) {
1775
- const response = apiResponse['response'];
1776
- if (response) {
1777
- const operationResponse = new GenerateVideosResponse();
1778
- const responseVideos = response['videos'];
1779
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1780
- return {
1781
- video: {
1782
- uri: generatedVideo['gcsUri'],
1783
- videoBytes: generatedVideo['bytesBase64Encoded']
1784
- ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1785
- : undefined,
1786
- mimeType: generatedVideo['mimeType'],
1787
- },
1788
- };
1789
- });
1790
- operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1791
- operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1792
- operation.response = operationResponse;
1793
- }
1794
- }
1795
- else {
1796
- const response = apiResponse['response'];
1797
- if (response) {
1798
- const operationResponse = new GenerateVideosResponse();
1799
- const generatedVideoResponse = response['generateVideoResponse'];
1800
- const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1801
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1802
- const video = generatedVideo['video'];
1803
- return {
1804
- video: {
1805
- uri: video === null || video === void 0 ? void 0 : video['uri'],
1806
- videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1807
- ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1808
- : undefined,
1809
- mimeType: generatedVideo['encoding'],
1810
- },
1811
- };
1812
- });
1813
- operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1814
- operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1815
- operation.response = operationResponse;
1816
- }
1817
- }
1818
- return operation;
1819
- }
1820
- }
1821
1840
  /** Client generated response to a `ToolCall` received from the server.
1822
1841
 
1823
1842
  Individual `FunctionResponse` objects are matched to the respective
@@ -2464,6 +2483,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
2464
2483
  description: mcpToolSchema['description'],
2465
2484
  parametersJsonSchema: mcpToolSchema['inputSchema'],
2466
2485
  };
2486
+ if (mcpToolSchema['outputSchema']) {
2487
+ functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
2488
+ }
2467
2489
  if (config.behavior) {
2468
2490
  functionDeclaration['behavior'] = config.behavior;
2469
2491
  }
@@ -5711,8 +5733,14 @@ function cachedContentFromMldev(fromObject) {
5711
5733
  }
5712
5734
  return toObject;
5713
5735
  }
5714
- function deleteCachedContentResponseFromMldev() {
5736
+ function deleteCachedContentResponseFromMldev(fromObject) {
5715
5737
  const toObject = {};
5738
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
5739
+ 'sdkHttpResponse',
5740
+ ]);
5741
+ if (fromSdkHttpResponse != null) {
5742
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
5743
+ }
5716
5744
  return toObject;
5717
5745
  }
5718
5746
  function listCachedContentsResponseFromMldev(fromObject) {
@@ -5777,8 +5805,14 @@ function cachedContentFromVertex(fromObject) {
5777
5805
  }
5778
5806
  return toObject;
5779
5807
  }
5780
- function deleteCachedContentResponseFromVertex() {
5808
+ function deleteCachedContentResponseFromVertex(fromObject) {
5781
5809
  const toObject = {};
5810
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
5811
+ 'sdkHttpResponse',
5812
+ ]);
5813
+ if (fromSdkHttpResponse != null) {
5814
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
5815
+ }
5782
5816
  return toObject;
5783
5817
  }
5784
5818
  function listCachedContentsResponseFromVertex(fromObject) {
@@ -6015,10 +6049,16 @@ class Caches extends BaseModule {
6015
6049
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
6016
6050
  })
6017
6051
  .then((httpResponse) => {
6018
- return httpResponse.json();
6052
+ return httpResponse.json().then((jsonResponse) => {
6053
+ const response = jsonResponse;
6054
+ response.sdkHttpResponse = {
6055
+ headers: httpResponse.headers,
6056
+ };
6057
+ return response;
6058
+ });
6019
6059
  });
6020
- return response.then(() => {
6021
- const resp = deleteCachedContentResponseFromVertex();
6060
+ return response.then((apiResponse) => {
6061
+ const resp = deleteCachedContentResponseFromVertex(apiResponse);
6022
6062
  const typedResp = new DeleteCachedContentResponse();
6023
6063
  Object.assign(typedResp, resp);
6024
6064
  return typedResp;
@@ -6041,10 +6081,16 @@ class Caches extends BaseModule {
6041
6081
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
6042
6082
  })
6043
6083
  .then((httpResponse) => {
6044
- return httpResponse.json();
6084
+ return httpResponse.json().then((jsonResponse) => {
6085
+ const response = jsonResponse;
6086
+ response.sdkHttpResponse = {
6087
+ headers: httpResponse.headers,
6088
+ };
6089
+ return response;
6090
+ });
6045
6091
  });
6046
- return response.then(() => {
6047
- const resp = deleteCachedContentResponseFromMldev();
6092
+ return response.then((apiResponse) => {
6093
+ const resp = deleteCachedContentResponseFromMldev(apiResponse);
6048
6094
  const typedResp = new DeleteCachedContentResponse();
6049
6095
  Object.assign(typedResp, resp);
6050
6096
  return typedResp;
@@ -6848,8 +6894,14 @@ function createFileResponseFromMldev(fromObject) {
6848
6894
  }
6849
6895
  return toObject;
6850
6896
  }
6851
- function deleteFileResponseFromMldev() {
6897
+ function deleteFileResponseFromMldev(fromObject) {
6852
6898
  const toObject = {};
6899
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
6900
+ 'sdkHttpResponse',
6901
+ ]);
6902
+ if (fromSdkHttpResponse != null) {
6903
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
6904
+ }
6853
6905
  return toObject;
6854
6906
  }
6855
6907
 
@@ -7118,10 +7170,16 @@ class Files extends BaseModule {
7118
7170
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
7119
7171
  })
7120
7172
  .then((httpResponse) => {
7121
- return httpResponse.json();
7173
+ return httpResponse.json().then((jsonResponse) => {
7174
+ const response = jsonResponse;
7175
+ response.sdkHttpResponse = {
7176
+ headers: httpResponse.headers,
7177
+ };
7178
+ return response;
7179
+ });
7122
7180
  });
7123
- return response.then(() => {
7124
- const resp = deleteFileResponseFromMldev();
7181
+ return response.then((apiResponse) => {
7182
+ const resp = deleteFileResponseFromMldev(apiResponse);
7125
7183
  const typedResp = new DeleteFileResponse();
7126
7184
  Object.assign(typedResp, resp);
7127
7185
  return typedResp;
@@ -10424,6 +10482,21 @@ function imageToMldev(fromObject) {
10424
10482
  }
10425
10483
  return toObject;
10426
10484
  }
10485
+ function generateVideosSourceToMldev(fromObject, parentObject) {
10486
+ const toObject = {};
10487
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
10488
+ if (parentObject !== undefined && fromPrompt != null) {
10489
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
10490
+ }
10491
+ const fromImage = getValueByPath(fromObject, ['image']);
10492
+ if (parentObject !== undefined && fromImage != null) {
10493
+ setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
10494
+ }
10495
+ if (getValueByPath(fromObject, ['video']) !== undefined) {
10496
+ throw new Error('video parameter is not supported in Gemini API.');
10497
+ }
10498
+ return toObject;
10499
+ }
10427
10500
  function generateVideosConfigToMldev(fromObject, parentObject) {
10428
10501
  const toObject = {};
10429
10502
  const fromNumberOfVideos = getValueByPath(fromObject, [
@@ -10451,8 +10524,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
10451
10524
  if (parentObject !== undefined && fromAspectRatio != null) {
10452
10525
  setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
10453
10526
  }
10454
- if (getValueByPath(fromObject, ['resolution']) !== undefined) {
10455
- throw new Error('resolution parameter is not supported in Gemini API.');
10527
+ const fromResolution = getValueByPath(fromObject, ['resolution']);
10528
+ if (parentObject !== undefined && fromResolution != null) {
10529
+ setValueByPath(parentObject, ['parameters', 'resolution'], fromResolution);
10456
10530
  }
10457
10531
  const fromPersonGeneration = getValueByPath(fromObject, [
10458
10532
  'personGeneration',
@@ -10506,6 +10580,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
10506
10580
  if (getValueByPath(fromObject, ['video']) !== undefined) {
10507
10581
  throw new Error('video parameter is not supported in Gemini API.');
10508
10582
  }
10583
+ const fromSource = getValueByPath(fromObject, ['source']);
10584
+ if (fromSource != null) {
10585
+ setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
10586
+ }
10509
10587
  const fromConfig = getValueByPath(fromObject, ['config']);
10510
10588
  if (fromConfig != null) {
10511
10589
  setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
@@ -11630,6 +11708,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
11630
11708
  }
11631
11709
  function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
11632
11710
  const toObject = {};
11711
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
11712
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
11713
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
11714
+ }
11633
11715
  const fromIncludeRaiReason = getValueByPath(fromObject, [
11634
11716
  'includeRaiReason',
11635
11717
  ]);
@@ -11758,6 +11840,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
11758
11840
  if (parentObject !== undefined && fromPersonGeneration != null) {
11759
11841
  setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
11760
11842
  }
11843
+ const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
11844
+ if (parentObject !== undefined && fromAddWatermark != null) {
11845
+ setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
11846
+ }
11761
11847
  const fromOutputMimeType = getValueByPath(fromObject, [
11762
11848
  'outputMimeType',
11763
11849
  ]);
@@ -12034,6 +12120,22 @@ function videoToVertex(fromObject) {
12034
12120
  }
12035
12121
  return toObject;
12036
12122
  }
12123
+ function generateVideosSourceToVertex(fromObject, parentObject) {
12124
+ const toObject = {};
12125
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
12126
+ if (parentObject !== undefined && fromPrompt != null) {
12127
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
12128
+ }
12129
+ const fromImage = getValueByPath(fromObject, ['image']);
12130
+ if (parentObject !== undefined && fromImage != null) {
12131
+ setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
12132
+ }
12133
+ const fromVideo = getValueByPath(fromObject, ['video']);
12134
+ if (parentObject !== undefined && fromVideo != null) {
12135
+ setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
12136
+ }
12137
+ return toObject;
12138
+ }
12037
12139
  function videoGenerationReferenceImageToVertex(fromObject) {
12038
12140
  const toObject = {};
12039
12141
  const fromImage = getValueByPath(fromObject, ['image']);
@@ -12152,6 +12254,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
12152
12254
  if (fromVideo != null) {
12153
12255
  setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
12154
12256
  }
12257
+ const fromSource = getValueByPath(fromObject, ['source']);
12258
+ if (fromSource != null) {
12259
+ setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
12260
+ }
12155
12261
  const fromConfig = getValueByPath(fromObject, ['config']);
12156
12262
  if (fromConfig != null) {
12157
12263
  setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
@@ -12602,8 +12708,14 @@ function listModelsResponseFromMldev(fromObject) {
12602
12708
  }
12603
12709
  return toObject;
12604
12710
  }
12605
- function deleteModelResponseFromMldev() {
12711
+ function deleteModelResponseFromMldev(fromObject) {
12606
12712
  const toObject = {};
12713
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12714
+ 'sdkHttpResponse',
12715
+ ]);
12716
+ if (fromSdkHttpResponse != null) {
12717
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12718
+ }
12607
12719
  return toObject;
12608
12720
  }
12609
12721
  function countTokensResponseFromMldev(fromObject) {
@@ -13348,8 +13460,14 @@ function listModelsResponseFromVertex(fromObject) {
13348
13460
  }
13349
13461
  return toObject;
13350
13462
  }
13351
- function deleteModelResponseFromVertex() {
13463
+ function deleteModelResponseFromVertex(fromObject) {
13352
13464
  const toObject = {};
13465
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13466
+ 'sdkHttpResponse',
13467
+ ]);
13468
+ if (fromSdkHttpResponse != null) {
13469
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13470
+ }
13353
13471
  return toObject;
13354
13472
  }
13355
13473
  function countTokensResponseFromVertex(fromObject) {
@@ -13466,7 +13584,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
13466
13584
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
13467
13585
  const USER_AGENT_HEADER = 'User-Agent';
13468
13586
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
13469
- const SDK_VERSION = '1.15.0'; // x-release-please-version
13587
+ const SDK_VERSION = '1.17.0'; // x-release-please-version
13470
13588
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
13471
13589
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
13472
13590
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -15238,7 +15356,9 @@ class Models extends BaseModule {
15238
15356
  * ```ts
15239
15357
  * const operation = await ai.models.generateVideos({
15240
15358
  * model: 'veo-2.0-generate-001',
15241
- * prompt: 'A neon hologram of a cat driving at top speed',
15359
+ * source: {
15360
+ * prompt: 'A neon hologram of a cat driving at top speed',
15361
+ * },
15242
15362
  * config: {
15243
15363
  * numberOfVideos: 1
15244
15364
  * });
@@ -15252,6 +15372,9 @@ class Models extends BaseModule {
15252
15372
  * ```
15253
15373
  */
15254
15374
  this.generateVideos = async (params) => {
15375
+ if ((params.prompt || params.image || params.video) && params.source) {
15376
+ throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
15377
+ }
15255
15378
  return await this.generateVideosInternal(params);
15256
15379
  };
15257
15380
  }
@@ -15666,23 +15789,7 @@ class Models extends BaseModule {
15666
15789
  }
15667
15790
  }
15668
15791
  /**
15669
- * Generates an image based on a text description and configuration.
15670
- *
15671
- * @param params - The parameters for generating images.
15672
- * @return The response from the API.
15673
- *
15674
- * @example
15675
- * ```ts
15676
- * const response = await ai.models.generateImages({
15677
- * model: 'imagen-3.0-generate-002',
15678
- * prompt: 'Robot holding a red skateboard',
15679
- * config: {
15680
- * numberOfImages: 1,
15681
- * includeRaiReason: true,
15682
- * },
15683
- * });
15684
- * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
15685
- * ```
15792
+ * Private method for generating images.
15686
15793
  */
15687
15794
  async generateImagesInternal(params) {
15688
15795
  var _a, _b, _c, _d;
@@ -15754,6 +15861,9 @@ class Models extends BaseModule {
15754
15861
  });
15755
15862
  }
15756
15863
  }
15864
+ /**
15865
+ * Private method for editing an image.
15866
+ */
15757
15867
  async editImageInternal(params) {
15758
15868
  var _a, _b;
15759
15869
  let response;
@@ -15795,6 +15905,9 @@ class Models extends BaseModule {
15795
15905
  throw new Error('This method is only supported by the Vertex AI.');
15796
15906
  }
15797
15907
  }
15908
+ /**
15909
+ * Private method for upscaling an image.
15910
+ */
15798
15911
  async upscaleImageInternal(params) {
15799
15912
  var _a, _b;
15800
15913
  let response;
@@ -16200,10 +16313,16 @@ class Models extends BaseModule {
16200
16313
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
16201
16314
  })
16202
16315
  .then((httpResponse) => {
16203
- return httpResponse.json();
16316
+ return httpResponse.json().then((jsonResponse) => {
16317
+ const response = jsonResponse;
16318
+ response.sdkHttpResponse = {
16319
+ headers: httpResponse.headers,
16320
+ };
16321
+ return response;
16322
+ });
16204
16323
  });
16205
- return response.then(() => {
16206
- const resp = deleteModelResponseFromVertex();
16324
+ return response.then((apiResponse) => {
16325
+ const resp = deleteModelResponseFromVertex(apiResponse);
16207
16326
  const typedResp = new DeleteModelResponse();
16208
16327
  Object.assign(typedResp, resp);
16209
16328
  return typedResp;
@@ -16226,10 +16345,16 @@ class Models extends BaseModule {
16226
16345
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
16227
16346
  })
16228
16347
  .then((httpResponse) => {
16229
- return httpResponse.json();
16348
+ return httpResponse.json().then((jsonResponse) => {
16349
+ const response = jsonResponse;
16350
+ response.sdkHttpResponse = {
16351
+ headers: httpResponse.headers,
16352
+ };
16353
+ return response;
16354
+ });
16230
16355
  });
16231
- return response.then(() => {
16232
- const resp = deleteModelResponseFromMldev();
16356
+ return response.then((apiResponse) => {
16357
+ const resp = deleteModelResponseFromMldev(apiResponse);
16233
16358
  const typedResp = new DeleteModelResponse();
16234
16359
  Object.assign(typedResp, resp);
16235
16360
  return typedResp;
@@ -16382,27 +16507,7 @@ class Models extends BaseModule {
16382
16507
  }
16383
16508
  }
16384
16509
  /**
16385
- * Generates videos based on a text description and configuration.
16386
- *
16387
- * @param params - The parameters for generating videos.
16388
- * @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
16389
- *
16390
- * @example
16391
- * ```ts
16392
- * const operation = await ai.models.generateVideos({
16393
- * model: 'veo-2.0-generate-001',
16394
- * prompt: 'A neon hologram of a cat driving at top speed',
16395
- * config: {
16396
- * numberOfVideos: 1
16397
- * });
16398
- *
16399
- * while (!operation.done) {
16400
- * await new Promise(resolve => setTimeout(resolve, 10000));
16401
- * operation = await ai.operations.getVideosOperation({operation: operation});
16402
- * }
16403
- *
16404
- * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
16405
- * ```
16510
+ * Private method for generating videos.
16406
16511
  */
16407
16512
  async generateVideosInternal(params) {
16408
16513
  var _a, _b, _c, _d;
@@ -16484,13 +16589,17 @@ function getOperationParametersToMldev(fromObject) {
16484
16589
  }
16485
16590
  return toObject;
16486
16591
  }
16487
- function getOperationParametersToVertex(fromObject) {
16592
+ function fetchPredictOperationParametersToVertex(fromObject) {
16488
16593
  const toObject = {};
16489
16594
  const fromOperationName = getValueByPath(fromObject, [
16490
16595
  'operationName',
16491
16596
  ]);
16492
16597
  if (fromOperationName != null) {
16493
- setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
16598
+ setValueByPath(toObject, ['operationName'], fromOperationName);
16599
+ }
16600
+ const fromResourceName = getValueByPath(fromObject, ['resourceName']);
16601
+ if (fromResourceName != null) {
16602
+ setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
16494
16603
  }
16495
16604
  const fromConfig = getValueByPath(fromObject, ['config']);
16496
16605
  if (fromConfig != null) {
@@ -16498,17 +16607,13 @@ function getOperationParametersToVertex(fromObject) {
16498
16607
  }
16499
16608
  return toObject;
16500
16609
  }
16501
- function fetchPredictOperationParametersToVertex(fromObject) {
16610
+ function getOperationParametersToVertex(fromObject) {
16502
16611
  const toObject = {};
16503
16612
  const fromOperationName = getValueByPath(fromObject, [
16504
16613
  'operationName',
16505
16614
  ]);
16506
16615
  if (fromOperationName != null) {
16507
- setValueByPath(toObject, ['operationName'], fromOperationName);
16508
- }
16509
- const fromResourceName = getValueByPath(fromObject, ['resourceName']);
16510
- if (fromResourceName != null) {
16511
- setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
16616
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
16512
16617
  }
16513
16618
  const fromConfig = getValueByPath(fromObject, ['config']);
16514
16619
  if (fromConfig != null) {
@@ -17595,6 +17700,18 @@ function listTuningJobsParametersToMldev(fromObject) {
17595
17700
  }
17596
17701
  return toObject;
17597
17702
  }
17703
+ function cancelTuningJobParametersToMldev(fromObject) {
17704
+ const toObject = {};
17705
+ const fromName = getValueByPath(fromObject, ['name']);
17706
+ if (fromName != null) {
17707
+ setValueByPath(toObject, ['_url', 'name'], fromName);
17708
+ }
17709
+ const fromConfig = getValueByPath(fromObject, ['config']);
17710
+ if (fromConfig != null) {
17711
+ setValueByPath(toObject, ['config'], fromConfig);
17712
+ }
17713
+ return toObject;
17714
+ }
17598
17715
  function tuningExampleToMldev(fromObject) {
17599
17716
  const toObject = {};
17600
17717
  const fromTextInput = getValueByPath(fromObject, ['textInput']);
@@ -17732,6 +17849,18 @@ function listTuningJobsParametersToVertex(fromObject) {
17732
17849
  }
17733
17850
  return toObject;
17734
17851
  }
17852
+ function cancelTuningJobParametersToVertex(fromObject) {
17853
+ const toObject = {};
17854
+ const fromName = getValueByPath(fromObject, ['name']);
17855
+ if (fromName != null) {
17856
+ setValueByPath(toObject, ['_url', 'name'], fromName);
17857
+ }
17858
+ const fromConfig = getValueByPath(fromObject, ['config']);
17859
+ if (fromConfig != null) {
17860
+ setValueByPath(toObject, ['config'], fromConfig);
17861
+ }
17862
+ return toObject;
17863
+ }
17735
17864
  function tuningDatasetToVertex(fromObject, parentObject) {
17736
17865
  const toObject = {};
17737
17866
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
@@ -18385,6 +18514,54 @@ class Tunings extends BaseModule {
18385
18514
  });
18386
18515
  }
18387
18516
  }
18517
+ /**
18518
+ * Cancels a tuning job.
18519
+ *
18520
+ * @param params - The parameters for the cancel request.
18521
+ * @return The empty response returned by the API.
18522
+ *
18523
+ * @example
18524
+ * ```ts
18525
+ * await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
18526
+ * ```
18527
+ */
18528
+ async cancel(params) {
18529
+ var _a, _b, _c, _d;
18530
+ let path = '';
18531
+ let queryParams = {};
18532
+ if (this.apiClient.isVertexAI()) {
18533
+ const body = cancelTuningJobParametersToVertex(params);
18534
+ path = formatMap('{name}:cancel', body['_url']);
18535
+ queryParams = body['_query'];
18536
+ delete body['config'];
18537
+ delete body['_url'];
18538
+ delete body['_query'];
18539
+ await this.apiClient.request({
18540
+ path: path,
18541
+ queryParams: queryParams,
18542
+ body: JSON.stringify(body),
18543
+ httpMethod: 'POST',
18544
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
18545
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
18546
+ });
18547
+ }
18548
+ else {
18549
+ const body = cancelTuningJobParametersToMldev(params);
18550
+ path = formatMap('{name}:cancel', body['_url']);
18551
+ queryParams = body['_query'];
18552
+ delete body['config'];
18553
+ delete body['_url'];
18554
+ delete body['_query'];
18555
+ await this.apiClient.request({
18556
+ path: path,
18557
+ queryParams: queryParams,
18558
+ body: JSON.stringify(body),
18559
+ httpMethod: 'POST',
18560
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
18561
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
18562
+ });
18563
+ }
18564
+ }
18388
18565
  async tuneInternal(params) {
18389
18566
  var _a, _b;
18390
18567
  let response;
@@ -18713,5 +18890,5 @@ class GoogleGenAI {
18713
18890
  }
18714
18891
  }
18715
18892
 
18716
- 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, SegmentImageResponse, SegmentMode, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMode, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
18893
+ 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, SegmentImageResponse, SegmentMode, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, Tokens, TrafficType, TuningMode, TurnCoverage, Type, UpscaleImageResponse, UrlRetrievalStatus, VideoCompressionQuality, VideoGenerationReferenceType, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
18717
18894
  //# sourceMappingURL=index.mjs.map