@google/genai 0.12.0 → 0.14.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.
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var googleAuthLibrary = require('google-auth-library');
4
+ var fs = require('fs');
5
+ var node_stream = require('node:stream');
4
6
  var NodeWs = require('ws');
5
- var fs = require('fs/promises');
7
+ var fs$1 = require('fs/promises');
6
8
 
7
9
  function _interopNamespaceDefault(e) {
8
10
  var n = Object.create(null);
@@ -22,7 +24,7 @@ function _interopNamespaceDefault(e) {
22
24
  }
23
25
 
24
26
  var NodeWs__namespace = /*#__PURE__*/_interopNamespaceDefault(NodeWs);
25
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
27
+ var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs$1);
26
28
 
27
29
  /**
28
30
  * @license
@@ -545,15 +547,81 @@ function tBytes(apiClient, fromImageBytes) {
545
547
  // TODO(b/389133914): Remove dummy bytes converter.
546
548
  return fromImageBytes;
547
549
  }
550
+ function _isFile(origin) {
551
+ return (origin !== null &&
552
+ origin !== undefined &&
553
+ typeof origin === 'object' &&
554
+ 'name' in origin);
555
+ }
556
+ function isGeneratedVideo(origin) {
557
+ return (origin !== null &&
558
+ origin !== undefined &&
559
+ typeof origin === 'object' &&
560
+ 'video' in origin);
561
+ }
562
+ function isVideo(origin) {
563
+ return (origin !== null &&
564
+ origin !== undefined &&
565
+ typeof origin === 'object' &&
566
+ 'uri' in origin);
567
+ }
548
568
  function tFileName(apiClient, fromName) {
549
- if (typeof fromName !== 'string') {
550
- throw new Error('fromName must be a string');
569
+ var _a;
570
+ let name;
571
+ if (_isFile(fromName)) {
572
+ name = fromName.name;
573
+ }
574
+ if (isVideo(fromName)) {
575
+ name = fromName.uri;
576
+ if (name === undefined) {
577
+ return undefined;
578
+ }
551
579
  }
552
- // Remove the files/ prefx for MLdev urls to get the actual name of the file.
553
- if (fromName.startsWith('files/')) {
554
- return fromName.split('files/')[1];
580
+ if (isGeneratedVideo(fromName)) {
581
+ name = (_a = fromName.video) === null || _a === void 0 ? void 0 : _a.uri;
582
+ if (name === undefined) {
583
+ return undefined;
584
+ }
585
+ }
586
+ if (typeof fromName === 'string') {
587
+ name = fromName;
588
+ }
589
+ if (name === undefined) {
590
+ throw new Error('Could not extract file name from the provided input.');
591
+ }
592
+ if (name.startsWith('https://')) {
593
+ const suffix = name.split('files/')[1];
594
+ const match = suffix.match(/[a-z0-9]+/);
595
+ if (match === null) {
596
+ throw new Error(`Could not extract file name from URI ${name}`);
597
+ }
598
+ name = match[0];
599
+ }
600
+ else if (name.startsWith('files/')) {
601
+ name = name.split('files/')[1];
602
+ }
603
+ return name;
604
+ }
605
+ function tModelsUrl(apiClient, baseModels) {
606
+ let res;
607
+ if (apiClient.isVertexAI()) {
608
+ res = baseModels ? 'publishers/google/models' : 'models';
609
+ }
610
+ else {
611
+ res = baseModels ? 'models' : 'tunedModels';
555
612
  }
556
- return fromName;
613
+ return res;
614
+ }
615
+ function tExtractModels(apiClient, response) {
616
+ for (const key of ['models', 'tunedModels', 'publisherModels']) {
617
+ if (hasField(response, key)) {
618
+ return response[key];
619
+ }
620
+ }
621
+ return [];
622
+ }
623
+ function hasField(data, fieldName) {
624
+ return data !== null && typeof data === 'object' && fieldName in data;
557
625
  }
558
626
 
559
627
  /**
@@ -561,6 +629,21 @@ function tFileName(apiClient, fromName) {
561
629
  * Copyright 2025 Google LLC
562
630
  * SPDX-License-Identifier: Apache-2.0
563
631
  */
632
+ function blobToMldev$2(apiClient, fromObject) {
633
+ const toObject = {};
634
+ if (getValueByPath(fromObject, ['displayName']) !== undefined) {
635
+ throw new Error('displayName parameter is not supported in Gemini API.');
636
+ }
637
+ const fromData = getValueByPath(fromObject, ['data']);
638
+ if (fromData != null) {
639
+ setValueByPath(toObject, ['data'], fromData);
640
+ }
641
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
642
+ if (fromMimeType != null) {
643
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
644
+ }
645
+ return toObject;
646
+ }
564
647
  function partToMldev$2(apiClient, fromObject) {
565
648
  const toObject = {};
566
649
  if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
@@ -570,6 +653,10 @@ function partToMldev$2(apiClient, fromObject) {
570
653
  if (fromThought != null) {
571
654
  setValueByPath(toObject, ['thought'], fromThought);
572
655
  }
656
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
657
+ if (fromInlineData != null) {
658
+ setValueByPath(toObject, ['inlineData'], blobToMldev$2(apiClient, fromInlineData));
659
+ }
573
660
  const fromCodeExecutionResult = getValueByPath(fromObject, [
574
661
  'codeExecutionResult',
575
662
  ]);
@@ -596,10 +683,6 @@ function partToMldev$2(apiClient, fromObject) {
596
683
  if (fromFunctionResponse != null) {
597
684
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
598
685
  }
599
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
600
- if (fromInlineData != null) {
601
- setValueByPath(toObject, ['inlineData'], fromInlineData);
602
- }
603
686
  const fromText = getValueByPath(fromObject, ['text']);
604
687
  if (fromText != null) {
605
688
  setValueByPath(toObject, ['text'], fromText);
@@ -667,6 +750,12 @@ function toolToMldev$2(apiClient, fromObject) {
667
750
  if (fromGoogleSearchRetrieval != null) {
668
751
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev$2(apiClient, fromGoogleSearchRetrieval));
669
752
  }
753
+ if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
754
+ throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
755
+ }
756
+ if (getValueByPath(fromObject, ['googleMaps']) !== undefined) {
757
+ throw new Error('googleMaps parameter is not supported in Gemini API.');
758
+ }
670
759
  const fromCodeExecution = getValueByPath(fromObject, [
671
760
  'codeExecution',
672
761
  ]);
@@ -703,6 +792,9 @@ function toolConfigToMldev$1(apiClient, fromObject) {
703
792
  if (fromFunctionCallingConfig != null) {
704
793
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(apiClient, fromFunctionCallingConfig));
705
794
  }
795
+ if (getValueByPath(fromObject, ['retrievalConfig']) !== undefined) {
796
+ throw new Error('retrievalConfig parameter is not supported in Gemini API.');
797
+ }
706
798
  return toObject;
707
799
  }
708
800
  function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
@@ -831,6 +923,22 @@ function listCachedContentsParametersToMldev(apiClient, fromObject) {
831
923
  }
832
924
  return toObject;
833
925
  }
926
+ function blobToVertex$2(apiClient, fromObject) {
927
+ const toObject = {};
928
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
929
+ if (fromDisplayName != null) {
930
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
931
+ }
932
+ const fromData = getValueByPath(fromObject, ['data']);
933
+ if (fromData != null) {
934
+ setValueByPath(toObject, ['data'], fromData);
935
+ }
936
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
937
+ if (fromMimeType != null) {
938
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
939
+ }
940
+ return toObject;
941
+ }
834
942
  function partToVertex$2(apiClient, fromObject) {
835
943
  const toObject = {};
836
944
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -843,6 +951,10 @@ function partToVertex$2(apiClient, fromObject) {
843
951
  if (fromThought != null) {
844
952
  setValueByPath(toObject, ['thought'], fromThought);
845
953
  }
954
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
955
+ if (fromInlineData != null) {
956
+ setValueByPath(toObject, ['inlineData'], blobToVertex$2(apiClient, fromInlineData));
957
+ }
846
958
  const fromCodeExecutionResult = getValueByPath(fromObject, [
847
959
  'codeExecutionResult',
848
960
  ]);
@@ -869,10 +981,6 @@ function partToVertex$2(apiClient, fromObject) {
869
981
  if (fromFunctionResponse != null) {
870
982
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
871
983
  }
872
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
873
- if (fromInlineData != null) {
874
- setValueByPath(toObject, ['inlineData'], fromInlineData);
875
- }
876
984
  const fromText = getValueByPath(fromObject, ['text']);
877
985
  if (fromText != null) {
878
986
  setValueByPath(toObject, ['text'], fromText);
@@ -925,6 +1033,58 @@ function googleSearchRetrievalToVertex$2(apiClient, fromObject) {
925
1033
  }
926
1034
  return toObject;
927
1035
  }
1036
+ function enterpriseWebSearchToVertex$2() {
1037
+ const toObject = {};
1038
+ return toObject;
1039
+ }
1040
+ function apiKeyConfigToVertex$2(apiClient, fromObject) {
1041
+ const toObject = {};
1042
+ const fromApiKeyString = getValueByPath(fromObject, ['apiKeyString']);
1043
+ if (fromApiKeyString != null) {
1044
+ setValueByPath(toObject, ['apiKeyString'], fromApiKeyString);
1045
+ }
1046
+ return toObject;
1047
+ }
1048
+ function authConfigToVertex$2(apiClient, fromObject) {
1049
+ const toObject = {};
1050
+ const fromApiKeyConfig = getValueByPath(fromObject, ['apiKeyConfig']);
1051
+ if (fromApiKeyConfig != null) {
1052
+ setValueByPath(toObject, ['apiKeyConfig'], apiKeyConfigToVertex$2(apiClient, fromApiKeyConfig));
1053
+ }
1054
+ const fromAuthType = getValueByPath(fromObject, ['authType']);
1055
+ if (fromAuthType != null) {
1056
+ setValueByPath(toObject, ['authType'], fromAuthType);
1057
+ }
1058
+ const fromGoogleServiceAccountConfig = getValueByPath(fromObject, [
1059
+ 'googleServiceAccountConfig',
1060
+ ]);
1061
+ if (fromGoogleServiceAccountConfig != null) {
1062
+ setValueByPath(toObject, ['googleServiceAccountConfig'], fromGoogleServiceAccountConfig);
1063
+ }
1064
+ const fromHttpBasicAuthConfig = getValueByPath(fromObject, [
1065
+ 'httpBasicAuthConfig',
1066
+ ]);
1067
+ if (fromHttpBasicAuthConfig != null) {
1068
+ setValueByPath(toObject, ['httpBasicAuthConfig'], fromHttpBasicAuthConfig);
1069
+ }
1070
+ const fromOauthConfig = getValueByPath(fromObject, ['oauthConfig']);
1071
+ if (fromOauthConfig != null) {
1072
+ setValueByPath(toObject, ['oauthConfig'], fromOauthConfig);
1073
+ }
1074
+ const fromOidcConfig = getValueByPath(fromObject, ['oidcConfig']);
1075
+ if (fromOidcConfig != null) {
1076
+ setValueByPath(toObject, ['oidcConfig'], fromOidcConfig);
1077
+ }
1078
+ return toObject;
1079
+ }
1080
+ function googleMapsToVertex$2(apiClient, fromObject) {
1081
+ const toObject = {};
1082
+ const fromAuthConfig = getValueByPath(fromObject, ['authConfig']);
1083
+ if (fromAuthConfig != null) {
1084
+ setValueByPath(toObject, ['authConfig'], authConfigToVertex$2(apiClient, fromAuthConfig));
1085
+ }
1086
+ return toObject;
1087
+ }
928
1088
  function toolToVertex$2(apiClient, fromObject) {
929
1089
  const toObject = {};
930
1090
  const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
@@ -941,6 +1101,16 @@ function toolToVertex$2(apiClient, fromObject) {
941
1101
  if (fromGoogleSearchRetrieval != null) {
942
1102
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex$2(apiClient, fromGoogleSearchRetrieval));
943
1103
  }
1104
+ const fromEnterpriseWebSearch = getValueByPath(fromObject, [
1105
+ 'enterpriseWebSearch',
1106
+ ]);
1107
+ if (fromEnterpriseWebSearch != null) {
1108
+ setValueByPath(toObject, ['enterpriseWebSearch'], enterpriseWebSearchToVertex$2());
1109
+ }
1110
+ const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
1111
+ if (fromGoogleMaps != null) {
1112
+ setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$2(apiClient, fromGoogleMaps));
1113
+ }
944
1114
  const fromCodeExecution = getValueByPath(fromObject, [
945
1115
  'codeExecution',
946
1116
  ]);
@@ -969,6 +1139,26 @@ function functionCallingConfigToVertex$1(apiClient, fromObject) {
969
1139
  }
970
1140
  return toObject;
971
1141
  }
1142
+ function latLngToVertex$1(apiClient, fromObject) {
1143
+ const toObject = {};
1144
+ const fromLatitude = getValueByPath(fromObject, ['latitude']);
1145
+ if (fromLatitude != null) {
1146
+ setValueByPath(toObject, ['latitude'], fromLatitude);
1147
+ }
1148
+ const fromLongitude = getValueByPath(fromObject, ['longitude']);
1149
+ if (fromLongitude != null) {
1150
+ setValueByPath(toObject, ['longitude'], fromLongitude);
1151
+ }
1152
+ return toObject;
1153
+ }
1154
+ function retrievalConfigToVertex$1(apiClient, fromObject) {
1155
+ const toObject = {};
1156
+ const fromLatLng = getValueByPath(fromObject, ['latLng']);
1157
+ if (fromLatLng != null) {
1158
+ setValueByPath(toObject, ['latLng'], latLngToVertex$1(apiClient, fromLatLng));
1159
+ }
1160
+ return toObject;
1161
+ }
972
1162
  function toolConfigToVertex$1(apiClient, fromObject) {
973
1163
  const toObject = {};
974
1164
  const fromFunctionCallingConfig = getValueByPath(fromObject, [
@@ -977,6 +1167,12 @@ function toolConfigToVertex$1(apiClient, fromObject) {
977
1167
  if (fromFunctionCallingConfig != null) {
978
1168
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToVertex$1(apiClient, fromFunctionCallingConfig));
979
1169
  }
1170
+ const fromRetrievalConfig = getValueByPath(fromObject, [
1171
+ 'retrievalConfig',
1172
+ ]);
1173
+ if (fromRetrievalConfig != null) {
1174
+ setValueByPath(toObject, ['retrievalConfig'], retrievalConfigToVertex$1(apiClient, fromRetrievalConfig));
1175
+ }
980
1176
  return toObject;
981
1177
  }
982
1178
  function createCachedContentConfigToVertex(apiClient, fromObject, parentObject) {
@@ -1456,6 +1652,17 @@ exports.Mode = void 0;
1456
1652
  Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
1457
1653
  Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
1458
1654
  })(exports.Mode || (exports.Mode = {}));
1655
+ /** Type of auth scheme. */
1656
+ exports.AuthType = void 0;
1657
+ (function (AuthType) {
1658
+ AuthType["AUTH_TYPE_UNSPECIFIED"] = "AUTH_TYPE_UNSPECIFIED";
1659
+ AuthType["NO_AUTH"] = "NO_AUTH";
1660
+ AuthType["API_KEY_AUTH"] = "API_KEY_AUTH";
1661
+ AuthType["HTTP_BASIC_AUTH"] = "HTTP_BASIC_AUTH";
1662
+ AuthType["GOOGLE_SERVICE_ACCOUNT_AUTH"] = "GOOGLE_SERVICE_ACCOUNT_AUTH";
1663
+ AuthType["OAUTH"] = "OAUTH";
1664
+ AuthType["OIDC_AUTH"] = "OIDC_AUTH";
1665
+ })(exports.AuthType || (exports.AuthType = {}));
1459
1666
  /** Optional. The type of the data. */
1460
1667
  exports.Type = void 0;
1461
1668
  (function (Type) {
@@ -1609,21 +1816,6 @@ exports.ImagePromptLanguage = void 0;
1609
1816
  ImagePromptLanguage["ko"] = "ko";
1610
1817
  ImagePromptLanguage["hi"] = "hi";
1611
1818
  })(exports.ImagePromptLanguage || (exports.ImagePromptLanguage = {}));
1612
- /** State for the lifecycle of a File. */
1613
- exports.FileState = void 0;
1614
- (function (FileState) {
1615
- FileState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
1616
- FileState["PROCESSING"] = "PROCESSING";
1617
- FileState["ACTIVE"] = "ACTIVE";
1618
- FileState["FAILED"] = "FAILED";
1619
- })(exports.FileState || (exports.FileState = {}));
1620
- /** Source of the File. */
1621
- exports.FileSource = void 0;
1622
- (function (FileSource) {
1623
- FileSource["SOURCE_UNSPECIFIED"] = "SOURCE_UNSPECIFIED";
1624
- FileSource["UPLOADED"] = "UPLOADED";
1625
- FileSource["GENERATED"] = "GENERATED";
1626
- })(exports.FileSource || (exports.FileSource = {}));
1627
1819
  /** Enum representing the mask mode of a mask reference image. */
1628
1820
  exports.MaskReferenceMode = void 0;
1629
1821
  (function (MaskReferenceMode) {
@@ -1649,6 +1841,33 @@ exports.SubjectReferenceType = void 0;
1649
1841
  SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
1650
1842
  SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
1651
1843
  })(exports.SubjectReferenceType || (exports.SubjectReferenceType = {}));
1844
+ /** Enum representing the Imagen 3 Edit mode. */
1845
+ exports.EditMode = void 0;
1846
+ (function (EditMode) {
1847
+ EditMode["EDIT_MODE_DEFAULT"] = "EDIT_MODE_DEFAULT";
1848
+ EditMode["EDIT_MODE_INPAINT_REMOVAL"] = "EDIT_MODE_INPAINT_REMOVAL";
1849
+ EditMode["EDIT_MODE_INPAINT_INSERTION"] = "EDIT_MODE_INPAINT_INSERTION";
1850
+ EditMode["EDIT_MODE_OUTPAINT"] = "EDIT_MODE_OUTPAINT";
1851
+ EditMode["EDIT_MODE_CONTROLLED_EDITING"] = "EDIT_MODE_CONTROLLED_EDITING";
1852
+ EditMode["EDIT_MODE_STYLE"] = "EDIT_MODE_STYLE";
1853
+ EditMode["EDIT_MODE_BGSWAP"] = "EDIT_MODE_BGSWAP";
1854
+ EditMode["EDIT_MODE_PRODUCT_IMAGE"] = "EDIT_MODE_PRODUCT_IMAGE";
1855
+ })(exports.EditMode || (exports.EditMode = {}));
1856
+ /** State for the lifecycle of a File. */
1857
+ exports.FileState = void 0;
1858
+ (function (FileState) {
1859
+ FileState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
1860
+ FileState["PROCESSING"] = "PROCESSING";
1861
+ FileState["ACTIVE"] = "ACTIVE";
1862
+ FileState["FAILED"] = "FAILED";
1863
+ })(exports.FileState || (exports.FileState = {}));
1864
+ /** Source of the File. */
1865
+ exports.FileSource = void 0;
1866
+ (function (FileSource) {
1867
+ FileSource["SOURCE_UNSPECIFIED"] = "SOURCE_UNSPECIFIED";
1868
+ FileSource["UPLOADED"] = "UPLOADED";
1869
+ FileSource["GENERATED"] = "GENERATED";
1870
+ })(exports.FileSource || (exports.FileSource = {}));
1652
1871
  /** Server content modalities. */
1653
1872
  exports.MediaModality = void 0;
1654
1873
  (function (MediaModality) {
@@ -2063,6 +2282,13 @@ class EmbedContentResponse {
2063
2282
  /** The output images response. */
2064
2283
  class GenerateImagesResponse {
2065
2284
  }
2285
+ /** Response for the request to edit an image. */
2286
+ class EditImageResponse {
2287
+ }
2288
+ class UpscaleImageResponse {
2289
+ }
2290
+ class ListModelsResponse {
2291
+ }
2066
2292
  class DeleteModelResponse {
2067
2293
  }
2068
2294
  /** Response for counting tokens. */
@@ -2110,6 +2336,176 @@ class DeleteFileResponse {
2110
2336
  /** Represents a single response in a replay. */
2111
2337
  class ReplayResponse {
2112
2338
  }
2339
+ /** A raw reference image.
2340
+
2341
+ A raw reference image represents the base image to edit, provided by the user.
2342
+ It can optionally be provided in addition to a mask reference image or
2343
+ a style reference image.
2344
+ */
2345
+ class RawReferenceImage {
2346
+ /** Internal method to convert to ReferenceImageAPIInternal. */
2347
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2348
+ toReferenceImageAPI() {
2349
+ const referenceImageAPI = {
2350
+ referenceType: 'REFERENCE_TYPE_RAW',
2351
+ referenceImage: this.referenceImage,
2352
+ referenceId: this.referenceId,
2353
+ };
2354
+ return referenceImageAPI;
2355
+ }
2356
+ }
2357
+ /** A mask reference image.
2358
+
2359
+ This encapsulates either a mask image provided by the user and configs for
2360
+ the user provided mask, or only config parameters for the model to generate
2361
+ a mask.
2362
+
2363
+ A mask image is an image whose non-zero values indicate where to edit the base
2364
+ image. If the user provides a mask image, the mask must be in the same
2365
+ dimensions as the raw image.
2366
+ */
2367
+ class MaskReferenceImage {
2368
+ /** Internal method to convert to ReferenceImageAPIInternal. */
2369
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2370
+ toReferenceImageAPI() {
2371
+ const referenceImageAPI = {
2372
+ referenceType: 'REFERENCE_TYPE_MASK',
2373
+ referenceImage: this.referenceImage,
2374
+ referenceId: this.referenceId,
2375
+ maskImageConfig: this.config,
2376
+ };
2377
+ return referenceImageAPI;
2378
+ }
2379
+ }
2380
+ /** A control reference image.
2381
+
2382
+ The image of the control reference image is either a control image provided
2383
+ by the user, or a regular image which the backend will use to generate a
2384
+ control image of. In the case of the latter, the
2385
+ enable_control_image_computation field in the config should be set to True.
2386
+
2387
+ A control image is an image that represents a sketch image of areas for the
2388
+ model to fill in based on the prompt.
2389
+ */
2390
+ class ControlReferenceImage {
2391
+ /** Internal method to convert to ReferenceImageAPIInternal. */
2392
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2393
+ toReferenceImageAPI() {
2394
+ const referenceImageAPI = {
2395
+ referenceType: 'REFERENCE_TYPE_CONTROL',
2396
+ referenceImage: this.referenceImage,
2397
+ referenceId: this.referenceId,
2398
+ controlImageConfig: this.config,
2399
+ };
2400
+ return referenceImageAPI;
2401
+ }
2402
+ }
2403
+ /** A style reference image.
2404
+
2405
+ This encapsulates a style reference image provided by the user, and
2406
+ additionally optional config parameters for the style reference image.
2407
+
2408
+ A raw reference image can also be provided as a destination for the style to
2409
+ be applied to.
2410
+ */
2411
+ class StyleReferenceImage {
2412
+ /** Internal method to convert to ReferenceImageAPIInternal. */
2413
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2414
+ toReferenceImageAPI() {
2415
+ const referenceImageAPI = {
2416
+ referenceType: 'REFERENCE_TYPE_STYLE',
2417
+ referenceImage: this.referenceImage,
2418
+ referenceId: this.referenceId,
2419
+ styleImageConfig: this.config,
2420
+ };
2421
+ return referenceImageAPI;
2422
+ }
2423
+ }
2424
+ /** A subject reference image.
2425
+
2426
+ This encapsulates a subject reference image provided by the user, and
2427
+ additionally optional config parameters for the subject reference image.
2428
+
2429
+ A raw reference image can also be provided as a destination for the subject to
2430
+ be applied to.
2431
+ */
2432
+ class SubjectReferenceImage {
2433
+ /* Internal method to convert to ReferenceImageAPIInternal. */
2434
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2435
+ toReferenceImageAPI() {
2436
+ const referenceImageAPI = {
2437
+ referenceType: 'REFERENCE_TYPE_SUBJECT',
2438
+ referenceImage: this.referenceImage,
2439
+ referenceId: this.referenceId,
2440
+ subjectImageConfig: this.config,
2441
+ };
2442
+ return referenceImageAPI;
2443
+ }
2444
+ }
2445
+ /** Response message for API call. */
2446
+ class LiveServerMessage {
2447
+ /**
2448
+ * Returns the concatenation of all text parts from the server content if present.
2449
+ *
2450
+ * @remarks
2451
+ * If there are non-text parts in the response, the concatenation of all text
2452
+ * parts will be returned, and a warning will be logged.
2453
+ */
2454
+ get text() {
2455
+ var _a, _b, _c;
2456
+ let text = '';
2457
+ let anyTextPartFound = false;
2458
+ const nonTextParts = [];
2459
+ for (const part of (_c = (_b = (_a = this.serverContent) === null || _a === void 0 ? void 0 : _a.modelTurn) === null || _b === void 0 ? void 0 : _b.parts) !== null && _c !== void 0 ? _c : []) {
2460
+ for (const [fieldName, fieldValue] of Object.entries(part)) {
2461
+ if (fieldName !== 'text' &&
2462
+ fieldName !== 'thought' &&
2463
+ fieldValue !== null) {
2464
+ nonTextParts.push(fieldName);
2465
+ }
2466
+ }
2467
+ if (typeof part.text === 'string') {
2468
+ if (typeof part.thought === 'boolean' && part.thought) {
2469
+ continue;
2470
+ }
2471
+ anyTextPartFound = true;
2472
+ text += part.text;
2473
+ }
2474
+ }
2475
+ if (nonTextParts.length > 0) {
2476
+ console.warn(`there are non-text parts ${nonTextParts} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`);
2477
+ }
2478
+ // part.text === '' is different from part.text is null
2479
+ return anyTextPartFound ? text : undefined;
2480
+ }
2481
+ /**
2482
+ * Returns the concatenation of all inline data parts from the server content if present.
2483
+ *
2484
+ * @remarks
2485
+ * If there are non-inline data parts in the
2486
+ * response, the concatenation of all inline data parts will be returned, and
2487
+ * a warning will be logged.
2488
+ */
2489
+ get data() {
2490
+ var _a, _b, _c;
2491
+ let data = '';
2492
+ const nonDataParts = [];
2493
+ for (const part of (_c = (_b = (_a = this.serverContent) === null || _a === void 0 ? void 0 : _a.modelTurn) === null || _b === void 0 ? void 0 : _b.parts) !== null && _c !== void 0 ? _c : []) {
2494
+ for (const [fieldName, fieldValue] of Object.entries(part)) {
2495
+ if (fieldName !== 'inlineData' && fieldValue !== null) {
2496
+ nonDataParts.push(fieldName);
2497
+ }
2498
+ }
2499
+ if (part.inlineData && typeof part.inlineData.data === 'string') {
2500
+ data += atob(part.inlineData.data);
2501
+ }
2502
+ }
2503
+ if (nonDataParts.length > 0) {
2504
+ console.warn(`there are non-data parts ${nonDataParts} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`);
2505
+ }
2506
+ return data.length > 0 ? btoa(data) : undefined;
2507
+ }
2508
+ }
2113
2509
  /** Client generated response to a `ToolCall` received from the server.
2114
2510
 
2115
2511
  Individual `FunctionResponse` objects are matched to the respective
@@ -3196,6 +3592,25 @@ class Files extends BaseModule {
3196
3592
  return file;
3197
3593
  });
3198
3594
  }
3595
+ /**
3596
+ * Downloads a remotely stored file asynchronously to a location specified in
3597
+ * the `params` object. This method only works on Node environment, to
3598
+ * download files in the browser, use a browser compliant method like an <a>
3599
+ * tag.
3600
+ *
3601
+ * @param params - The parameters for the download request.
3602
+ *
3603
+ * @example
3604
+ * The following code downloads an example file named "files/mehozpxf877d" as
3605
+ * "file.txt".
3606
+ *
3607
+ * ```ts
3608
+ * await ai.files.download({file: file.name, downloadPath: 'file.txt'});
3609
+ * ```
3610
+ */
3611
+ async download(params) {
3612
+ await this.apiClient.downloadFile(params);
3613
+ }
3199
3614
  async listInternal(params) {
3200
3615
  var _a, _b;
3201
3616
  let response;
@@ -3369,6 +3784,37 @@ class Files extends BaseModule {
3369
3784
  * Copyright 2025 Google LLC
3370
3785
  * SPDX-License-Identifier: Apache-2.0
3371
3786
  */
3787
+ function blobToMldev$1(apiClient, fromObject) {
3788
+ const toObject = {};
3789
+ if (getValueByPath(fromObject, ['displayName']) !== undefined) {
3790
+ throw new Error('displayName parameter is not supported in Gemini API.');
3791
+ }
3792
+ const fromData = getValueByPath(fromObject, ['data']);
3793
+ if (fromData != null) {
3794
+ setValueByPath(toObject, ['data'], fromData);
3795
+ }
3796
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
3797
+ if (fromMimeType != null) {
3798
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
3799
+ }
3800
+ return toObject;
3801
+ }
3802
+ function blobToVertex$1(apiClient, fromObject) {
3803
+ const toObject = {};
3804
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
3805
+ if (fromDisplayName != null) {
3806
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
3807
+ }
3808
+ const fromData = getValueByPath(fromObject, ['data']);
3809
+ if (fromData != null) {
3810
+ setValueByPath(toObject, ['data'], fromData);
3811
+ }
3812
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
3813
+ if (fromMimeType != null) {
3814
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
3815
+ }
3816
+ return toObject;
3817
+ }
3372
3818
  function partToMldev$1(apiClient, fromObject) {
3373
3819
  const toObject = {};
3374
3820
  if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
@@ -3378,6 +3824,10 @@ function partToMldev$1(apiClient, fromObject) {
3378
3824
  if (fromThought != null) {
3379
3825
  setValueByPath(toObject, ['thought'], fromThought);
3380
3826
  }
3827
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
3828
+ if (fromInlineData != null) {
3829
+ setValueByPath(toObject, ['inlineData'], blobToMldev$1(apiClient, fromInlineData));
3830
+ }
3381
3831
  const fromCodeExecutionResult = getValueByPath(fromObject, [
3382
3832
  'codeExecutionResult',
3383
3833
  ]);
@@ -3404,10 +3854,6 @@ function partToMldev$1(apiClient, fromObject) {
3404
3854
  if (fromFunctionResponse != null) {
3405
3855
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
3406
3856
  }
3407
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
3408
- if (fromInlineData != null) {
3409
- setValueByPath(toObject, ['inlineData'], fromInlineData);
3410
- }
3411
3857
  const fromText = getValueByPath(fromObject, ['text']);
3412
3858
  if (fromText != null) {
3413
3859
  setValueByPath(toObject, ['text'], fromText);
@@ -3426,6 +3872,10 @@ function partToVertex$1(apiClient, fromObject) {
3426
3872
  if (fromThought != null) {
3427
3873
  setValueByPath(toObject, ['thought'], fromThought);
3428
3874
  }
3875
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
3876
+ if (fromInlineData != null) {
3877
+ setValueByPath(toObject, ['inlineData'], blobToVertex$1(apiClient, fromInlineData));
3878
+ }
3429
3879
  const fromCodeExecutionResult = getValueByPath(fromObject, [
3430
3880
  'codeExecutionResult',
3431
3881
  ]);
@@ -3452,10 +3902,6 @@ function partToVertex$1(apiClient, fromObject) {
3452
3902
  if (fromFunctionResponse != null) {
3453
3903
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
3454
3904
  }
3455
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
3456
- if (fromInlineData != null) {
3457
- setValueByPath(toObject, ['inlineData'], fromInlineData);
3458
- }
3459
3905
  const fromText = getValueByPath(fromObject, ['text']);
3460
3906
  if (fromText != null) {
3461
3907
  setValueByPath(toObject, ['text'], fromText);
@@ -3554,6 +4000,58 @@ function googleSearchRetrievalToVertex$1(apiClient, fromObject) {
3554
4000
  }
3555
4001
  return toObject;
3556
4002
  }
4003
+ function enterpriseWebSearchToVertex$1() {
4004
+ const toObject = {};
4005
+ return toObject;
4006
+ }
4007
+ function apiKeyConfigToVertex$1(apiClient, fromObject) {
4008
+ const toObject = {};
4009
+ const fromApiKeyString = getValueByPath(fromObject, ['apiKeyString']);
4010
+ if (fromApiKeyString != null) {
4011
+ setValueByPath(toObject, ['apiKeyString'], fromApiKeyString);
4012
+ }
4013
+ return toObject;
4014
+ }
4015
+ function authConfigToVertex$1(apiClient, fromObject) {
4016
+ const toObject = {};
4017
+ const fromApiKeyConfig = getValueByPath(fromObject, ['apiKeyConfig']);
4018
+ if (fromApiKeyConfig != null) {
4019
+ setValueByPath(toObject, ['apiKeyConfig'], apiKeyConfigToVertex$1(apiClient, fromApiKeyConfig));
4020
+ }
4021
+ const fromAuthType = getValueByPath(fromObject, ['authType']);
4022
+ if (fromAuthType != null) {
4023
+ setValueByPath(toObject, ['authType'], fromAuthType);
4024
+ }
4025
+ const fromGoogleServiceAccountConfig = getValueByPath(fromObject, [
4026
+ 'googleServiceAccountConfig',
4027
+ ]);
4028
+ if (fromGoogleServiceAccountConfig != null) {
4029
+ setValueByPath(toObject, ['googleServiceAccountConfig'], fromGoogleServiceAccountConfig);
4030
+ }
4031
+ const fromHttpBasicAuthConfig = getValueByPath(fromObject, [
4032
+ 'httpBasicAuthConfig',
4033
+ ]);
4034
+ if (fromHttpBasicAuthConfig != null) {
4035
+ setValueByPath(toObject, ['httpBasicAuthConfig'], fromHttpBasicAuthConfig);
4036
+ }
4037
+ const fromOauthConfig = getValueByPath(fromObject, ['oauthConfig']);
4038
+ if (fromOauthConfig != null) {
4039
+ setValueByPath(toObject, ['oauthConfig'], fromOauthConfig);
4040
+ }
4041
+ const fromOidcConfig = getValueByPath(fromObject, ['oidcConfig']);
4042
+ if (fromOidcConfig != null) {
4043
+ setValueByPath(toObject, ['oidcConfig'], fromOidcConfig);
4044
+ }
4045
+ return toObject;
4046
+ }
4047
+ function googleMapsToVertex$1(apiClient, fromObject) {
4048
+ const toObject = {};
4049
+ const fromAuthConfig = getValueByPath(fromObject, ['authConfig']);
4050
+ if (fromAuthConfig != null) {
4051
+ setValueByPath(toObject, ['authConfig'], authConfigToVertex$1(apiClient, fromAuthConfig));
4052
+ }
4053
+ return toObject;
4054
+ }
3557
4055
  function toolToMldev$1(apiClient, fromObject) {
3558
4056
  const toObject = {};
3559
4057
  if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
@@ -3569,6 +4067,12 @@ function toolToMldev$1(apiClient, fromObject) {
3569
4067
  if (fromGoogleSearchRetrieval != null) {
3570
4068
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev$1(apiClient, fromGoogleSearchRetrieval));
3571
4069
  }
4070
+ if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
4071
+ throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
4072
+ }
4073
+ if (getValueByPath(fromObject, ['googleMaps']) !== undefined) {
4074
+ throw new Error('googleMaps parameter is not supported in Gemini API.');
4075
+ }
3572
4076
  const fromCodeExecution = getValueByPath(fromObject, [
3573
4077
  'codeExecution',
3574
4078
  ]);
@@ -3599,6 +4103,16 @@ function toolToVertex$1(apiClient, fromObject) {
3599
4103
  if (fromGoogleSearchRetrieval != null) {
3600
4104
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex$1(apiClient, fromGoogleSearchRetrieval));
3601
4105
  }
4106
+ const fromEnterpriseWebSearch = getValueByPath(fromObject, [
4107
+ 'enterpriseWebSearch',
4108
+ ]);
4109
+ if (fromEnterpriseWebSearch != null) {
4110
+ setValueByPath(toObject, ['enterpriseWebSearch'], enterpriseWebSearchToVertex$1());
4111
+ }
4112
+ const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
4113
+ if (fromGoogleMaps != null) {
4114
+ setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$1(apiClient, fromGoogleMaps));
4115
+ }
3602
4116
  const fromCodeExecution = getValueByPath(fromObject, [
3603
4117
  'codeExecution',
3604
4118
  ]);
@@ -3864,8 +4378,11 @@ function liveConnectConfigToMldev(apiClient, fromObject, parentObject) {
3864
4378
  if (parentObject !== undefined && fromSessionResumption != null) {
3865
4379
  setValueByPath(parentObject, ['setup', 'sessionResumption'], sessionResumptionConfigToMldev(apiClient, fromSessionResumption));
3866
4380
  }
3867
- if (getValueByPath(fromObject, ['inputAudioTranscription']) !== undefined) {
3868
- throw new Error('inputAudioTranscription parameter is not supported in Gemini API.');
4381
+ const fromInputAudioTranscription = getValueByPath(fromObject, [
4382
+ 'inputAudioTranscription',
4383
+ ]);
4384
+ if (parentObject !== undefined && fromInputAudioTranscription != null) {
4385
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev());
3869
4386
  }
3870
4387
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
3871
4388
  'outputAudioTranscription',
@@ -4098,12 +4615,44 @@ function liveServerSetupCompleteFromVertex() {
4098
4615
  const toObject = {};
4099
4616
  return toObject;
4100
4617
  }
4618
+ function blobFromMldev$1(apiClient, fromObject) {
4619
+ const toObject = {};
4620
+ const fromData = getValueByPath(fromObject, ['data']);
4621
+ if (fromData != null) {
4622
+ setValueByPath(toObject, ['data'], fromData);
4623
+ }
4624
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
4625
+ if (fromMimeType != null) {
4626
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
4627
+ }
4628
+ return toObject;
4629
+ }
4630
+ function blobFromVertex$1(apiClient, fromObject) {
4631
+ const toObject = {};
4632
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
4633
+ if (fromDisplayName != null) {
4634
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
4635
+ }
4636
+ const fromData = getValueByPath(fromObject, ['data']);
4637
+ if (fromData != null) {
4638
+ setValueByPath(toObject, ['data'], fromData);
4639
+ }
4640
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
4641
+ if (fromMimeType != null) {
4642
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
4643
+ }
4644
+ return toObject;
4645
+ }
4101
4646
  function partFromMldev$1(apiClient, fromObject) {
4102
4647
  const toObject = {};
4103
4648
  const fromThought = getValueByPath(fromObject, ['thought']);
4104
4649
  if (fromThought != null) {
4105
4650
  setValueByPath(toObject, ['thought'], fromThought);
4106
4651
  }
4652
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
4653
+ if (fromInlineData != null) {
4654
+ setValueByPath(toObject, ['inlineData'], blobFromMldev$1(apiClient, fromInlineData));
4655
+ }
4107
4656
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4108
4657
  'codeExecutionResult',
4109
4658
  ]);
@@ -4130,10 +4679,6 @@ function partFromMldev$1(apiClient, fromObject) {
4130
4679
  if (fromFunctionResponse != null) {
4131
4680
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
4132
4681
  }
4133
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
4134
- if (fromInlineData != null) {
4135
- setValueByPath(toObject, ['inlineData'], fromInlineData);
4136
- }
4137
4682
  const fromText = getValueByPath(fromObject, ['text']);
4138
4683
  if (fromText != null) {
4139
4684
  setValueByPath(toObject, ['text'], fromText);
@@ -4152,6 +4697,10 @@ function partFromVertex$1(apiClient, fromObject) {
4152
4697
  if (fromThought != null) {
4153
4698
  setValueByPath(toObject, ['thought'], fromThought);
4154
4699
  }
4700
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
4701
+ if (fromInlineData != null) {
4702
+ setValueByPath(toObject, ['inlineData'], blobFromVertex$1(apiClient, fromInlineData));
4703
+ }
4155
4704
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4156
4705
  'codeExecutionResult',
4157
4706
  ]);
@@ -4178,10 +4727,6 @@ function partFromVertex$1(apiClient, fromObject) {
4178
4727
  if (fromFunctionResponse != null) {
4179
4728
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
4180
4729
  }
4181
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
4182
- if (fromInlineData != null) {
4183
- setValueByPath(toObject, ['inlineData'], fromInlineData);
4184
- }
4185
4730
  const fromText = getValueByPath(fromObject, ['text']);
4186
4731
  if (fromText != null) {
4187
4732
  setValueByPath(toObject, ['text'], fromText);
@@ -4750,6 +5295,21 @@ function liveServerMessageFromVertex(apiClient, fromObject) {
4750
5295
  * Copyright 2025 Google LLC
4751
5296
  * SPDX-License-Identifier: Apache-2.0
4752
5297
  */
5298
+ function blobToMldev(apiClient, fromObject) {
5299
+ const toObject = {};
5300
+ if (getValueByPath(fromObject, ['displayName']) !== undefined) {
5301
+ throw new Error('displayName parameter is not supported in Gemini API.');
5302
+ }
5303
+ const fromData = getValueByPath(fromObject, ['data']);
5304
+ if (fromData != null) {
5305
+ setValueByPath(toObject, ['data'], fromData);
5306
+ }
5307
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
5308
+ if (fromMimeType != null) {
5309
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
5310
+ }
5311
+ return toObject;
5312
+ }
4753
5313
  function partToMldev(apiClient, fromObject) {
4754
5314
  const toObject = {};
4755
5315
  if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
@@ -4759,6 +5319,10 @@ function partToMldev(apiClient, fromObject) {
4759
5319
  if (fromThought != null) {
4760
5320
  setValueByPath(toObject, ['thought'], fromThought);
4761
5321
  }
5322
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
5323
+ if (fromInlineData != null) {
5324
+ setValueByPath(toObject, ['inlineData'], blobToMldev(apiClient, fromInlineData));
5325
+ }
4762
5326
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4763
5327
  'codeExecutionResult',
4764
5328
  ]);
@@ -4785,10 +5349,6 @@ function partToMldev(apiClient, fromObject) {
4785
5349
  if (fromFunctionResponse != null) {
4786
5350
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
4787
5351
  }
4788
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
4789
- if (fromInlineData != null) {
4790
- setValueByPath(toObject, ['inlineData'], fromInlineData);
4791
- }
4792
5352
  const fromText = getValueByPath(fromObject, ['text']);
4793
5353
  if (fromText != null) {
4794
5354
  setValueByPath(toObject, ['text'], fromText);
@@ -4871,6 +5431,12 @@ function toolToMldev(apiClient, fromObject) {
4871
5431
  if (fromGoogleSearchRetrieval != null) {
4872
5432
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev(apiClient, fromGoogleSearchRetrieval));
4873
5433
  }
5434
+ if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
5435
+ throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
5436
+ }
5437
+ if (getValueByPath(fromObject, ['googleMaps']) !== undefined) {
5438
+ throw new Error('googleMaps parameter is not supported in Gemini API.');
5439
+ }
4874
5440
  const fromCodeExecution = getValueByPath(fromObject, [
4875
5441
  'codeExecution',
4876
5442
  ]);
@@ -4907,6 +5473,9 @@ function toolConfigToMldev(apiClient, fromObject) {
4907
5473
  if (fromFunctionCallingConfig != null) {
4908
5474
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(apiClient, fromFunctionCallingConfig));
4909
5475
  }
5476
+ if (getValueByPath(fromObject, ['retrievalConfig']) !== undefined) {
5477
+ throw new Error('retrievalConfig parameter is not supported in Gemini API.');
5478
+ }
4910
5479
  return toObject;
4911
5480
  }
4912
5481
  function prebuiltVoiceConfigToMldev(apiClient, fromObject) {
@@ -5268,6 +5837,34 @@ function getModelParametersToMldev(apiClient, fromObject) {
5268
5837
  }
5269
5838
  return toObject;
5270
5839
  }
5840
+ function listModelsConfigToMldev(apiClient, fromObject, parentObject) {
5841
+ const toObject = {};
5842
+ const fromPageSize = getValueByPath(fromObject, ['pageSize']);
5843
+ if (parentObject !== undefined && fromPageSize != null) {
5844
+ setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
5845
+ }
5846
+ const fromPageToken = getValueByPath(fromObject, ['pageToken']);
5847
+ if (parentObject !== undefined && fromPageToken != null) {
5848
+ setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
5849
+ }
5850
+ const fromFilter = getValueByPath(fromObject, ['filter']);
5851
+ if (parentObject !== undefined && fromFilter != null) {
5852
+ setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
5853
+ }
5854
+ const fromQueryBase = getValueByPath(fromObject, ['queryBase']);
5855
+ if (parentObject !== undefined && fromQueryBase != null) {
5856
+ setValueByPath(parentObject, ['_url', 'models_url'], tModelsUrl(apiClient, fromQueryBase));
5857
+ }
5858
+ return toObject;
5859
+ }
5860
+ function listModelsParametersToMldev(apiClient, fromObject) {
5861
+ const toObject = {};
5862
+ const fromConfig = getValueByPath(fromObject, ['config']);
5863
+ if (fromConfig != null) {
5864
+ setValueByPath(toObject, ['config'], listModelsConfigToMldev(apiClient, fromConfig, toObject));
5865
+ }
5866
+ return toObject;
5867
+ }
5271
5868
  function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
5272
5869
  const toObject = {};
5273
5870
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
@@ -5278,6 +5875,12 @@ function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
5278
5875
  if (parentObject !== undefined && fromDescription != null) {
5279
5876
  setValueByPath(parentObject, ['description'], fromDescription);
5280
5877
  }
5878
+ const fromDefaultCheckpointId = getValueByPath(fromObject, [
5879
+ 'defaultCheckpointId',
5880
+ ]);
5881
+ if (parentObject !== undefined && fromDefaultCheckpointId != null) {
5882
+ setValueByPath(parentObject, ['defaultCheckpointId'], fromDefaultCheckpointId);
5883
+ }
5281
5884
  return toObject;
5282
5885
  }
5283
5886
  function updateModelParametersToMldev(apiClient, fromObject) {
@@ -5424,6 +6027,22 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
5424
6027
  }
5425
6028
  return toObject;
5426
6029
  }
6030
+ function blobToVertex(apiClient, fromObject) {
6031
+ const toObject = {};
6032
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
6033
+ if (fromDisplayName != null) {
6034
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
6035
+ }
6036
+ const fromData = getValueByPath(fromObject, ['data']);
6037
+ if (fromData != null) {
6038
+ setValueByPath(toObject, ['data'], fromData);
6039
+ }
6040
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
6041
+ if (fromMimeType != null) {
6042
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
6043
+ }
6044
+ return toObject;
6045
+ }
5427
6046
  function partToVertex(apiClient, fromObject) {
5428
6047
  const toObject = {};
5429
6048
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -5436,6 +6055,10 @@ function partToVertex(apiClient, fromObject) {
5436
6055
  if (fromThought != null) {
5437
6056
  setValueByPath(toObject, ['thought'], fromThought);
5438
6057
  }
6058
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
6059
+ if (fromInlineData != null) {
6060
+ setValueByPath(toObject, ['inlineData'], blobToVertex(apiClient, fromInlineData));
6061
+ }
5439
6062
  const fromCodeExecutionResult = getValueByPath(fromObject, [
5440
6063
  'codeExecutionResult',
5441
6064
  ]);
@@ -5462,10 +6085,6 @@ function partToVertex(apiClient, fromObject) {
5462
6085
  if (fromFunctionResponse != null) {
5463
6086
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
5464
6087
  }
5465
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
5466
- if (fromInlineData != null) {
5467
- setValueByPath(toObject, ['inlineData'], fromInlineData);
5468
- }
5469
6088
  const fromText = getValueByPath(fromObject, ['text']);
5470
6089
  if (fromText != null) {
5471
6090
  setValueByPath(toObject, ['text'], fromText);
@@ -5544,6 +6163,58 @@ function googleSearchRetrievalToVertex(apiClient, fromObject) {
5544
6163
  }
5545
6164
  return toObject;
5546
6165
  }
6166
+ function enterpriseWebSearchToVertex() {
6167
+ const toObject = {};
6168
+ return toObject;
6169
+ }
6170
+ function apiKeyConfigToVertex(apiClient, fromObject) {
6171
+ const toObject = {};
6172
+ const fromApiKeyString = getValueByPath(fromObject, ['apiKeyString']);
6173
+ if (fromApiKeyString != null) {
6174
+ setValueByPath(toObject, ['apiKeyString'], fromApiKeyString);
6175
+ }
6176
+ return toObject;
6177
+ }
6178
+ function authConfigToVertex(apiClient, fromObject) {
6179
+ const toObject = {};
6180
+ const fromApiKeyConfig = getValueByPath(fromObject, ['apiKeyConfig']);
6181
+ if (fromApiKeyConfig != null) {
6182
+ setValueByPath(toObject, ['apiKeyConfig'], apiKeyConfigToVertex(apiClient, fromApiKeyConfig));
6183
+ }
6184
+ const fromAuthType = getValueByPath(fromObject, ['authType']);
6185
+ if (fromAuthType != null) {
6186
+ setValueByPath(toObject, ['authType'], fromAuthType);
6187
+ }
6188
+ const fromGoogleServiceAccountConfig = getValueByPath(fromObject, [
6189
+ 'googleServiceAccountConfig',
6190
+ ]);
6191
+ if (fromGoogleServiceAccountConfig != null) {
6192
+ setValueByPath(toObject, ['googleServiceAccountConfig'], fromGoogleServiceAccountConfig);
6193
+ }
6194
+ const fromHttpBasicAuthConfig = getValueByPath(fromObject, [
6195
+ 'httpBasicAuthConfig',
6196
+ ]);
6197
+ if (fromHttpBasicAuthConfig != null) {
6198
+ setValueByPath(toObject, ['httpBasicAuthConfig'], fromHttpBasicAuthConfig);
6199
+ }
6200
+ const fromOauthConfig = getValueByPath(fromObject, ['oauthConfig']);
6201
+ if (fromOauthConfig != null) {
6202
+ setValueByPath(toObject, ['oauthConfig'], fromOauthConfig);
6203
+ }
6204
+ const fromOidcConfig = getValueByPath(fromObject, ['oidcConfig']);
6205
+ if (fromOidcConfig != null) {
6206
+ setValueByPath(toObject, ['oidcConfig'], fromOidcConfig);
6207
+ }
6208
+ return toObject;
6209
+ }
6210
+ function googleMapsToVertex(apiClient, fromObject) {
6211
+ const toObject = {};
6212
+ const fromAuthConfig = getValueByPath(fromObject, ['authConfig']);
6213
+ if (fromAuthConfig != null) {
6214
+ setValueByPath(toObject, ['authConfig'], authConfigToVertex(apiClient, fromAuthConfig));
6215
+ }
6216
+ return toObject;
6217
+ }
5547
6218
  function toolToVertex(apiClient, fromObject) {
5548
6219
  const toObject = {};
5549
6220
  const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
@@ -5560,6 +6231,16 @@ function toolToVertex(apiClient, fromObject) {
5560
6231
  if (fromGoogleSearchRetrieval != null) {
5561
6232
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex(apiClient, fromGoogleSearchRetrieval));
5562
6233
  }
6234
+ const fromEnterpriseWebSearch = getValueByPath(fromObject, [
6235
+ 'enterpriseWebSearch',
6236
+ ]);
6237
+ if (fromEnterpriseWebSearch != null) {
6238
+ setValueByPath(toObject, ['enterpriseWebSearch'], enterpriseWebSearchToVertex());
6239
+ }
6240
+ const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
6241
+ if (fromGoogleMaps != null) {
6242
+ setValueByPath(toObject, ['googleMaps'], googleMapsToVertex(apiClient, fromGoogleMaps));
6243
+ }
5563
6244
  const fromCodeExecution = getValueByPath(fromObject, [
5564
6245
  'codeExecution',
5565
6246
  ]);
@@ -5588,6 +6269,26 @@ function functionCallingConfigToVertex(apiClient, fromObject) {
5588
6269
  }
5589
6270
  return toObject;
5590
6271
  }
6272
+ function latLngToVertex(apiClient, fromObject) {
6273
+ const toObject = {};
6274
+ const fromLatitude = getValueByPath(fromObject, ['latitude']);
6275
+ if (fromLatitude != null) {
6276
+ setValueByPath(toObject, ['latitude'], fromLatitude);
6277
+ }
6278
+ const fromLongitude = getValueByPath(fromObject, ['longitude']);
6279
+ if (fromLongitude != null) {
6280
+ setValueByPath(toObject, ['longitude'], fromLongitude);
6281
+ }
6282
+ return toObject;
6283
+ }
6284
+ function retrievalConfigToVertex(apiClient, fromObject) {
6285
+ const toObject = {};
6286
+ const fromLatLng = getValueByPath(fromObject, ['latLng']);
6287
+ if (fromLatLng != null) {
6288
+ setValueByPath(toObject, ['latLng'], latLngToVertex(apiClient, fromLatLng));
6289
+ }
6290
+ return toObject;
6291
+ }
5591
6292
  function toolConfigToVertex(apiClient, fromObject) {
5592
6293
  const toObject = {};
5593
6294
  const fromFunctionCallingConfig = getValueByPath(fromObject, [
@@ -5596,6 +6297,12 @@ function toolConfigToVertex(apiClient, fromObject) {
5596
6297
  if (fromFunctionCallingConfig != null) {
5597
6298
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToVertex(apiClient, fromFunctionCallingConfig));
5598
6299
  }
6300
+ const fromRetrievalConfig = getValueByPath(fromObject, [
6301
+ 'retrievalConfig',
6302
+ ]);
6303
+ if (fromRetrievalConfig != null) {
6304
+ setValueByPath(toObject, ['retrievalConfig'], retrievalConfigToVertex(apiClient, fromRetrievalConfig));
6305
+ }
5599
6306
  return toObject;
5600
6307
  }
5601
6308
  function prebuiltVoiceConfigToVertex(apiClient, fromObject) {
@@ -5962,6 +6669,286 @@ function generateImagesParametersToVertex(apiClient, fromObject) {
5962
6669
  }
5963
6670
  return toObject;
5964
6671
  }
6672
+ function imageToVertex(apiClient, fromObject) {
6673
+ const toObject = {};
6674
+ const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
6675
+ if (fromGcsUri != null) {
6676
+ setValueByPath(toObject, ['gcsUri'], fromGcsUri);
6677
+ }
6678
+ const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
6679
+ if (fromImageBytes != null) {
6680
+ setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
6681
+ }
6682
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
6683
+ if (fromMimeType != null) {
6684
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
6685
+ }
6686
+ return toObject;
6687
+ }
6688
+ function maskReferenceConfigToVertex(apiClient, fromObject) {
6689
+ const toObject = {};
6690
+ const fromMaskMode = getValueByPath(fromObject, ['maskMode']);
6691
+ if (fromMaskMode != null) {
6692
+ setValueByPath(toObject, ['maskMode'], fromMaskMode);
6693
+ }
6694
+ const fromSegmentationClasses = getValueByPath(fromObject, [
6695
+ 'segmentationClasses',
6696
+ ]);
6697
+ if (fromSegmentationClasses != null) {
6698
+ setValueByPath(toObject, ['maskClasses'], fromSegmentationClasses);
6699
+ }
6700
+ const fromMaskDilation = getValueByPath(fromObject, ['maskDilation']);
6701
+ if (fromMaskDilation != null) {
6702
+ setValueByPath(toObject, ['dilation'], fromMaskDilation);
6703
+ }
6704
+ return toObject;
6705
+ }
6706
+ function controlReferenceConfigToVertex(apiClient, fromObject) {
6707
+ const toObject = {};
6708
+ const fromControlType = getValueByPath(fromObject, ['controlType']);
6709
+ if (fromControlType != null) {
6710
+ setValueByPath(toObject, ['controlType'], fromControlType);
6711
+ }
6712
+ const fromEnableControlImageComputation = getValueByPath(fromObject, [
6713
+ 'enableControlImageComputation',
6714
+ ]);
6715
+ if (fromEnableControlImageComputation != null) {
6716
+ setValueByPath(toObject, ['computeControl'], fromEnableControlImageComputation);
6717
+ }
6718
+ return toObject;
6719
+ }
6720
+ function styleReferenceConfigToVertex(apiClient, fromObject) {
6721
+ const toObject = {};
6722
+ const fromStyleDescription = getValueByPath(fromObject, [
6723
+ 'styleDescription',
6724
+ ]);
6725
+ if (fromStyleDescription != null) {
6726
+ setValueByPath(toObject, ['styleDescription'], fromStyleDescription);
6727
+ }
6728
+ return toObject;
6729
+ }
6730
+ function subjectReferenceConfigToVertex(apiClient, fromObject) {
6731
+ const toObject = {};
6732
+ const fromSubjectType = getValueByPath(fromObject, ['subjectType']);
6733
+ if (fromSubjectType != null) {
6734
+ setValueByPath(toObject, ['subjectType'], fromSubjectType);
6735
+ }
6736
+ const fromSubjectDescription = getValueByPath(fromObject, [
6737
+ 'subjectDescription',
6738
+ ]);
6739
+ if (fromSubjectDescription != null) {
6740
+ setValueByPath(toObject, ['subjectDescription'], fromSubjectDescription);
6741
+ }
6742
+ return toObject;
6743
+ }
6744
+ function referenceImageAPIInternalToVertex(apiClient, fromObject) {
6745
+ const toObject = {};
6746
+ const fromReferenceImage = getValueByPath(fromObject, [
6747
+ 'referenceImage',
6748
+ ]);
6749
+ if (fromReferenceImage != null) {
6750
+ setValueByPath(toObject, ['referenceImage'], imageToVertex(apiClient, fromReferenceImage));
6751
+ }
6752
+ const fromReferenceId = getValueByPath(fromObject, ['referenceId']);
6753
+ if (fromReferenceId != null) {
6754
+ setValueByPath(toObject, ['referenceId'], fromReferenceId);
6755
+ }
6756
+ const fromReferenceType = getValueByPath(fromObject, [
6757
+ 'referenceType',
6758
+ ]);
6759
+ if (fromReferenceType != null) {
6760
+ setValueByPath(toObject, ['referenceType'], fromReferenceType);
6761
+ }
6762
+ const fromMaskImageConfig = getValueByPath(fromObject, [
6763
+ 'maskImageConfig',
6764
+ ]);
6765
+ if (fromMaskImageConfig != null) {
6766
+ setValueByPath(toObject, ['maskImageConfig'], maskReferenceConfigToVertex(apiClient, fromMaskImageConfig));
6767
+ }
6768
+ const fromControlImageConfig = getValueByPath(fromObject, [
6769
+ 'controlImageConfig',
6770
+ ]);
6771
+ if (fromControlImageConfig != null) {
6772
+ setValueByPath(toObject, ['controlImageConfig'], controlReferenceConfigToVertex(apiClient, fromControlImageConfig));
6773
+ }
6774
+ const fromStyleImageConfig = getValueByPath(fromObject, [
6775
+ 'styleImageConfig',
6776
+ ]);
6777
+ if (fromStyleImageConfig != null) {
6778
+ setValueByPath(toObject, ['styleImageConfig'], styleReferenceConfigToVertex(apiClient, fromStyleImageConfig));
6779
+ }
6780
+ const fromSubjectImageConfig = getValueByPath(fromObject, [
6781
+ 'subjectImageConfig',
6782
+ ]);
6783
+ if (fromSubjectImageConfig != null) {
6784
+ setValueByPath(toObject, ['subjectImageConfig'], subjectReferenceConfigToVertex(apiClient, fromSubjectImageConfig));
6785
+ }
6786
+ return toObject;
6787
+ }
6788
+ function editImageConfigToVertex(apiClient, fromObject, parentObject) {
6789
+ const toObject = {};
6790
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
6791
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
6792
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
6793
+ }
6794
+ const fromNegativePrompt = getValueByPath(fromObject, [
6795
+ 'negativePrompt',
6796
+ ]);
6797
+ if (parentObject !== undefined && fromNegativePrompt != null) {
6798
+ setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
6799
+ }
6800
+ const fromNumberOfImages = getValueByPath(fromObject, [
6801
+ 'numberOfImages',
6802
+ ]);
6803
+ if (parentObject !== undefined && fromNumberOfImages != null) {
6804
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
6805
+ }
6806
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
6807
+ if (parentObject !== undefined && fromAspectRatio != null) {
6808
+ setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
6809
+ }
6810
+ const fromGuidanceScale = getValueByPath(fromObject, [
6811
+ 'guidanceScale',
6812
+ ]);
6813
+ if (parentObject !== undefined && fromGuidanceScale != null) {
6814
+ setValueByPath(parentObject, ['parameters', 'guidanceScale'], fromGuidanceScale);
6815
+ }
6816
+ const fromSeed = getValueByPath(fromObject, ['seed']);
6817
+ if (parentObject !== undefined && fromSeed != null) {
6818
+ setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
6819
+ }
6820
+ const fromSafetyFilterLevel = getValueByPath(fromObject, [
6821
+ 'safetyFilterLevel',
6822
+ ]);
6823
+ if (parentObject !== undefined && fromSafetyFilterLevel != null) {
6824
+ setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
6825
+ }
6826
+ const fromPersonGeneration = getValueByPath(fromObject, [
6827
+ 'personGeneration',
6828
+ ]);
6829
+ if (parentObject !== undefined && fromPersonGeneration != null) {
6830
+ setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
6831
+ }
6832
+ const fromIncludeSafetyAttributes = getValueByPath(fromObject, [
6833
+ 'includeSafetyAttributes',
6834
+ ]);
6835
+ if (parentObject !== undefined && fromIncludeSafetyAttributes != null) {
6836
+ setValueByPath(parentObject, ['parameters', 'includeSafetyAttributes'], fromIncludeSafetyAttributes);
6837
+ }
6838
+ const fromIncludeRaiReason = getValueByPath(fromObject, [
6839
+ 'includeRaiReason',
6840
+ ]);
6841
+ if (parentObject !== undefined && fromIncludeRaiReason != null) {
6842
+ setValueByPath(parentObject, ['parameters', 'includeRaiReason'], fromIncludeRaiReason);
6843
+ }
6844
+ const fromLanguage = getValueByPath(fromObject, ['language']);
6845
+ if (parentObject !== undefined && fromLanguage != null) {
6846
+ setValueByPath(parentObject, ['parameters', 'language'], fromLanguage);
6847
+ }
6848
+ const fromOutputMimeType = getValueByPath(fromObject, [
6849
+ 'outputMimeType',
6850
+ ]);
6851
+ if (parentObject !== undefined && fromOutputMimeType != null) {
6852
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
6853
+ }
6854
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
6855
+ 'outputCompressionQuality',
6856
+ ]);
6857
+ if (parentObject !== undefined && fromOutputCompressionQuality != null) {
6858
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
6859
+ }
6860
+ const fromEditMode = getValueByPath(fromObject, ['editMode']);
6861
+ if (parentObject !== undefined && fromEditMode != null) {
6862
+ setValueByPath(parentObject, ['parameters', 'editMode'], fromEditMode);
6863
+ }
6864
+ const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
6865
+ if (parentObject !== undefined && fromBaseSteps != null) {
6866
+ setValueByPath(parentObject, ['parameters', 'editConfig', 'baseSteps'], fromBaseSteps);
6867
+ }
6868
+ return toObject;
6869
+ }
6870
+ function editImageParametersInternalToVertex(apiClient, fromObject) {
6871
+ const toObject = {};
6872
+ const fromModel = getValueByPath(fromObject, ['model']);
6873
+ if (fromModel != null) {
6874
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
6875
+ }
6876
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
6877
+ if (fromPrompt != null) {
6878
+ setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
6879
+ }
6880
+ const fromReferenceImages = getValueByPath(fromObject, [
6881
+ 'referenceImages',
6882
+ ]);
6883
+ if (fromReferenceImages != null) {
6884
+ let transformedList = fromReferenceImages;
6885
+ if (Array.isArray(transformedList)) {
6886
+ transformedList = transformedList.map((item) => {
6887
+ return referenceImageAPIInternalToVertex(apiClient, item);
6888
+ });
6889
+ }
6890
+ setValueByPath(toObject, ['instances[0]', 'referenceImages'], transformedList);
6891
+ }
6892
+ const fromConfig = getValueByPath(fromObject, ['config']);
6893
+ if (fromConfig != null) {
6894
+ setValueByPath(toObject, ['config'], editImageConfigToVertex(apiClient, fromConfig, toObject));
6895
+ }
6896
+ return toObject;
6897
+ }
6898
+ function upscaleImageAPIConfigInternalToVertex(apiClient, fromObject, parentObject) {
6899
+ const toObject = {};
6900
+ const fromIncludeRaiReason = getValueByPath(fromObject, [
6901
+ 'includeRaiReason',
6902
+ ]);
6903
+ if (parentObject !== undefined && fromIncludeRaiReason != null) {
6904
+ setValueByPath(parentObject, ['parameters', 'includeRaiReason'], fromIncludeRaiReason);
6905
+ }
6906
+ const fromOutputMimeType = getValueByPath(fromObject, [
6907
+ 'outputMimeType',
6908
+ ]);
6909
+ if (parentObject !== undefined && fromOutputMimeType != null) {
6910
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
6911
+ }
6912
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
6913
+ 'outputCompressionQuality',
6914
+ ]);
6915
+ if (parentObject !== undefined && fromOutputCompressionQuality != null) {
6916
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
6917
+ }
6918
+ const fromNumberOfImages = getValueByPath(fromObject, [
6919
+ 'numberOfImages',
6920
+ ]);
6921
+ if (parentObject !== undefined && fromNumberOfImages != null) {
6922
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
6923
+ }
6924
+ const fromMode = getValueByPath(fromObject, ['mode']);
6925
+ if (parentObject !== undefined && fromMode != null) {
6926
+ setValueByPath(parentObject, ['parameters', 'mode'], fromMode);
6927
+ }
6928
+ return toObject;
6929
+ }
6930
+ function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject) {
6931
+ const toObject = {};
6932
+ const fromModel = getValueByPath(fromObject, ['model']);
6933
+ if (fromModel != null) {
6934
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
6935
+ }
6936
+ const fromImage = getValueByPath(fromObject, ['image']);
6937
+ if (fromImage != null) {
6938
+ setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
6939
+ }
6940
+ const fromUpscaleFactor = getValueByPath(fromObject, [
6941
+ 'upscaleFactor',
6942
+ ]);
6943
+ if (fromUpscaleFactor != null) {
6944
+ setValueByPath(toObject, ['parameters', 'upscaleConfig', 'upscaleFactor'], fromUpscaleFactor);
6945
+ }
6946
+ const fromConfig = getValueByPath(fromObject, ['config']);
6947
+ if (fromConfig != null) {
6948
+ setValueByPath(toObject, ['config'], upscaleImageAPIConfigInternalToVertex(apiClient, fromConfig, toObject));
6949
+ }
6950
+ return toObject;
6951
+ }
5965
6952
  function getModelParametersToVertex(apiClient, fromObject) {
5966
6953
  const toObject = {};
5967
6954
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -5974,6 +6961,34 @@ function getModelParametersToVertex(apiClient, fromObject) {
5974
6961
  }
5975
6962
  return toObject;
5976
6963
  }
6964
+ function listModelsConfigToVertex(apiClient, fromObject, parentObject) {
6965
+ const toObject = {};
6966
+ const fromPageSize = getValueByPath(fromObject, ['pageSize']);
6967
+ if (parentObject !== undefined && fromPageSize != null) {
6968
+ setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
6969
+ }
6970
+ const fromPageToken = getValueByPath(fromObject, ['pageToken']);
6971
+ if (parentObject !== undefined && fromPageToken != null) {
6972
+ setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
6973
+ }
6974
+ const fromFilter = getValueByPath(fromObject, ['filter']);
6975
+ if (parentObject !== undefined && fromFilter != null) {
6976
+ setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
6977
+ }
6978
+ const fromQueryBase = getValueByPath(fromObject, ['queryBase']);
6979
+ if (parentObject !== undefined && fromQueryBase != null) {
6980
+ setValueByPath(parentObject, ['_url', 'models_url'], tModelsUrl(apiClient, fromQueryBase));
6981
+ }
6982
+ return toObject;
6983
+ }
6984
+ function listModelsParametersToVertex(apiClient, fromObject) {
6985
+ const toObject = {};
6986
+ const fromConfig = getValueByPath(fromObject, ['config']);
6987
+ if (fromConfig != null) {
6988
+ setValueByPath(toObject, ['config'], listModelsConfigToVertex(apiClient, fromConfig, toObject));
6989
+ }
6990
+ return toObject;
6991
+ }
5977
6992
  function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
5978
6993
  const toObject = {};
5979
6994
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
@@ -5984,6 +6999,12 @@ function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
5984
6999
  if (parentObject !== undefined && fromDescription != null) {
5985
7000
  setValueByPath(parentObject, ['description'], fromDescription);
5986
7001
  }
7002
+ const fromDefaultCheckpointId = getValueByPath(fromObject, [
7003
+ 'defaultCheckpointId',
7004
+ ]);
7005
+ if (parentObject !== undefined && fromDefaultCheckpointId != null) {
7006
+ setValueByPath(parentObject, ['defaultCheckpointId'], fromDefaultCheckpointId);
7007
+ }
5987
7008
  return toObject;
5988
7009
  }
5989
7010
  function updateModelParametersToVertex(apiClient, fromObject) {
@@ -6080,22 +7101,6 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
6080
7101
  }
6081
7102
  return toObject;
6082
7103
  }
6083
- function imageToVertex(apiClient, fromObject) {
6084
- const toObject = {};
6085
- const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
6086
- if (fromGcsUri != null) {
6087
- setValueByPath(toObject, ['gcsUri'], fromGcsUri);
6088
- }
6089
- const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
6090
- if (fromImageBytes != null) {
6091
- setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
6092
- }
6093
- const fromMimeType = getValueByPath(fromObject, ['mimeType']);
6094
- if (fromMimeType != null) {
6095
- setValueByPath(toObject, ['mimeType'], fromMimeType);
6096
- }
6097
- return toObject;
6098
- }
6099
7104
  function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
6100
7105
  const toObject = {};
6101
7106
  const fromNumberOfVideos = getValueByPath(fromObject, [
@@ -6174,12 +7179,28 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
6174
7179
  }
6175
7180
  return toObject;
6176
7181
  }
7182
+ function blobFromMldev(apiClient, fromObject) {
7183
+ const toObject = {};
7184
+ const fromData = getValueByPath(fromObject, ['data']);
7185
+ if (fromData != null) {
7186
+ setValueByPath(toObject, ['data'], fromData);
7187
+ }
7188
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
7189
+ if (fromMimeType != null) {
7190
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
7191
+ }
7192
+ return toObject;
7193
+ }
6177
7194
  function partFromMldev(apiClient, fromObject) {
6178
7195
  const toObject = {};
6179
7196
  const fromThought = getValueByPath(fromObject, ['thought']);
6180
7197
  if (fromThought != null) {
6181
7198
  setValueByPath(toObject, ['thought'], fromThought);
6182
7199
  }
7200
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
7201
+ if (fromInlineData != null) {
7202
+ setValueByPath(toObject, ['inlineData'], blobFromMldev(apiClient, fromInlineData));
7203
+ }
6183
7204
  const fromCodeExecutionResult = getValueByPath(fromObject, [
6184
7205
  'codeExecutionResult',
6185
7206
  ]);
@@ -6206,10 +7227,6 @@ function partFromMldev(apiClient, fromObject) {
6206
7227
  if (fromFunctionResponse != null) {
6207
7228
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
6208
7229
  }
6209
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
6210
- if (fromInlineData != null) {
6211
- setValueByPath(toObject, ['inlineData'], fromInlineData);
6212
- }
6213
7230
  const fromText = getValueByPath(fromObject, ['text']);
6214
7231
  if (fromText != null) {
6215
7232
  setValueByPath(toObject, ['text'], fromText);
@@ -6484,6 +7501,26 @@ function modelFromMldev(apiClient, fromObject) {
6484
7501
  }
6485
7502
  return toObject;
6486
7503
  }
7504
+ function listModelsResponseFromMldev(apiClient, fromObject) {
7505
+ const toObject = {};
7506
+ const fromNextPageToken = getValueByPath(fromObject, [
7507
+ 'nextPageToken',
7508
+ ]);
7509
+ if (fromNextPageToken != null) {
7510
+ setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
7511
+ }
7512
+ const fromModels = getValueByPath(fromObject, ['_self']);
7513
+ if (fromModels != null) {
7514
+ let transformedList = tExtractModels(apiClient, fromModels);
7515
+ if (Array.isArray(transformedList)) {
7516
+ transformedList = transformedList.map((item) => {
7517
+ return modelFromMldev(apiClient, item);
7518
+ });
7519
+ }
7520
+ setValueByPath(toObject, ['models'], transformedList);
7521
+ }
7522
+ return toObject;
7523
+ }
6487
7524
  function deleteModelResponseFromMldev() {
6488
7525
  const toObject = {};
6489
7526
  return toObject;
@@ -6584,6 +7621,22 @@ function generateVideosOperationFromMldev$1(apiClient, fromObject) {
6584
7621
  }
6585
7622
  return toObject;
6586
7623
  }
7624
+ function blobFromVertex(apiClient, fromObject) {
7625
+ const toObject = {};
7626
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
7627
+ if (fromDisplayName != null) {
7628
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
7629
+ }
7630
+ const fromData = getValueByPath(fromObject, ['data']);
7631
+ if (fromData != null) {
7632
+ setValueByPath(toObject, ['data'], fromData);
7633
+ }
7634
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
7635
+ if (fromMimeType != null) {
7636
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
7637
+ }
7638
+ return toObject;
7639
+ }
6587
7640
  function partFromVertex(apiClient, fromObject) {
6588
7641
  const toObject = {};
6589
7642
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -6596,6 +7649,10 @@ function partFromVertex(apiClient, fromObject) {
6596
7649
  if (fromThought != null) {
6597
7650
  setValueByPath(toObject, ['thought'], fromThought);
6598
7651
  }
7652
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
7653
+ if (fromInlineData != null) {
7654
+ setValueByPath(toObject, ['inlineData'], blobFromVertex(apiClient, fromInlineData));
7655
+ }
6599
7656
  const fromCodeExecutionResult = getValueByPath(fromObject, [
6600
7657
  'codeExecutionResult',
6601
7658
  ]);
@@ -6622,10 +7679,6 @@ function partFromVertex(apiClient, fromObject) {
6622
7679
  if (fromFunctionResponse != null) {
6623
7680
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
6624
7681
  }
6625
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
6626
- if (fromInlineData != null) {
6627
- setValueByPath(toObject, ['inlineData'], fromInlineData);
6628
- }
6629
7682
  const fromText = getValueByPath(fromObject, ['text']);
6630
7683
  if (fromText != null) {
6631
7684
  setValueByPath(toObject, ['text'], fromText);
@@ -6885,6 +7938,38 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
6885
7938
  }
6886
7939
  return toObject;
6887
7940
  }
7941
+ function editImageResponseFromVertex(apiClient, fromObject) {
7942
+ const toObject = {};
7943
+ const fromGeneratedImages = getValueByPath(fromObject, [
7944
+ 'predictions',
7945
+ ]);
7946
+ if (fromGeneratedImages != null) {
7947
+ let transformedList = fromGeneratedImages;
7948
+ if (Array.isArray(transformedList)) {
7949
+ transformedList = transformedList.map((item) => {
7950
+ return generatedImageFromVertex(apiClient, item);
7951
+ });
7952
+ }
7953
+ setValueByPath(toObject, ['generatedImages'], transformedList);
7954
+ }
7955
+ return toObject;
7956
+ }
7957
+ function upscaleImageResponseFromVertex(apiClient, fromObject) {
7958
+ const toObject = {};
7959
+ const fromGeneratedImages = getValueByPath(fromObject, [
7960
+ 'predictions',
7961
+ ]);
7962
+ if (fromGeneratedImages != null) {
7963
+ let transformedList = fromGeneratedImages;
7964
+ if (Array.isArray(transformedList)) {
7965
+ transformedList = transformedList.map((item) => {
7966
+ return generatedImageFromVertex(apiClient, item);
7967
+ });
7968
+ }
7969
+ setValueByPath(toObject, ['generatedImages'], transformedList);
7970
+ }
7971
+ return toObject;
7972
+ }
6888
7973
  function endpointFromVertex(apiClient, fromObject) {
6889
7974
  const toObject = {};
6890
7975
  const fromName = getValueByPath(fromObject, ['endpoint']);
@@ -6918,6 +8003,22 @@ function tunedModelInfoFromVertex(apiClient, fromObject) {
6918
8003
  }
6919
8004
  return toObject;
6920
8005
  }
8006
+ function checkpointFromVertex(apiClient, fromObject) {
8007
+ const toObject = {};
8008
+ const fromCheckpointId = getValueByPath(fromObject, ['checkpointId']);
8009
+ if (fromCheckpointId != null) {
8010
+ setValueByPath(toObject, ['checkpointId'], fromCheckpointId);
8011
+ }
8012
+ const fromEpoch = getValueByPath(fromObject, ['epoch']);
8013
+ if (fromEpoch != null) {
8014
+ setValueByPath(toObject, ['epoch'], fromEpoch);
8015
+ }
8016
+ const fromStep = getValueByPath(fromObject, ['step']);
8017
+ if (fromStep != null) {
8018
+ setValueByPath(toObject, ['step'], fromStep);
8019
+ }
8020
+ return toObject;
8021
+ }
6921
8022
  function modelFromVertex(apiClient, fromObject) {
6922
8023
  const toObject = {};
6923
8024
  const fromName = getValueByPath(fromObject, ['name']);
@@ -6936,23 +8037,59 @@ function modelFromVertex(apiClient, fromObject) {
6936
8037
  if (fromVersion != null) {
6937
8038
  setValueByPath(toObject, ['version'], fromVersion);
6938
8039
  }
6939
- const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
6940
- if (fromEndpoints != null) {
6941
- let transformedList = fromEndpoints;
8040
+ const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
8041
+ if (fromEndpoints != null) {
8042
+ let transformedList = fromEndpoints;
8043
+ if (Array.isArray(transformedList)) {
8044
+ transformedList = transformedList.map((item) => {
8045
+ return endpointFromVertex(apiClient, item);
8046
+ });
8047
+ }
8048
+ setValueByPath(toObject, ['endpoints'], transformedList);
8049
+ }
8050
+ const fromLabels = getValueByPath(fromObject, ['labels']);
8051
+ if (fromLabels != null) {
8052
+ setValueByPath(toObject, ['labels'], fromLabels);
8053
+ }
8054
+ const fromTunedModelInfo = getValueByPath(fromObject, ['_self']);
8055
+ if (fromTunedModelInfo != null) {
8056
+ setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromVertex(apiClient, fromTunedModelInfo));
8057
+ }
8058
+ const fromDefaultCheckpointId = getValueByPath(fromObject, [
8059
+ 'defaultCheckpointId',
8060
+ ]);
8061
+ if (fromDefaultCheckpointId != null) {
8062
+ setValueByPath(toObject, ['defaultCheckpointId'], fromDefaultCheckpointId);
8063
+ }
8064
+ const fromCheckpoints = getValueByPath(fromObject, ['checkpoints']);
8065
+ if (fromCheckpoints != null) {
8066
+ let transformedList = fromCheckpoints;
8067
+ if (Array.isArray(transformedList)) {
8068
+ transformedList = transformedList.map((item) => {
8069
+ return checkpointFromVertex(apiClient, item);
8070
+ });
8071
+ }
8072
+ setValueByPath(toObject, ['checkpoints'], transformedList);
8073
+ }
8074
+ return toObject;
8075
+ }
8076
+ function listModelsResponseFromVertex(apiClient, fromObject) {
8077
+ const toObject = {};
8078
+ const fromNextPageToken = getValueByPath(fromObject, [
8079
+ 'nextPageToken',
8080
+ ]);
8081
+ if (fromNextPageToken != null) {
8082
+ setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
8083
+ }
8084
+ const fromModels = getValueByPath(fromObject, ['_self']);
8085
+ if (fromModels != null) {
8086
+ let transformedList = tExtractModels(apiClient, fromModels);
6942
8087
  if (Array.isArray(transformedList)) {
6943
8088
  transformedList = transformedList.map((item) => {
6944
- return endpointFromVertex(apiClient, item);
8089
+ return modelFromVertex(apiClient, item);
6945
8090
  });
6946
8091
  }
6947
- setValueByPath(toObject, ['endpoints'], transformedList);
6948
- }
6949
- const fromLabels = getValueByPath(fromObject, ['labels']);
6950
- if (fromLabels != null) {
6951
- setValueByPath(toObject, ['labels'], fromLabels);
6952
- }
6953
- const fromTunedModelInfo = getValueByPath(fromObject, ['_self']);
6954
- if (fromTunedModelInfo != null) {
6955
- setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromVertex(apiClient, fromTunedModelInfo));
8092
+ setValueByPath(toObject, ['models'], transformedList);
6956
8093
  }
6957
8094
  return toObject;
6958
8095
  }
@@ -7073,7 +8210,7 @@ const FUNCTION_RESPONSE_REQUIRES_ID = 'FunctionResponse request must have an `id
7073
8210
  * @param event The MessageEvent from the WebSocket.
7074
8211
  */
7075
8212
  async function handleWebSocketMessage(apiClient, onmessage, event) {
7076
- let serverMessage;
8213
+ const serverMessage = new LiveServerMessage();
7077
8214
  let data;
7078
8215
  if (event.data instanceof Blob) {
7079
8216
  data = JSON.parse(await event.data.text());
@@ -7082,10 +8219,12 @@ async function handleWebSocketMessage(apiClient, onmessage, event) {
7082
8219
  data = JSON.parse(event.data);
7083
8220
  }
7084
8221
  if (apiClient.isVertexAI()) {
7085
- serverMessage = liveServerMessageFromVertex(apiClient, data);
8222
+ const resp = liveServerMessageFromVertex(apiClient, data);
8223
+ Object.assign(serverMessage, resp);
7086
8224
  }
7087
8225
  else {
7088
- serverMessage = liveServerMessageFromMldev(apiClient, data);
8226
+ const resp = liveServerMessageFromMldev(apiClient, data);
8227
+ Object.assign(serverMessage, resp);
7089
8228
  }
7090
8229
  onmessage(serverMessage);
7091
8230
  }
@@ -7542,9 +8681,7 @@ class Models extends BaseModule {
7542
8681
  /**
7543
8682
  * Generates an image based on a text description and configuration.
7544
8683
  *
7545
- * @param model - The model to use.
7546
- * @param prompt - A text description of the image to generate.
7547
- * @param [config] - The config for image generation.
8684
+ * @param params - The parameters for generating images.
7548
8685
  * @return The response from the API.
7549
8686
  *
7550
8687
  * @example
@@ -7592,6 +8729,97 @@ class Models extends BaseModule {
7592
8729
  return response;
7593
8730
  });
7594
8731
  };
8732
+ this.list = async (params) => {
8733
+ var _a;
8734
+ const defaultConfig = {
8735
+ queryBase: true,
8736
+ };
8737
+ const actualConfig = Object.assign(Object.assign({}, defaultConfig), params === null || params === void 0 ? void 0 : params.config);
8738
+ const actualParams = {
8739
+ config: actualConfig,
8740
+ };
8741
+ if (this.apiClient.isVertexAI()) {
8742
+ if (!actualParams.config.queryBase) {
8743
+ if ((_a = actualParams.config) === null || _a === void 0 ? void 0 : _a.filter) {
8744
+ throw new Error('Filtering tuned models list for Vertex AI is not currently supported');
8745
+ }
8746
+ else {
8747
+ actualParams.config.filter = 'labels.tune-type:*';
8748
+ }
8749
+ }
8750
+ }
8751
+ return new Pager(exports.PagedItem.PAGED_ITEM_MODELS, (x) => this.listInternal(x), await this.listInternal(actualParams), actualParams);
8752
+ };
8753
+ /**
8754
+ * Edits an image based on a prompt, list of reference images, and configuration.
8755
+ *
8756
+ * @param params - The parameters for editing an image.
8757
+ * @return The response from the API.
8758
+ *
8759
+ * @example
8760
+ * ```ts
8761
+ * const response = await client.models.editImage({
8762
+ * model: 'imagen-3.0-capability-001',
8763
+ * prompt: 'Generate an image containing a mug with the product logo [1] visible on the side of the mug.',
8764
+ * referenceImages: [subjectReferenceImage]
8765
+ * config: {
8766
+ * numberOfImages: 1,
8767
+ * includeRaiReason: true,
8768
+ * },
8769
+ * });
8770
+ * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
8771
+ * ```
8772
+ */
8773
+ this.editImage = async (params) => {
8774
+ const paramsInternal = {
8775
+ model: params.model,
8776
+ prompt: params.prompt,
8777
+ referenceImages: [],
8778
+ config: params.config,
8779
+ };
8780
+ if (params.referenceImages) {
8781
+ if (params.referenceImages) {
8782
+ paramsInternal.referenceImages = params.referenceImages.map((img) => img.toReferenceImageAPI());
8783
+ }
8784
+ }
8785
+ return await this.editImageInternal(paramsInternal);
8786
+ };
8787
+ /**
8788
+ * Upscales an image based on an image, upscale factor, and configuration.
8789
+ * Only supported in Vertex AI currently.
8790
+ *
8791
+ * @param params - The parameters for upscaling an image.
8792
+ * @return The response from the API.
8793
+ *
8794
+ * @example
8795
+ * ```ts
8796
+ * const response = await client.models.upscaleImage({
8797
+ * model: 'imagen-3.0-generate-002',
8798
+ * image: image,
8799
+ * upscaleFactor: 'x2',
8800
+ * config: {
8801
+ * includeRaiReason: true,
8802
+ * },
8803
+ * });
8804
+ * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
8805
+ * ```
8806
+ */
8807
+ this.upscaleImage = async (params) => {
8808
+ let apiConfig = {
8809
+ numberOfImages: 1,
8810
+ mode: 'upscale',
8811
+ };
8812
+ if (params.config) {
8813
+ apiConfig = Object.assign(Object.assign({}, apiConfig), params.config);
8814
+ }
8815
+ const apiParams = {
8816
+ model: params.model,
8817
+ image: params.image,
8818
+ upscaleFactor: params.upscaleFactor,
8819
+ config: apiConfig,
8820
+ };
8821
+ return await this.upscaleImageInternal(apiParams);
8822
+ };
7595
8823
  }
7596
8824
  async generateContentInternal(params) {
7597
8825
  var _a, _b, _c, _d;
@@ -7893,6 +9121,76 @@ class Models extends BaseModule {
7893
9121
  });
7894
9122
  }
7895
9123
  }
9124
+ async editImageInternal(params) {
9125
+ var _a, _b;
9126
+ let response;
9127
+ let path = '';
9128
+ let queryParams = {};
9129
+ if (this.apiClient.isVertexAI()) {
9130
+ const body = editImageParametersInternalToVertex(this.apiClient, params);
9131
+ path = formatMap('{model}:predict', body['_url']);
9132
+ queryParams = body['_query'];
9133
+ delete body['config'];
9134
+ delete body['_url'];
9135
+ delete body['_query'];
9136
+ response = this.apiClient
9137
+ .request({
9138
+ path: path,
9139
+ queryParams: queryParams,
9140
+ body: JSON.stringify(body),
9141
+ httpMethod: 'POST',
9142
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
9143
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
9144
+ })
9145
+ .then((httpResponse) => {
9146
+ return httpResponse.json();
9147
+ });
9148
+ return response.then((apiResponse) => {
9149
+ const resp = editImageResponseFromVertex(this.apiClient, apiResponse);
9150
+ const typedResp = new EditImageResponse();
9151
+ Object.assign(typedResp, resp);
9152
+ return typedResp;
9153
+ });
9154
+ }
9155
+ else {
9156
+ throw new Error('This method is only supported by the Vertex AI.');
9157
+ }
9158
+ }
9159
+ async upscaleImageInternal(params) {
9160
+ var _a, _b;
9161
+ let response;
9162
+ let path = '';
9163
+ let queryParams = {};
9164
+ if (this.apiClient.isVertexAI()) {
9165
+ const body = upscaleImageAPIParametersInternalToVertex(this.apiClient, params);
9166
+ path = formatMap('{model}:predict', body['_url']);
9167
+ queryParams = body['_query'];
9168
+ delete body['config'];
9169
+ delete body['_url'];
9170
+ delete body['_query'];
9171
+ response = this.apiClient
9172
+ .request({
9173
+ path: path,
9174
+ queryParams: queryParams,
9175
+ body: JSON.stringify(body),
9176
+ httpMethod: 'POST',
9177
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
9178
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
9179
+ })
9180
+ .then((httpResponse) => {
9181
+ return httpResponse.json();
9182
+ });
9183
+ return response.then((apiResponse) => {
9184
+ const resp = upscaleImageResponseFromVertex(this.apiClient, apiResponse);
9185
+ const typedResp = new UpscaleImageResponse();
9186
+ Object.assign(typedResp, resp);
9187
+ return typedResp;
9188
+ });
9189
+ }
9190
+ else {
9191
+ throw new Error('This method is only supported by the Vertex AI.');
9192
+ }
9193
+ }
7896
9194
  /**
7897
9195
  * Fetches information about a model by name.
7898
9196
  *
@@ -7955,6 +9253,64 @@ class Models extends BaseModule {
7955
9253
  });
7956
9254
  }
7957
9255
  }
9256
+ async listInternal(params) {
9257
+ var _a, _b, _c, _d;
9258
+ let response;
9259
+ let path = '';
9260
+ let queryParams = {};
9261
+ if (this.apiClient.isVertexAI()) {
9262
+ const body = listModelsParametersToVertex(this.apiClient, params);
9263
+ path = formatMap('{models_url}', body['_url']);
9264
+ queryParams = body['_query'];
9265
+ delete body['config'];
9266
+ delete body['_url'];
9267
+ delete body['_query'];
9268
+ response = this.apiClient
9269
+ .request({
9270
+ path: path,
9271
+ queryParams: queryParams,
9272
+ body: JSON.stringify(body),
9273
+ httpMethod: 'GET',
9274
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
9275
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
9276
+ })
9277
+ .then((httpResponse) => {
9278
+ return httpResponse.json();
9279
+ });
9280
+ return response.then((apiResponse) => {
9281
+ const resp = listModelsResponseFromVertex(this.apiClient, apiResponse);
9282
+ const typedResp = new ListModelsResponse();
9283
+ Object.assign(typedResp, resp);
9284
+ return typedResp;
9285
+ });
9286
+ }
9287
+ else {
9288
+ const body = listModelsParametersToMldev(this.apiClient, params);
9289
+ path = formatMap('{models_url}', body['_url']);
9290
+ queryParams = body['_query'];
9291
+ delete body['config'];
9292
+ delete body['_url'];
9293
+ delete body['_query'];
9294
+ response = this.apiClient
9295
+ .request({
9296
+ path: path,
9297
+ queryParams: queryParams,
9298
+ body: JSON.stringify(body),
9299
+ httpMethod: 'GET',
9300
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
9301
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
9302
+ })
9303
+ .then((httpResponse) => {
9304
+ return httpResponse.json();
9305
+ });
9306
+ return response.then((apiResponse) => {
9307
+ const resp = listModelsResponseFromMldev(this.apiClient, apiResponse);
9308
+ const typedResp = new ListModelsResponse();
9309
+ Object.assign(typedResp, resp);
9310
+ return typedResp;
9311
+ });
9312
+ }
9313
+ }
7958
9314
  /**
7959
9315
  * Updates a tuned model by its name.
7960
9316
  *
@@ -8650,7 +10006,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
8650
10006
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
8651
10007
  const USER_AGENT_HEADER = 'User-Agent';
8652
10008
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
8653
- const SDK_VERSION = '0.12.0'; // x-release-please-version
10009
+ const SDK_VERSION = '0.14.0'; // x-release-please-version
8654
10010
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
8655
10011
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
8656
10012
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -8697,18 +10053,11 @@ class ApiClient {
8697
10053
  if (this.clientOptions.vertexai) {
8698
10054
  initHttpOptions.apiVersion =
8699
10055
  (_a = this.clientOptions.apiVersion) !== null && _a !== void 0 ? _a : VERTEX_AI_API_DEFAULT_VERSION;
8700
- // Assume that proj/api key validation occurs before they are passed in.
8701
- if (this.getProject() || this.getLocation()) {
8702
- initHttpOptions.baseUrl = `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
8703
- this.clientOptions.apiKey = undefined; // unset API key.
8704
- }
8705
- else {
8706
- initHttpOptions.baseUrl = `https://aiplatform.googleapis.com/`;
8707
- this.clientOptions.project = undefined; // unset project.
8708
- this.clientOptions.location = undefined; // unset location.
8709
- }
10056
+ initHttpOptions.baseUrl = this.baseUrlFromProjectLocation();
10057
+ this.normalizeAuthParameters();
8710
10058
  }
8711
10059
  else {
10060
+ // Gemini API
8712
10061
  initHttpOptions.apiVersion =
8713
10062
  (_b = this.clientOptions.apiVersion) !== null && _b !== void 0 ? _b : GOOGLE_AI_API_DEFAULT_VERSION;
8714
10063
  initHttpOptions.baseUrl = `https://generativelanguage.googleapis.com/`;
@@ -8719,6 +10068,39 @@ class ApiClient {
8719
10068
  this.clientOptions.httpOptions = this.patchHttpOptions(initHttpOptions, opts.httpOptions);
8720
10069
  }
8721
10070
  }
10071
+ /**
10072
+ * Determines the base URL for Vertex AI based on project and location.
10073
+ * Uses the global endpoint if location is 'global' or if project/location
10074
+ * are not specified (implying API key usage).
10075
+ * @private
10076
+ */
10077
+ baseUrlFromProjectLocation() {
10078
+ if (this.clientOptions.project &&
10079
+ this.clientOptions.location &&
10080
+ this.clientOptions.location !== 'global') {
10081
+ // Regional endpoint
10082
+ return `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
10083
+ }
10084
+ // Global endpoint (covers 'global' location and API key usage)
10085
+ return `https://aiplatform.googleapis.com/`;
10086
+ }
10087
+ /**
10088
+ * Normalizes authentication parameters for Vertex AI.
10089
+ * If project and location are provided, API key is cleared.
10090
+ * If project and location are not provided (implying API key usage),
10091
+ * project and location are cleared.
10092
+ * @private
10093
+ */
10094
+ normalizeAuthParameters() {
10095
+ if (this.clientOptions.project && this.clientOptions.location) {
10096
+ // Using project/location for auth, clear potential API key
10097
+ this.clientOptions.apiKey = undefined;
10098
+ return;
10099
+ }
10100
+ // Using API key for auth (or no auth provided yet), clear project/location
10101
+ this.clientOptions.project = undefined;
10102
+ this.clientOptions.location = undefined;
10103
+ }
8722
10104
  isVertexAI() {
8723
10105
  var _a;
8724
10106
  return (_a = this.clientOptions.vertexai) !== null && _a !== void 0 ? _a : false;
@@ -9056,6 +10438,16 @@ class ApiClient {
9056
10438
  const uploadUrl = await this.fetchUploadUrl(fileToUpload, config);
9057
10439
  return uploader.upload(file, uploadUrl, this);
9058
10440
  }
10441
+ /**
10442
+ * Downloads a file asynchronously to the specified path.
10443
+ *
10444
+ * @params params - The parameters for the download request, see {@link
10445
+ * DownloadFileParameters}
10446
+ */
10447
+ async downloadFile(params) {
10448
+ const downloader = this.clientOptions.downloader;
10449
+ await downloader.download(params, this);
10450
+ }
9059
10451
  async fetchUploadUrl(file, config) {
9060
10452
  var _a;
9061
10453
  let httpOptions = {};
@@ -9201,6 +10593,66 @@ function buildGoogleAuthOptions(googleAuthOptions) {
9201
10593
  }
9202
10594
  }
9203
10595
 
10596
+ /**
10597
+ * @license
10598
+ * Copyright 2025 Google LLC
10599
+ * SPDX-License-Identifier: Apache-2.0
10600
+ */
10601
+ class NodeDownloader {
10602
+ async download(params, apiClient) {
10603
+ if (params.downloadPath) {
10604
+ const response = await downloadFile(params, apiClient);
10605
+ if (response instanceof HttpResponse) {
10606
+ const writer = fs.createWriteStream(params.downloadPath);
10607
+ node_stream.Readable.fromWeb(response.responseInternal.body).pipe(writer);
10608
+ }
10609
+ else {
10610
+ fs.writeFile(params.downloadPath, response, { encoding: 'base64' }, (error) => {
10611
+ if (error) {
10612
+ throw new Error(`Failed to write file to ${params.downloadPath}: ${error}`);
10613
+ }
10614
+ });
10615
+ }
10616
+ }
10617
+ }
10618
+ }
10619
+ async function downloadFile(params, apiClient) {
10620
+ var _a, _b, _c;
10621
+ const name = tFileName(apiClient, params.file);
10622
+ if (name !== undefined) {
10623
+ return await apiClient.request({
10624
+ path: `files/${name}:download`,
10625
+ httpMethod: 'GET',
10626
+ queryParams: {
10627
+ 'alt': 'media',
10628
+ },
10629
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
10630
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
10631
+ });
10632
+ }
10633
+ else if (isGeneratedVideo(params.file)) {
10634
+ const videoBytes = (_c = params.file.video) === null || _c === void 0 ? void 0 : _c.videoBytes;
10635
+ if (typeof videoBytes === 'string') {
10636
+ return videoBytes;
10637
+ }
10638
+ else {
10639
+ throw new Error('Failed to download generated video, Uri or videoBytes not found.');
10640
+ }
10641
+ }
10642
+ else if (isVideo(params.file)) {
10643
+ const videoBytes = params.file.videoBytes;
10644
+ if (typeof videoBytes === 'string') {
10645
+ return videoBytes;
10646
+ }
10647
+ else {
10648
+ throw new Error('Failed to download video, Uri or videoBytes not found.');
10649
+ }
10650
+ }
10651
+ else {
10652
+ throw new Error('Unsupported file type');
10653
+ }
10654
+ }
10655
+
9204
10656
  /**
9205
10657
  * @license
9206
10658
  * Copyright 2025 Google LLC
@@ -9332,6 +10784,10 @@ function createTuningJobConfigToMldev(apiClient, fromObject, parentObject) {
9332
10784
  if (fromLearningRateMultiplier != null) {
9333
10785
  setValueByPath(toObject, ['tuningTask', 'hyperparameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
9334
10786
  }
10787
+ if (getValueByPath(fromObject, ['exportLastCheckpointOnly']) !==
10788
+ undefined) {
10789
+ throw new Error('exportLastCheckpointOnly parameter is not supported in Gemini API.');
10790
+ }
9335
10791
  if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
9336
10792
  throw new Error('adapterSize parameter is not supported in Gemini API.');
9337
10793
  }
@@ -9446,6 +10902,12 @@ function createTuningJobConfigToVertex(apiClient, fromObject, parentObject) {
9446
10902
  if (parentObject !== undefined && fromLearningRateMultiplier != null) {
9447
10903
  setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
9448
10904
  }
10905
+ const fromExportLastCheckpointOnly = getValueByPath(fromObject, [
10906
+ 'exportLastCheckpointOnly',
10907
+ ]);
10908
+ if (parentObject !== undefined && fromExportLastCheckpointOnly != null) {
10909
+ setValueByPath(parentObject, ['supervisedTuningSpec', 'exportLastCheckpointOnly'], fromExportLastCheckpointOnly);
10910
+ }
9449
10911
  const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
9450
10912
  if (parentObject !== undefined && fromAdapterSize != null) {
9451
10913
  setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
@@ -9598,6 +11060,26 @@ function operationFromMldev(apiClient, fromObject) {
9598
11060
  }
9599
11061
  return toObject;
9600
11062
  }
11063
+ function tunedModelCheckpointFromVertex(apiClient, fromObject) {
11064
+ const toObject = {};
11065
+ const fromCheckpointId = getValueByPath(fromObject, ['checkpointId']);
11066
+ if (fromCheckpointId != null) {
11067
+ setValueByPath(toObject, ['checkpointId'], fromCheckpointId);
11068
+ }
11069
+ const fromEpoch = getValueByPath(fromObject, ['epoch']);
11070
+ if (fromEpoch != null) {
11071
+ setValueByPath(toObject, ['epoch'], fromEpoch);
11072
+ }
11073
+ const fromStep = getValueByPath(fromObject, ['step']);
11074
+ if (fromStep != null) {
11075
+ setValueByPath(toObject, ['step'], fromStep);
11076
+ }
11077
+ const fromEndpoint = getValueByPath(fromObject, ['endpoint']);
11078
+ if (fromEndpoint != null) {
11079
+ setValueByPath(toObject, ['endpoint'], fromEndpoint);
11080
+ }
11081
+ return toObject;
11082
+ }
9601
11083
  function tunedModelFromVertex(apiClient, fromObject) {
9602
11084
  const toObject = {};
9603
11085
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -9608,6 +11090,16 @@ function tunedModelFromVertex(apiClient, fromObject) {
9608
11090
  if (fromEndpoint != null) {
9609
11091
  setValueByPath(toObject, ['endpoint'], fromEndpoint);
9610
11092
  }
11093
+ const fromCheckpoints = getValueByPath(fromObject, ['checkpoints']);
11094
+ if (fromCheckpoints != null) {
11095
+ let transformedList = fromCheckpoints;
11096
+ if (Array.isArray(transformedList)) {
11097
+ transformedList = transformedList.map((item) => {
11098
+ return tunedModelCheckpointFromVertex(apiClient, item);
11099
+ });
11100
+ }
11101
+ setValueByPath(toObject, ['checkpoints'], transformedList);
11102
+ }
9611
11103
  return toObject;
9612
11104
  }
9613
11105
  function tuningJobFromVertex(apiClient, fromObject) {
@@ -9969,8 +11461,12 @@ class Tunings extends BaseModule {
9969
11461
  }
9970
11462
 
9971
11463
  const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
11464
+ const MAX_RETRY_COUNT = 3;
11465
+ const INITIAL_RETRY_DELAY_MS = 1000;
11466
+ const DELAY_MULTIPLIER = 2;
11467
+ const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
9972
11468
  async function uploadBlob(file, uploadUrl, apiClient) {
9973
- var _a, _b;
11469
+ var _a, _b, _c;
9974
11470
  let fileSize = 0;
9975
11471
  let offset = 0;
9976
11472
  let response = new HttpResponse(new Response());
@@ -9982,24 +11478,34 @@ async function uploadBlob(file, uploadUrl, apiClient) {
9982
11478
  if (offset + chunkSize >= fileSize) {
9983
11479
  uploadCommand += ', finalize';
9984
11480
  }
9985
- response = await apiClient.request({
9986
- path: '',
9987
- body: chunk,
9988
- httpMethod: 'POST',
9989
- httpOptions: {
9990
- apiVersion: '',
9991
- baseUrl: uploadUrl,
9992
- headers: {
9993
- 'X-Goog-Upload-Command': uploadCommand,
9994
- 'X-Goog-Upload-Offset': String(offset),
9995
- 'Content-Length': String(chunkSize),
11481
+ let retryCount = 0;
11482
+ let currentDelayMs = INITIAL_RETRY_DELAY_MS;
11483
+ while (retryCount < MAX_RETRY_COUNT) {
11484
+ response = await apiClient.request({
11485
+ path: '',
11486
+ body: chunk,
11487
+ httpMethod: 'POST',
11488
+ httpOptions: {
11489
+ apiVersion: '',
11490
+ baseUrl: uploadUrl,
11491
+ headers: {
11492
+ 'X-Goog-Upload-Command': uploadCommand,
11493
+ 'X-Goog-Upload-Offset': String(offset),
11494
+ 'Content-Length': String(chunkSize),
11495
+ },
9996
11496
  },
9997
- },
9998
- });
11497
+ });
11498
+ if ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
11499
+ break;
11500
+ }
11501
+ retryCount++;
11502
+ await sleep(currentDelayMs);
11503
+ currentDelayMs = currentDelayMs * DELAY_MULTIPLIER;
11504
+ }
9999
11505
  offset += chunkSize;
10000
11506
  // The `x-goog-upload-status` header field can be `active`, `final` and
10001
11507
  //`cancelled` in resposne.
10002
- if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a['x-goog-upload-status']) !== 'active') {
11508
+ if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
10003
11509
  break;
10004
11510
  }
10005
11511
  // TODO(b/401391430) Investigate why the upload status is not finalized
@@ -10009,7 +11515,7 @@ async function uploadBlob(file, uploadUrl, apiClient) {
10009
11515
  }
10010
11516
  }
10011
11517
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
10012
- if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b['x-goog-upload-status']) !== 'final') {
11518
+ if (((_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
10013
11519
  throw new Error('Failed to upload file: Upload status is not finalized.');
10014
11520
  }
10015
11521
  return responseJson['file'];
@@ -10018,6 +11524,9 @@ async function getBlobStat(file) {
10018
11524
  const fileStat = { size: file.size, type: file.type };
10019
11525
  return fileStat;
10020
11526
  }
11527
+ function sleep(ms) {
11528
+ return new Promise((resolvePromise) => setTimeout(resolvePromise, ms));
11529
+ }
10021
11530
 
10022
11531
  /**
10023
11532
  * @license
@@ -10136,7 +11645,7 @@ class NodeUploader {
10136
11645
  return mimeType;
10137
11646
  }
10138
11647
  async uploadFileFromPath(file, uploadUrl, apiClient) {
10139
- var _a, _b;
11648
+ var _a, _b, _c;
10140
11649
  let fileSize = 0;
10141
11650
  let offset = 0;
10142
11651
  let response = new HttpResponse(new Response());
@@ -10159,24 +11668,34 @@ class NodeUploader {
10159
11668
  throw new Error(`Failed to read ${chunkSize} bytes from file at offset ${offset}. bytes actually read: ${bytesRead}`);
10160
11669
  }
10161
11670
  const chunk = new Blob([buffer]);
10162
- response = await apiClient.request({
10163
- path: '',
10164
- body: chunk,
10165
- httpMethod: 'POST',
10166
- httpOptions: {
10167
- apiVersion: '',
10168
- baseUrl: uploadUrl,
10169
- headers: {
10170
- 'X-Goog-Upload-Command': uploadCommand,
10171
- 'X-Goog-Upload-Offset': String(offset),
10172
- 'Content-Length': String(bytesRead),
11671
+ let retryCount = 0;
11672
+ let currentDelayMs = INITIAL_RETRY_DELAY_MS;
11673
+ while (retryCount < MAX_RETRY_COUNT) {
11674
+ response = await apiClient.request({
11675
+ path: '',
11676
+ body: chunk,
11677
+ httpMethod: 'POST',
11678
+ httpOptions: {
11679
+ apiVersion: '',
11680
+ baseUrl: uploadUrl,
11681
+ headers: {
11682
+ 'X-Goog-Upload-Command': uploadCommand,
11683
+ 'X-Goog-Upload-Offset': String(offset),
11684
+ 'Content-Length': String(bytesRead),
11685
+ },
10173
11686
  },
10174
- },
10175
- });
11687
+ });
11688
+ if ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
11689
+ break;
11690
+ }
11691
+ retryCount++;
11692
+ await sleep(currentDelayMs);
11693
+ currentDelayMs = currentDelayMs * DELAY_MULTIPLIER;
11694
+ }
10176
11695
  offset += bytesRead;
10177
11696
  // The `x-goog-upload-status` header field can be `active`, `final` and
10178
11697
  //`cancelled` in resposne.
10179
- if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a['x-goog-upload-status']) !== 'active') {
11698
+ if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
10180
11699
  break;
10181
11700
  }
10182
11701
  if (fileSize <= offset) {
@@ -10184,7 +11703,7 @@ class NodeUploader {
10184
11703
  }
10185
11704
  }
10186
11705
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
10187
- if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b['x-goog-upload-status']) !== 'final') {
11706
+ if (((_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
10188
11707
  throw new Error('Failed to upload file: Upload status is not finalized.');
10189
11708
  }
10190
11709
  return responseJson['file'];
@@ -10306,6 +11825,7 @@ class GoogleGenAI {
10306
11825
  httpOptions: options.httpOptions,
10307
11826
  userAgentExtra: LANGUAGE_LABEL_PREFIX + process.version,
10308
11827
  uploader: new NodeUploader(),
11828
+ downloader: new NodeDownloader(),
10309
11829
  });
10310
11830
  this.models = new Models(this.apiClient);
10311
11831
  this.live = new Live(this.apiClient, auth, new NodeWebSocketFactory());
@@ -10334,11 +11854,13 @@ exports.Caches = Caches;
10334
11854
  exports.Chat = Chat;
10335
11855
  exports.Chats = Chats;
10336
11856
  exports.ComputeTokensResponse = ComputeTokensResponse;
11857
+ exports.ControlReferenceImage = ControlReferenceImage;
10337
11858
  exports.CountTokensResponse = CountTokensResponse;
10338
11859
  exports.CreateFileResponse = CreateFileResponse;
10339
11860
  exports.DeleteCachedContentResponse = DeleteCachedContentResponse;
10340
11861
  exports.DeleteFileResponse = DeleteFileResponse;
10341
11862
  exports.DeleteModelResponse = DeleteModelResponse;
11863
+ exports.EditImageResponse = EditImageResponse;
10342
11864
  exports.EmbedContentResponse = EmbedContentResponse;
10343
11865
  exports.Files = Files;
10344
11866
  exports.FunctionResponse = FunctionResponse;
@@ -10351,15 +11873,22 @@ exports.GoogleGenAI = GoogleGenAI;
10351
11873
  exports.HttpResponse = HttpResponse;
10352
11874
  exports.ListCachedContentsResponse = ListCachedContentsResponse;
10353
11875
  exports.ListFilesResponse = ListFilesResponse;
11876
+ exports.ListModelsResponse = ListModelsResponse;
10354
11877
  exports.ListTuningJobsResponse = ListTuningJobsResponse;
10355
11878
  exports.Live = Live;
10356
11879
  exports.LiveClientToolResponse = LiveClientToolResponse;
10357
11880
  exports.LiveSendToolResponseParameters = LiveSendToolResponseParameters;
11881
+ exports.LiveServerMessage = LiveServerMessage;
11882
+ exports.MaskReferenceImage = MaskReferenceImage;
10358
11883
  exports.Models = Models;
10359
11884
  exports.Operations = Operations;
10360
11885
  exports.Pager = Pager;
11886
+ exports.RawReferenceImage = RawReferenceImage;
10361
11887
  exports.ReplayResponse = ReplayResponse;
10362
11888
  exports.Session = Session;
11889
+ exports.StyleReferenceImage = StyleReferenceImage;
11890
+ exports.SubjectReferenceImage = SubjectReferenceImage;
11891
+ exports.UpscaleImageResponse = UpscaleImageResponse;
10363
11892
  exports.createModelContent = createModelContent;
10364
11893
  exports.createPartFromBase64 = createPartFromBase64;
10365
11894
  exports.createPartFromCodeExecutionResult = createPartFromCodeExecutionResult;