@google/genai 1.44.0 → 1.46.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.
@@ -594,6 +594,18 @@ function videoFromVertex$1(fromObject) {
594
594
  * Copyright 2025 Google LLC
595
595
  * SPDX-License-Identifier: Apache-2.0
596
596
  */
597
+ /** Programming language of the `code`. */
598
+ var Language;
599
+ (function (Language) {
600
+ /**
601
+ * Unspecified language. This value should not be used.
602
+ */
603
+ Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
604
+ /**
605
+ * Python >= 3.10, with numpy and simpy available.
606
+ */
607
+ Language["PYTHON"] = "PYTHON";
608
+ })(Language || (Language = {}));
597
609
  /** Outcome of the code execution. */
598
610
  var Outcome;
599
611
  (function (Outcome) {
@@ -614,18 +626,6 @@ var Outcome;
614
626
  */
615
627
  Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
616
628
  })(Outcome || (Outcome = {}));
617
- /** Programming language of the `code`. */
618
- var Language;
619
- (function (Language) {
620
- /**
621
- * Unspecified language. This value should not be used.
622
- */
623
- Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
624
- /**
625
- * Python >= 3.10, with numpy and simpy available.
626
- */
627
- Language["PYTHON"] = "PYTHON";
628
- })(Language || (Language = {}));
629
629
  /** Specifies how the response should be scheduled in the conversation. */
630
630
  var FunctionResponseScheduling;
631
631
  (function (FunctionResponseScheduling) {
@@ -1454,6 +1454,34 @@ var PartMediaResolutionLevel;
1454
1454
  */
1455
1455
  PartMediaResolutionLevel["MEDIA_RESOLUTION_ULTRA_HIGH"] = "MEDIA_RESOLUTION_ULTRA_HIGH";
1456
1456
  })(PartMediaResolutionLevel || (PartMediaResolutionLevel = {}));
1457
+ /** The type of tool in the function call. */
1458
+ var ToolType;
1459
+ (function (ToolType) {
1460
+ /**
1461
+ * Unspecified tool type.
1462
+ */
1463
+ ToolType["TOOL_TYPE_UNSPECIFIED"] = "TOOL_TYPE_UNSPECIFIED";
1464
+ /**
1465
+ * Google search tool, maps to Tool.google_search.search_types.web_search.
1466
+ */
1467
+ ToolType["GOOGLE_SEARCH_WEB"] = "GOOGLE_SEARCH_WEB";
1468
+ /**
1469
+ * Image search tool, maps to Tool.google_search.search_types.image_search.
1470
+ */
1471
+ ToolType["GOOGLE_SEARCH_IMAGE"] = "GOOGLE_SEARCH_IMAGE";
1472
+ /**
1473
+ * URL context tool, maps to Tool.url_context.
1474
+ */
1475
+ ToolType["URL_CONTEXT"] = "URL_CONTEXT";
1476
+ /**
1477
+ * Google maps tool, maps to Tool.google_maps.
1478
+ */
1479
+ ToolType["GOOGLE_MAPS"] = "GOOGLE_MAPS";
1480
+ /**
1481
+ * File search tool, maps to Tool.file_search.
1482
+ */
1483
+ ToolType["FILE_SEARCH"] = "FILE_SEARCH";
1484
+ })(ToolType || (ToolType = {}));
1457
1485
  /** Resource scope. */
1458
1486
  var ResourceScope;
1459
1487
  (function (ResourceScope) {
@@ -1949,6 +1977,14 @@ var LiveMusicPlaybackControl;
1949
1977
  */
1950
1978
  LiveMusicPlaybackControl["RESET_CONTEXT"] = "RESET_CONTEXT";
1951
1979
  })(LiveMusicPlaybackControl || (LiveMusicPlaybackControl = {}));
1980
+ /** The output from a server-side `ToolCall` execution.
1981
+
1982
+ This message contains the results of a tool invocation that was initiated by a
1983
+ `ToolCall` from the model. The client should pass this `ToolResponse` back to
1984
+ the API in a subsequent turn within a `Content` message, along with the
1985
+ corresponding `ToolCall`. */
1986
+ class ToolResponse {
1987
+ }
1952
1988
  /** Raw media bytes for function response.
1953
1989
 
1954
1990
  Text should not be sent as raw bytes, use the FunctionResponse.response
@@ -4677,6 +4713,14 @@ function partToMldev$4(fromObject) {
4677
4713
  if (fromVideoMetadata != null) {
4678
4714
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
4679
4715
  }
4716
+ const fromToolCall = getValueByPath(fromObject, ['toolCall']);
4717
+ if (fromToolCall != null) {
4718
+ setValueByPath(toObject, ['toolCall'], fromToolCall);
4719
+ }
4720
+ const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
4721
+ if (fromToolResponse != null) {
4722
+ setValueByPath(toObject, ['toolResponse'], fromToolResponse);
4723
+ }
4680
4724
  return toObject;
4681
4725
  }
4682
4726
  function safetySettingToMldev$1(fromObject) {
@@ -4708,6 +4752,10 @@ function toolConfigToMldev$2(fromObject) {
4708
4752
  if (fromFunctionCallingConfig != null) {
4709
4753
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$2(fromFunctionCallingConfig));
4710
4754
  }
4755
+ const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
4756
+ if (fromIncludeServerSideToolInvocations != null) {
4757
+ setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
4758
+ }
4711
4759
  return toObject;
4712
4760
  }
4713
4761
  function toolToMldev$4(fromObject) {
@@ -5530,6 +5578,24 @@ function contentToMldev$3(fromObject) {
5530
5578
  }
5531
5579
  return toObject;
5532
5580
  }
5581
+ function contentToVertex$2(fromObject) {
5582
+ const toObject = {};
5583
+ const fromParts = getValueByPath(fromObject, ['parts']);
5584
+ if (fromParts != null) {
5585
+ let transformedList = fromParts;
5586
+ if (Array.isArray(transformedList)) {
5587
+ transformedList = transformedList.map((item) => {
5588
+ return partToVertex$2(item);
5589
+ });
5590
+ }
5591
+ setValueByPath(toObject, ['parts'], transformedList);
5592
+ }
5593
+ const fromRole = getValueByPath(fromObject, ['role']);
5594
+ if (fromRole != null) {
5595
+ setValueByPath(toObject, ['role'], fromRole);
5596
+ }
5597
+ return toObject;
5598
+ }
5533
5599
  function createCachedContentConfigToMldev(fromObject, parentObject) {
5534
5600
  const toObject = {};
5535
5601
  const fromTtl = getValueByPath(fromObject, ['ttl']);
@@ -5598,7 +5664,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
5598
5664
  let transformedList = tContents(fromContents);
5599
5665
  if (Array.isArray(transformedList)) {
5600
5666
  transformedList = transformedList.map((item) => {
5601
- return item;
5667
+ return contentToVertex$2(item);
5602
5668
  });
5603
5669
  }
5604
5670
  setValueByPath(parentObject, ['contents'], transformedList);
@@ -5607,7 +5673,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
5607
5673
  'systemInstruction',
5608
5674
  ]);
5609
5675
  if (parentObject !== undefined && fromSystemInstruction != null) {
5610
- setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
5676
+ setValueByPath(parentObject, ['systemInstruction'], contentToVertex$2(tContent(fromSystemInstruction)));
5611
5677
  }
5612
5678
  const fromTools = getValueByPath(fromObject, ['tools']);
5613
5679
  if (parentObject !== undefined && fromTools != null) {
@@ -5621,7 +5687,7 @@ function createCachedContentConfigToVertex(fromObject, parentObject) {
5621
5687
  }
5622
5688
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
5623
5689
  if (parentObject !== undefined && fromToolConfig != null) {
5624
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
5690
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex$1(fromToolConfig));
5625
5691
  }
5626
5692
  const fromKmsKeyName = getValueByPath(fromObject, ['kmsKeyName']);
5627
5693
  if (parentObject !== undefined && fromKmsKeyName != null) {
@@ -5981,6 +6047,80 @@ function partToMldev$3(fromObject) {
5981
6047
  if (fromVideoMetadata != null) {
5982
6048
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
5983
6049
  }
6050
+ const fromToolCall = getValueByPath(fromObject, ['toolCall']);
6051
+ if (fromToolCall != null) {
6052
+ setValueByPath(toObject, ['toolCall'], fromToolCall);
6053
+ }
6054
+ const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
6055
+ if (fromToolResponse != null) {
6056
+ setValueByPath(toObject, ['toolResponse'], fromToolResponse);
6057
+ }
6058
+ return toObject;
6059
+ }
6060
+ function partToVertex$2(fromObject) {
6061
+ const toObject = {};
6062
+ const fromMediaResolution = getValueByPath(fromObject, [
6063
+ 'mediaResolution',
6064
+ ]);
6065
+ if (fromMediaResolution != null) {
6066
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
6067
+ }
6068
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
6069
+ 'codeExecutionResult',
6070
+ ]);
6071
+ if (fromCodeExecutionResult != null) {
6072
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
6073
+ }
6074
+ const fromExecutableCode = getValueByPath(fromObject, [
6075
+ 'executableCode',
6076
+ ]);
6077
+ if (fromExecutableCode != null) {
6078
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
6079
+ }
6080
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
6081
+ if (fromFileData != null) {
6082
+ setValueByPath(toObject, ['fileData'], fromFileData);
6083
+ }
6084
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
6085
+ if (fromFunctionCall != null) {
6086
+ setValueByPath(toObject, ['functionCall'], fromFunctionCall);
6087
+ }
6088
+ const fromFunctionResponse = getValueByPath(fromObject, [
6089
+ 'functionResponse',
6090
+ ]);
6091
+ if (fromFunctionResponse != null) {
6092
+ setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
6093
+ }
6094
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
6095
+ if (fromInlineData != null) {
6096
+ setValueByPath(toObject, ['inlineData'], fromInlineData);
6097
+ }
6098
+ const fromText = getValueByPath(fromObject, ['text']);
6099
+ if (fromText != null) {
6100
+ setValueByPath(toObject, ['text'], fromText);
6101
+ }
6102
+ const fromThought = getValueByPath(fromObject, ['thought']);
6103
+ if (fromThought != null) {
6104
+ setValueByPath(toObject, ['thought'], fromThought);
6105
+ }
6106
+ const fromThoughtSignature = getValueByPath(fromObject, [
6107
+ 'thoughtSignature',
6108
+ ]);
6109
+ if (fromThoughtSignature != null) {
6110
+ setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
6111
+ }
6112
+ const fromVideoMetadata = getValueByPath(fromObject, [
6113
+ 'videoMetadata',
6114
+ ]);
6115
+ if (fromVideoMetadata != null) {
6116
+ setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
6117
+ }
6118
+ if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
6119
+ throw new Error('toolCall parameter is not supported in Vertex AI.');
6120
+ }
6121
+ if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
6122
+ throw new Error('toolResponse parameter is not supported in Vertex AI.');
6123
+ }
5984
6124
  return toObject;
5985
6125
  }
5986
6126
  function toolConfigToMldev$1(fromObject) {
@@ -5997,6 +6137,30 @@ function toolConfigToMldev$1(fromObject) {
5997
6137
  if (fromFunctionCallingConfig != null) {
5998
6138
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev$1(fromFunctionCallingConfig));
5999
6139
  }
6140
+ const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
6141
+ if (fromIncludeServerSideToolInvocations != null) {
6142
+ setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
6143
+ }
6144
+ return toObject;
6145
+ }
6146
+ function toolConfigToVertex$1(fromObject) {
6147
+ const toObject = {};
6148
+ const fromRetrievalConfig = getValueByPath(fromObject, [
6149
+ 'retrievalConfig',
6150
+ ]);
6151
+ if (fromRetrievalConfig != null) {
6152
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
6153
+ }
6154
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
6155
+ 'functionCallingConfig',
6156
+ ]);
6157
+ if (fromFunctionCallingConfig != null) {
6158
+ setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
6159
+ }
6160
+ if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
6161
+ undefined) {
6162
+ throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
6163
+ }
6000
6164
  return toObject;
6001
6165
  }
6002
6166
  function toolToMldev$3(fromObject) {
@@ -7417,6 +7581,13 @@ class Files extends BaseModule {
7417
7581
  * Copyright 2025 Google LLC
7418
7582
  * SPDX-License-Identifier: Apache-2.0
7419
7583
  */
7584
+ function audioTranscriptionConfigToMldev$1(fromObject) {
7585
+ const toObject = {};
7586
+ if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
7587
+ throw new Error('languageCodes parameter is not supported in Gemini API.');
7588
+ }
7589
+ return toObject;
7590
+ }
7420
7591
  function authConfigToMldev$2(fromObject) {
7421
7592
  const toObject = {};
7422
7593
  const fromApiKey = getValueByPath(fromObject, ['apiKey']);
@@ -7477,6 +7648,24 @@ function contentToMldev$2(fromObject) {
7477
7648
  }
7478
7649
  return toObject;
7479
7650
  }
7651
+ function contentToVertex$1(fromObject) {
7652
+ const toObject = {};
7653
+ const fromParts = getValueByPath(fromObject, ['parts']);
7654
+ if (fromParts != null) {
7655
+ let transformedList = fromParts;
7656
+ if (Array.isArray(transformedList)) {
7657
+ transformedList = transformedList.map((item) => {
7658
+ return partToVertex$1(item);
7659
+ });
7660
+ }
7661
+ setValueByPath(toObject, ['parts'], transformedList);
7662
+ }
7663
+ const fromRole = getValueByPath(fromObject, ['role']);
7664
+ if (fromRole != null) {
7665
+ setValueByPath(toObject, ['role'], fromRole);
7666
+ }
7667
+ return toObject;
7668
+ }
7480
7669
  function fileDataToMldev$2(fromObject) {
7481
7670
  const toObject = {};
7482
7671
  if (getValueByPath(fromObject, ['displayName']) !== undefined) {
@@ -7793,13 +7982,13 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
7793
7982
  'inputAudioTranscription',
7794
7983
  ]);
7795
7984
  if (parentObject !== undefined && fromInputAudioTranscription != null) {
7796
- setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
7985
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromInputAudioTranscription));
7797
7986
  }
7798
7987
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
7799
7988
  'outputAudioTranscription',
7800
7989
  ]);
7801
7990
  if (parentObject !== undefined && fromOutputAudioTranscription != null) {
7802
- setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
7991
+ setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromOutputAudioTranscription));
7803
7992
  }
7804
7993
  const fromRealtimeInputConfig = getValueByPath(fromObject, [
7805
7994
  'realtimeInputConfig',
@@ -7884,7 +8073,7 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
7884
8073
  'systemInstruction',
7885
8074
  ]);
7886
8075
  if (parentObject !== undefined && fromSystemInstruction != null) {
7887
- setValueByPath(parentObject, ['setup', 'systemInstruction'], tContent(fromSystemInstruction));
8076
+ setValueByPath(parentObject, ['setup', 'systemInstruction'], contentToVertex$1(tContent(fromSystemInstruction)));
7888
8077
  }
7889
8078
  const fromTools = getValueByPath(fromObject, ['tools']);
7890
8079
  if (parentObject !== undefined && fromTools != null) {
@@ -8184,6 +8373,80 @@ function partToMldev$2(fromObject) {
8184
8373
  if (fromVideoMetadata != null) {
8185
8374
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
8186
8375
  }
8376
+ const fromToolCall = getValueByPath(fromObject, ['toolCall']);
8377
+ if (fromToolCall != null) {
8378
+ setValueByPath(toObject, ['toolCall'], fromToolCall);
8379
+ }
8380
+ const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
8381
+ if (fromToolResponse != null) {
8382
+ setValueByPath(toObject, ['toolResponse'], fromToolResponse);
8383
+ }
8384
+ return toObject;
8385
+ }
8386
+ function partToVertex$1(fromObject) {
8387
+ const toObject = {};
8388
+ const fromMediaResolution = getValueByPath(fromObject, [
8389
+ 'mediaResolution',
8390
+ ]);
8391
+ if (fromMediaResolution != null) {
8392
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
8393
+ }
8394
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
8395
+ 'codeExecutionResult',
8396
+ ]);
8397
+ if (fromCodeExecutionResult != null) {
8398
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
8399
+ }
8400
+ const fromExecutableCode = getValueByPath(fromObject, [
8401
+ 'executableCode',
8402
+ ]);
8403
+ if (fromExecutableCode != null) {
8404
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
8405
+ }
8406
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
8407
+ if (fromFileData != null) {
8408
+ setValueByPath(toObject, ['fileData'], fromFileData);
8409
+ }
8410
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
8411
+ if (fromFunctionCall != null) {
8412
+ setValueByPath(toObject, ['functionCall'], fromFunctionCall);
8413
+ }
8414
+ const fromFunctionResponse = getValueByPath(fromObject, [
8415
+ 'functionResponse',
8416
+ ]);
8417
+ if (fromFunctionResponse != null) {
8418
+ setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
8419
+ }
8420
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
8421
+ if (fromInlineData != null) {
8422
+ setValueByPath(toObject, ['inlineData'], fromInlineData);
8423
+ }
8424
+ const fromText = getValueByPath(fromObject, ['text']);
8425
+ if (fromText != null) {
8426
+ setValueByPath(toObject, ['text'], fromText);
8427
+ }
8428
+ const fromThought = getValueByPath(fromObject, ['thought']);
8429
+ if (fromThought != null) {
8430
+ setValueByPath(toObject, ['thought'], fromThought);
8431
+ }
8432
+ const fromThoughtSignature = getValueByPath(fromObject, [
8433
+ 'thoughtSignature',
8434
+ ]);
8435
+ if (fromThoughtSignature != null) {
8436
+ setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
8437
+ }
8438
+ const fromVideoMetadata = getValueByPath(fromObject, [
8439
+ 'videoMetadata',
8440
+ ]);
8441
+ if (fromVideoMetadata != null) {
8442
+ setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
8443
+ }
8444
+ if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
8445
+ throw new Error('toolCall parameter is not supported in Vertex AI.');
8446
+ }
8447
+ if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
8448
+ throw new Error('toolResponse parameter is not supported in Vertex AI.');
8449
+ }
8187
8450
  return toObject;
8188
8451
  }
8189
8452
  function sessionResumptionConfigToMldev$1(fromObject) {
@@ -8552,7 +8815,7 @@ function citationMetadataFromMldev(fromObject, _rootObject) {
8552
8815
  }
8553
8816
  return toObject;
8554
8817
  }
8555
- function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
8818
+ function computeTokensParametersToVertex(apiClient, fromObject, rootObject) {
8556
8819
  const toObject = {};
8557
8820
  const fromModel = getValueByPath(fromObject, ['model']);
8558
8821
  if (fromModel != null) {
@@ -8563,7 +8826,7 @@ function computeTokensParametersToVertex(apiClient, fromObject, _rootObject) {
8563
8826
  let transformedList = tContents(fromContents);
8564
8827
  if (Array.isArray(transformedList)) {
8565
8828
  transformedList = transformedList.map((item) => {
8566
- return item;
8829
+ return contentToVertex(item);
8567
8830
  });
8568
8831
  }
8569
8832
  setValueByPath(toObject, ['contents'], transformedList);
@@ -8632,6 +8895,24 @@ function contentToMldev$1(fromObject, rootObject) {
8632
8895
  }
8633
8896
  return toObject;
8634
8897
  }
8898
+ function contentToVertex(fromObject, rootObject) {
8899
+ const toObject = {};
8900
+ const fromParts = getValueByPath(fromObject, ['parts']);
8901
+ if (fromParts != null) {
8902
+ let transformedList = fromParts;
8903
+ if (Array.isArray(transformedList)) {
8904
+ transformedList = transformedList.map((item) => {
8905
+ return partToVertex(item);
8906
+ });
8907
+ }
8908
+ setValueByPath(toObject, ['parts'], transformedList);
8909
+ }
8910
+ const fromRole = getValueByPath(fromObject, ['role']);
8911
+ if (fromRole != null) {
8912
+ setValueByPath(toObject, ['role'], fromRole);
8913
+ }
8914
+ return toObject;
8915
+ }
8635
8916
  function controlReferenceConfigToVertex(fromObject, _rootObject) {
8636
8917
  const toObject = {};
8637
8918
  const fromControlType = getValueByPath(fromObject, ['controlType']);
@@ -8665,7 +8946,7 @@ function countTokensConfigToVertex(fromObject, parentObject, rootObject) {
8665
8946
  'systemInstruction',
8666
8947
  ]);
8667
8948
  if (parentObject !== undefined && fromSystemInstruction != null) {
8668
- setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
8949
+ setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
8669
8950
  }
8670
8951
  const fromTools = getValueByPath(fromObject, ['tools']);
8671
8952
  if (parentObject !== undefined && fromTools != null) {
@@ -8718,7 +8999,7 @@ function countTokensParametersToVertex(apiClient, fromObject, rootObject) {
8718
8999
  let transformedList = tContents(fromContents);
8719
9000
  if (Array.isArray(transformedList)) {
8720
9001
  transformedList = transformedList.map((item) => {
8721
- return item;
9002
+ return contentToVertex(item);
8722
9003
  });
8723
9004
  }
8724
9005
  setValueByPath(toObject, ['contents'], transformedList);
@@ -9122,7 +9403,7 @@ function embedContentParametersPrivateToVertex(apiClient, fromObject, rootObject
9122
9403
  if (discriminatorContent === 'EMBED_CONTENT') {
9123
9404
  const fromContent = getValueByPath(fromObject, ['content']);
9124
9405
  if (fromContent != null) {
9125
- setValueByPath(toObject, ['content'], tContent(fromContent));
9406
+ setValueByPath(toObject, ['content'], contentToVertex(tContent(fromContent)));
9126
9407
  }
9127
9408
  }
9128
9409
  const fromConfig = getValueByPath(fromObject, ['config']);
@@ -9473,7 +9754,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
9473
9754
  'systemInstruction',
9474
9755
  ]);
9475
9756
  if (parentObject !== undefined && fromSystemInstruction != null) {
9476
- setValueByPath(parentObject, ['systemInstruction'], tContent(fromSystemInstruction));
9757
+ setValueByPath(parentObject, ['systemInstruction'], contentToVertex(tContent(fromSystemInstruction)));
9477
9758
  }
9478
9759
  const fromTemperature = getValueByPath(fromObject, ['temperature']);
9479
9760
  if (fromTemperature != null) {
@@ -9585,7 +9866,7 @@ function generateContentConfigToVertex(apiClient, fromObject, parentObject, root
9585
9866
  }
9586
9867
  const fromToolConfig = getValueByPath(fromObject, ['toolConfig']);
9587
9868
  if (parentObject !== undefined && fromToolConfig != null) {
9588
- setValueByPath(parentObject, ['toolConfig'], fromToolConfig);
9869
+ setValueByPath(parentObject, ['toolConfig'], toolConfigToVertex(fromToolConfig));
9589
9870
  }
9590
9871
  const fromLabels = getValueByPath(fromObject, ['labels']);
9591
9872
  if (parentObject !== undefined && fromLabels != null) {
@@ -9674,7 +9955,7 @@ function generateContentParametersToVertex(apiClient, fromObject, rootObject) {
9674
9955
  let transformedList = tContents(fromContents);
9675
9956
  if (Array.isArray(transformedList)) {
9676
9957
  transformedList = transformedList.map((item) => {
9677
- return item;
9958
+ return contentToVertex(item);
9678
9959
  });
9679
9960
  }
9680
9961
  setValueByPath(toObject, ['contents'], transformedList);
@@ -11078,6 +11359,80 @@ function partToMldev$1(fromObject, rootObject) {
11078
11359
  if (fromVideoMetadata != null) {
11079
11360
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
11080
11361
  }
11362
+ const fromToolCall = getValueByPath(fromObject, ['toolCall']);
11363
+ if (fromToolCall != null) {
11364
+ setValueByPath(toObject, ['toolCall'], fromToolCall);
11365
+ }
11366
+ const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
11367
+ if (fromToolResponse != null) {
11368
+ setValueByPath(toObject, ['toolResponse'], fromToolResponse);
11369
+ }
11370
+ return toObject;
11371
+ }
11372
+ function partToVertex(fromObject, _rootObject) {
11373
+ const toObject = {};
11374
+ const fromMediaResolution = getValueByPath(fromObject, [
11375
+ 'mediaResolution',
11376
+ ]);
11377
+ if (fromMediaResolution != null) {
11378
+ setValueByPath(toObject, ['mediaResolution'], fromMediaResolution);
11379
+ }
11380
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
11381
+ 'codeExecutionResult',
11382
+ ]);
11383
+ if (fromCodeExecutionResult != null) {
11384
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
11385
+ }
11386
+ const fromExecutableCode = getValueByPath(fromObject, [
11387
+ 'executableCode',
11388
+ ]);
11389
+ if (fromExecutableCode != null) {
11390
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
11391
+ }
11392
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
11393
+ if (fromFileData != null) {
11394
+ setValueByPath(toObject, ['fileData'], fromFileData);
11395
+ }
11396
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
11397
+ if (fromFunctionCall != null) {
11398
+ setValueByPath(toObject, ['functionCall'], fromFunctionCall);
11399
+ }
11400
+ const fromFunctionResponse = getValueByPath(fromObject, [
11401
+ 'functionResponse',
11402
+ ]);
11403
+ if (fromFunctionResponse != null) {
11404
+ setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
11405
+ }
11406
+ const fromInlineData = getValueByPath(fromObject, ['inlineData']);
11407
+ if (fromInlineData != null) {
11408
+ setValueByPath(toObject, ['inlineData'], fromInlineData);
11409
+ }
11410
+ const fromText = getValueByPath(fromObject, ['text']);
11411
+ if (fromText != null) {
11412
+ setValueByPath(toObject, ['text'], fromText);
11413
+ }
11414
+ const fromThought = getValueByPath(fromObject, ['thought']);
11415
+ if (fromThought != null) {
11416
+ setValueByPath(toObject, ['thought'], fromThought);
11417
+ }
11418
+ const fromThoughtSignature = getValueByPath(fromObject, [
11419
+ 'thoughtSignature',
11420
+ ]);
11421
+ if (fromThoughtSignature != null) {
11422
+ setValueByPath(toObject, ['thoughtSignature'], fromThoughtSignature);
11423
+ }
11424
+ const fromVideoMetadata = getValueByPath(fromObject, [
11425
+ 'videoMetadata',
11426
+ ]);
11427
+ if (fromVideoMetadata != null) {
11428
+ setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
11429
+ }
11430
+ if (getValueByPath(fromObject, ['toolCall']) !== undefined) {
11431
+ throw new Error('toolCall parameter is not supported in Vertex AI.');
11432
+ }
11433
+ if (getValueByPath(fromObject, ['toolResponse']) !== undefined) {
11434
+ throw new Error('toolResponse parameter is not supported in Vertex AI.');
11435
+ }
11081
11436
  return toObject;
11082
11437
  }
11083
11438
  function productImageToVertex(fromObject, rootObject) {
@@ -11411,6 +11766,30 @@ function toolConfigToMldev(fromObject, rootObject) {
11411
11766
  if (fromFunctionCallingConfig != null) {
11412
11767
  setValueByPath(toObject, ['functionCallingConfig'], functionCallingConfigToMldev(fromFunctionCallingConfig));
11413
11768
  }
11769
+ const fromIncludeServerSideToolInvocations = getValueByPath(fromObject, ['includeServerSideToolInvocations']);
11770
+ if (fromIncludeServerSideToolInvocations != null) {
11771
+ setValueByPath(toObject, ['includeServerSideToolInvocations'], fromIncludeServerSideToolInvocations);
11772
+ }
11773
+ return toObject;
11774
+ }
11775
+ function toolConfigToVertex(fromObject, _rootObject) {
11776
+ const toObject = {};
11777
+ const fromRetrievalConfig = getValueByPath(fromObject, [
11778
+ 'retrievalConfig',
11779
+ ]);
11780
+ if (fromRetrievalConfig != null) {
11781
+ setValueByPath(toObject, ['retrievalConfig'], fromRetrievalConfig);
11782
+ }
11783
+ const fromFunctionCallingConfig = getValueByPath(fromObject, [
11784
+ 'functionCallingConfig',
11785
+ ]);
11786
+ if (fromFunctionCallingConfig != null) {
11787
+ setValueByPath(toObject, ['functionCallingConfig'], fromFunctionCallingConfig);
11788
+ }
11789
+ if (getValueByPath(fromObject, ['includeServerSideToolInvocations']) !==
11790
+ undefined) {
11791
+ throw new Error('includeServerSideToolInvocations parameter is not supported in Vertex AI.');
11792
+ }
11414
11793
  return toObject;
11415
11794
  }
11416
11795
  function toolToMldev$1(fromObject, rootObject) {
@@ -12100,7 +12479,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
12100
12479
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
12101
12480
  const USER_AGENT_HEADER = 'User-Agent';
12102
12481
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
12103
- const SDK_VERSION = '1.44.0'; // x-release-please-version
12482
+ const SDK_VERSION = '1.46.0'; // x-release-please-version
12104
12483
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
12105
12484
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
12106
12485
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -13459,7 +13838,7 @@ class Session {
13459
13838
  }
13460
13839
  }
13461
13840
  const clientMessage = {
13462
- toolResponse: { functionResponses: functionResponses },
13841
+ toolResponse: { 'functionResponses': functionResponses },
13463
13842
  };
13464
13843
  return clientMessage;
13465
13844
  }
@@ -15432,6 +15811,13 @@ class Operations extends BaseModule {
15432
15811
  * Copyright 2025 Google LLC
15433
15812
  * SPDX-License-Identifier: Apache-2.0
15434
15813
  */
15814
+ function audioTranscriptionConfigToMldev(fromObject) {
15815
+ const toObject = {};
15816
+ if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
15817
+ throw new Error('languageCodes parameter is not supported in Gemini API.');
15818
+ }
15819
+ return toObject;
15820
+ }
15435
15821
  function authConfigToMldev(fromObject) {
15436
15822
  const toObject = {};
15437
15823
  const fromApiKey = getValueByPath(fromObject, ['apiKey']);
@@ -15683,13 +16069,13 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
15683
16069
  'inputAudioTranscription',
15684
16070
  ]);
15685
16071
  if (parentObject !== undefined && fromInputAudioTranscription != null) {
15686
- setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
16072
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev(fromInputAudioTranscription));
15687
16073
  }
15688
16074
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
15689
16075
  'outputAudioTranscription',
15690
16076
  ]);
15691
16077
  if (parentObject !== undefined && fromOutputAudioTranscription != null) {
15692
- setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
16078
+ setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev(fromOutputAudioTranscription));
15693
16079
  }
15694
16080
  const fromRealtimeInputConfig = getValueByPath(fromObject, [
15695
16081
  'realtimeInputConfig',
@@ -15782,6 +16168,14 @@ function partToMldev(fromObject) {
15782
16168
  if (fromVideoMetadata != null) {
15783
16169
  setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
15784
16170
  }
16171
+ const fromToolCall = getValueByPath(fromObject, ['toolCall']);
16172
+ if (fromToolCall != null) {
16173
+ setValueByPath(toObject, ['toolCall'], fromToolCall);
16174
+ }
16175
+ const fromToolResponse = getValueByPath(fromObject, ['toolResponse']);
16176
+ if (fromToolResponse != null) {
16177
+ setValueByPath(toObject, ['toolResponse'], fromToolResponse);
16178
+ }
15785
16179
  return toObject;
15786
16180
  }
15787
16181
  function sessionResumptionConfigToMldev(fromObject) {
@@ -16951,6 +17345,30 @@ const FallbackEncoder = ({ headers, body }) => {
16951
17345
  };
16952
17346
  };
16953
17347
 
17348
+ /**
17349
+ * @license
17350
+ * Copyright 2025 Google LLC
17351
+ * SPDX-License-Identifier: Apache-2.0
17352
+ */
17353
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
17354
+ /**
17355
+ * Basic re-implementation of `qs.stringify` for primitive types.
17356
+ */
17357
+ function stringifyQuery(query) {
17358
+ return Object.entries(query)
17359
+ .filter(([_, value]) => typeof value !== 'undefined')
17360
+ .map(([key, value]) => {
17361
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
17362
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
17363
+ }
17364
+ if (value === null) {
17365
+ return `${encodeURIComponent(key)}=`;
17366
+ }
17367
+ throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
17368
+ })
17369
+ .join('&');
17370
+ }
17371
+
16954
17372
  /**
16955
17373
  * @license
16956
17374
  * Copyright 2025 Google LLC
@@ -18094,18 +18512,7 @@ class BaseGeminiNextGenAPIClient {
18094
18512
  * Basic re-implementation of `qs.stringify` for primitive types.
18095
18513
  */
18096
18514
  stringifyQuery(query) {
18097
- return Object.entries(query)
18098
- .filter(([_, value]) => typeof value !== 'undefined')
18099
- .map(([key, value]) => {
18100
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
18101
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
18102
- }
18103
- if (value === null) {
18104
- return `${encodeURIComponent(key)}=`;
18105
- }
18106
- throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
18107
- })
18108
- .join('&');
18515
+ return stringifyQuery(query);
18109
18516
  }
18110
18517
  getUserAgent() {
18111
18518
  return `${this.constructor.name}/JS ${VERSION}`;
@@ -18122,8 +18529,9 @@ class BaseGeminiNextGenAPIClient {
18122
18529
  new URL(path)
18123
18530
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
18124
18531
  const defaultQuery = this.defaultQuery();
18125
- if (!isEmptyObj(defaultQuery)) {
18126
- query = Object.assign(Object.assign({}, defaultQuery), query);
18532
+ const pathQuery = Object.fromEntries(url.searchParams);
18533
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
18534
+ query = Object.assign(Object.assign(Object.assign({}, pathQuery), defaultQuery), query);
18127
18535
  }
18128
18536
  if (typeof query === 'object' && query && !Array.isArray(query)) {
18129
18537
  url.search = this.stringifyQuery(query);
@@ -18344,9 +18752,9 @@ class BaseGeminiNextGenAPIClient {
18344
18752
  timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
18345
18753
  }
18346
18754
  }
18347
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
18348
- // just do what it says, but otherwise calculate a default
18349
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
18755
+ // If the API asks us to wait a certain amount of time, just do what it
18756
+ // says, but otherwise calculate a default
18757
+ if (timeoutMillis === undefined) {
18350
18758
  const maxRetries = (_b = options.maxRetries) !== null && _b !== void 0 ? _b : this.maxRetries;
18351
18759
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
18352
18760
  }
@@ -19891,18 +20299,18 @@ const MAX_RETRY_COUNT = 3;
19891
20299
  const INITIAL_RETRY_DELAY_MS = 1000;
19892
20300
  const DELAY_MULTIPLIER = 2;
19893
20301
  const X_GOOG_UPLOAD_STATUS_HEADER_FIELD = 'x-goog-upload-status';
19894
- async function uploadBlob(file, uploadUrl, apiClient) {
20302
+ async function uploadBlob(file, uploadUrl, apiClient, httpOptions) {
19895
20303
  var _a;
19896
- const response = await uploadBlobInternal(file, uploadUrl, apiClient);
20304
+ const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
19897
20305
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
19898
20306
  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') {
19899
20307
  throw new Error('Failed to upload file: Upload status is not finalized.');
19900
20308
  }
19901
20309
  return responseJson['file'];
19902
20310
  }
19903
- async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
20311
+ async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
19904
20312
  var _a;
19905
- const response = await uploadBlobInternal(file, uploadUrl, apiClient);
20313
+ const response = await uploadBlobInternal(file, uploadUrl, apiClient, httpOptions);
19906
20314
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
19907
20315
  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') {
19908
20316
  throw new Error('Failed to upload file: Upload status is not finalized.');
@@ -19912,8 +20320,18 @@ async function uploadBlobToFileSearchStore(file, uploadUrl, apiClient) {
19912
20320
  Object.assign(typedResp, resp);
19913
20321
  return typedResp;
19914
20322
  }
19915
- async function uploadBlobInternal(file, uploadUrl, apiClient) {
19916
- var _a, _b;
20323
+ async function uploadBlobInternal(file, uploadUrl, apiClient, httpOptions) {
20324
+ var _a, _b, _c;
20325
+ let finalUrl = uploadUrl;
20326
+ const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
20327
+ if (effectiveBaseUrl) {
20328
+ const baseUri = new URL(effectiveBaseUrl);
20329
+ const uploadUri = new URL(uploadUrl);
20330
+ uploadUri.protocol = baseUri.protocol;
20331
+ uploadUri.host = baseUri.host;
20332
+ uploadUri.port = baseUri.port;
20333
+ finalUrl = uploadUri.toString();
20334
+ }
19917
20335
  let fileSize = 0;
19918
20336
  let offset = 0;
19919
20337
  let response = new HttpResponse(new Response());
@@ -19928,21 +20346,14 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
19928
20346
  let retryCount = 0;
19929
20347
  let currentDelayMs = INITIAL_RETRY_DELAY_MS;
19930
20348
  while (retryCount < MAX_RETRY_COUNT) {
20349
+ 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) });
19931
20350
  response = await apiClient.request({
19932
20351
  path: '',
19933
20352
  body: chunk,
19934
20353
  httpMethod: 'POST',
19935
- httpOptions: {
19936
- apiVersion: '',
19937
- baseUrl: uploadUrl,
19938
- headers: {
19939
- 'X-Goog-Upload-Command': uploadCommand,
19940
- 'X-Goog-Upload-Offset': String(offset),
19941
- 'Content-Length': String(chunkSize),
19942
- },
19943
- },
20354
+ httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
19944
20355
  });
19945
- if ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
20356
+ if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
19946
20357
  break;
19947
20358
  }
19948
20359
  retryCount++;
@@ -19952,7 +20363,7 @@ async function uploadBlobInternal(file, uploadUrl, apiClient) {
19952
20363
  offset += chunkSize;
19953
20364
  // The `x-goog-upload-status` header field can be `active`, `final` and
19954
20365
  //`cancelled` in resposne.
19955
- 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') {
20366
+ 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') {
19956
20367
  break;
19957
20368
  }
19958
20369
  // TODO(b/401391430) Investigate why the upload status is not finalized
@@ -19989,20 +20400,20 @@ class NodeUploader {
19989
20400
  return await getBlobStat(file);
19990
20401
  }
19991
20402
  }
19992
- async upload(file, uploadUrl, apiClient) {
20403
+ async upload(file, uploadUrl, apiClient, httpOptions) {
19993
20404
  if (typeof file === 'string') {
19994
- return await this.uploadFileFromPath(file, uploadUrl, apiClient);
20405
+ return await this.uploadFileFromPath(file, uploadUrl, apiClient, httpOptions);
19995
20406
  }
19996
20407
  else {
19997
- return uploadBlob(file, uploadUrl, apiClient);
20408
+ return uploadBlob(file, uploadUrl, apiClient, httpOptions);
19998
20409
  }
19999
20410
  }
20000
- async uploadToFileSearchStore(file, uploadUrl, apiClient) {
20411
+ async uploadToFileSearchStore(file, uploadUrl, apiClient, httpOptions) {
20001
20412
  if (typeof file === 'string') {
20002
- return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient);
20413
+ return await this.uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient, httpOptions);
20003
20414
  }
20004
20415
  else {
20005
- return uploadBlobToFileSearchStore(file, uploadUrl, apiClient);
20416
+ return uploadBlobToFileSearchStore(file, uploadUrl, apiClient, httpOptions);
20006
20417
  }
20007
20418
  }
20008
20419
  /**
@@ -20095,18 +20506,18 @@ class NodeUploader {
20095
20506
  // Return the MIME type.
20096
20507
  return mimeType;
20097
20508
  }
20098
- async uploadFileFromPath(file, uploadUrl, apiClient) {
20509
+ async uploadFileFromPath(file, uploadUrl, apiClient, httpOptions) {
20099
20510
  var _a;
20100
- const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
20511
+ const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions);
20101
20512
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
20102
20513
  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') {
20103
20514
  throw new Error('Failed to upload file: Upload status is not finalized.');
20104
20515
  }
20105
20516
  return responseJson['file'];
20106
20517
  }
20107
- async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient) {
20518
+ async uploadFileToFileSearchStoreFromPath(file, uploadUrl, apiClient, httpOptions) {
20108
20519
  var _a;
20109
- const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient);
20520
+ const response = await this.uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions);
20110
20521
  const responseJson = (await (response === null || response === void 0 ? void 0 : response.json()));
20111
20522
  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') {
20112
20523
  throw new Error('Failed to upload file: Upload status is not finalized.');
@@ -20116,8 +20527,18 @@ class NodeUploader {
20116
20527
  Object.assign(typedResp, resp);
20117
20528
  return typedResp;
20118
20529
  }
20119
- async uploadFileFromPathInternal(file, uploadUrl, apiClient) {
20120
- var _a, _b;
20530
+ async uploadFileFromPathInternal(file, uploadUrl, apiClient, httpOptions) {
20531
+ var _a, _b, _c;
20532
+ let finalUrl = uploadUrl;
20533
+ const effectiveBaseUrl = (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.baseUrl) || ((_a = apiClient.clientOptions.httpOptions) === null || _a === void 0 ? void 0 : _a.baseUrl);
20534
+ if (effectiveBaseUrl) {
20535
+ const baseUri = new URL(effectiveBaseUrl);
20536
+ const uploadUri = new URL(uploadUrl);
20537
+ uploadUri.protocol = baseUri.protocol;
20538
+ uploadUri.host = baseUri.host;
20539
+ uploadUri.port = baseUri.port;
20540
+ finalUrl = uploadUri.toString();
20541
+ }
20121
20542
  let fileSize = 0;
20122
20543
  let offset = 0;
20123
20544
  let response = new HttpResponse(new Response());
@@ -20144,22 +20565,14 @@ class NodeUploader {
20144
20565
  let retryCount = 0;
20145
20566
  let currentDelayMs = INITIAL_RETRY_DELAY_MS;
20146
20567
  while (retryCount < MAX_RETRY_COUNT) {
20568
+ 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 });
20147
20569
  response = await apiClient.request({
20148
20570
  path: '',
20149
20571
  body: chunk,
20150
20572
  httpMethod: 'POST',
20151
- httpOptions: {
20152
- apiVersion: '',
20153
- baseUrl: uploadUrl,
20154
- headers: {
20155
- 'X-Goog-Upload-Command': uploadCommand,
20156
- 'X-Goog-Upload-Offset': String(offset),
20157
- 'Content-Length': String(bytesRead),
20158
- 'X-Goog-Upload-File-Name': fileName,
20159
- },
20160
- },
20573
+ httpOptions: Object.assign(Object.assign({}, httpOptions), { apiVersion: '', baseUrl: finalUrl, headers: mergedHeaders }),
20161
20574
  });
20162
- if ((_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
20575
+ if ((_b = response === null || response === void 0 ? void 0 : response.headers) === null || _b === void 0 ? void 0 : _b[X_GOOG_UPLOAD_STATUS_HEADER_FIELD]) {
20163
20576
  break;
20164
20577
  }
20165
20578
  retryCount++;
@@ -20169,7 +20582,7 @@ class NodeUploader {
20169
20582
  offset += bytesRead;
20170
20583
  // The `x-goog-upload-status` header field can be `active`, `final` and
20171
20584
  //`cancelled` in resposne.
20172
- 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') {
20585
+ 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') {
20173
20586
  break;
20174
20587
  }
20175
20588
  if (fileSize <= offset) {
@@ -20409,5 +20822,5 @@ function getApiKeyFromEnv() {
20409
20822
  return envGoogleApiKey || envGeminiApiKey || undefined;
20410
20823
  }
20411
20824
 
20412
- export { ActivityHandling, AdapterSize, AggregationMetric, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EmbeddingApiType, EndSensitivity, Environment, EvaluateDatasetResponse, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PairwiseChoice, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, ProminentPeople, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReplayResponse, ResourceScope, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, TrafficType, TuningJobState, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
20825
+ export { ActivityHandling, AdapterSize, AggregationMetric, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EmbeddingApiType, EndSensitivity, Environment, EvaluateDatasetResponse, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MediaModality, MediaResolution, Modality, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PairwiseChoice, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, ProminentPeople, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReplayResponse, ResourceScope, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, ToolResponse, ToolType, TrafficType, TuningJobState, TuningMethod, TuningMode, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
20413
20826
  //# sourceMappingURL=index.mjs.map