@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.
@@ -805,6 +805,10 @@ var FunctionCallingConfigMode;
805
805
  * Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
806
806
  */
807
807
  FunctionCallingConfigMode["NONE"] = "NONE";
808
+ /**
809
+ * 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".
810
+ */
811
+ FunctionCallingConfigMode["VALIDATED"] = "VALIDATED";
808
812
  })(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
809
813
  /** Enum that controls the safety filter level for objectionable content. */
810
814
  var SafetyFilterLevel;
@@ -891,7 +895,7 @@ var SubjectReferenceType;
891
895
  SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
892
896
  SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
893
897
  })(SubjectReferenceType || (SubjectReferenceType = {}));
894
- /** Enum representing the Imagen 3 Edit mode. */
898
+ /** Enum representing the editing mode. */
895
899
  var EditMode;
896
900
  (function (EditMode) {
897
901
  EditMode["EDIT_MODE_DEFAULT"] = "EDIT_MODE_DEFAULT";
@@ -912,6 +916,21 @@ var SegmentMode;
912
916
  SegmentMode["SEMANTIC"] = "SEMANTIC";
913
917
  SegmentMode["INTERACTIVE"] = "INTERACTIVE";
914
918
  })(SegmentMode || (SegmentMode = {}));
919
+ /** Enum for the reference type of a video generation reference image. */
920
+ var VideoGenerationReferenceType;
921
+ (function (VideoGenerationReferenceType) {
922
+ /**
923
+ * A reference image that provides assets to the generated video,
924
+ such as the scene, an object, a character, etc.
925
+ */
926
+ VideoGenerationReferenceType["ASSET"] = "ASSET";
927
+ /**
928
+ * A reference image that provides aesthetics including colors,
929
+ lighting, texture, etc., to be used as the style of the generated video,
930
+ such as 'anime', 'photography', 'origami', etc.
931
+ */
932
+ VideoGenerationReferenceType["STYLE"] = "STYLE";
933
+ })(VideoGenerationReferenceType || (VideoGenerationReferenceType = {}));
915
934
  /** Enum that controls the compression quality of the generated videos. */
916
935
  var VideoCompressionQuality;
917
936
  (function (VideoCompressionQuality) {
@@ -1574,6 +1593,65 @@ class ComputeTokensResponse {
1574
1593
  /** Response with generated videos. */
1575
1594
  class GenerateVideosResponse {
1576
1595
  }
1596
+ /** A video generation operation. */
1597
+ class GenerateVideosOperation {
1598
+ /**
1599
+ * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
1600
+ * @internal
1601
+ */
1602
+ _fromAPIResponse({ apiResponse, isVertexAI, }) {
1603
+ const operation = new GenerateVideosOperation();
1604
+ operation.name = apiResponse['name'];
1605
+ operation.metadata = apiResponse['metadata'];
1606
+ operation.done = apiResponse['done'];
1607
+ operation.error = apiResponse['error'];
1608
+ if (isVertexAI) {
1609
+ const response = apiResponse['response'];
1610
+ if (response) {
1611
+ const operationResponse = new GenerateVideosResponse();
1612
+ const responseVideos = response['videos'];
1613
+ operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1614
+ return {
1615
+ video: {
1616
+ uri: generatedVideo['gcsUri'],
1617
+ videoBytes: generatedVideo['bytesBase64Encoded']
1618
+ ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1619
+ : undefined,
1620
+ mimeType: generatedVideo['mimeType'],
1621
+ },
1622
+ };
1623
+ });
1624
+ operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1625
+ operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1626
+ operation.response = operationResponse;
1627
+ }
1628
+ }
1629
+ else {
1630
+ const response = apiResponse['response'];
1631
+ if (response) {
1632
+ const operationResponse = new GenerateVideosResponse();
1633
+ const generatedVideoResponse = response['generateVideoResponse'];
1634
+ const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1635
+ operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1636
+ const video = generatedVideo['video'];
1637
+ return {
1638
+ video: {
1639
+ uri: video === null || video === void 0 ? void 0 : video['uri'],
1640
+ videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1641
+ ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1642
+ : undefined,
1643
+ mimeType: generatedVideo['encoding'],
1644
+ },
1645
+ };
1646
+ });
1647
+ operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1648
+ operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1649
+ operation.response = operationResponse;
1650
+ }
1651
+ }
1652
+ return operation;
1653
+ }
1654
+ }
1577
1655
  /** Response for the list tuning jobs method. */
1578
1656
  class ListTuningJobsResponse {
1579
1657
  }
@@ -1765,65 +1843,6 @@ class LiveServerMessage {
1765
1843
  return data.length > 0 ? btoa(data) : undefined;
1766
1844
  }
1767
1845
  }
1768
- /** A video generation long-running operation. */
1769
- class GenerateVideosOperation {
1770
- /**
1771
- * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
1772
- * @internal
1773
- */
1774
- _fromAPIResponse({ apiResponse, isVertexAI, }) {
1775
- const operation = new GenerateVideosOperation();
1776
- operation.name = apiResponse['name'];
1777
- operation.metadata = apiResponse['metadata'];
1778
- operation.done = apiResponse['done'];
1779
- operation.error = apiResponse['error'];
1780
- if (isVertexAI) {
1781
- const response = apiResponse['response'];
1782
- if (response) {
1783
- const operationResponse = new GenerateVideosResponse();
1784
- const responseVideos = response['videos'];
1785
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1786
- return {
1787
- video: {
1788
- uri: generatedVideo['gcsUri'],
1789
- videoBytes: generatedVideo['bytesBase64Encoded']
1790
- ? tBytes$1(generatedVideo['bytesBase64Encoded'])
1791
- : undefined,
1792
- mimeType: generatedVideo['mimeType'],
1793
- },
1794
- };
1795
- });
1796
- operationResponse.raiMediaFilteredCount = response['raiMediaFilteredCount'];
1797
- operationResponse.raiMediaFilteredReasons = response['raiMediaFilteredReasons'];
1798
- operation.response = operationResponse;
1799
- }
1800
- }
1801
- else {
1802
- const response = apiResponse['response'];
1803
- if (response) {
1804
- const operationResponse = new GenerateVideosResponse();
1805
- const generatedVideoResponse = response['generateVideoResponse'];
1806
- const responseVideos = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['generatedSamples'];
1807
- operationResponse.generatedVideos = responseVideos === null || responseVideos === void 0 ? void 0 : responseVideos.map((generatedVideo) => {
1808
- const video = generatedVideo['video'];
1809
- return {
1810
- video: {
1811
- uri: video === null || video === void 0 ? void 0 : video['uri'],
1812
- videoBytes: (video === null || video === void 0 ? void 0 : video['encodedVideo'])
1813
- ? tBytes$1(video === null || video === void 0 ? void 0 : video['encodedVideo'])
1814
- : undefined,
1815
- mimeType: generatedVideo['encoding'],
1816
- },
1817
- };
1818
- });
1819
- operationResponse.raiMediaFilteredCount = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredCount'];
1820
- operationResponse.raiMediaFilteredReasons = generatedVideoResponse === null || generatedVideoResponse === void 0 ? void 0 : generatedVideoResponse['raiMediaFilteredReasons'];
1821
- operation.response = operationResponse;
1822
- }
1823
- }
1824
- return operation;
1825
- }
1826
- }
1827
1846
  /** Client generated response to a `ToolCall` received from the server.
1828
1847
 
1829
1848
  Individual `FunctionResponse` objects are matched to the respective
@@ -2470,6 +2489,9 @@ function mcpToGeminiTool(mcpTool, config = {}) {
2470
2489
  description: mcpToolSchema['description'],
2471
2490
  parametersJsonSchema: mcpToolSchema['inputSchema'],
2472
2491
  };
2492
+ if (mcpToolSchema['outputSchema']) {
2493
+ functionDeclaration['responseJsonSchema'] = mcpToolSchema['outputSchema'];
2494
+ }
2473
2495
  if (config.behavior) {
2474
2496
  functionDeclaration['behavior'] = config.behavior;
2475
2497
  }
@@ -5717,8 +5739,14 @@ function cachedContentFromMldev(fromObject) {
5717
5739
  }
5718
5740
  return toObject;
5719
5741
  }
5720
- function deleteCachedContentResponseFromMldev() {
5742
+ function deleteCachedContentResponseFromMldev(fromObject) {
5721
5743
  const toObject = {};
5744
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
5745
+ 'sdkHttpResponse',
5746
+ ]);
5747
+ if (fromSdkHttpResponse != null) {
5748
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
5749
+ }
5722
5750
  return toObject;
5723
5751
  }
5724
5752
  function listCachedContentsResponseFromMldev(fromObject) {
@@ -5783,8 +5811,14 @@ function cachedContentFromVertex(fromObject) {
5783
5811
  }
5784
5812
  return toObject;
5785
5813
  }
5786
- function deleteCachedContentResponseFromVertex() {
5814
+ function deleteCachedContentResponseFromVertex(fromObject) {
5787
5815
  const toObject = {};
5816
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
5817
+ 'sdkHttpResponse',
5818
+ ]);
5819
+ if (fromSdkHttpResponse != null) {
5820
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
5821
+ }
5788
5822
  return toObject;
5789
5823
  }
5790
5824
  function listCachedContentsResponseFromVertex(fromObject) {
@@ -6021,10 +6055,16 @@ class Caches extends BaseModule {
6021
6055
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
6022
6056
  })
6023
6057
  .then((httpResponse) => {
6024
- return httpResponse.json();
6058
+ return httpResponse.json().then((jsonResponse) => {
6059
+ const response = jsonResponse;
6060
+ response.sdkHttpResponse = {
6061
+ headers: httpResponse.headers,
6062
+ };
6063
+ return response;
6064
+ });
6025
6065
  });
6026
- return response.then(() => {
6027
- const resp = deleteCachedContentResponseFromVertex();
6066
+ return response.then((apiResponse) => {
6067
+ const resp = deleteCachedContentResponseFromVertex(apiResponse);
6028
6068
  const typedResp = new DeleteCachedContentResponse();
6029
6069
  Object.assign(typedResp, resp);
6030
6070
  return typedResp;
@@ -6047,10 +6087,16 @@ class Caches extends BaseModule {
6047
6087
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
6048
6088
  })
6049
6089
  .then((httpResponse) => {
6050
- return httpResponse.json();
6090
+ return httpResponse.json().then((jsonResponse) => {
6091
+ const response = jsonResponse;
6092
+ response.sdkHttpResponse = {
6093
+ headers: httpResponse.headers,
6094
+ };
6095
+ return response;
6096
+ });
6051
6097
  });
6052
- return response.then(() => {
6053
- const resp = deleteCachedContentResponseFromMldev();
6098
+ return response.then((apiResponse) => {
6099
+ const resp = deleteCachedContentResponseFromMldev(apiResponse);
6054
6100
  const typedResp = new DeleteCachedContentResponse();
6055
6101
  Object.assign(typedResp, resp);
6056
6102
  return typedResp;
@@ -6854,8 +6900,14 @@ function createFileResponseFromMldev(fromObject) {
6854
6900
  }
6855
6901
  return toObject;
6856
6902
  }
6857
- function deleteFileResponseFromMldev() {
6903
+ function deleteFileResponseFromMldev(fromObject) {
6858
6904
  const toObject = {};
6905
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
6906
+ 'sdkHttpResponse',
6907
+ ]);
6908
+ if (fromSdkHttpResponse != null) {
6909
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
6910
+ }
6859
6911
  return toObject;
6860
6912
  }
6861
6913
 
@@ -7124,10 +7176,16 @@ class Files extends BaseModule {
7124
7176
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
7125
7177
  })
7126
7178
  .then((httpResponse) => {
7127
- return httpResponse.json();
7179
+ return httpResponse.json().then((jsonResponse) => {
7180
+ const response = jsonResponse;
7181
+ response.sdkHttpResponse = {
7182
+ headers: httpResponse.headers,
7183
+ };
7184
+ return response;
7185
+ });
7128
7186
  });
7129
- return response.then(() => {
7130
- const resp = deleteFileResponseFromMldev();
7187
+ return response.then((apiResponse) => {
7188
+ const resp = deleteFileResponseFromMldev(apiResponse);
7131
7189
  const typedResp = new DeleteFileResponse();
7132
7190
  Object.assign(typedResp, resp);
7133
7191
  return typedResp;
@@ -10430,6 +10488,21 @@ function imageToMldev(fromObject) {
10430
10488
  }
10431
10489
  return toObject;
10432
10490
  }
10491
+ function generateVideosSourceToMldev(fromObject, parentObject) {
10492
+ const toObject = {};
10493
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
10494
+ if (parentObject !== undefined && fromPrompt != null) {
10495
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
10496
+ }
10497
+ const fromImage = getValueByPath(fromObject, ['image']);
10498
+ if (parentObject !== undefined && fromImage != null) {
10499
+ setValueByPath(parentObject, ['instances[0]', 'image'], imageToMldev(fromImage));
10500
+ }
10501
+ if (getValueByPath(fromObject, ['video']) !== undefined) {
10502
+ throw new Error('video parameter is not supported in Gemini API.');
10503
+ }
10504
+ return toObject;
10505
+ }
10433
10506
  function generateVideosConfigToMldev(fromObject, parentObject) {
10434
10507
  const toObject = {};
10435
10508
  const fromNumberOfVideos = getValueByPath(fromObject, [
@@ -10457,8 +10530,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
10457
10530
  if (parentObject !== undefined && fromAspectRatio != null) {
10458
10531
  setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
10459
10532
  }
10460
- if (getValueByPath(fromObject, ['resolution']) !== undefined) {
10461
- throw new Error('resolution parameter is not supported in Gemini API.');
10533
+ const fromResolution = getValueByPath(fromObject, ['resolution']);
10534
+ if (parentObject !== undefined && fromResolution != null) {
10535
+ setValueByPath(parentObject, ['parameters', 'resolution'], fromResolution);
10462
10536
  }
10463
10537
  const fromPersonGeneration = getValueByPath(fromObject, [
10464
10538
  'personGeneration',
@@ -10512,6 +10586,10 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
10512
10586
  if (getValueByPath(fromObject, ['video']) !== undefined) {
10513
10587
  throw new Error('video parameter is not supported in Gemini API.');
10514
10588
  }
10589
+ const fromSource = getValueByPath(fromObject, ['source']);
10590
+ if (fromSource != null) {
10591
+ setValueByPath(toObject, ['config'], generateVideosSourceToMldev(fromSource, toObject));
10592
+ }
10515
10593
  const fromConfig = getValueByPath(fromObject, ['config']);
10516
10594
  if (fromConfig != null) {
10517
10595
  setValueByPath(toObject, ['config'], generateVideosConfigToMldev(fromConfig, toObject));
@@ -11636,6 +11714,10 @@ function editImageParametersInternalToVertex(apiClient, fromObject) {
11636
11714
  }
11637
11715
  function upscaleImageAPIConfigInternalToVertex(fromObject, parentObject) {
11638
11716
  const toObject = {};
11717
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
11718
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
11719
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
11720
+ }
11639
11721
  const fromIncludeRaiReason = getValueByPath(fromObject, [
11640
11722
  'includeRaiReason',
11641
11723
  ]);
@@ -11764,6 +11846,10 @@ function recontextImageConfigToVertex(fromObject, parentObject) {
11764
11846
  if (parentObject !== undefined && fromPersonGeneration != null) {
11765
11847
  setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
11766
11848
  }
11849
+ const fromAddWatermark = getValueByPath(fromObject, ['addWatermark']);
11850
+ if (parentObject !== undefined && fromAddWatermark != null) {
11851
+ setValueByPath(parentObject, ['parameters', 'addWatermark'], fromAddWatermark);
11852
+ }
11767
11853
  const fromOutputMimeType = getValueByPath(fromObject, [
11768
11854
  'outputMimeType',
11769
11855
  ]);
@@ -12040,6 +12126,22 @@ function videoToVertex(fromObject) {
12040
12126
  }
12041
12127
  return toObject;
12042
12128
  }
12129
+ function generateVideosSourceToVertex(fromObject, parentObject) {
12130
+ const toObject = {};
12131
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
12132
+ if (parentObject !== undefined && fromPrompt != null) {
12133
+ setValueByPath(parentObject, ['instances[0]', 'prompt'], fromPrompt);
12134
+ }
12135
+ const fromImage = getValueByPath(fromObject, ['image']);
12136
+ if (parentObject !== undefined && fromImage != null) {
12137
+ setValueByPath(parentObject, ['instances[0]', 'image'], imageToVertex(fromImage));
12138
+ }
12139
+ const fromVideo = getValueByPath(fromObject, ['video']);
12140
+ if (parentObject !== undefined && fromVideo != null) {
12141
+ setValueByPath(parentObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
12142
+ }
12143
+ return toObject;
12144
+ }
12043
12145
  function videoGenerationReferenceImageToVertex(fromObject) {
12044
12146
  const toObject = {};
12045
12147
  const fromImage = getValueByPath(fromObject, ['image']);
@@ -12158,6 +12260,10 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
12158
12260
  if (fromVideo != null) {
12159
12261
  setValueByPath(toObject, ['instances[0]', 'video'], videoToVertex(fromVideo));
12160
12262
  }
12263
+ const fromSource = getValueByPath(fromObject, ['source']);
12264
+ if (fromSource != null) {
12265
+ setValueByPath(toObject, ['config'], generateVideosSourceToVertex(fromSource, toObject));
12266
+ }
12161
12267
  const fromConfig = getValueByPath(fromObject, ['config']);
12162
12268
  if (fromConfig != null) {
12163
12269
  setValueByPath(toObject, ['config'], generateVideosConfigToVertex(fromConfig, toObject));
@@ -12608,8 +12714,14 @@ function listModelsResponseFromMldev(fromObject) {
12608
12714
  }
12609
12715
  return toObject;
12610
12716
  }
12611
- function deleteModelResponseFromMldev() {
12717
+ function deleteModelResponseFromMldev(fromObject) {
12612
12718
  const toObject = {};
12719
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
12720
+ 'sdkHttpResponse',
12721
+ ]);
12722
+ if (fromSdkHttpResponse != null) {
12723
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
12724
+ }
12613
12725
  return toObject;
12614
12726
  }
12615
12727
  function countTokensResponseFromMldev(fromObject) {
@@ -13354,8 +13466,14 @@ function listModelsResponseFromVertex(fromObject) {
13354
13466
  }
13355
13467
  return toObject;
13356
13468
  }
13357
- function deleteModelResponseFromVertex() {
13469
+ function deleteModelResponseFromVertex(fromObject) {
13358
13470
  const toObject = {};
13471
+ const fromSdkHttpResponse = getValueByPath(fromObject, [
13472
+ 'sdkHttpResponse',
13473
+ ]);
13474
+ if (fromSdkHttpResponse != null) {
13475
+ setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse);
13476
+ }
13359
13477
  return toObject;
13360
13478
  }
13361
13479
  function countTokensResponseFromVertex(fromObject) {
@@ -13472,7 +13590,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
13472
13590
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
13473
13591
  const USER_AGENT_HEADER = 'User-Agent';
13474
13592
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
13475
- const SDK_VERSION = '1.15.0'; // x-release-please-version
13593
+ const SDK_VERSION = '1.17.0'; // x-release-please-version
13476
13594
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
13477
13595
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
13478
13596
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -15244,7 +15362,9 @@ class Models extends BaseModule {
15244
15362
  * ```ts
15245
15363
  * const operation = await ai.models.generateVideos({
15246
15364
  * model: 'veo-2.0-generate-001',
15247
- * prompt: 'A neon hologram of a cat driving at top speed',
15365
+ * source: {
15366
+ * prompt: 'A neon hologram of a cat driving at top speed',
15367
+ * },
15248
15368
  * config: {
15249
15369
  * numberOfVideos: 1
15250
15370
  * });
@@ -15258,6 +15378,9 @@ class Models extends BaseModule {
15258
15378
  * ```
15259
15379
  */
15260
15380
  this.generateVideos = async (params) => {
15381
+ if ((params.prompt || params.image || params.video) && params.source) {
15382
+ throw new Error('Source and prompt/image/video are mutually exclusive. Please only use source.');
15383
+ }
15261
15384
  return await this.generateVideosInternal(params);
15262
15385
  };
15263
15386
  }
@@ -15672,23 +15795,7 @@ class Models extends BaseModule {
15672
15795
  }
15673
15796
  }
15674
15797
  /**
15675
- * Generates an image based on a text description and configuration.
15676
- *
15677
- * @param params - The parameters for generating images.
15678
- * @return The response from the API.
15679
- *
15680
- * @example
15681
- * ```ts
15682
- * const response = await ai.models.generateImages({
15683
- * model: 'imagen-3.0-generate-002',
15684
- * prompt: 'Robot holding a red skateboard',
15685
- * config: {
15686
- * numberOfImages: 1,
15687
- * includeRaiReason: true,
15688
- * },
15689
- * });
15690
- * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
15691
- * ```
15798
+ * Private method for generating images.
15692
15799
  */
15693
15800
  async generateImagesInternal(params) {
15694
15801
  var _a, _b, _c, _d;
@@ -15760,6 +15867,9 @@ class Models extends BaseModule {
15760
15867
  });
15761
15868
  }
15762
15869
  }
15870
+ /**
15871
+ * Private method for editing an image.
15872
+ */
15763
15873
  async editImageInternal(params) {
15764
15874
  var _a, _b;
15765
15875
  let response;
@@ -15801,6 +15911,9 @@ class Models extends BaseModule {
15801
15911
  throw new Error('This method is only supported by the Vertex AI.');
15802
15912
  }
15803
15913
  }
15914
+ /**
15915
+ * Private method for upscaling an image.
15916
+ */
15804
15917
  async upscaleImageInternal(params) {
15805
15918
  var _a, _b;
15806
15919
  let response;
@@ -16206,10 +16319,16 @@ class Models extends BaseModule {
16206
16319
  abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
16207
16320
  })
16208
16321
  .then((httpResponse) => {
16209
- return httpResponse.json();
16322
+ return httpResponse.json().then((jsonResponse) => {
16323
+ const response = jsonResponse;
16324
+ response.sdkHttpResponse = {
16325
+ headers: httpResponse.headers,
16326
+ };
16327
+ return response;
16328
+ });
16210
16329
  });
16211
- return response.then(() => {
16212
- const resp = deleteModelResponseFromVertex();
16330
+ return response.then((apiResponse) => {
16331
+ const resp = deleteModelResponseFromVertex(apiResponse);
16213
16332
  const typedResp = new DeleteModelResponse();
16214
16333
  Object.assign(typedResp, resp);
16215
16334
  return typedResp;
@@ -16232,10 +16351,16 @@ class Models extends BaseModule {
16232
16351
  abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
16233
16352
  })
16234
16353
  .then((httpResponse) => {
16235
- return httpResponse.json();
16354
+ return httpResponse.json().then((jsonResponse) => {
16355
+ const response = jsonResponse;
16356
+ response.sdkHttpResponse = {
16357
+ headers: httpResponse.headers,
16358
+ };
16359
+ return response;
16360
+ });
16236
16361
  });
16237
- return response.then(() => {
16238
- const resp = deleteModelResponseFromMldev();
16362
+ return response.then((apiResponse) => {
16363
+ const resp = deleteModelResponseFromMldev(apiResponse);
16239
16364
  const typedResp = new DeleteModelResponse();
16240
16365
  Object.assign(typedResp, resp);
16241
16366
  return typedResp;
@@ -16388,27 +16513,7 @@ class Models extends BaseModule {
16388
16513
  }
16389
16514
  }
16390
16515
  /**
16391
- * Generates videos based on a text description and configuration.
16392
- *
16393
- * @param params - The parameters for generating videos.
16394
- * @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
16395
- *
16396
- * @example
16397
- * ```ts
16398
- * const operation = await ai.models.generateVideos({
16399
- * model: 'veo-2.0-generate-001',
16400
- * prompt: 'A neon hologram of a cat driving at top speed',
16401
- * config: {
16402
- * numberOfVideos: 1
16403
- * });
16404
- *
16405
- * while (!operation.done) {
16406
- * await new Promise(resolve => setTimeout(resolve, 10000));
16407
- * operation = await ai.operations.getVideosOperation({operation: operation});
16408
- * }
16409
- *
16410
- * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
16411
- * ```
16516
+ * Private method for generating videos.
16412
16517
  */
16413
16518
  async generateVideosInternal(params) {
16414
16519
  var _a, _b, _c, _d;
@@ -16490,13 +16595,17 @@ function getOperationParametersToMldev(fromObject) {
16490
16595
  }
16491
16596
  return toObject;
16492
16597
  }
16493
- function getOperationParametersToVertex(fromObject) {
16598
+ function fetchPredictOperationParametersToVertex(fromObject) {
16494
16599
  const toObject = {};
16495
16600
  const fromOperationName = getValueByPath(fromObject, [
16496
16601
  'operationName',
16497
16602
  ]);
16498
16603
  if (fromOperationName != null) {
16499
- setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
16604
+ setValueByPath(toObject, ['operationName'], fromOperationName);
16605
+ }
16606
+ const fromResourceName = getValueByPath(fromObject, ['resourceName']);
16607
+ if (fromResourceName != null) {
16608
+ setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
16500
16609
  }
16501
16610
  const fromConfig = getValueByPath(fromObject, ['config']);
16502
16611
  if (fromConfig != null) {
@@ -16504,17 +16613,13 @@ function getOperationParametersToVertex(fromObject) {
16504
16613
  }
16505
16614
  return toObject;
16506
16615
  }
16507
- function fetchPredictOperationParametersToVertex(fromObject) {
16616
+ function getOperationParametersToVertex(fromObject) {
16508
16617
  const toObject = {};
16509
16618
  const fromOperationName = getValueByPath(fromObject, [
16510
16619
  'operationName',
16511
16620
  ]);
16512
16621
  if (fromOperationName != null) {
16513
- setValueByPath(toObject, ['operationName'], fromOperationName);
16514
- }
16515
- const fromResourceName = getValueByPath(fromObject, ['resourceName']);
16516
- if (fromResourceName != null) {
16517
- setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
16622
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
16518
16623
  }
16519
16624
  const fromConfig = getValueByPath(fromObject, ['config']);
16520
16625
  if (fromConfig != null) {
@@ -17775,6 +17880,18 @@ function listTuningJobsParametersToMldev(fromObject) {
17775
17880
  }
17776
17881
  return toObject;
17777
17882
  }
17883
+ function cancelTuningJobParametersToMldev(fromObject) {
17884
+ const toObject = {};
17885
+ const fromName = getValueByPath(fromObject, ['name']);
17886
+ if (fromName != null) {
17887
+ setValueByPath(toObject, ['_url', 'name'], fromName);
17888
+ }
17889
+ const fromConfig = getValueByPath(fromObject, ['config']);
17890
+ if (fromConfig != null) {
17891
+ setValueByPath(toObject, ['config'], fromConfig);
17892
+ }
17893
+ return toObject;
17894
+ }
17778
17895
  function tuningExampleToMldev(fromObject) {
17779
17896
  const toObject = {};
17780
17897
  const fromTextInput = getValueByPath(fromObject, ['textInput']);
@@ -17912,6 +18029,18 @@ function listTuningJobsParametersToVertex(fromObject) {
17912
18029
  }
17913
18030
  return toObject;
17914
18031
  }
18032
+ function cancelTuningJobParametersToVertex(fromObject) {
18033
+ const toObject = {};
18034
+ const fromName = getValueByPath(fromObject, ['name']);
18035
+ if (fromName != null) {
18036
+ setValueByPath(toObject, ['_url', 'name'], fromName);
18037
+ }
18038
+ const fromConfig = getValueByPath(fromObject, ['config']);
18039
+ if (fromConfig != null) {
18040
+ setValueByPath(toObject, ['config'], fromConfig);
18041
+ }
18042
+ return toObject;
18043
+ }
17915
18044
  function tuningDatasetToVertex(fromObject, parentObject) {
17916
18045
  const toObject = {};
17917
18046
  const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
@@ -18565,6 +18694,54 @@ class Tunings extends BaseModule {
18565
18694
  });
18566
18695
  }
18567
18696
  }
18697
+ /**
18698
+ * Cancels a tuning job.
18699
+ *
18700
+ * @param params - The parameters for the cancel request.
18701
+ * @return The empty response returned by the API.
18702
+ *
18703
+ * @example
18704
+ * ```ts
18705
+ * await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
18706
+ * ```
18707
+ */
18708
+ async cancel(params) {
18709
+ var _a, _b, _c, _d;
18710
+ let path = '';
18711
+ let queryParams = {};
18712
+ if (this.apiClient.isVertexAI()) {
18713
+ const body = cancelTuningJobParametersToVertex(params);
18714
+ path = formatMap('{name}:cancel', body['_url']);
18715
+ queryParams = body['_query'];
18716
+ delete body['config'];
18717
+ delete body['_url'];
18718
+ delete body['_query'];
18719
+ await this.apiClient.request({
18720
+ path: path,
18721
+ queryParams: queryParams,
18722
+ body: JSON.stringify(body),
18723
+ httpMethod: 'POST',
18724
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
18725
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
18726
+ });
18727
+ }
18728
+ else {
18729
+ const body = cancelTuningJobParametersToMldev(params);
18730
+ path = formatMap('{name}:cancel', body['_url']);
18731
+ queryParams = body['_query'];
18732
+ delete body['config'];
18733
+ delete body['_url'];
18734
+ delete body['_query'];
18735
+ await this.apiClient.request({
18736
+ path: path,
18737
+ queryParams: queryParams,
18738
+ body: JSON.stringify(body),
18739
+ httpMethod: 'POST',
18740
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
18741
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
18742
+ });
18743
+ }
18744
+ }
18568
18745
  async tuneInternal(params) {
18569
18746
  var _a, _b;
18570
18747
  let response;
@@ -19048,8 +19225,8 @@ function getApiKeyFromEnv() {
19048
19225
  if (envGoogleApiKey && envGeminiApiKey) {
19049
19226
  console.warn('Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY.');
19050
19227
  }
19051
- return envGoogleApiKey || envGeminiApiKey;
19228
+ return envGoogleApiKey || envGeminiApiKey || undefined;
19052
19229
  }
19053
19230
 
19054
- 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 };
19231
+ 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 };
19055
19232
  //# sourceMappingURL=index.mjs.map