@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.
@@ -519,15 +519,81 @@ function tBytes(apiClient, fromImageBytes) {
519
519
  // TODO(b/389133914): Remove dummy bytes converter.
520
520
  return fromImageBytes;
521
521
  }
522
+ function _isFile(origin) {
523
+ return (origin !== null &&
524
+ origin !== undefined &&
525
+ typeof origin === 'object' &&
526
+ 'name' in origin);
527
+ }
528
+ function isGeneratedVideo(origin) {
529
+ return (origin !== null &&
530
+ origin !== undefined &&
531
+ typeof origin === 'object' &&
532
+ 'video' in origin);
533
+ }
534
+ function isVideo(origin) {
535
+ return (origin !== null &&
536
+ origin !== undefined &&
537
+ typeof origin === 'object' &&
538
+ 'uri' in origin);
539
+ }
522
540
  function tFileName(apiClient, fromName) {
523
- if (typeof fromName !== 'string') {
524
- throw new Error('fromName must be a string');
541
+ var _a;
542
+ let name;
543
+ if (_isFile(fromName)) {
544
+ name = fromName.name;
545
+ }
546
+ if (isVideo(fromName)) {
547
+ name = fromName.uri;
548
+ if (name === undefined) {
549
+ return undefined;
550
+ }
525
551
  }
526
- // Remove the files/ prefx for MLdev urls to get the actual name of the file.
527
- if (fromName.startsWith('files/')) {
528
- return fromName.split('files/')[1];
552
+ if (isGeneratedVideo(fromName)) {
553
+ name = (_a = fromName.video) === null || _a === void 0 ? void 0 : _a.uri;
554
+ if (name === undefined) {
555
+ return undefined;
556
+ }
557
+ }
558
+ if (typeof fromName === 'string') {
559
+ name = fromName;
560
+ }
561
+ if (name === undefined) {
562
+ throw new Error('Could not extract file name from the provided input.');
563
+ }
564
+ if (name.startsWith('https://')) {
565
+ const suffix = name.split('files/')[1];
566
+ const match = suffix.match(/[a-z0-9]+/);
567
+ if (match === null) {
568
+ throw new Error(`Could not extract file name from URI ${name}`);
569
+ }
570
+ name = match[0];
571
+ }
572
+ else if (name.startsWith('files/')) {
573
+ name = name.split('files/')[1];
574
+ }
575
+ return name;
576
+ }
577
+ function tModelsUrl(apiClient, baseModels) {
578
+ let res;
579
+ if (apiClient.isVertexAI()) {
580
+ res = baseModels ? 'publishers/google/models' : 'models';
581
+ }
582
+ else {
583
+ res = baseModels ? 'models' : 'tunedModels';
529
584
  }
530
- return fromName;
585
+ return res;
586
+ }
587
+ function tExtractModels(apiClient, response) {
588
+ for (const key of ['models', 'tunedModels', 'publisherModels']) {
589
+ if (hasField(response, key)) {
590
+ return response[key];
591
+ }
592
+ }
593
+ return [];
594
+ }
595
+ function hasField(data, fieldName) {
596
+ return data !== null && typeof data === 'object' && fieldName in data;
531
597
  }
532
598
 
533
599
  /**
@@ -535,6 +601,21 @@ function tFileName(apiClient, fromName) {
535
601
  * Copyright 2025 Google LLC
536
602
  * SPDX-License-Identifier: Apache-2.0
537
603
  */
604
+ function blobToMldev$2(apiClient, fromObject) {
605
+ const toObject = {};
606
+ if (getValueByPath(fromObject, ['displayName']) !== undefined) {
607
+ throw new Error('displayName parameter is not supported in Gemini API.');
608
+ }
609
+ const fromData = getValueByPath(fromObject, ['data']);
610
+ if (fromData != null) {
611
+ setValueByPath(toObject, ['data'], fromData);
612
+ }
613
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
614
+ if (fromMimeType != null) {
615
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
616
+ }
617
+ return toObject;
618
+ }
538
619
  function partToMldev$2(apiClient, fromObject) {
539
620
  const toObject = {};
540
621
  if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
@@ -544,6 +625,10 @@ function partToMldev$2(apiClient, fromObject) {
544
625
  if (fromThought != null) {
545
626
  setValueByPath(toObject, ['thought'], fromThought);
546
627
  }
628
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
629
+ if (fromInlineData != null) {
630
+ setValueByPath(toObject, ['inlineData'], blobToMldev$2(apiClient, fromInlineData));
631
+ }
547
632
  const fromCodeExecutionResult = getValueByPath(fromObject, [
548
633
  'codeExecutionResult',
549
634
  ]);
@@ -570,10 +655,6 @@ function partToMldev$2(apiClient, fromObject) {
570
655
  if (fromFunctionResponse != null) {
571
656
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
572
657
  }
573
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
574
- if (fromInlineData != null) {
575
- setValueByPath(toObject, ['inlineData'], fromInlineData);
576
- }
577
658
  const fromText = getValueByPath(fromObject, ['text']);
578
659
  if (fromText != null) {
579
660
  setValueByPath(toObject, ['text'], fromText);
@@ -641,6 +722,12 @@ function toolToMldev$2(apiClient, fromObject) {
641
722
  if (fromGoogleSearchRetrieval != null) {
642
723
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev$2(apiClient, fromGoogleSearchRetrieval));
643
724
  }
725
+ if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
726
+ throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
727
+ }
728
+ if (getValueByPath(fromObject, ['googleMaps']) !== undefined) {
729
+ throw new Error('googleMaps parameter is not supported in Gemini API.');
730
+ }
644
731
  const fromCodeExecution = getValueByPath(fromObject, [
645
732
  'codeExecution',
646
733
  ]);
@@ -677,6 +764,9 @@ function toolConfigToMldev$1(apiClient, fromObject) {
677
764
  if (fromFunctionCallingConfig != null) {
678
765
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(apiClient, fromFunctionCallingConfig));
679
766
  }
767
+ if (getValueByPath(fromObject, ['retrievalConfig']) !== undefined) {
768
+ throw new Error('retrievalConfig parameter is not supported in Gemini API.');
769
+ }
680
770
  return toObject;
681
771
  }
682
772
  function createCachedContentConfigToMldev(apiClient, fromObject, parentObject) {
@@ -805,6 +895,22 @@ function listCachedContentsParametersToMldev(apiClient, fromObject) {
805
895
  }
806
896
  return toObject;
807
897
  }
898
+ function blobToVertex$2(apiClient, fromObject) {
899
+ const toObject = {};
900
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
901
+ if (fromDisplayName != null) {
902
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
903
+ }
904
+ const fromData = getValueByPath(fromObject, ['data']);
905
+ if (fromData != null) {
906
+ setValueByPath(toObject, ['data'], fromData);
907
+ }
908
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
909
+ if (fromMimeType != null) {
910
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
911
+ }
912
+ return toObject;
913
+ }
808
914
  function partToVertex$2(apiClient, fromObject) {
809
915
  const toObject = {};
810
916
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -817,6 +923,10 @@ function partToVertex$2(apiClient, fromObject) {
817
923
  if (fromThought != null) {
818
924
  setValueByPath(toObject, ['thought'], fromThought);
819
925
  }
926
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
927
+ if (fromInlineData != null) {
928
+ setValueByPath(toObject, ['inlineData'], blobToVertex$2(apiClient, fromInlineData));
929
+ }
820
930
  const fromCodeExecutionResult = getValueByPath(fromObject, [
821
931
  'codeExecutionResult',
822
932
  ]);
@@ -843,10 +953,6 @@ function partToVertex$2(apiClient, fromObject) {
843
953
  if (fromFunctionResponse != null) {
844
954
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
845
955
  }
846
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
847
- if (fromInlineData != null) {
848
- setValueByPath(toObject, ['inlineData'], fromInlineData);
849
- }
850
956
  const fromText = getValueByPath(fromObject, ['text']);
851
957
  if (fromText != null) {
852
958
  setValueByPath(toObject, ['text'], fromText);
@@ -899,6 +1005,58 @@ function googleSearchRetrievalToVertex$2(apiClient, fromObject) {
899
1005
  }
900
1006
  return toObject;
901
1007
  }
1008
+ function enterpriseWebSearchToVertex$2() {
1009
+ const toObject = {};
1010
+ return toObject;
1011
+ }
1012
+ function apiKeyConfigToVertex$2(apiClient, fromObject) {
1013
+ const toObject = {};
1014
+ const fromApiKeyString = getValueByPath(fromObject, ['apiKeyString']);
1015
+ if (fromApiKeyString != null) {
1016
+ setValueByPath(toObject, ['apiKeyString'], fromApiKeyString);
1017
+ }
1018
+ return toObject;
1019
+ }
1020
+ function authConfigToVertex$2(apiClient, fromObject) {
1021
+ const toObject = {};
1022
+ const fromApiKeyConfig = getValueByPath(fromObject, ['apiKeyConfig']);
1023
+ if (fromApiKeyConfig != null) {
1024
+ setValueByPath(toObject, ['apiKeyConfig'], apiKeyConfigToVertex$2(apiClient, fromApiKeyConfig));
1025
+ }
1026
+ const fromAuthType = getValueByPath(fromObject, ['authType']);
1027
+ if (fromAuthType != null) {
1028
+ setValueByPath(toObject, ['authType'], fromAuthType);
1029
+ }
1030
+ const fromGoogleServiceAccountConfig = getValueByPath(fromObject, [
1031
+ 'googleServiceAccountConfig',
1032
+ ]);
1033
+ if (fromGoogleServiceAccountConfig != null) {
1034
+ setValueByPath(toObject, ['googleServiceAccountConfig'], fromGoogleServiceAccountConfig);
1035
+ }
1036
+ const fromHttpBasicAuthConfig = getValueByPath(fromObject, [
1037
+ 'httpBasicAuthConfig',
1038
+ ]);
1039
+ if (fromHttpBasicAuthConfig != null) {
1040
+ setValueByPath(toObject, ['httpBasicAuthConfig'], fromHttpBasicAuthConfig);
1041
+ }
1042
+ const fromOauthConfig = getValueByPath(fromObject, ['oauthConfig']);
1043
+ if (fromOauthConfig != null) {
1044
+ setValueByPath(toObject, ['oauthConfig'], fromOauthConfig);
1045
+ }
1046
+ const fromOidcConfig = getValueByPath(fromObject, ['oidcConfig']);
1047
+ if (fromOidcConfig != null) {
1048
+ setValueByPath(toObject, ['oidcConfig'], fromOidcConfig);
1049
+ }
1050
+ return toObject;
1051
+ }
1052
+ function googleMapsToVertex$2(apiClient, fromObject) {
1053
+ const toObject = {};
1054
+ const fromAuthConfig = getValueByPath(fromObject, ['authConfig']);
1055
+ if (fromAuthConfig != null) {
1056
+ setValueByPath(toObject, ['authConfig'], authConfigToVertex$2(apiClient, fromAuthConfig));
1057
+ }
1058
+ return toObject;
1059
+ }
902
1060
  function toolToVertex$2(apiClient, fromObject) {
903
1061
  const toObject = {};
904
1062
  const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
@@ -915,6 +1073,16 @@ function toolToVertex$2(apiClient, fromObject) {
915
1073
  if (fromGoogleSearchRetrieval != null) {
916
1074
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex$2(apiClient, fromGoogleSearchRetrieval));
917
1075
  }
1076
+ const fromEnterpriseWebSearch = getValueByPath(fromObject, [
1077
+ 'enterpriseWebSearch',
1078
+ ]);
1079
+ if (fromEnterpriseWebSearch != null) {
1080
+ setValueByPath(toObject, ['enterpriseWebSearch'], enterpriseWebSearchToVertex$2());
1081
+ }
1082
+ const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
1083
+ if (fromGoogleMaps != null) {
1084
+ setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$2(apiClient, fromGoogleMaps));
1085
+ }
918
1086
  const fromCodeExecution = getValueByPath(fromObject, [
919
1087
  'codeExecution',
920
1088
  ]);
@@ -943,6 +1111,26 @@ function functionCallingConfigToVertex$1(apiClient, fromObject) {
943
1111
  }
944
1112
  return toObject;
945
1113
  }
1114
+ function latLngToVertex$1(apiClient, fromObject) {
1115
+ const toObject = {};
1116
+ const fromLatitude = getValueByPath(fromObject, ['latitude']);
1117
+ if (fromLatitude != null) {
1118
+ setValueByPath(toObject, ['latitude'], fromLatitude);
1119
+ }
1120
+ const fromLongitude = getValueByPath(fromObject, ['longitude']);
1121
+ if (fromLongitude != null) {
1122
+ setValueByPath(toObject, ['longitude'], fromLongitude);
1123
+ }
1124
+ return toObject;
1125
+ }
1126
+ function retrievalConfigToVertex$1(apiClient, fromObject) {
1127
+ const toObject = {};
1128
+ const fromLatLng = getValueByPath(fromObject, ['latLng']);
1129
+ if (fromLatLng != null) {
1130
+ setValueByPath(toObject, ['latLng'], latLngToVertex$1(apiClient, fromLatLng));
1131
+ }
1132
+ return toObject;
1133
+ }
946
1134
  function toolConfigToVertex$1(apiClient, fromObject) {
947
1135
  const toObject = {};
948
1136
  const fromFunctionCallingConfig = getValueByPath(fromObject, [
@@ -951,6 +1139,12 @@ function toolConfigToVertex$1(apiClient, fromObject) {
951
1139
  if (fromFunctionCallingConfig != null) {
952
1140
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToVertex$1(apiClient, fromFunctionCallingConfig));
953
1141
  }
1142
+ const fromRetrievalConfig = getValueByPath(fromObject, [
1143
+ 'retrievalConfig',
1144
+ ]);
1145
+ if (fromRetrievalConfig != null) {
1146
+ setValueByPath(toObject, ['retrievalConfig'], retrievalConfigToVertex$1(apiClient, fromRetrievalConfig));
1147
+ }
954
1148
  return toObject;
955
1149
  }
956
1150
  function createCachedContentConfigToVertex(apiClient, fromObject, parentObject) {
@@ -1430,6 +1624,17 @@ var Mode;
1430
1624
  Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
1431
1625
  Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
1432
1626
  })(Mode || (Mode = {}));
1627
+ /** Type of auth scheme. */
1628
+ var AuthType;
1629
+ (function (AuthType) {
1630
+ AuthType["AUTH_TYPE_UNSPECIFIED"] = "AUTH_TYPE_UNSPECIFIED";
1631
+ AuthType["NO_AUTH"] = "NO_AUTH";
1632
+ AuthType["API_KEY_AUTH"] = "API_KEY_AUTH";
1633
+ AuthType["HTTP_BASIC_AUTH"] = "HTTP_BASIC_AUTH";
1634
+ AuthType["GOOGLE_SERVICE_ACCOUNT_AUTH"] = "GOOGLE_SERVICE_ACCOUNT_AUTH";
1635
+ AuthType["OAUTH"] = "OAUTH";
1636
+ AuthType["OIDC_AUTH"] = "OIDC_AUTH";
1637
+ })(AuthType || (AuthType = {}));
1433
1638
  /** Optional. The type of the data. */
1434
1639
  var Type;
1435
1640
  (function (Type) {
@@ -1583,21 +1788,6 @@ var ImagePromptLanguage;
1583
1788
  ImagePromptLanguage["ko"] = "ko";
1584
1789
  ImagePromptLanguage["hi"] = "hi";
1585
1790
  })(ImagePromptLanguage || (ImagePromptLanguage = {}));
1586
- /** State for the lifecycle of a File. */
1587
- var FileState;
1588
- (function (FileState) {
1589
- FileState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
1590
- FileState["PROCESSING"] = "PROCESSING";
1591
- FileState["ACTIVE"] = "ACTIVE";
1592
- FileState["FAILED"] = "FAILED";
1593
- })(FileState || (FileState = {}));
1594
- /** Source of the File. */
1595
- var FileSource;
1596
- (function (FileSource) {
1597
- FileSource["SOURCE_UNSPECIFIED"] = "SOURCE_UNSPECIFIED";
1598
- FileSource["UPLOADED"] = "UPLOADED";
1599
- FileSource["GENERATED"] = "GENERATED";
1600
- })(FileSource || (FileSource = {}));
1601
1791
  /** Enum representing the mask mode of a mask reference image. */
1602
1792
  var MaskReferenceMode;
1603
1793
  (function (MaskReferenceMode) {
@@ -1623,6 +1813,33 @@ var SubjectReferenceType;
1623
1813
  SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
1624
1814
  SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
1625
1815
  })(SubjectReferenceType || (SubjectReferenceType = {}));
1816
+ /** Enum representing the Imagen 3 Edit mode. */
1817
+ var EditMode;
1818
+ (function (EditMode) {
1819
+ EditMode["EDIT_MODE_DEFAULT"] = "EDIT_MODE_DEFAULT";
1820
+ EditMode["EDIT_MODE_INPAINT_REMOVAL"] = "EDIT_MODE_INPAINT_REMOVAL";
1821
+ EditMode["EDIT_MODE_INPAINT_INSERTION"] = "EDIT_MODE_INPAINT_INSERTION";
1822
+ EditMode["EDIT_MODE_OUTPAINT"] = "EDIT_MODE_OUTPAINT";
1823
+ EditMode["EDIT_MODE_CONTROLLED_EDITING"] = "EDIT_MODE_CONTROLLED_EDITING";
1824
+ EditMode["EDIT_MODE_STYLE"] = "EDIT_MODE_STYLE";
1825
+ EditMode["EDIT_MODE_BGSWAP"] = "EDIT_MODE_BGSWAP";
1826
+ EditMode["EDIT_MODE_PRODUCT_IMAGE"] = "EDIT_MODE_PRODUCT_IMAGE";
1827
+ })(EditMode || (EditMode = {}));
1828
+ /** State for the lifecycle of a File. */
1829
+ var FileState;
1830
+ (function (FileState) {
1831
+ FileState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
1832
+ FileState["PROCESSING"] = "PROCESSING";
1833
+ FileState["ACTIVE"] = "ACTIVE";
1834
+ FileState["FAILED"] = "FAILED";
1835
+ })(FileState || (FileState = {}));
1836
+ /** Source of the File. */
1837
+ var FileSource;
1838
+ (function (FileSource) {
1839
+ FileSource["SOURCE_UNSPECIFIED"] = "SOURCE_UNSPECIFIED";
1840
+ FileSource["UPLOADED"] = "UPLOADED";
1841
+ FileSource["GENERATED"] = "GENERATED";
1842
+ })(FileSource || (FileSource = {}));
1626
1843
  /** Server content modalities. */
1627
1844
  var MediaModality;
1628
1845
  (function (MediaModality) {
@@ -2037,6 +2254,13 @@ class EmbedContentResponse {
2037
2254
  /** The output images response. */
2038
2255
  class GenerateImagesResponse {
2039
2256
  }
2257
+ /** Response for the request to edit an image. */
2258
+ class EditImageResponse {
2259
+ }
2260
+ class UpscaleImageResponse {
2261
+ }
2262
+ class ListModelsResponse {
2263
+ }
2040
2264
  class DeleteModelResponse {
2041
2265
  }
2042
2266
  /** Response for counting tokens. */
@@ -2084,6 +2308,176 @@ class DeleteFileResponse {
2084
2308
  /** Represents a single response in a replay. */
2085
2309
  class ReplayResponse {
2086
2310
  }
2311
+ /** A raw reference image.
2312
+
2313
+ A raw reference image represents the base image to edit, provided by the user.
2314
+ It can optionally be provided in addition to a mask reference image or
2315
+ a style reference image.
2316
+ */
2317
+ class RawReferenceImage {
2318
+ /** Internal method to convert to ReferenceImageAPIInternal. */
2319
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2320
+ toReferenceImageAPI() {
2321
+ const referenceImageAPI = {
2322
+ referenceType: 'REFERENCE_TYPE_RAW',
2323
+ referenceImage: this.referenceImage,
2324
+ referenceId: this.referenceId,
2325
+ };
2326
+ return referenceImageAPI;
2327
+ }
2328
+ }
2329
+ /** A mask reference image.
2330
+
2331
+ This encapsulates either a mask image provided by the user and configs for
2332
+ the user provided mask, or only config parameters for the model to generate
2333
+ a mask.
2334
+
2335
+ A mask image is an image whose non-zero values indicate where to edit the base
2336
+ image. If the user provides a mask image, the mask must be in the same
2337
+ dimensions as the raw image.
2338
+ */
2339
+ class MaskReferenceImage {
2340
+ /** Internal method to convert to ReferenceImageAPIInternal. */
2341
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2342
+ toReferenceImageAPI() {
2343
+ const referenceImageAPI = {
2344
+ referenceType: 'REFERENCE_TYPE_MASK',
2345
+ referenceImage: this.referenceImage,
2346
+ referenceId: this.referenceId,
2347
+ maskImageConfig: this.config,
2348
+ };
2349
+ return referenceImageAPI;
2350
+ }
2351
+ }
2352
+ /** A control reference image.
2353
+
2354
+ The image of the control reference image is either a control image provided
2355
+ by the user, or a regular image which the backend will use to generate a
2356
+ control image of. In the case of the latter, the
2357
+ enable_control_image_computation field in the config should be set to True.
2358
+
2359
+ A control image is an image that represents a sketch image of areas for the
2360
+ model to fill in based on the prompt.
2361
+ */
2362
+ class ControlReferenceImage {
2363
+ /** Internal method to convert to ReferenceImageAPIInternal. */
2364
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2365
+ toReferenceImageAPI() {
2366
+ const referenceImageAPI = {
2367
+ referenceType: 'REFERENCE_TYPE_CONTROL',
2368
+ referenceImage: this.referenceImage,
2369
+ referenceId: this.referenceId,
2370
+ controlImageConfig: this.config,
2371
+ };
2372
+ return referenceImageAPI;
2373
+ }
2374
+ }
2375
+ /** A style reference image.
2376
+
2377
+ This encapsulates a style reference image provided by the user, and
2378
+ additionally optional config parameters for the style reference image.
2379
+
2380
+ A raw reference image can also be provided as a destination for the style to
2381
+ be applied to.
2382
+ */
2383
+ class StyleReferenceImage {
2384
+ /** Internal method to convert to ReferenceImageAPIInternal. */
2385
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2386
+ toReferenceImageAPI() {
2387
+ const referenceImageAPI = {
2388
+ referenceType: 'REFERENCE_TYPE_STYLE',
2389
+ referenceImage: this.referenceImage,
2390
+ referenceId: this.referenceId,
2391
+ styleImageConfig: this.config,
2392
+ };
2393
+ return referenceImageAPI;
2394
+ }
2395
+ }
2396
+ /** A subject reference image.
2397
+
2398
+ This encapsulates a subject reference image provided by the user, and
2399
+ additionally optional config parameters for the subject reference image.
2400
+
2401
+ A raw reference image can also be provided as a destination for the subject to
2402
+ be applied to.
2403
+ */
2404
+ class SubjectReferenceImage {
2405
+ /* Internal method to convert to ReferenceImageAPIInternal. */
2406
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2407
+ toReferenceImageAPI() {
2408
+ const referenceImageAPI = {
2409
+ referenceType: 'REFERENCE_TYPE_SUBJECT',
2410
+ referenceImage: this.referenceImage,
2411
+ referenceId: this.referenceId,
2412
+ subjectImageConfig: this.config,
2413
+ };
2414
+ return referenceImageAPI;
2415
+ }
2416
+ }
2417
+ /** Response message for API call. */
2418
+ class LiveServerMessage {
2419
+ /**
2420
+ * Returns the concatenation of all text parts from the server content if present.
2421
+ *
2422
+ * @remarks
2423
+ * If there are non-text parts in the response, the concatenation of all text
2424
+ * parts will be returned, and a warning will be logged.
2425
+ */
2426
+ get text() {
2427
+ var _a, _b, _c;
2428
+ let text = '';
2429
+ let anyTextPartFound = false;
2430
+ const nonTextParts = [];
2431
+ 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 : []) {
2432
+ for (const [fieldName, fieldValue] of Object.entries(part)) {
2433
+ if (fieldName !== 'text' &&
2434
+ fieldName !== 'thought' &&
2435
+ fieldValue !== null) {
2436
+ nonTextParts.push(fieldName);
2437
+ }
2438
+ }
2439
+ if (typeof part.text === 'string') {
2440
+ if (typeof part.thought === 'boolean' && part.thought) {
2441
+ continue;
2442
+ }
2443
+ anyTextPartFound = true;
2444
+ text += part.text;
2445
+ }
2446
+ }
2447
+ if (nonTextParts.length > 0) {
2448
+ 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.`);
2449
+ }
2450
+ // part.text === '' is different from part.text is null
2451
+ return anyTextPartFound ? text : undefined;
2452
+ }
2453
+ /**
2454
+ * Returns the concatenation of all inline data parts from the server content if present.
2455
+ *
2456
+ * @remarks
2457
+ * If there are non-inline data parts in the
2458
+ * response, the concatenation of all inline data parts will be returned, and
2459
+ * a warning will be logged.
2460
+ */
2461
+ get data() {
2462
+ var _a, _b, _c;
2463
+ let data = '';
2464
+ const nonDataParts = [];
2465
+ 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 : []) {
2466
+ for (const [fieldName, fieldValue] of Object.entries(part)) {
2467
+ if (fieldName !== 'inlineData' && fieldValue !== null) {
2468
+ nonDataParts.push(fieldName);
2469
+ }
2470
+ }
2471
+ if (part.inlineData && typeof part.inlineData.data === 'string') {
2472
+ data += atob(part.inlineData.data);
2473
+ }
2474
+ }
2475
+ if (nonDataParts.length > 0) {
2476
+ 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.`);
2477
+ }
2478
+ return data.length > 0 ? btoa(data) : undefined;
2479
+ }
2480
+ }
2087
2481
  /** Client generated response to a `ToolCall` received from the server.
2088
2482
 
2089
2483
  Individual `FunctionResponse` objects are matched to the respective
@@ -3170,6 +3564,25 @@ class Files extends BaseModule {
3170
3564
  return file;
3171
3565
  });
3172
3566
  }
3567
+ /**
3568
+ * Downloads a remotely stored file asynchronously to a location specified in
3569
+ * the `params` object. This method only works on Node environment, to
3570
+ * download files in the browser, use a browser compliant method like an <a>
3571
+ * tag.
3572
+ *
3573
+ * @param params - The parameters for the download request.
3574
+ *
3575
+ * @example
3576
+ * The following code downloads an example file named "files/mehozpxf877d" as
3577
+ * "file.txt".
3578
+ *
3579
+ * ```ts
3580
+ * await ai.files.download({file: file.name, downloadPath: 'file.txt'});
3581
+ * ```
3582
+ */
3583
+ async download(params) {
3584
+ await this.apiClient.downloadFile(params);
3585
+ }
3173
3586
  async listInternal(params) {
3174
3587
  var _a, _b;
3175
3588
  let response;
@@ -3343,6 +3756,37 @@ class Files extends BaseModule {
3343
3756
  * Copyright 2025 Google LLC
3344
3757
  * SPDX-License-Identifier: Apache-2.0
3345
3758
  */
3759
+ function blobToMldev$1(apiClient, fromObject) {
3760
+ const toObject = {};
3761
+ if (getValueByPath(fromObject, ['displayName']) !== undefined) {
3762
+ throw new Error('displayName parameter is not supported in Gemini API.');
3763
+ }
3764
+ const fromData = getValueByPath(fromObject, ['data']);
3765
+ if (fromData != null) {
3766
+ setValueByPath(toObject, ['data'], fromData);
3767
+ }
3768
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
3769
+ if (fromMimeType != null) {
3770
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
3771
+ }
3772
+ return toObject;
3773
+ }
3774
+ function blobToVertex$1(apiClient, fromObject) {
3775
+ const toObject = {};
3776
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
3777
+ if (fromDisplayName != null) {
3778
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
3779
+ }
3780
+ const fromData = getValueByPath(fromObject, ['data']);
3781
+ if (fromData != null) {
3782
+ setValueByPath(toObject, ['data'], fromData);
3783
+ }
3784
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
3785
+ if (fromMimeType != null) {
3786
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
3787
+ }
3788
+ return toObject;
3789
+ }
3346
3790
  function partToMldev$1(apiClient, fromObject) {
3347
3791
  const toObject = {};
3348
3792
  if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
@@ -3352,6 +3796,10 @@ function partToMldev$1(apiClient, fromObject) {
3352
3796
  if (fromThought != null) {
3353
3797
  setValueByPath(toObject, ['thought'], fromThought);
3354
3798
  }
3799
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
3800
+ if (fromInlineData != null) {
3801
+ setValueByPath(toObject, ['inlineData'], blobToMldev$1(apiClient, fromInlineData));
3802
+ }
3355
3803
  const fromCodeExecutionResult = getValueByPath(fromObject, [
3356
3804
  'codeExecutionResult',
3357
3805
  ]);
@@ -3378,10 +3826,6 @@ function partToMldev$1(apiClient, fromObject) {
3378
3826
  if (fromFunctionResponse != null) {
3379
3827
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
3380
3828
  }
3381
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
3382
- if (fromInlineData != null) {
3383
- setValueByPath(toObject, ['inlineData'], fromInlineData);
3384
- }
3385
3829
  const fromText = getValueByPath(fromObject, ['text']);
3386
3830
  if (fromText != null) {
3387
3831
  setValueByPath(toObject, ['text'], fromText);
@@ -3400,6 +3844,10 @@ function partToVertex$1(apiClient, fromObject) {
3400
3844
  if (fromThought != null) {
3401
3845
  setValueByPath(toObject, ['thought'], fromThought);
3402
3846
  }
3847
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
3848
+ if (fromInlineData != null) {
3849
+ setValueByPath(toObject, ['inlineData'], blobToVertex$1(apiClient, fromInlineData));
3850
+ }
3403
3851
  const fromCodeExecutionResult = getValueByPath(fromObject, [
3404
3852
  'codeExecutionResult',
3405
3853
  ]);
@@ -3426,10 +3874,6 @@ function partToVertex$1(apiClient, fromObject) {
3426
3874
  if (fromFunctionResponse != null) {
3427
3875
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
3428
3876
  }
3429
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
3430
- if (fromInlineData != null) {
3431
- setValueByPath(toObject, ['inlineData'], fromInlineData);
3432
- }
3433
3877
  const fromText = getValueByPath(fromObject, ['text']);
3434
3878
  if (fromText != null) {
3435
3879
  setValueByPath(toObject, ['text'], fromText);
@@ -3528,6 +3972,58 @@ function googleSearchRetrievalToVertex$1(apiClient, fromObject) {
3528
3972
  }
3529
3973
  return toObject;
3530
3974
  }
3975
+ function enterpriseWebSearchToVertex$1() {
3976
+ const toObject = {};
3977
+ return toObject;
3978
+ }
3979
+ function apiKeyConfigToVertex$1(apiClient, fromObject) {
3980
+ const toObject = {};
3981
+ const fromApiKeyString = getValueByPath(fromObject, ['apiKeyString']);
3982
+ if (fromApiKeyString != null) {
3983
+ setValueByPath(toObject, ['apiKeyString'], fromApiKeyString);
3984
+ }
3985
+ return toObject;
3986
+ }
3987
+ function authConfigToVertex$1(apiClient, fromObject) {
3988
+ const toObject = {};
3989
+ const fromApiKeyConfig = getValueByPath(fromObject, ['apiKeyConfig']);
3990
+ if (fromApiKeyConfig != null) {
3991
+ setValueByPath(toObject, ['apiKeyConfig'], apiKeyConfigToVertex$1(apiClient, fromApiKeyConfig));
3992
+ }
3993
+ const fromAuthType = getValueByPath(fromObject, ['authType']);
3994
+ if (fromAuthType != null) {
3995
+ setValueByPath(toObject, ['authType'], fromAuthType);
3996
+ }
3997
+ const fromGoogleServiceAccountConfig = getValueByPath(fromObject, [
3998
+ 'googleServiceAccountConfig',
3999
+ ]);
4000
+ if (fromGoogleServiceAccountConfig != null) {
4001
+ setValueByPath(toObject, ['googleServiceAccountConfig'], fromGoogleServiceAccountConfig);
4002
+ }
4003
+ const fromHttpBasicAuthConfig = getValueByPath(fromObject, [
4004
+ 'httpBasicAuthConfig',
4005
+ ]);
4006
+ if (fromHttpBasicAuthConfig != null) {
4007
+ setValueByPath(toObject, ['httpBasicAuthConfig'], fromHttpBasicAuthConfig);
4008
+ }
4009
+ const fromOauthConfig = getValueByPath(fromObject, ['oauthConfig']);
4010
+ if (fromOauthConfig != null) {
4011
+ setValueByPath(toObject, ['oauthConfig'], fromOauthConfig);
4012
+ }
4013
+ const fromOidcConfig = getValueByPath(fromObject, ['oidcConfig']);
4014
+ if (fromOidcConfig != null) {
4015
+ setValueByPath(toObject, ['oidcConfig'], fromOidcConfig);
4016
+ }
4017
+ return toObject;
4018
+ }
4019
+ function googleMapsToVertex$1(apiClient, fromObject) {
4020
+ const toObject = {};
4021
+ const fromAuthConfig = getValueByPath(fromObject, ['authConfig']);
4022
+ if (fromAuthConfig != null) {
4023
+ setValueByPath(toObject, ['authConfig'], authConfigToVertex$1(apiClient, fromAuthConfig));
4024
+ }
4025
+ return toObject;
4026
+ }
3531
4027
  function toolToMldev$1(apiClient, fromObject) {
3532
4028
  const toObject = {};
3533
4029
  if (getValueByPath(fromObject, ['retrieval']) !== undefined) {
@@ -3543,6 +4039,12 @@ function toolToMldev$1(apiClient, fromObject) {
3543
4039
  if (fromGoogleSearchRetrieval != null) {
3544
4040
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev$1(apiClient, fromGoogleSearchRetrieval));
3545
4041
  }
4042
+ if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
4043
+ throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
4044
+ }
4045
+ if (getValueByPath(fromObject, ['googleMaps']) !== undefined) {
4046
+ throw new Error('googleMaps parameter is not supported in Gemini API.');
4047
+ }
3546
4048
  const fromCodeExecution = getValueByPath(fromObject, [
3547
4049
  'codeExecution',
3548
4050
  ]);
@@ -3573,6 +4075,16 @@ function toolToVertex$1(apiClient, fromObject) {
3573
4075
  if (fromGoogleSearchRetrieval != null) {
3574
4076
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex$1(apiClient, fromGoogleSearchRetrieval));
3575
4077
  }
4078
+ const fromEnterpriseWebSearch = getValueByPath(fromObject, [
4079
+ 'enterpriseWebSearch',
4080
+ ]);
4081
+ if (fromEnterpriseWebSearch != null) {
4082
+ setValueByPath(toObject, ['enterpriseWebSearch'], enterpriseWebSearchToVertex$1());
4083
+ }
4084
+ const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
4085
+ if (fromGoogleMaps != null) {
4086
+ setValueByPath(toObject, ['googleMaps'], googleMapsToVertex$1(apiClient, fromGoogleMaps));
4087
+ }
3576
4088
  const fromCodeExecution = getValueByPath(fromObject, [
3577
4089
  'codeExecution',
3578
4090
  ]);
@@ -3838,8 +4350,11 @@ function liveConnectConfigToMldev(apiClient, fromObject, parentObject) {
3838
4350
  if (parentObject !== undefined && fromSessionResumption != null) {
3839
4351
  setValueByPath(parentObject, ['setup', 'sessionResumption'], sessionResumptionConfigToMldev(apiClient, fromSessionResumption));
3840
4352
  }
3841
- if (getValueByPath(fromObject, ['inputAudioTranscription']) !== undefined) {
3842
- throw new Error('inputAudioTranscription parameter is not supported in Gemini API.');
4353
+ const fromInputAudioTranscription = getValueByPath(fromObject, [
4354
+ 'inputAudioTranscription',
4355
+ ]);
4356
+ if (parentObject !== undefined && fromInputAudioTranscription != null) {
4357
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev());
3843
4358
  }
3844
4359
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
3845
4360
  'outputAudioTranscription',
@@ -4072,12 +4587,44 @@ function liveServerSetupCompleteFromVertex() {
4072
4587
  const toObject = {};
4073
4588
  return toObject;
4074
4589
  }
4590
+ function blobFromMldev$1(apiClient, fromObject) {
4591
+ const toObject = {};
4592
+ const fromData = getValueByPath(fromObject, ['data']);
4593
+ if (fromData != null) {
4594
+ setValueByPath(toObject, ['data'], fromData);
4595
+ }
4596
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
4597
+ if (fromMimeType != null) {
4598
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
4599
+ }
4600
+ return toObject;
4601
+ }
4602
+ function blobFromVertex$1(apiClient, fromObject) {
4603
+ const toObject = {};
4604
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
4605
+ if (fromDisplayName != null) {
4606
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
4607
+ }
4608
+ const fromData = getValueByPath(fromObject, ['data']);
4609
+ if (fromData != null) {
4610
+ setValueByPath(toObject, ['data'], fromData);
4611
+ }
4612
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
4613
+ if (fromMimeType != null) {
4614
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
4615
+ }
4616
+ return toObject;
4617
+ }
4075
4618
  function partFromMldev$1(apiClient, fromObject) {
4076
4619
  const toObject = {};
4077
4620
  const fromThought = getValueByPath(fromObject, ['thought']);
4078
4621
  if (fromThought != null) {
4079
4622
  setValueByPath(toObject, ['thought'], fromThought);
4080
4623
  }
4624
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
4625
+ if (fromInlineData != null) {
4626
+ setValueByPath(toObject, ['inlineData'], blobFromMldev$1(apiClient, fromInlineData));
4627
+ }
4081
4628
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4082
4629
  'codeExecutionResult',
4083
4630
  ]);
@@ -4104,10 +4651,6 @@ function partFromMldev$1(apiClient, fromObject) {
4104
4651
  if (fromFunctionResponse != null) {
4105
4652
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
4106
4653
  }
4107
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
4108
- if (fromInlineData != null) {
4109
- setValueByPath(toObject, ['inlineData'], fromInlineData);
4110
- }
4111
4654
  const fromText = getValueByPath(fromObject, ['text']);
4112
4655
  if (fromText != null) {
4113
4656
  setValueByPath(toObject, ['text'], fromText);
@@ -4126,6 +4669,10 @@ function partFromVertex$1(apiClient, fromObject) {
4126
4669
  if (fromThought != null) {
4127
4670
  setValueByPath(toObject, ['thought'], fromThought);
4128
4671
  }
4672
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
4673
+ if (fromInlineData != null) {
4674
+ setValueByPath(toObject, ['inlineData'], blobFromVertex$1(apiClient, fromInlineData));
4675
+ }
4129
4676
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4130
4677
  'codeExecutionResult',
4131
4678
  ]);
@@ -4152,10 +4699,6 @@ function partFromVertex$1(apiClient, fromObject) {
4152
4699
  if (fromFunctionResponse != null) {
4153
4700
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
4154
4701
  }
4155
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
4156
- if (fromInlineData != null) {
4157
- setValueByPath(toObject, ['inlineData'], fromInlineData);
4158
- }
4159
4702
  const fromText = getValueByPath(fromObject, ['text']);
4160
4703
  if (fromText != null) {
4161
4704
  setValueByPath(toObject, ['text'], fromText);
@@ -4724,6 +5267,21 @@ function liveServerMessageFromVertex(apiClient, fromObject) {
4724
5267
  * Copyright 2025 Google LLC
4725
5268
  * SPDX-License-Identifier: Apache-2.0
4726
5269
  */
5270
+ function blobToMldev(apiClient, fromObject) {
5271
+ const toObject = {};
5272
+ if (getValueByPath(fromObject, ['displayName']) !== undefined) {
5273
+ throw new Error('displayName parameter is not supported in Gemini API.');
5274
+ }
5275
+ const fromData = getValueByPath(fromObject, ['data']);
5276
+ if (fromData != null) {
5277
+ setValueByPath(toObject, ['data'], fromData);
5278
+ }
5279
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
5280
+ if (fromMimeType != null) {
5281
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
5282
+ }
5283
+ return toObject;
5284
+ }
4727
5285
  function partToMldev(apiClient, fromObject) {
4728
5286
  const toObject = {};
4729
5287
  if (getValueByPath(fromObject, ['videoMetadata']) !== undefined) {
@@ -4733,6 +5291,10 @@ function partToMldev(apiClient, fromObject) {
4733
5291
  if (fromThought != null) {
4734
5292
  setValueByPath(toObject, ['thought'], fromThought);
4735
5293
  }
5294
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
5295
+ if (fromInlineData != null) {
5296
+ setValueByPath(toObject, ['inlineData'], blobToMldev(apiClient, fromInlineData));
5297
+ }
4736
5298
  const fromCodeExecutionResult = getValueByPath(fromObject, [
4737
5299
  'codeExecutionResult',
4738
5300
  ]);
@@ -4759,10 +5321,6 @@ function partToMldev(apiClient, fromObject) {
4759
5321
  if (fromFunctionResponse != null) {
4760
5322
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
4761
5323
  }
4762
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
4763
- if (fromInlineData != null) {
4764
- setValueByPath(toObject, ['inlineData'], fromInlineData);
4765
- }
4766
5324
  const fromText = getValueByPath(fromObject, ['text']);
4767
5325
  if (fromText != null) {
4768
5326
  setValueByPath(toObject, ['text'], fromText);
@@ -4845,6 +5403,12 @@ function toolToMldev(apiClient, fromObject) {
4845
5403
  if (fromGoogleSearchRetrieval != null) {
4846
5404
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToMldev(apiClient, fromGoogleSearchRetrieval));
4847
5405
  }
5406
+ if (getValueByPath(fromObject, ['enterpriseWebSearch']) !== undefined) {
5407
+ throw new Error('enterpriseWebSearch parameter is not supported in Gemini API.');
5408
+ }
5409
+ if (getValueByPath(fromObject, ['googleMaps']) !== undefined) {
5410
+ throw new Error('googleMaps parameter is not supported in Gemini API.');
5411
+ }
4848
5412
  const fromCodeExecution = getValueByPath(fromObject, [
4849
5413
  'codeExecution',
4850
5414
  ]);
@@ -4881,6 +5445,9 @@ function toolConfigToMldev(apiClient, fromObject) {
4881
5445
  if (fromFunctionCallingConfig != null) {
4882
5446
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(apiClient, fromFunctionCallingConfig));
4883
5447
  }
5448
+ if (getValueByPath(fromObject, ['retrievalConfig']) !== undefined) {
5449
+ throw new Error('retrievalConfig parameter is not supported in Gemini API.');
5450
+ }
4884
5451
  return toObject;
4885
5452
  }
4886
5453
  function prebuiltVoiceConfigToMldev(apiClient, fromObject) {
@@ -5242,6 +5809,34 @@ function getModelParametersToMldev(apiClient, fromObject) {
5242
5809
  }
5243
5810
  return toObject;
5244
5811
  }
5812
+ function listModelsConfigToMldev(apiClient, fromObject, parentObject) {
5813
+ const toObject = {};
5814
+ const fromPageSize = getValueByPath(fromObject, ['pageSize']);
5815
+ if (parentObject !== undefined && fromPageSize != null) {
5816
+ setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
5817
+ }
5818
+ const fromPageToken = getValueByPath(fromObject, ['pageToken']);
5819
+ if (parentObject !== undefined && fromPageToken != null) {
5820
+ setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
5821
+ }
5822
+ const fromFilter = getValueByPath(fromObject, ['filter']);
5823
+ if (parentObject !== undefined && fromFilter != null) {
5824
+ setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
5825
+ }
5826
+ const fromQueryBase = getValueByPath(fromObject, ['queryBase']);
5827
+ if (parentObject !== undefined && fromQueryBase != null) {
5828
+ setValueByPath(parentObject, ['_url', 'models_url'], tModelsUrl(apiClient, fromQueryBase));
5829
+ }
5830
+ return toObject;
5831
+ }
5832
+ function listModelsParametersToMldev(apiClient, fromObject) {
5833
+ const toObject = {};
5834
+ const fromConfig = getValueByPath(fromObject, ['config']);
5835
+ if (fromConfig != null) {
5836
+ setValueByPath(toObject, ['config'], listModelsConfigToMldev(apiClient, fromConfig, toObject));
5837
+ }
5838
+ return toObject;
5839
+ }
5245
5840
  function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
5246
5841
  const toObject = {};
5247
5842
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
@@ -5252,6 +5847,12 @@ function updateModelConfigToMldev(apiClient, fromObject, parentObject) {
5252
5847
  if (parentObject !== undefined && fromDescription != null) {
5253
5848
  setValueByPath(parentObject, ['description'], fromDescription);
5254
5849
  }
5850
+ const fromDefaultCheckpointId = getValueByPath(fromObject, [
5851
+ 'defaultCheckpointId',
5852
+ ]);
5853
+ if (parentObject !== undefined && fromDefaultCheckpointId != null) {
5854
+ setValueByPath(parentObject, ['defaultCheckpointId'], fromDefaultCheckpointId);
5855
+ }
5255
5856
  return toObject;
5256
5857
  }
5257
5858
  function updateModelParametersToMldev(apiClient, fromObject) {
@@ -5398,6 +5999,22 @@ function generateVideosParametersToMldev(apiClient, fromObject) {
5398
5999
  }
5399
6000
  return toObject;
5400
6001
  }
6002
+ function blobToVertex(apiClient, fromObject) {
6003
+ const toObject = {};
6004
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
6005
+ if (fromDisplayName != null) {
6006
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
6007
+ }
6008
+ const fromData = getValueByPath(fromObject, ['data']);
6009
+ if (fromData != null) {
6010
+ setValueByPath(toObject, ['data'], fromData);
6011
+ }
6012
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
6013
+ if (fromMimeType != null) {
6014
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
6015
+ }
6016
+ return toObject;
6017
+ }
5401
6018
  function partToVertex(apiClient, fromObject) {
5402
6019
  const toObject = {};
5403
6020
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -5410,6 +6027,10 @@ function partToVertex(apiClient, fromObject) {
5410
6027
  if (fromThought != null) {
5411
6028
  setValueByPath(toObject, ['thought'], fromThought);
5412
6029
  }
6030
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
6031
+ if (fromInlineData != null) {
6032
+ setValueByPath(toObject, ['inlineData'], blobToVertex(apiClient, fromInlineData));
6033
+ }
5413
6034
  const fromCodeExecutionResult = getValueByPath(fromObject, [
5414
6035
  'codeExecutionResult',
5415
6036
  ]);
@@ -5436,10 +6057,6 @@ function partToVertex(apiClient, fromObject) {
5436
6057
  if (fromFunctionResponse != null) {
5437
6058
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
5438
6059
  }
5439
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
5440
- if (fromInlineData != null) {
5441
- setValueByPath(toObject, ['inlineData'], fromInlineData);
5442
- }
5443
6060
  const fromText = getValueByPath(fromObject, ['text']);
5444
6061
  if (fromText != null) {
5445
6062
  setValueByPath(toObject, ['text'], fromText);
@@ -5518,6 +6135,58 @@ function googleSearchRetrievalToVertex(apiClient, fromObject) {
5518
6135
  }
5519
6136
  return toObject;
5520
6137
  }
6138
+ function enterpriseWebSearchToVertex() {
6139
+ const toObject = {};
6140
+ return toObject;
6141
+ }
6142
+ function apiKeyConfigToVertex(apiClient, fromObject) {
6143
+ const toObject = {};
6144
+ const fromApiKeyString = getValueByPath(fromObject, ['apiKeyString']);
6145
+ if (fromApiKeyString != null) {
6146
+ setValueByPath(toObject, ['apiKeyString'], fromApiKeyString);
6147
+ }
6148
+ return toObject;
6149
+ }
6150
+ function authConfigToVertex(apiClient, fromObject) {
6151
+ const toObject = {};
6152
+ const fromApiKeyConfig = getValueByPath(fromObject, ['apiKeyConfig']);
6153
+ if (fromApiKeyConfig != null) {
6154
+ setValueByPath(toObject, ['apiKeyConfig'], apiKeyConfigToVertex(apiClient, fromApiKeyConfig));
6155
+ }
6156
+ const fromAuthType = getValueByPath(fromObject, ['authType']);
6157
+ if (fromAuthType != null) {
6158
+ setValueByPath(toObject, ['authType'], fromAuthType);
6159
+ }
6160
+ const fromGoogleServiceAccountConfig = getValueByPath(fromObject, [
6161
+ 'googleServiceAccountConfig',
6162
+ ]);
6163
+ if (fromGoogleServiceAccountConfig != null) {
6164
+ setValueByPath(toObject, ['googleServiceAccountConfig'], fromGoogleServiceAccountConfig);
6165
+ }
6166
+ const fromHttpBasicAuthConfig = getValueByPath(fromObject, [
6167
+ 'httpBasicAuthConfig',
6168
+ ]);
6169
+ if (fromHttpBasicAuthConfig != null) {
6170
+ setValueByPath(toObject, ['httpBasicAuthConfig'], fromHttpBasicAuthConfig);
6171
+ }
6172
+ const fromOauthConfig = getValueByPath(fromObject, ['oauthConfig']);
6173
+ if (fromOauthConfig != null) {
6174
+ setValueByPath(toObject, ['oauthConfig'], fromOauthConfig);
6175
+ }
6176
+ const fromOidcConfig = getValueByPath(fromObject, ['oidcConfig']);
6177
+ if (fromOidcConfig != null) {
6178
+ setValueByPath(toObject, ['oidcConfig'], fromOidcConfig);
6179
+ }
6180
+ return toObject;
6181
+ }
6182
+ function googleMapsToVertex(apiClient, fromObject) {
6183
+ const toObject = {};
6184
+ const fromAuthConfig = getValueByPath(fromObject, ['authConfig']);
6185
+ if (fromAuthConfig != null) {
6186
+ setValueByPath(toObject, ['authConfig'], authConfigToVertex(apiClient, fromAuthConfig));
6187
+ }
6188
+ return toObject;
6189
+ }
5521
6190
  function toolToVertex(apiClient, fromObject) {
5522
6191
  const toObject = {};
5523
6192
  const fromRetrieval = getValueByPath(fromObject, ['retrieval']);
@@ -5534,6 +6203,16 @@ function toolToVertex(apiClient, fromObject) {
5534
6203
  if (fromGoogleSearchRetrieval != null) {
5535
6204
  setValueByPath(toObject, ['googleSearchRetrieval'], googleSearchRetrievalToVertex(apiClient, fromGoogleSearchRetrieval));
5536
6205
  }
6206
+ const fromEnterpriseWebSearch = getValueByPath(fromObject, [
6207
+ 'enterpriseWebSearch',
6208
+ ]);
6209
+ if (fromEnterpriseWebSearch != null) {
6210
+ setValueByPath(toObject, ['enterpriseWebSearch'], enterpriseWebSearchToVertex());
6211
+ }
6212
+ const fromGoogleMaps = getValueByPath(fromObject, ['googleMaps']);
6213
+ if (fromGoogleMaps != null) {
6214
+ setValueByPath(toObject, ['googleMaps'], googleMapsToVertex(apiClient, fromGoogleMaps));
6215
+ }
5537
6216
  const fromCodeExecution = getValueByPath(fromObject, [
5538
6217
  'codeExecution',
5539
6218
  ]);
@@ -5562,6 +6241,26 @@ function functionCallingConfigToVertex(apiClient, fromObject) {
5562
6241
  }
5563
6242
  return toObject;
5564
6243
  }
6244
+ function latLngToVertex(apiClient, fromObject) {
6245
+ const toObject = {};
6246
+ const fromLatitude = getValueByPath(fromObject, ['latitude']);
6247
+ if (fromLatitude != null) {
6248
+ setValueByPath(toObject, ['latitude'], fromLatitude);
6249
+ }
6250
+ const fromLongitude = getValueByPath(fromObject, ['longitude']);
6251
+ if (fromLongitude != null) {
6252
+ setValueByPath(toObject, ['longitude'], fromLongitude);
6253
+ }
6254
+ return toObject;
6255
+ }
6256
+ function retrievalConfigToVertex(apiClient, fromObject) {
6257
+ const toObject = {};
6258
+ const fromLatLng = getValueByPath(fromObject, ['latLng']);
6259
+ if (fromLatLng != null) {
6260
+ setValueByPath(toObject, ['latLng'], latLngToVertex(apiClient, fromLatLng));
6261
+ }
6262
+ return toObject;
6263
+ }
5565
6264
  function toolConfigToVertex(apiClient, fromObject) {
5566
6265
  const toObject = {};
5567
6266
  const fromFunctionCallingConfig = getValueByPath(fromObject, [
@@ -5570,6 +6269,12 @@ function toolConfigToVertex(apiClient, fromObject) {
5570
6269
  if (fromFunctionCallingConfig != null) {
5571
6270
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToVertex(apiClient, fromFunctionCallingConfig));
5572
6271
  }
6272
+ const fromRetrievalConfig = getValueByPath(fromObject, [
6273
+ 'retrievalConfig',
6274
+ ]);
6275
+ if (fromRetrievalConfig != null) {
6276
+ setValueByPath(toObject, ['retrievalConfig'], retrievalConfigToVertex(apiClient, fromRetrievalConfig));
6277
+ }
5573
6278
  return toObject;
5574
6279
  }
5575
6280
  function prebuiltVoiceConfigToVertex(apiClient, fromObject) {
@@ -5936,6 +6641,286 @@ function generateImagesParametersToVertex(apiClient, fromObject) {
5936
6641
  }
5937
6642
  return toObject;
5938
6643
  }
6644
+ function imageToVertex(apiClient, fromObject) {
6645
+ const toObject = {};
6646
+ const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
6647
+ if (fromGcsUri != null) {
6648
+ setValueByPath(toObject, ['gcsUri'], fromGcsUri);
6649
+ }
6650
+ const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
6651
+ if (fromImageBytes != null) {
6652
+ setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
6653
+ }
6654
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
6655
+ if (fromMimeType != null) {
6656
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
6657
+ }
6658
+ return toObject;
6659
+ }
6660
+ function maskReferenceConfigToVertex(apiClient, fromObject) {
6661
+ const toObject = {};
6662
+ const fromMaskMode = getValueByPath(fromObject, ['maskMode']);
6663
+ if (fromMaskMode != null) {
6664
+ setValueByPath(toObject, ['maskMode'], fromMaskMode);
6665
+ }
6666
+ const fromSegmentationClasses = getValueByPath(fromObject, [
6667
+ 'segmentationClasses',
6668
+ ]);
6669
+ if (fromSegmentationClasses != null) {
6670
+ setValueByPath(toObject, ['maskClasses'], fromSegmentationClasses);
6671
+ }
6672
+ const fromMaskDilation = getValueByPath(fromObject, ['maskDilation']);
6673
+ if (fromMaskDilation != null) {
6674
+ setValueByPath(toObject, ['dilation'], fromMaskDilation);
6675
+ }
6676
+ return toObject;
6677
+ }
6678
+ function controlReferenceConfigToVertex(apiClient, fromObject) {
6679
+ const toObject = {};
6680
+ const fromControlType = getValueByPath(fromObject, ['controlType']);
6681
+ if (fromControlType != null) {
6682
+ setValueByPath(toObject, ['controlType'], fromControlType);
6683
+ }
6684
+ const fromEnableControlImageComputation = getValueByPath(fromObject, [
6685
+ 'enableControlImageComputation',
6686
+ ]);
6687
+ if (fromEnableControlImageComputation != null) {
6688
+ setValueByPath(toObject, ['computeControl'], fromEnableControlImageComputation);
6689
+ }
6690
+ return toObject;
6691
+ }
6692
+ function styleReferenceConfigToVertex(apiClient, fromObject) {
6693
+ const toObject = {};
6694
+ const fromStyleDescription = getValueByPath(fromObject, [
6695
+ 'styleDescription',
6696
+ ]);
6697
+ if (fromStyleDescription != null) {
6698
+ setValueByPath(toObject, ['styleDescription'], fromStyleDescription);
6699
+ }
6700
+ return toObject;
6701
+ }
6702
+ function subjectReferenceConfigToVertex(apiClient, fromObject) {
6703
+ const toObject = {};
6704
+ const fromSubjectType = getValueByPath(fromObject, ['subjectType']);
6705
+ if (fromSubjectType != null) {
6706
+ setValueByPath(toObject, ['subjectType'], fromSubjectType);
6707
+ }
6708
+ const fromSubjectDescription = getValueByPath(fromObject, [
6709
+ 'subjectDescription',
6710
+ ]);
6711
+ if (fromSubjectDescription != null) {
6712
+ setValueByPath(toObject, ['subjectDescription'], fromSubjectDescription);
6713
+ }
6714
+ return toObject;
6715
+ }
6716
+ function referenceImageAPIInternalToVertex(apiClient, fromObject) {
6717
+ const toObject = {};
6718
+ const fromReferenceImage = getValueByPath(fromObject, [
6719
+ 'referenceImage',
6720
+ ]);
6721
+ if (fromReferenceImage != null) {
6722
+ setValueByPath(toObject, ['referenceImage'], imageToVertex(apiClient, fromReferenceImage));
6723
+ }
6724
+ const fromReferenceId = getValueByPath(fromObject, ['referenceId']);
6725
+ if (fromReferenceId != null) {
6726
+ setValueByPath(toObject, ['referenceId'], fromReferenceId);
6727
+ }
6728
+ const fromReferenceType = getValueByPath(fromObject, [
6729
+ 'referenceType',
6730
+ ]);
6731
+ if (fromReferenceType != null) {
6732
+ setValueByPath(toObject, ['referenceType'], fromReferenceType);
6733
+ }
6734
+ const fromMaskImageConfig = getValueByPath(fromObject, [
6735
+ 'maskImageConfig',
6736
+ ]);
6737
+ if (fromMaskImageConfig != null) {
6738
+ setValueByPath(toObject, ['maskImageConfig'], maskReferenceConfigToVertex(apiClient, fromMaskImageConfig));
6739
+ }
6740
+ const fromControlImageConfig = getValueByPath(fromObject, [
6741
+ 'controlImageConfig',
6742
+ ]);
6743
+ if (fromControlImageConfig != null) {
6744
+ setValueByPath(toObject, ['controlImageConfig'], controlReferenceConfigToVertex(apiClient, fromControlImageConfig));
6745
+ }
6746
+ const fromStyleImageConfig = getValueByPath(fromObject, [
6747
+ 'styleImageConfig',
6748
+ ]);
6749
+ if (fromStyleImageConfig != null) {
6750
+ setValueByPath(toObject, ['styleImageConfig'], styleReferenceConfigToVertex(apiClient, fromStyleImageConfig));
6751
+ }
6752
+ const fromSubjectImageConfig = getValueByPath(fromObject, [
6753
+ 'subjectImageConfig',
6754
+ ]);
6755
+ if (fromSubjectImageConfig != null) {
6756
+ setValueByPath(toObject, ['subjectImageConfig'], subjectReferenceConfigToVertex(apiClient, fromSubjectImageConfig));
6757
+ }
6758
+ return toObject;
6759
+ }
6760
+ function editImageConfigToVertex(apiClient, fromObject, parentObject) {
6761
+ const toObject = {};
6762
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
6763
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
6764
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
6765
+ }
6766
+ const fromNegativePrompt = getValueByPath(fromObject, [
6767
+ 'negativePrompt',
6768
+ ]);
6769
+ if (parentObject !== undefined && fromNegativePrompt != null) {
6770
+ setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
6771
+ }
6772
+ const fromNumberOfImages = getValueByPath(fromObject, [
6773
+ 'numberOfImages',
6774
+ ]);
6775
+ if (parentObject !== undefined && fromNumberOfImages != null) {
6776
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
6777
+ }
6778
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
6779
+ if (parentObject !== undefined && fromAspectRatio != null) {
6780
+ setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
6781
+ }
6782
+ const fromGuidanceScale = getValueByPath(fromObject, [
6783
+ 'guidanceScale',
6784
+ ]);
6785
+ if (parentObject !== undefined && fromGuidanceScale != null) {
6786
+ setValueByPath(parentObject, ['parameters', 'guidanceScale'], fromGuidanceScale);
6787
+ }
6788
+ const fromSeed = getValueByPath(fromObject, ['seed']);
6789
+ if (parentObject !== undefined && fromSeed != null) {
6790
+ setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
6791
+ }
6792
+ const fromSafetyFilterLevel = getValueByPath(fromObject, [
6793
+ 'safetyFilterLevel',
6794
+ ]);
6795
+ if (parentObject !== undefined && fromSafetyFilterLevel != null) {
6796
+ setValueByPath(parentObject, ['parameters', 'safetySetting'], fromSafetyFilterLevel);
6797
+ }
6798
+ const fromPersonGeneration = getValueByPath(fromObject, [
6799
+ 'personGeneration',
6800
+ ]);
6801
+ if (parentObject !== undefined && fromPersonGeneration != null) {
6802
+ setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
6803
+ }
6804
+ const fromIncludeSafetyAttributes = getValueByPath(fromObject, [
6805
+ 'includeSafetyAttributes',
6806
+ ]);
6807
+ if (parentObject !== undefined && fromIncludeSafetyAttributes != null) {
6808
+ setValueByPath(parentObject, ['parameters', 'includeSafetyAttributes'], fromIncludeSafetyAttributes);
6809
+ }
6810
+ const fromIncludeRaiReason = getValueByPath(fromObject, [
6811
+ 'includeRaiReason',
6812
+ ]);
6813
+ if (parentObject !== undefined && fromIncludeRaiReason != null) {
6814
+ setValueByPath(parentObject, ['parameters', 'includeRaiReason'], fromIncludeRaiReason);
6815
+ }
6816
+ const fromLanguage = getValueByPath(fromObject, ['language']);
6817
+ if (parentObject !== undefined && fromLanguage != null) {
6818
+ setValueByPath(parentObject, ['parameters', 'language'], fromLanguage);
6819
+ }
6820
+ const fromOutputMimeType = getValueByPath(fromObject, [
6821
+ 'outputMimeType',
6822
+ ]);
6823
+ if (parentObject !== undefined && fromOutputMimeType != null) {
6824
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
6825
+ }
6826
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
6827
+ 'outputCompressionQuality',
6828
+ ]);
6829
+ if (parentObject !== undefined && fromOutputCompressionQuality != null) {
6830
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
6831
+ }
6832
+ const fromEditMode = getValueByPath(fromObject, ['editMode']);
6833
+ if (parentObject !== undefined && fromEditMode != null) {
6834
+ setValueByPath(parentObject, ['parameters', 'editMode'], fromEditMode);
6835
+ }
6836
+ const fromBaseSteps = getValueByPath(fromObject, ['baseSteps']);
6837
+ if (parentObject !== undefined && fromBaseSteps != null) {
6838
+ setValueByPath(parentObject, ['parameters', 'editConfig', 'baseSteps'], fromBaseSteps);
6839
+ }
6840
+ return toObject;
6841
+ }
6842
+ function editImageParametersInternalToVertex(apiClient, fromObject) {
6843
+ const toObject = {};
6844
+ const fromModel = getValueByPath(fromObject, ['model']);
6845
+ if (fromModel != null) {
6846
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
6847
+ }
6848
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
6849
+ if (fromPrompt != null) {
6850
+ setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
6851
+ }
6852
+ const fromReferenceImages = getValueByPath(fromObject, [
6853
+ 'referenceImages',
6854
+ ]);
6855
+ if (fromReferenceImages != null) {
6856
+ let transformedList = fromReferenceImages;
6857
+ if (Array.isArray(transformedList)) {
6858
+ transformedList = transformedList.map((item) => {
6859
+ return referenceImageAPIInternalToVertex(apiClient, item);
6860
+ });
6861
+ }
6862
+ setValueByPath(toObject, ['instances[0]', 'referenceImages'], transformedList);
6863
+ }
6864
+ const fromConfig = getValueByPath(fromObject, ['config']);
6865
+ if (fromConfig != null) {
6866
+ setValueByPath(toObject, ['config'], editImageConfigToVertex(apiClient, fromConfig, toObject));
6867
+ }
6868
+ return toObject;
6869
+ }
6870
+ function upscaleImageAPIConfigInternalToVertex(apiClient, fromObject, parentObject) {
6871
+ const toObject = {};
6872
+ const fromIncludeRaiReason = getValueByPath(fromObject, [
6873
+ 'includeRaiReason',
6874
+ ]);
6875
+ if (parentObject !== undefined && fromIncludeRaiReason != null) {
6876
+ setValueByPath(parentObject, ['parameters', 'includeRaiReason'], fromIncludeRaiReason);
6877
+ }
6878
+ const fromOutputMimeType = getValueByPath(fromObject, [
6879
+ 'outputMimeType',
6880
+ ]);
6881
+ if (parentObject !== undefined && fromOutputMimeType != null) {
6882
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'mimeType'], fromOutputMimeType);
6883
+ }
6884
+ const fromOutputCompressionQuality = getValueByPath(fromObject, [
6885
+ 'outputCompressionQuality',
6886
+ ]);
6887
+ if (parentObject !== undefined && fromOutputCompressionQuality != null) {
6888
+ setValueByPath(parentObject, ['parameters', 'outputOptions', 'compressionQuality'], fromOutputCompressionQuality);
6889
+ }
6890
+ const fromNumberOfImages = getValueByPath(fromObject, [
6891
+ 'numberOfImages',
6892
+ ]);
6893
+ if (parentObject !== undefined && fromNumberOfImages != null) {
6894
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfImages);
6895
+ }
6896
+ const fromMode = getValueByPath(fromObject, ['mode']);
6897
+ if (parentObject !== undefined && fromMode != null) {
6898
+ setValueByPath(parentObject, ['parameters', 'mode'], fromMode);
6899
+ }
6900
+ return toObject;
6901
+ }
6902
+ function upscaleImageAPIParametersInternalToVertex(apiClient, fromObject) {
6903
+ const toObject = {};
6904
+ const fromModel = getValueByPath(fromObject, ['model']);
6905
+ if (fromModel != null) {
6906
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
6907
+ }
6908
+ const fromImage = getValueByPath(fromObject, ['image']);
6909
+ if (fromImage != null) {
6910
+ setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
6911
+ }
6912
+ const fromUpscaleFactor = getValueByPath(fromObject, [
6913
+ 'upscaleFactor',
6914
+ ]);
6915
+ if (fromUpscaleFactor != null) {
6916
+ setValueByPath(toObject, ['parameters', 'upscaleConfig', 'upscaleFactor'], fromUpscaleFactor);
6917
+ }
6918
+ const fromConfig = getValueByPath(fromObject, ['config']);
6919
+ if (fromConfig != null) {
6920
+ setValueByPath(toObject, ['config'], upscaleImageAPIConfigInternalToVertex(apiClient, fromConfig, toObject));
6921
+ }
6922
+ return toObject;
6923
+ }
5939
6924
  function getModelParametersToVertex(apiClient, fromObject) {
5940
6925
  const toObject = {};
5941
6926
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -5948,6 +6933,34 @@ function getModelParametersToVertex(apiClient, fromObject) {
5948
6933
  }
5949
6934
  return toObject;
5950
6935
  }
6936
+ function listModelsConfigToVertex(apiClient, fromObject, parentObject) {
6937
+ const toObject = {};
6938
+ const fromPageSize = getValueByPath(fromObject, ['pageSize']);
6939
+ if (parentObject !== undefined && fromPageSize != null) {
6940
+ setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize);
6941
+ }
6942
+ const fromPageToken = getValueByPath(fromObject, ['pageToken']);
6943
+ if (parentObject !== undefined && fromPageToken != null) {
6944
+ setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken);
6945
+ }
6946
+ const fromFilter = getValueByPath(fromObject, ['filter']);
6947
+ if (parentObject !== undefined && fromFilter != null) {
6948
+ setValueByPath(parentObject, ['_query', 'filter'], fromFilter);
6949
+ }
6950
+ const fromQueryBase = getValueByPath(fromObject, ['queryBase']);
6951
+ if (parentObject !== undefined && fromQueryBase != null) {
6952
+ setValueByPath(parentObject, ['_url', 'models_url'], tModelsUrl(apiClient, fromQueryBase));
6953
+ }
6954
+ return toObject;
6955
+ }
6956
+ function listModelsParametersToVertex(apiClient, fromObject) {
6957
+ const toObject = {};
6958
+ const fromConfig = getValueByPath(fromObject, ['config']);
6959
+ if (fromConfig != null) {
6960
+ setValueByPath(toObject, ['config'], listModelsConfigToVertex(apiClient, fromConfig, toObject));
6961
+ }
6962
+ return toObject;
6963
+ }
5951
6964
  function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
5952
6965
  const toObject = {};
5953
6966
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
@@ -5958,6 +6971,12 @@ function updateModelConfigToVertex(apiClient, fromObject, parentObject) {
5958
6971
  if (parentObject !== undefined && fromDescription != null) {
5959
6972
  setValueByPath(parentObject, ['description'], fromDescription);
5960
6973
  }
6974
+ const fromDefaultCheckpointId = getValueByPath(fromObject, [
6975
+ 'defaultCheckpointId',
6976
+ ]);
6977
+ if (parentObject !== undefined && fromDefaultCheckpointId != null) {
6978
+ setValueByPath(parentObject, ['defaultCheckpointId'], fromDefaultCheckpointId);
6979
+ }
5961
6980
  return toObject;
5962
6981
  }
5963
6982
  function updateModelParametersToVertex(apiClient, fromObject) {
@@ -6054,22 +7073,6 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
6054
7073
  }
6055
7074
  return toObject;
6056
7075
  }
6057
- function imageToVertex(apiClient, fromObject) {
6058
- const toObject = {};
6059
- const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
6060
- if (fromGcsUri != null) {
6061
- setValueByPath(toObject, ['gcsUri'], fromGcsUri);
6062
- }
6063
- const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
6064
- if (fromImageBytes != null) {
6065
- setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
6066
- }
6067
- const fromMimeType = getValueByPath(fromObject, ['mimeType']);
6068
- if (fromMimeType != null) {
6069
- setValueByPath(toObject, ['mimeType'], fromMimeType);
6070
- }
6071
- return toObject;
6072
- }
6073
7076
  function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
6074
7077
  const toObject = {};
6075
7078
  const fromNumberOfVideos = getValueByPath(fromObject, [
@@ -6148,12 +7151,28 @@ function generateVideosParametersToVertex(apiClient, fromObject) {
6148
7151
  }
6149
7152
  return toObject;
6150
7153
  }
7154
+ function blobFromMldev(apiClient, fromObject) {
7155
+ const toObject = {};
7156
+ const fromData = getValueByPath(fromObject, ['data']);
7157
+ if (fromData != null) {
7158
+ setValueByPath(toObject, ['data'], fromData);
7159
+ }
7160
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
7161
+ if (fromMimeType != null) {
7162
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
7163
+ }
7164
+ return toObject;
7165
+ }
6151
7166
  function partFromMldev(apiClient, fromObject) {
6152
7167
  const toObject = {};
6153
7168
  const fromThought = getValueByPath(fromObject, ['thought']);
6154
7169
  if (fromThought != null) {
6155
7170
  setValueByPath(toObject, ['thought'], fromThought);
6156
7171
  }
7172
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
7173
+ if (fromInlineData != null) {
7174
+ setValueByPath(toObject, ['inlineData'], blobFromMldev(apiClient, fromInlineData));
7175
+ }
6157
7176
  const fromCodeExecutionResult = getValueByPath(fromObject, [
6158
7177
  'codeExecutionResult',
6159
7178
  ]);
@@ -6180,10 +7199,6 @@ function partFromMldev(apiClient, fromObject) {
6180
7199
  if (fromFunctionResponse != null) {
6181
7200
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
6182
7201
  }
6183
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
6184
- if (fromInlineData != null) {
6185
- setValueByPath(toObject, ['inlineData'], fromInlineData);
6186
- }
6187
7202
  const fromText = getValueByPath(fromObject, ['text']);
6188
7203
  if (fromText != null) {
6189
7204
  setValueByPath(toObject, ['text'], fromText);
@@ -6458,6 +7473,26 @@ function modelFromMldev(apiClient, fromObject) {
6458
7473
  }
6459
7474
  return toObject;
6460
7475
  }
7476
+ function listModelsResponseFromMldev(apiClient, fromObject) {
7477
+ const toObject = {};
7478
+ const fromNextPageToken = getValueByPath(fromObject, [
7479
+ 'nextPageToken',
7480
+ ]);
7481
+ if (fromNextPageToken != null) {
7482
+ setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
7483
+ }
7484
+ const fromModels = getValueByPath(fromObject, ['_self']);
7485
+ if (fromModels != null) {
7486
+ let transformedList = tExtractModels(apiClient, fromModels);
7487
+ if (Array.isArray(transformedList)) {
7488
+ transformedList = transformedList.map((item) => {
7489
+ return modelFromMldev(apiClient, item);
7490
+ });
7491
+ }
7492
+ setValueByPath(toObject, ['models'], transformedList);
7493
+ }
7494
+ return toObject;
7495
+ }
6461
7496
  function deleteModelResponseFromMldev() {
6462
7497
  const toObject = {};
6463
7498
  return toObject;
@@ -6558,6 +7593,22 @@ function generateVideosOperationFromMldev$1(apiClient, fromObject) {
6558
7593
  }
6559
7594
  return toObject;
6560
7595
  }
7596
+ function blobFromVertex(apiClient, fromObject) {
7597
+ const toObject = {};
7598
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
7599
+ if (fromDisplayName != null) {
7600
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
7601
+ }
7602
+ const fromData = getValueByPath(fromObject, ['data']);
7603
+ if (fromData != null) {
7604
+ setValueByPath(toObject, ['data'], fromData);
7605
+ }
7606
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
7607
+ if (fromMimeType != null) {
7608
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
7609
+ }
7610
+ return toObject;
7611
+ }
6561
7612
  function partFromVertex(apiClient, fromObject) {
6562
7613
  const toObject = {};
6563
7614
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -6570,6 +7621,10 @@ function partFromVertex(apiClient, fromObject) {
6570
7621
  if (fromThought != null) {
6571
7622
  setValueByPath(toObject, ['thought'], fromThought);
6572
7623
  }
7624
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
7625
+ if (fromInlineData != null) {
7626
+ setValueByPath(toObject, ['inlineData'], blobFromVertex(apiClient, fromInlineData));
7627
+ }
6573
7628
  const fromCodeExecutionResult = getValueByPath(fromObject, [
6574
7629
  'codeExecutionResult',
6575
7630
  ]);
@@ -6596,10 +7651,6 @@ function partFromVertex(apiClient, fromObject) {
6596
7651
  if (fromFunctionResponse != null) {
6597
7652
  setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
6598
7653
  }
6599
- const fromInlineData = getValueByPath(fromObject, ['inlineData']);
6600
- if (fromInlineData != null) {
6601
- setValueByPath(toObject, ['inlineData'], fromInlineData);
6602
- }
6603
7654
  const fromText = getValueByPath(fromObject, ['text']);
6604
7655
  if (fromText != null) {
6605
7656
  setValueByPath(toObject, ['text'], fromText);
@@ -6837,7 +7888,29 @@ function generatedImageFromVertex(apiClient, fromObject) {
6837
7888
  }
6838
7889
  return toObject;
6839
7890
  }
6840
- function generateImagesResponseFromVertex(apiClient, fromObject) {
7891
+ function generateImagesResponseFromVertex(apiClient, fromObject) {
7892
+ const toObject = {};
7893
+ const fromGeneratedImages = getValueByPath(fromObject, [
7894
+ 'predictions',
7895
+ ]);
7896
+ if (fromGeneratedImages != null) {
7897
+ let transformedList = fromGeneratedImages;
7898
+ if (Array.isArray(transformedList)) {
7899
+ transformedList = transformedList.map((item) => {
7900
+ return generatedImageFromVertex(apiClient, item);
7901
+ });
7902
+ }
7903
+ setValueByPath(toObject, ['generatedImages'], transformedList);
7904
+ }
7905
+ const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
7906
+ 'positivePromptSafetyAttributes',
7907
+ ]);
7908
+ if (fromPositivePromptSafetyAttributes != null) {
7909
+ setValueByPath(toObject, ['positivePromptSafetyAttributes'], safetyAttributesFromVertex(apiClient, fromPositivePromptSafetyAttributes));
7910
+ }
7911
+ return toObject;
7912
+ }
7913
+ function editImageResponseFromVertex(apiClient, fromObject) {
6841
7914
  const toObject = {};
6842
7915
  const fromGeneratedImages = getValueByPath(fromObject, [
6843
7916
  'predictions',
@@ -6851,11 +7924,21 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
6851
7924
  }
6852
7925
  setValueByPath(toObject, ['generatedImages'], transformedList);
6853
7926
  }
6854
- const fromPositivePromptSafetyAttributes = getValueByPath(fromObject, [
6855
- 'positivePromptSafetyAttributes',
7927
+ return toObject;
7928
+ }
7929
+ function upscaleImageResponseFromVertex(apiClient, fromObject) {
7930
+ const toObject = {};
7931
+ const fromGeneratedImages = getValueByPath(fromObject, [
7932
+ 'predictions',
6856
7933
  ]);
6857
- if (fromPositivePromptSafetyAttributes != null) {
6858
- setValueByPath(toObject, ['positivePromptSafetyAttributes'], safetyAttributesFromVertex(apiClient, fromPositivePromptSafetyAttributes));
7934
+ if (fromGeneratedImages != null) {
7935
+ let transformedList = fromGeneratedImages;
7936
+ if (Array.isArray(transformedList)) {
7937
+ transformedList = transformedList.map((item) => {
7938
+ return generatedImageFromVertex(apiClient, item);
7939
+ });
7940
+ }
7941
+ setValueByPath(toObject, ['generatedImages'], transformedList);
6859
7942
  }
6860
7943
  return toObject;
6861
7944
  }
@@ -6892,6 +7975,22 @@ function tunedModelInfoFromVertex(apiClient, fromObject) {
6892
7975
  }
6893
7976
  return toObject;
6894
7977
  }
7978
+ function checkpointFromVertex(apiClient, fromObject) {
7979
+ const toObject = {};
7980
+ const fromCheckpointId = getValueByPath(fromObject, ['checkpointId']);
7981
+ if (fromCheckpointId != null) {
7982
+ setValueByPath(toObject, ['checkpointId'], fromCheckpointId);
7983
+ }
7984
+ const fromEpoch = getValueByPath(fromObject, ['epoch']);
7985
+ if (fromEpoch != null) {
7986
+ setValueByPath(toObject, ['epoch'], fromEpoch);
7987
+ }
7988
+ const fromStep = getValueByPath(fromObject, ['step']);
7989
+ if (fromStep != null) {
7990
+ setValueByPath(toObject, ['step'], fromStep);
7991
+ }
7992
+ return toObject;
7993
+ }
6895
7994
  function modelFromVertex(apiClient, fromObject) {
6896
7995
  const toObject = {};
6897
7996
  const fromName = getValueByPath(fromObject, ['name']);
@@ -6928,6 +8027,42 @@ function modelFromVertex(apiClient, fromObject) {
6928
8027
  if (fromTunedModelInfo != null) {
6929
8028
  setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromVertex(apiClient, fromTunedModelInfo));
6930
8029
  }
8030
+ const fromDefaultCheckpointId = getValueByPath(fromObject, [
8031
+ 'defaultCheckpointId',
8032
+ ]);
8033
+ if (fromDefaultCheckpointId != null) {
8034
+ setValueByPath(toObject, ['defaultCheckpointId'], fromDefaultCheckpointId);
8035
+ }
8036
+ const fromCheckpoints = getValueByPath(fromObject, ['checkpoints']);
8037
+ if (fromCheckpoints != null) {
8038
+ let transformedList = fromCheckpoints;
8039
+ if (Array.isArray(transformedList)) {
8040
+ transformedList = transformedList.map((item) => {
8041
+ return checkpointFromVertex(apiClient, item);
8042
+ });
8043
+ }
8044
+ setValueByPath(toObject, ['checkpoints'], transformedList);
8045
+ }
8046
+ return toObject;
8047
+ }
8048
+ function listModelsResponseFromVertex(apiClient, fromObject) {
8049
+ const toObject = {};
8050
+ const fromNextPageToken = getValueByPath(fromObject, [
8051
+ 'nextPageToken',
8052
+ ]);
8053
+ if (fromNextPageToken != null) {
8054
+ setValueByPath(toObject, ['nextPageToken'], fromNextPageToken);
8055
+ }
8056
+ const fromModels = getValueByPath(fromObject, ['_self']);
8057
+ if (fromModels != null) {
8058
+ let transformedList = tExtractModels(apiClient, fromModels);
8059
+ if (Array.isArray(transformedList)) {
8060
+ transformedList = transformedList.map((item) => {
8061
+ return modelFromVertex(apiClient, item);
8062
+ });
8063
+ }
8064
+ setValueByPath(toObject, ['models'], transformedList);
8065
+ }
6931
8066
  return toObject;
6932
8067
  }
6933
8068
  function deleteModelResponseFromVertex() {
@@ -7047,7 +8182,7 @@ const FUNCTION_RESPONSE_REQUIRES_ID = 'FunctionResponse request must have an `id
7047
8182
  * @param event The MessageEvent from the WebSocket.
7048
8183
  */
7049
8184
  async function handleWebSocketMessage(apiClient, onmessage, event) {
7050
- let serverMessage;
8185
+ const serverMessage = new LiveServerMessage();
7051
8186
  let data;
7052
8187
  if (event.data instanceof Blob) {
7053
8188
  data = JSON.parse(await event.data.text());
@@ -7056,10 +8191,12 @@ async function handleWebSocketMessage(apiClient, onmessage, event) {
7056
8191
  data = JSON.parse(event.data);
7057
8192
  }
7058
8193
  if (apiClient.isVertexAI()) {
7059
- serverMessage = liveServerMessageFromVertex(apiClient, data);
8194
+ const resp = liveServerMessageFromVertex(apiClient, data);
8195
+ Object.assign(serverMessage, resp);
7060
8196
  }
7061
8197
  else {
7062
- serverMessage = liveServerMessageFromMldev(apiClient, data);
8198
+ const resp = liveServerMessageFromMldev(apiClient, data);
8199
+ Object.assign(serverMessage, resp);
7063
8200
  }
7064
8201
  onmessage(serverMessage);
7065
8202
  }
@@ -7516,9 +8653,7 @@ class Models extends BaseModule {
7516
8653
  /**
7517
8654
  * Generates an image based on a text description and configuration.
7518
8655
  *
7519
- * @param model - The model to use.
7520
- * @param prompt - A text description of the image to generate.
7521
- * @param [config] - The config for image generation.
8656
+ * @param params - The parameters for generating images.
7522
8657
  * @return The response from the API.
7523
8658
  *
7524
8659
  * @example
@@ -7566,6 +8701,97 @@ class Models extends BaseModule {
7566
8701
  return response;
7567
8702
  });
7568
8703
  };
8704
+ this.list = async (params) => {
8705
+ var _a;
8706
+ const defaultConfig = {
8707
+ queryBase: true,
8708
+ };
8709
+ const actualConfig = Object.assign(Object.assign({}, defaultConfig), params === null || params === void 0 ? void 0 : params.config);
8710
+ const actualParams = {
8711
+ config: actualConfig,
8712
+ };
8713
+ if (this.apiClient.isVertexAI()) {
8714
+ if (!actualParams.config.queryBase) {
8715
+ if ((_a = actualParams.config) === null || _a === void 0 ? void 0 : _a.filter) {
8716
+ throw new Error('Filtering tuned models list for Vertex AI is not currently supported');
8717
+ }
8718
+ else {
8719
+ actualParams.config.filter = 'labels.tune-type:*';
8720
+ }
8721
+ }
8722
+ }
8723
+ return new Pager(PagedItem.PAGED_ITEM_MODELS, (x) => this.listInternal(x), await this.listInternal(actualParams), actualParams);
8724
+ };
8725
+ /**
8726
+ * Edits an image based on a prompt, list of reference images, and configuration.
8727
+ *
8728
+ * @param params - The parameters for editing an image.
8729
+ * @return The response from the API.
8730
+ *
8731
+ * @example
8732
+ * ```ts
8733
+ * const response = await client.models.editImage({
8734
+ * model: 'imagen-3.0-capability-001',
8735
+ * prompt: 'Generate an image containing a mug with the product logo [1] visible on the side of the mug.',
8736
+ * referenceImages: [subjectReferenceImage]
8737
+ * config: {
8738
+ * numberOfImages: 1,
8739
+ * includeRaiReason: true,
8740
+ * },
8741
+ * });
8742
+ * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
8743
+ * ```
8744
+ */
8745
+ this.editImage = async (params) => {
8746
+ const paramsInternal = {
8747
+ model: params.model,
8748
+ prompt: params.prompt,
8749
+ referenceImages: [],
8750
+ config: params.config,
8751
+ };
8752
+ if (params.referenceImages) {
8753
+ if (params.referenceImages) {
8754
+ paramsInternal.referenceImages = params.referenceImages.map((img) => img.toReferenceImageAPI());
8755
+ }
8756
+ }
8757
+ return await this.editImageInternal(paramsInternal);
8758
+ };
8759
+ /**
8760
+ * Upscales an image based on an image, upscale factor, and configuration.
8761
+ * Only supported in Vertex AI currently.
8762
+ *
8763
+ * @param params - The parameters for upscaling an image.
8764
+ * @return The response from the API.
8765
+ *
8766
+ * @example
8767
+ * ```ts
8768
+ * const response = await client.models.upscaleImage({
8769
+ * model: 'imagen-3.0-generate-002',
8770
+ * image: image,
8771
+ * upscaleFactor: 'x2',
8772
+ * config: {
8773
+ * includeRaiReason: true,
8774
+ * },
8775
+ * });
8776
+ * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
8777
+ * ```
8778
+ */
8779
+ this.upscaleImage = async (params) => {
8780
+ let apiConfig = {
8781
+ numberOfImages: 1,
8782
+ mode: 'upscale',
8783
+ };
8784
+ if (params.config) {
8785
+ apiConfig = Object.assign(Object.assign({}, apiConfig), params.config);
8786
+ }
8787
+ const apiParams = {
8788
+ model: params.model,
8789
+ image: params.image,
8790
+ upscaleFactor: params.upscaleFactor,
8791
+ config: apiConfig,
8792
+ };
8793
+ return await this.upscaleImageInternal(apiParams);
8794
+ };
7569
8795
  }
7570
8796
  async generateContentInternal(params) {
7571
8797
  var _a, _b, _c, _d;
@@ -7867,6 +9093,76 @@ class Models extends BaseModule {
7867
9093
  });
7868
9094
  }
7869
9095
  }
9096
+ async editImageInternal(params) {
9097
+ var _a, _b;
9098
+ let response;
9099
+ let path = '';
9100
+ let queryParams = {};
9101
+ if (this.apiClient.isVertexAI()) {
9102
+ const body = editImageParametersInternalToVertex(this.apiClient, params);
9103
+ path = formatMap('{model}:predict', body['_url']);
9104
+ queryParams = body['_query'];
9105
+ delete body['config'];
9106
+ delete body['_url'];
9107
+ delete body['_query'];
9108
+ response = this.apiClient
9109
+ .request({
9110
+ path: path,
9111
+ queryParams: queryParams,
9112
+ body: JSON.stringify(body),
9113
+ httpMethod: 'POST',
9114
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
9115
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
9116
+ })
9117
+ .then((httpResponse) => {
9118
+ return httpResponse.json();
9119
+ });
9120
+ return response.then((apiResponse) => {
9121
+ const resp = editImageResponseFromVertex(this.apiClient, apiResponse);
9122
+ const typedResp = new EditImageResponse();
9123
+ Object.assign(typedResp, resp);
9124
+ return typedResp;
9125
+ });
9126
+ }
9127
+ else {
9128
+ throw new Error('This method is only supported by the Vertex AI.');
9129
+ }
9130
+ }
9131
+ async upscaleImageInternal(params) {
9132
+ var _a, _b;
9133
+ let response;
9134
+ let path = '';
9135
+ let queryParams = {};
9136
+ if (this.apiClient.isVertexAI()) {
9137
+ const body = upscaleImageAPIParametersInternalToVertex(this.apiClient, params);
9138
+ path = formatMap('{model}:predict', body['_url']);
9139
+ queryParams = body['_query'];
9140
+ delete body['config'];
9141
+ delete body['_url'];
9142
+ delete body['_query'];
9143
+ response = this.apiClient
9144
+ .request({
9145
+ path: path,
9146
+ queryParams: queryParams,
9147
+ body: JSON.stringify(body),
9148
+ httpMethod: 'POST',
9149
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
9150
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
9151
+ })
9152
+ .then((httpResponse) => {
9153
+ return httpResponse.json();
9154
+ });
9155
+ return response.then((apiResponse) => {
9156
+ const resp = upscaleImageResponseFromVertex(this.apiClient, apiResponse);
9157
+ const typedResp = new UpscaleImageResponse();
9158
+ Object.assign(typedResp, resp);
9159
+ return typedResp;
9160
+ });
9161
+ }
9162
+ else {
9163
+ throw new Error('This method is only supported by the Vertex AI.');
9164
+ }
9165
+ }
7870
9166
  /**
7871
9167
  * Fetches information about a model by name.
7872
9168
  *
@@ -7929,6 +9225,64 @@ class Models extends BaseModule {
7929
9225
  });
7930
9226
  }
7931
9227
  }
9228
+ async listInternal(params) {
9229
+ var _a, _b, _c, _d;
9230
+ let response;
9231
+ let path = '';
9232
+ let queryParams = {};
9233
+ if (this.apiClient.isVertexAI()) {
9234
+ const body = listModelsParametersToVertex(this.apiClient, params);
9235
+ path = formatMap('{models_url}', body['_url']);
9236
+ queryParams = body['_query'];
9237
+ delete body['config'];
9238
+ delete body['_url'];
9239
+ delete body['_query'];
9240
+ response = this.apiClient
9241
+ .request({
9242
+ path: path,
9243
+ queryParams: queryParams,
9244
+ body: JSON.stringify(body),
9245
+ httpMethod: 'GET',
9246
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
9247
+ abortSignal: (_b = params.config) === null || _b === void 0 ? void 0 : _b.abortSignal,
9248
+ })
9249
+ .then((httpResponse) => {
9250
+ return httpResponse.json();
9251
+ });
9252
+ return response.then((apiResponse) => {
9253
+ const resp = listModelsResponseFromVertex(this.apiClient, apiResponse);
9254
+ const typedResp = new ListModelsResponse();
9255
+ Object.assign(typedResp, resp);
9256
+ return typedResp;
9257
+ });
9258
+ }
9259
+ else {
9260
+ const body = listModelsParametersToMldev(this.apiClient, params);
9261
+ path = formatMap('{models_url}', body['_url']);
9262
+ queryParams = body['_query'];
9263
+ delete body['config'];
9264
+ delete body['_url'];
9265
+ delete body['_query'];
9266
+ response = this.apiClient
9267
+ .request({
9268
+ path: path,
9269
+ queryParams: queryParams,
9270
+ body: JSON.stringify(body),
9271
+ httpMethod: 'GET',
9272
+ httpOptions: (_c = params.config) === null || _c === void 0 ? void 0 : _c.httpOptions,
9273
+ abortSignal: (_d = params.config) === null || _d === void 0 ? void 0 : _d.abortSignal,
9274
+ })
9275
+ .then((httpResponse) => {
9276
+ return httpResponse.json();
9277
+ });
9278
+ return response.then((apiResponse) => {
9279
+ const resp = listModelsResponseFromMldev(this.apiClient, apiResponse);
9280
+ const typedResp = new ListModelsResponse();
9281
+ Object.assign(typedResp, resp);
9282
+ return typedResp;
9283
+ });
9284
+ }
9285
+ }
7932
9286
  /**
7933
9287
  * Updates a tuned model by its name.
7934
9288
  *
@@ -8624,7 +9978,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
8624
9978
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
8625
9979
  const USER_AGENT_HEADER = 'User-Agent';
8626
9980
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
8627
- const SDK_VERSION = '0.12.0'; // x-release-please-version
9981
+ const SDK_VERSION = '0.14.0'; // x-release-please-version
8628
9982
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
8629
9983
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
8630
9984
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -8671,18 +10025,11 @@ class ApiClient {
8671
10025
  if (this.clientOptions.vertexai) {
8672
10026
  initHttpOptions.apiVersion =
8673
10027
  (_a = this.clientOptions.apiVersion) !== null && _a !== void 0 ? _a : VERTEX_AI_API_DEFAULT_VERSION;
8674
- // Assume that proj/api key validation occurs before they are passed in.
8675
- if (this.getProject() || this.getLocation()) {
8676
- initHttpOptions.baseUrl = `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
8677
- this.clientOptions.apiKey = undefined; // unset API key.
8678
- }
8679
- else {
8680
- initHttpOptions.baseUrl = `https://aiplatform.googleapis.com/`;
8681
- this.clientOptions.project = undefined; // unset project.
8682
- this.clientOptions.location = undefined; // unset location.
8683
- }
10028
+ initHttpOptions.baseUrl = this.baseUrlFromProjectLocation();
10029
+ this.normalizeAuthParameters();
8684
10030
  }
8685
10031
  else {
10032
+ // Gemini API
8686
10033
  initHttpOptions.apiVersion =
8687
10034
  (_b = this.clientOptions.apiVersion) !== null && _b !== void 0 ? _b : GOOGLE_AI_API_DEFAULT_VERSION;
8688
10035
  initHttpOptions.baseUrl = `https://generativelanguage.googleapis.com/`;
@@ -8693,6 +10040,39 @@ class ApiClient {
8693
10040
  this.clientOptions.httpOptions = this.patchHttpOptions(initHttpOptions, opts.httpOptions);
8694
10041
  }
8695
10042
  }
10043
+ /**
10044
+ * Determines the base URL for Vertex AI based on project and location.
10045
+ * Uses the global endpoint if location is 'global' or if project/location
10046
+ * are not specified (implying API key usage).
10047
+ * @private
10048
+ */
10049
+ baseUrlFromProjectLocation() {
10050
+ if (this.clientOptions.project &&
10051
+ this.clientOptions.location &&
10052
+ this.clientOptions.location !== 'global') {
10053
+ // Regional endpoint
10054
+ return `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
10055
+ }
10056
+ // Global endpoint (covers 'global' location and API key usage)
10057
+ return `https://aiplatform.googleapis.com/`;
10058
+ }
10059
+ /**
10060
+ * Normalizes authentication parameters for Vertex AI.
10061
+ * If project and location are provided, API key is cleared.
10062
+ * If project and location are not provided (implying API key usage),
10063
+ * project and location are cleared.
10064
+ * @private
10065
+ */
10066
+ normalizeAuthParameters() {
10067
+ if (this.clientOptions.project && this.clientOptions.location) {
10068
+ // Using project/location for auth, clear potential API key
10069
+ this.clientOptions.apiKey = undefined;
10070
+ return;
10071
+ }
10072
+ // Using API key for auth (or no auth provided yet), clear project/location
10073
+ this.clientOptions.project = undefined;
10074
+ this.clientOptions.location = undefined;
10075
+ }
8696
10076
  isVertexAI() {
8697
10077
  var _a;
8698
10078
  return (_a = this.clientOptions.vertexai) !== null && _a !== void 0 ? _a : false;
@@ -9030,6 +10410,16 @@ class ApiClient {
9030
10410
  const uploadUrl = await this.fetchUploadUrl(fileToUpload, config);
9031
10411
  return uploader.upload(file, uploadUrl, this);
9032
10412
  }
10413
+ /**
10414
+ * Downloads a file asynchronously to the specified path.
10415
+ *
10416
+ * @params params - The parameters for the download request, see {@link
10417
+ * DownloadFileParameters}
10418
+ */
10419
+ async downloadFile(params) {
10420
+ const downloader = this.clientOptions.downloader;
10421
+ await downloader.download(params, this);
10422
+ }
9033
10423
  async fetchUploadUrl(file, config) {
9034
10424
  var _a;
9035
10425
  let httpOptions = {};
@@ -9195,6 +10585,10 @@ function createTuningJobConfigToMldev(apiClient, fromObject, parentObject) {
9195
10585
  if (fromLearningRateMultiplier != null) {
9196
10586
  setValueByPath(toObject, ['tuningTask', 'hyperparameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
9197
10587
  }
10588
+ if (getValueByPath(fromObject, ['exportLastCheckpointOnly']) !==
10589
+ undefined) {
10590
+ throw new Error('exportLastCheckpointOnly parameter is not supported in Gemini API.');
10591
+ }
9198
10592
  if (getValueByPath(fromObject, ['adapterSize']) !== undefined) {
9199
10593
  throw new Error('adapterSize parameter is not supported in Gemini API.');
9200
10594
  }
@@ -9309,6 +10703,12 @@ function createTuningJobConfigToVertex(apiClient, fromObject, parentObject) {
9309
10703
  if (parentObject !== undefined && fromLearningRateMultiplier != null) {
9310
10704
  setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'], fromLearningRateMultiplier);
9311
10705
  }
10706
+ const fromExportLastCheckpointOnly = getValueByPath(fromObject, [
10707
+ 'exportLastCheckpointOnly',
10708
+ ]);
10709
+ if (parentObject !== undefined && fromExportLastCheckpointOnly != null) {
10710
+ setValueByPath(parentObject, ['supervisedTuningSpec', 'exportLastCheckpointOnly'], fromExportLastCheckpointOnly);
10711
+ }
9312
10712
  const fromAdapterSize = getValueByPath(fromObject, ['adapterSize']);
9313
10713
  if (parentObject !== undefined && fromAdapterSize != null) {
9314
10714
  setValueByPath(parentObject, ['supervisedTuningSpec', 'hyperParameters', 'adapterSize'], fromAdapterSize);
@@ -9461,6 +10861,26 @@ function operationFromMldev(apiClient, fromObject) {
9461
10861
  }
9462
10862
  return toObject;
9463
10863
  }
10864
+ function tunedModelCheckpointFromVertex(apiClient, fromObject) {
10865
+ const toObject = {};
10866
+ const fromCheckpointId = getValueByPath(fromObject, ['checkpointId']);
10867
+ if (fromCheckpointId != null) {
10868
+ setValueByPath(toObject, ['checkpointId'], fromCheckpointId);
10869
+ }
10870
+ const fromEpoch = getValueByPath(fromObject, ['epoch']);
10871
+ if (fromEpoch != null) {
10872
+ setValueByPath(toObject, ['epoch'], fromEpoch);
10873
+ }
10874
+ const fromStep = getValueByPath(fromObject, ['step']);
10875
+ if (fromStep != null) {
10876
+ setValueByPath(toObject, ['step'], fromStep);
10877
+ }
10878
+ const fromEndpoint = getValueByPath(fromObject, ['endpoint']);
10879
+ if (fromEndpoint != null) {
10880
+ setValueByPath(toObject, ['endpoint'], fromEndpoint);
10881
+ }
10882
+ return toObject;
10883
+ }
9464
10884
  function tunedModelFromVertex(apiClient, fromObject) {
9465
10885
  const toObject = {};
9466
10886
  const fromModel = getValueByPath(fromObject, ['model']);
@@ -9471,6 +10891,16 @@ function tunedModelFromVertex(apiClient, fromObject) {
9471
10891
  if (fromEndpoint != null) {
9472
10892
  setValueByPath(toObject, ['endpoint'], fromEndpoint);
9473
10893
  }
10894
+ const fromCheckpoints = getValueByPath(fromObject, ['checkpoints']);
10895
+ if (fromCheckpoints != null) {
10896
+ let transformedList = fromCheckpoints;
10897
+ if (Array.isArray(transformedList)) {
10898
+ transformedList = transformedList.map((item) => {
10899
+ return tunedModelCheckpointFromVertex(apiClient, item);
10900
+ });
10901
+ }
10902
+ setValueByPath(toObject, ['checkpoints'], transformedList);
10903
+ }
9474
10904
  return toObject;
9475
10905
  }
9476
10906
  function tuningJobFromVertex(apiClient, fromObject) {
@@ -9831,9 +11261,24 @@ class Tunings extends BaseModule {
9831
11261
  }
9832
11262
  }
9833
11263
 
11264
+ /**
11265
+ * @license
11266
+ * Copyright 2025 Google LLC
11267
+ * SPDX-License-Identifier: Apache-2.0
11268
+ */
11269
+ class BrowserDownloader {
11270
+ async download(_params, _apiClient) {
11271
+ throw new Error('Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.');
11272
+ }
11273
+ }
11274
+
9834
11275
  const MAX_CHUNK_SIZE = 1024 * 1024 * 8; // bytes
11276
+ const MAX_RETRY_COUNT = 3;
11277
+ const INITIAL_RETRY_DELAY_MS = 1000;
11278
+ const DELAY_MULTIPLIER = 2;
11279
+ const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
9835
11280
  async function uploadBlob(file, uploadUrl, apiClient) {
9836
- var _a, _b;
11281
+ var _a, _b, _c;
9837
11282
  let fileSize = 0;
9838
11283
  let offset = 0;
9839
11284
  let response = new HttpResponse(new Response());
@@ -9845,24 +11290,34 @@ async function uploadBlob(file, uploadUrl, apiClient) {
9845
11290
  if (offset + chunkSize >= fileSize) {
9846
11291
  uploadCommand += ', finalize';
9847
11292
  }
9848
- response = await apiClient.request({
9849
- path: '',
9850
- body: chunk,
9851
- httpMethod: 'POST',
9852
- httpOptions: {
9853
- apiVersion: '',
9854
- baseUrl: uploadUrl,
9855
- headers: {
9856
- 'X-Goog-Upload-Command': uploadCommand,
9857
- 'X-Goog-Upload-Offset': String(offset),
9858
- 'Content-Length': String(chunkSize),
11293
+ let retryCount = 0;
11294
+ let currentDelayMs = INITIAL_RETRY_DELAY_MS;
11295
+ while (retryCount < MAX_RETRY_COUNT) {
11296
+ response = await apiClient.request({
11297
+ path: '',
11298
+ body: chunk,
11299
+ httpMethod: 'POST',
11300
+ httpOptions: {
11301
+ apiVersion: '',
11302
+ baseUrl: uploadUrl,
11303
+ headers: {
11304
+ 'X-Goog-Upload-Command': uploadCommand,
11305
+ 'X-Goog-Upload-Offset': String(offset),
11306
+ 'Content-Length': String(chunkSize),
11307
+ },
9859
11308
  },
9860
- },
9861
- });
11309
+ });
11310
+ if ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
11311
+ break;
11312
+ }
11313
+ retryCount++;
11314
+ await sleep(currentDelayMs);
11315
+ currentDelayMs = currentDelayMs * DELAY_MULTIPLIER;
11316
+ }
9862
11317
  offset += chunkSize;
9863
11318
  // The `x-goog-upload-status` header field can be `active`, `final` and
9864
11319
  //`cancelled` in resposne.
9865
- if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a['x-goog-upload-status']) !== 'active') {
11320
+ 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') {
9866
11321
  break;
9867
11322
  }
9868
11323
  // TODO(b/401391430) Investigate why the upload status is not finalized
@@ -9872,7 +11327,7 @@ async function uploadBlob(file, uploadUrl, apiClient) {
9872
11327
  }
9873
11328
  }
9874
11329
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
9875
- if (((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b['x-goog-upload-status']) !== 'final') {
11330
+ 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') {
9876
11331
  throw new Error('Failed to upload file: Upload status is not finalized.');
9877
11332
  }
9878
11333
  return responseJson['file'];
@@ -9881,6 +11336,9 @@ async function getBlobStat(file) {
9881
11336
  const fileStat = { size: file.size, type: file.type };
9882
11337
  return fileStat;
9883
11338
  }
11339
+ function sleep(ms) {
11340
+ return new Promise((resolvePromise) => setTimeout(resolvePromise, ms));
11341
+ }
9884
11342
 
9885
11343
  class BrowserUploader {
9886
11344
  async upload(file, uploadUrl, apiClient) {
@@ -10033,6 +11491,7 @@ class GoogleGenAI {
10033
11491
  httpOptions: options.httpOptions,
10034
11492
  userAgentExtra: LANGUAGE_LABEL_PREFIX + 'web',
10035
11493
  uploader: new BrowserUploader(),
11494
+ downloader: new BrowserDownloader(),
10036
11495
  });
10037
11496
  this.models = new Models(this.apiClient);
10038
11497
  this.live = new Live(this.apiClient, auth, new BrowserWebSocketFactory());
@@ -10044,5 +11503,5 @@ class GoogleGenAI {
10044
11503
  }
10045
11504
  }
10046
11505
 
10047
- export { ActivityHandling, AdapterSize, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, JobState, Language, ListCachedContentsResponse, ListFilesResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, StartSensitivity, SubjectReferenceType, TrafficType, TurnCoverage, Type, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, setDefaultBaseUrls };
11506
+ export { ActivityHandling, AdapterSize, AuthType, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EndSensitivity, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, JobState, Language, ListCachedContentsResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, RawReferenceImage, ReplayResponse, SafetyFilterLevel, Session, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, TrafficType, TurnCoverage, Type, UpscaleImageResponse, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, setDefaultBaseUrls };
10048
11507
  //# sourceMappingURL=index.mjs.map