@google/genai 1.45.0 → 1.47.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.
@@ -403,6 +403,18 @@ function uploadToFileSearchStoreResponseFromMldev(fromObject) {
403
403
  * Copyright 2025 Google LLC
404
404
  * SPDX-License-Identifier: Apache-2.0
405
405
  */
406
+ /** Programming language of the `code`. */
407
+ var Language;
408
+ (function (Language) {
409
+ /**
410
+ * Unspecified language. This value should not be used.
411
+ */
412
+ Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
413
+ /**
414
+ * Python >= 3.10, with numpy and simpy available.
415
+ */
416
+ Language["PYTHON"] = "PYTHON";
417
+ })(Language || (Language = {}));
406
418
  /** Outcome of the code execution. */
407
419
  var Outcome;
408
420
  (function (Outcome) {
@@ -423,18 +435,6 @@ var Outcome;
423
435
  */
424
436
  Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
425
437
  })(Outcome || (Outcome = {}));
426
- /** Programming language of the `code`. */
427
- var Language;
428
- (function (Language) {
429
- /**
430
- * Unspecified language. This value should not be used.
431
- */
432
- Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
433
- /**
434
- * Python >= 3.10, with numpy and simpy available.
435
- */
436
- Language["PYTHON"] = "PYTHON";
437
- })(Language || (Language = {}));
438
438
  /** Specifies how the response should be scheduled in the conversation. */
439
439
  var FunctionResponseScheduling;
440
440
  (function (FunctionResponseScheduling) {
@@ -491,38 +491,18 @@ var Type;
491
491
  */
492
492
  Type["NULL"] = "NULL";
493
493
  })(Type || (Type = {}));
494
- /** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
495
- var PhishBlockThreshold;
496
- (function (PhishBlockThreshold) {
497
- /**
498
- * Defaults to unspecified.
499
- */
500
- PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
501
- /**
502
- * Blocks Low and above confidence URL that is risky.
503
- */
504
- PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
505
- /**
506
- * Blocks Medium and above confidence URL that is risky.
507
- */
508
- PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
509
- /**
510
- * Blocks High and above confidence URL that is risky.
511
- */
512
- PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
513
- /**
514
- * Blocks Higher and above confidence URL that is risky.
515
- */
516
- PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
494
+ /** The environment being operated. */
495
+ var Environment;
496
+ (function (Environment) {
517
497
  /**
518
- * Blocks Very high and above confidence URL that is risky.
498
+ * Defaults to browser.
519
499
  */
520
- PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
500
+ Environment["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
521
501
  /**
522
- * Blocks Extremely high confidence URL that is risky.
502
+ * Operates in a web browser.
523
503
  */
524
- PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
525
- })(PhishBlockThreshold || (PhishBlockThreshold = {}));
504
+ Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
505
+ })(Environment || (Environment = {}));
526
506
  /** Type of auth scheme. This enum is not supported in Gemini API. */
527
507
  var AuthType;
528
508
  (function (AuthType) {
@@ -593,6 +573,38 @@ var ApiSpec;
593
573
  */
594
574
  ApiSpec["ELASTIC_SEARCH"] = "ELASTIC_SEARCH";
595
575
  })(ApiSpec || (ApiSpec = {}));
576
+ /** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
577
+ var PhishBlockThreshold;
578
+ (function (PhishBlockThreshold) {
579
+ /**
580
+ * Defaults to unspecified.
581
+ */
582
+ PhishBlockThreshold["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"] = "PHISH_BLOCK_THRESHOLD_UNSPECIFIED";
583
+ /**
584
+ * Blocks Low and above confidence URL that is risky.
585
+ */
586
+ PhishBlockThreshold["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
587
+ /**
588
+ * Blocks Medium and above confidence URL that is risky.
589
+ */
590
+ PhishBlockThreshold["BLOCK_MEDIUM_AND_ABOVE"] = "BLOCK_MEDIUM_AND_ABOVE";
591
+ /**
592
+ * Blocks High and above confidence URL that is risky.
593
+ */
594
+ PhishBlockThreshold["BLOCK_HIGH_AND_ABOVE"] = "BLOCK_HIGH_AND_ABOVE";
595
+ /**
596
+ * Blocks Higher and above confidence URL that is risky.
597
+ */
598
+ PhishBlockThreshold["BLOCK_HIGHER_AND_ABOVE"] = "BLOCK_HIGHER_AND_ABOVE";
599
+ /**
600
+ * Blocks Very high and above confidence URL that is risky.
601
+ */
602
+ PhishBlockThreshold["BLOCK_VERY_HIGH_AND_ABOVE"] = "BLOCK_VERY_HIGH_AND_ABOVE";
603
+ /**
604
+ * Blocks Extremely high confidence URL that is risky.
605
+ */
606
+ PhishBlockThreshold["BLOCK_ONLY_EXTREMELY_HIGH"] = "BLOCK_ONLY_EXTREMELY_HIGH";
607
+ })(PhishBlockThreshold || (PhishBlockThreshold = {}));
596
608
  /** Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This enum is not supported in Vertex AI. */
597
609
  var Behavior;
598
610
  (function (Behavior) {
@@ -652,6 +664,10 @@ var ThinkingLevel;
652
664
  * Unspecified thinking level.
653
665
  */
654
666
  ThinkingLevel["THINKING_LEVEL_UNSPECIFIED"] = "THINKING_LEVEL_UNSPECIFIED";
667
+ /**
668
+ * MINIMAL thinking level.
669
+ */
670
+ ThinkingLevel["MINIMAL"] = "MINIMAL";
655
671
  /**
656
672
  * Low thinking level.
657
673
  */
@@ -664,10 +680,6 @@ var ThinkingLevel;
664
680
  * High thinking level.
665
681
  */
666
682
  ThinkingLevel["HIGH"] = "HIGH";
667
- /**
668
- * MINIMAL thinking level.
669
- */
670
- ThinkingLevel["MINIMAL"] = "MINIMAL";
671
683
  })(ThinkingLevel || (ThinkingLevel = {}));
672
684
  /** Enum that controls the generation of people. */
673
685
  var PersonGeneration;
@@ -685,6 +697,22 @@ var PersonGeneration;
685
697
  */
686
698
  PersonGeneration["ALLOW_ALL"] = "ALLOW_ALL";
687
699
  })(PersonGeneration || (PersonGeneration = {}));
700
+ /** Controls whether prominent people (celebrities) generation is allowed. If used with personGeneration, personGeneration enum would take precedence. For instance, if ALLOW_NONE is set, all person generation would be blocked. If this field is unspecified, the default behavior is to allow prominent people. This enum is not supported in Gemini API. */
701
+ var ProminentPeople;
702
+ (function (ProminentPeople) {
703
+ /**
704
+ * Unspecified value. The model will proceed with the default behavior, which is to allow generation of prominent people.
705
+ */
706
+ ProminentPeople["PROMINENT_PEOPLE_UNSPECIFIED"] = "PROMINENT_PEOPLE_UNSPECIFIED";
707
+ /**
708
+ * Allows the model to generate images of prominent people.
709
+ */
710
+ ProminentPeople["ALLOW_PROMINENT_PEOPLE"] = "ALLOW_PROMINENT_PEOPLE";
711
+ /**
712
+ * Prevents the model from generating images of prominent people.
713
+ */
714
+ ProminentPeople["BLOCK_PROMINENT_PEOPLE"] = "BLOCK_PROMINENT_PEOPLE";
715
+ })(ProminentPeople || (ProminentPeople = {}));
688
716
  /** The harm category to be blocked. */
689
717
  var HarmCategory;
690
718
  (function (HarmCategory) {
@@ -1003,6 +1031,42 @@ var Modality;
1003
1031
  */
1004
1032
  Modality["AUDIO"] = "AUDIO";
1005
1033
  })(Modality || (Modality = {}));
1034
+ /** The stage of the underlying model. This enum is not supported in Vertex AI. */
1035
+ var ModelStage;
1036
+ (function (ModelStage) {
1037
+ /**
1038
+ * Unspecified model stage.
1039
+ */
1040
+ ModelStage["MODEL_STAGE_UNSPECIFIED"] = "MODEL_STAGE_UNSPECIFIED";
1041
+ /**
1042
+ * The underlying model is subject to lots of tunings.
1043
+ */
1044
+ ModelStage["UNSTABLE_EXPERIMENTAL"] = "UNSTABLE_EXPERIMENTAL";
1045
+ /**
1046
+ * Models in this stage are for experimental purposes only.
1047
+ */
1048
+ ModelStage["EXPERIMENTAL"] = "EXPERIMENTAL";
1049
+ /**
1050
+ * Models in this stage are more mature than experimental models.
1051
+ */
1052
+ ModelStage["PREVIEW"] = "PREVIEW";
1053
+ /**
1054
+ * Models in this stage are considered stable and ready for production use.
1055
+ */
1056
+ ModelStage["STABLE"] = "STABLE";
1057
+ /**
1058
+ * If the model is on this stage, it means that this model is on the path to deprecation in near future. Only existing customers can use this model.
1059
+ */
1060
+ ModelStage["LEGACY"] = "LEGACY";
1061
+ /**
1062
+ * Models in this stage are deprecated. These models cannot be used.
1063
+ */
1064
+ ModelStage["DEPRECATED"] = "DEPRECATED";
1065
+ /**
1066
+ * Models in this stage are retired. These models cannot be used.
1067
+ */
1068
+ ModelStage["RETIRED"] = "RETIRED";
1069
+ })(ModelStage || (ModelStage = {}));
1006
1070
  /** The media resolution to use. */
1007
1071
  var MediaResolution;
1008
1072
  (function (MediaResolution) {
@@ -1239,6 +1303,26 @@ var TuningTask;
1239
1303
  */
1240
1304
  TuningTask["TUNING_TASK_R2V"] = "TUNING_TASK_R2V";
1241
1305
  })(TuningTask || (TuningTask = {}));
1306
+ /** Output only. Current state of the `Document`. This enum is not supported in Vertex AI. */
1307
+ var DocumentState;
1308
+ (function (DocumentState) {
1309
+ /**
1310
+ * The default value. This value is used if the state is omitted.
1311
+ */
1312
+ DocumentState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
1313
+ /**
1314
+ * Some `Chunks` of the `Document` are being processed (embedding and vector storage).
1315
+ */
1316
+ DocumentState["STATE_PENDING"] = "STATE_PENDING";
1317
+ /**
1318
+ * All `Chunks` of the `Document` is processed and available for querying.
1319
+ */
1320
+ DocumentState["STATE_ACTIVE"] = "STATE_ACTIVE";
1321
+ /**
1322
+ * Some `Chunks` of the `Document` failed processing.
1323
+ */
1324
+ DocumentState["STATE_FAILED"] = "STATE_FAILED";
1325
+ })(DocumentState || (DocumentState = {}));
1242
1326
  /** The tokenization quality used for given media. */
1243
1327
  var PartMediaResolutionLevel;
1244
1328
  (function (PartMediaResolutionLevel) {
@@ -1263,6 +1347,34 @@ var PartMediaResolutionLevel;
1263
1347
  */
1264
1348
  PartMediaResolutionLevel["MEDIA_RESOLUTION_ULTRA_HIGH"] = "MEDIA_RESOLUTION_ULTRA_HIGH";
1265
1349
  })(PartMediaResolutionLevel || (PartMediaResolutionLevel = {}));
1350
+ /** The type of tool in the function call. */
1351
+ var ToolType;
1352
+ (function (ToolType) {
1353
+ /**
1354
+ * Unspecified tool type.
1355
+ */
1356
+ ToolType["TOOL_TYPE_UNSPECIFIED"] = "TOOL_TYPE_UNSPECIFIED";
1357
+ /**
1358
+ * Google search tool, maps to Tool.google_search.search_types.web_search.
1359
+ */
1360
+ ToolType["GOOGLE_SEARCH_WEB"] = "GOOGLE_SEARCH_WEB";
1361
+ /**
1362
+ * Image search tool, maps to Tool.google_search.search_types.image_search.
1363
+ */
1364
+ ToolType["GOOGLE_SEARCH_IMAGE"] = "GOOGLE_SEARCH_IMAGE";
1365
+ /**
1366
+ * URL context tool, maps to Tool.url_context.
1367
+ */
1368
+ ToolType["URL_CONTEXT"] = "URL_CONTEXT";
1369
+ /**
1370
+ * Google maps tool, maps to Tool.google_maps.
1371
+ */
1372
+ ToolType["GOOGLE_MAPS"] = "GOOGLE_MAPS";
1373
+ /**
1374
+ * File search tool, maps to Tool.file_search.
1375
+ */
1376
+ ToolType["FILE_SEARCH"] = "FILE_SEARCH";
1377
+ })(ToolType || (ToolType = {}));
1266
1378
  /** Resource scope. */
1267
1379
  var ResourceScope;
1268
1380
  (function (ResourceScope) {
@@ -1275,42 +1387,34 @@ var ResourceScope;
1275
1387
  */
1276
1388
  ResourceScope["COLLECTION"] = "COLLECTION";
1277
1389
  })(ResourceScope || (ResourceScope = {}));
1278
- /** Options for feature selection preference. */
1279
- var FeatureSelectionPreference;
1280
- (function (FeatureSelectionPreference) {
1281
- FeatureSelectionPreference["FEATURE_SELECTION_PREFERENCE_UNSPECIFIED"] = "FEATURE_SELECTION_PREFERENCE_UNSPECIFIED";
1282
- FeatureSelectionPreference["PRIORITIZE_QUALITY"] = "PRIORITIZE_QUALITY";
1283
- FeatureSelectionPreference["BALANCED"] = "BALANCED";
1284
- FeatureSelectionPreference["PRIORITIZE_COST"] = "PRIORITIZE_COST";
1285
- })(FeatureSelectionPreference || (FeatureSelectionPreference = {}));
1286
- /** The environment being operated. */
1287
- var Environment;
1288
- (function (Environment) {
1390
+ /** Pricing and performance service tier. */
1391
+ var ServiceTier;
1392
+ (function (ServiceTier) {
1289
1393
  /**
1290
- * Defaults to browser.
1394
+ * Default service tier, which is standard.
1291
1395
  */
1292
- Environment["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
1396
+ ServiceTier["SERVICE_TIER_UNSPECIFIED"] = "SERVICE_TIER_UNSPECIFIED";
1293
1397
  /**
1294
- * Operates in a web browser.
1398
+ * Flex service tier.
1295
1399
  */
1296
- Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
1297
- })(Environment || (Environment = {}));
1298
- /** Enum for controlling whether the model can generate images of prominent people (celebrities). */
1299
- var ProminentPeople;
1300
- (function (ProminentPeople) {
1400
+ ServiceTier["SERVICE_TIER_FLEX"] = "SERVICE_TIER_FLEX";
1301
1401
  /**
1302
- * Unspecified value. The model will proceed with the default behavior, which is to allow generation of prominent people.
1303
- */
1304
- ProminentPeople["PROMINENT_PEOPLE_UNSPECIFIED"] = "PROMINENT_PEOPLE_UNSPECIFIED";
1305
- /**
1306
- * Allows the model to generate images of prominent people.
1402
+ * Standard service tier.
1307
1403
  */
1308
- ProminentPeople["ALLOW_PROMINENT_PEOPLE"] = "ALLOW_PROMINENT_PEOPLE";
1404
+ ServiceTier["SERVICE_TIER_STANDARD"] = "SERVICE_TIER_STANDARD";
1309
1405
  /**
1310
- * Prevents the model from generating images of prominent people.
1406
+ * Priority service tier.
1311
1407
  */
1312
- ProminentPeople["BLOCK_PROMINENT_PEOPLE"] = "BLOCK_PROMINENT_PEOPLE";
1313
- })(ProminentPeople || (ProminentPeople = {}));
1408
+ ServiceTier["SERVICE_TIER_PRIORITY"] = "SERVICE_TIER_PRIORITY";
1409
+ })(ServiceTier || (ServiceTier = {}));
1410
+ /** Options for feature selection preference. */
1411
+ var FeatureSelectionPreference;
1412
+ (function (FeatureSelectionPreference) {
1413
+ FeatureSelectionPreference["FEATURE_SELECTION_PREFERENCE_UNSPECIFIED"] = "FEATURE_SELECTION_PREFERENCE_UNSPECIFIED";
1414
+ FeatureSelectionPreference["PRIORITIZE_QUALITY"] = "PRIORITIZE_QUALITY";
1415
+ FeatureSelectionPreference["BALANCED"] = "BALANCED";
1416
+ FeatureSelectionPreference["PRIORITIZE_COST"] = "PRIORITIZE_COST";
1417
+ })(FeatureSelectionPreference || (FeatureSelectionPreference = {}));
1314
1418
  /** Enum representing the Vertex embedding API to use. */
1315
1419
  var EmbeddingApiType;
1316
1420
  (function (EmbeddingApiType) {
@@ -1485,14 +1589,6 @@ var TuningMethod;
1485
1589
  */
1486
1590
  TuningMethod["DISTILLATION"] = "DISTILLATION";
1487
1591
  })(TuningMethod || (TuningMethod = {}));
1488
- /** State for the lifecycle of a Document. */
1489
- var DocumentState;
1490
- (function (DocumentState) {
1491
- DocumentState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
1492
- DocumentState["STATE_PENDING"] = "STATE_PENDING";
1493
- DocumentState["STATE_ACTIVE"] = "STATE_ACTIVE";
1494
- DocumentState["STATE_FAILED"] = "STATE_FAILED";
1495
- })(DocumentState || (DocumentState = {}));
1496
1592
  /** State for the lifecycle of a File. */
1497
1593
  var FileState;
1498
1594
  (function (FileState) {
@@ -1652,6 +1748,10 @@ var TurnCoverage;
1652
1748
  * The users turn includes all realtime input since the last turn, including inactivity (e.g. silence on the audio stream).
1653
1749
  */
1654
1750
  TurnCoverage["TURN_INCLUDES_ALL_INPUT"] = "TURN_INCLUDES_ALL_INPUT";
1751
+ /**
1752
+ * Includes audio activity and all video since the last turn. With automatic activity detection, audio activity means speech and excludes silence.
1753
+ */
1754
+ TurnCoverage["TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO"] = "TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO";
1655
1755
  })(TurnCoverage || (TurnCoverage = {}));
1656
1756
  /** Scale of the generated music. */
1657
1757
  var Scale;
@@ -1778,7 +1878,6 @@ class HttpResponse {
1778
1878
  class UploadToFileSearchStoreOperation {
1779
1879
  /**
1780
1880
  * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
1781
- * @internal
1782
1881
  */
1783
1882
  _fromAPIResponse({ apiResponse, _isVertexAI, }) {
1784
1883
  const operation = new UploadToFileSearchStoreOperation();
@@ -1798,7 +1897,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
1798
1897
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
1799
1898
  const USER_AGENT_HEADER = 'User-Agent';
1800
1899
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
1801
- const SDK_VERSION = '1.45.0'; // x-release-please-version
1900
+ const SDK_VERSION = '1.47.0'; // x-release-please-version
1802
1901
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
1803
1902
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
1804
1903
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -1858,6 +1957,11 @@ class ApiClient {
1858
1957
  // Vertex Express or global endpoint case.
1859
1958
  initHttpOptions.baseUrl = 'https://aiplatform.googleapis.com/';
1860
1959
  }
1960
+ else if (this.clientOptions.project &&
1961
+ this.clientOptions.location &&
1962
+ this.clientOptions.location === 'us') {
1963
+ initHttpOptions.baseUrl = `https://aiplatform.${this.clientOptions.location}.rep.googleapis.com/`;
1964
+ }
1861
1965
  else if (this.clientOptions.project && this.clientOptions.location) {
1862
1966
  initHttpOptions.baseUrl = `https://${this.clientOptions.location}-aiplatform.googleapis.com/`;
1863
1967
  }
@@ -2672,18 +2776,18 @@ const MAX_RETRY_COUNT = 3;
2672
2776
  const INITIAL_RETRY_DELAY_MS = 1000;
2673
2777
  const DELAY_MULTIPLIER = 2;
2674
2778
  const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
2675
- async function uploadBlob(file, uploadUrl, apiClient) {
2779
+ async function uploadBlob(file, uploadUrl, apiClient, httpOptions) {
2676
2780
  var _a;
2677
- const response = await uploadBlobInternal(file, uploadUrl, apiClient);
2781
+ const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
2678
2782
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
2679
2783
  if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
2680
2784
  throw new Error('Failed to upload file: Upload status is not finalized.');
2681
2785
  }
2682
2786
  return responseJson['file'];
2683
2787
  }
2684
- async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
2788
+ async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
2685
2789
  var _a;
2686
- const response = await uploadBlobInternal(file, uploadUrl, apiClient);
2790
+ const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
2687
2791
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
2688
2792
  if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
2689
2793
  throw new Error('Failed to upload file: Upload status is not finalized.');
@@ -2693,8 +2797,18 @@ async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
2693
2797
  Object.assign(typedResp, resp);
2694
2798
  return typedResp;
2695
2799
  }
2696
- async function uploadBlobInternal(file, uploadUrl, apiClient) {
2697
- var _a, _b;
2800
+ async function uploadBlobInternal(file, uploadUrl, apiClient, httpOptions) {
2801
+ var _a, _b, _c;
2802
+ let finalUrl = uploadUrl;
2803
+ const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
2804
+ if (effectiveBaseUrl) {
2805
+ const baseUri = new URL(effectiveBaseUrl);
2806
+ const uploadUri = new URL(uploadUrl);
2807
+ uploadUri.protocol = baseUri.protocol;
2808
+ uploadUri.host = baseUri.host;
2809
+ uploadUri.port = baseUri.port;
2810
+ finalUrl = uploadUri.toString();
2811
+ }
2698
2812
  let fileSize = 0;
2699
2813
  let offset = 0;
2700
2814
  let response = new HttpResponse(new Response());
@@ -2709,21 +2823,14 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
2709
2823
  let retryCount = 0;
2710
2824
  let currentDelayMs = INITIAL_RETRY_DELAY_MS;
2711
2825
  while (retryCount < MAX_RETRY_COUNT) {
2826
+ const mergedHeaders = Object.assign(Object.assign({}, ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.headers) || {})), { 'X-Goog-Upload-Command': uploadCommand, 'X-Goog-Upload-Offset': String(offset), 'Content-Length': String(chunkSize) });
2712
2827
  response = await apiClient.request({
2713
2828
  path: '',
2714
2829
  body: chunk,
2715
2830
  httpMethod: 'POST',
2716
- httpOptions: {
2717
- apiVersion: '',
2718
- baseUrl: uploadUrl,
2719
- headers: {
2720
- 'X-Goog-Upload-Command': uploadCommand,
2721
- 'X-Goog-Upload-Offset': String(offset),
2722
- 'Content-Length': String(chunkSize),
2723
- },
2724
- },
2831
+ httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
2725
2832
  });
2726
- if ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
2833
+ if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
2727
2834
  break;
2728
2835
  }
2729
2836
  retryCount++;
@@ -2733,7 +2840,7 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
2733
2840
  offset += chunkSize;
2734
2841
  // The `x-goog-upload-status` header field can be `active`, `final` and
2735
2842
  //`cancelled` in resposne.
2736
- 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') {
2843
+ if (((_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
2737
2844
  break;
2738
2845
  }
2739
2846
  // TODO(b/401391430) Investigate why the upload status is not finalized
@@ -2770,20 +2877,20 @@ class NodeUploader {
2770
2877
  return await getBlobStat(file);
2771
2878
  }
2772
2879
  }
2773
- async upload(file, uploadUrl, apiClient) {
2880
+ async upload(file, uploadUrl, apiClient, httpOptions) {
2774
2881
  if (typeof file === 'string') {
2775
- return await this.uploadFileFromPath(file, uploadUrl, apiClient);
2882
+ return await this.uploadFileFromPath(file, uploadUrl, apiClient, httpOptions);
2776
2883
  }
2777
2884
  else {
2778
- return uploadBlob(file, uploadUrl, apiClient);
2885
+ return uploadBlob(file, uploadUrl, apiClient, httpOptions);
2779
2886
  }
2780
2887
  }
2781
- async uploadToFileSearchStore(file, uploadUrl, apiClient) {
2888
+ async uploadToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
2782
2889
  if (typeof file === 'string') {
2783
- return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient);
2890
+ return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient, httpOptions);
2784
2891
  }
2785
2892
  else {
2786
- return uploadBlobToFileSearchStore(file, uploadUrl, apiClient);
2893
+ return uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions);
2787
2894
  }
2788
2895
  }
2789
2896
  /**
@@ -2876,18 +2983,18 @@ class NodeUploader {
2876
2983
  // Return the MIME type.
2877
2984
  return mimeType;
2878
2985
  }
2879
- async uploadFileFromPath(file, uploadUrl, apiClient) {
2986
+ async uploadFileFromPath(file, uploadUrl, apiClient, httpOptions) {
2880
2987
  var _a;
2881
- const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
2988
+ const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions);
2882
2989
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
2883
2990
  if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
2884
2991
  throw new Error('Failed to upload file: Upload status is not finalized.');
2885
2992
  }
2886
2993
  return responseJson['file'];
2887
2994
  }
2888
- async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient) {
2995
+ async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient, httpOptions) {
2889
2996
  var _a;
2890
- const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
2997
+ const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions);
2891
2998
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
2892
2999
  if (((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'final') {
2893
3000
  throw new Error('Failed to upload file: Upload status is not finalized.');
@@ -2897,8 +3004,18 @@ class NodeUploader {
2897
3004
  Object.assign(typedResp, resp);
2898
3005
  return typedResp;
2899
3006
  }
2900
- async uploadFileFromPathInternal(file, uploadUrl, apiClient) {
2901
- var _a, _b;
3007
+ async uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions) {
3008
+ var _a, _b, _c;
3009
+ let finalUrl = uploadUrl;
3010
+ const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
3011
+ if (effectiveBaseUrl) {
3012
+ const baseUri = new URL(effectiveBaseUrl);
3013
+ const uploadUri = new URL(uploadUrl);
3014
+ uploadUri.protocol = baseUri.protocol;
3015
+ uploadUri.host = baseUri.host;
3016
+ uploadUri.port = baseUri.port;
3017
+ finalUrl = uploadUri.toString();
3018
+ }
2902
3019
  let fileSize = 0;
2903
3020
  let offset = 0;
2904
3021
  let response = new HttpResponse(new Response());
@@ -2925,22 +3042,14 @@ class NodeUploader {
2925
3042
  let retryCount = 0;
2926
3043
  let currentDelayMs = INITIAL_RETRY_DELAY_MS;
2927
3044
  while (retryCount < MAX_RETRY_COUNT) {
3045
+ const mergedHeaders = Object.assign(Object.assign({}, ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.headers) || {})), { 'X-Goog-Upload-Command': uploadCommand, 'X-Goog-Upload-Offset': String(offset), 'Content-Length': String(bytesRead), 'X-Goog-Upload-File-Name': fileName });
2928
3046
  response = await apiClient.request({
2929
3047
  path: '',
2930
3048
  body: chunk,
2931
3049
  httpMethod: 'POST',
2932
- httpOptions: {
2933
- apiVersion: '',
2934
- baseUrl: uploadUrl,
2935
- headers: {
2936
- 'X-Goog-Upload-Command': uploadCommand,
2937
- 'X-Goog-Upload-Offset': String(offset),
2938
- 'Content-Length': String(bytesRead),
2939
- 'X-Goog-Upload-File-Name': fileName,
2940
- },
2941
- },
3050
+ httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
2942
3051
  });
2943
- if ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
3052
+ if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
2944
3053
  break;
2945
3054
  }
2946
3055
  retryCount++;
@@ -2950,7 +3059,7 @@ class NodeUploader {
2950
3059
  offset += bytesRead;
2951
3060
  // The `x-goog-upload-status` header field can be `active`, `final` and
2952
3061
  //`cancelled` in resposne.
2953
- 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') {
3062
+ if (((_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) !== 'active') {
2954
3063
  break;
2955
3064
  }
2956
3065
  if (fileSize <= offset) {