@google/genai 0.6.1 → 0.8.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.
package/dist/index.js CHANGED
@@ -1339,14 +1339,14 @@ function listCachedContentsResponseFromVertex(apiClient, fromObject) {
1339
1339
  /**
1340
1340
  * Pagers for the GenAI List APIs.
1341
1341
  */
1342
- var PagedItem;
1342
+ exports.PagedItem = void 0;
1343
1343
  (function (PagedItem) {
1344
1344
  PagedItem["PAGED_ITEM_BATCH_JOBS"] = "batchJobs";
1345
1345
  PagedItem["PAGED_ITEM_MODELS"] = "models";
1346
1346
  PagedItem["PAGED_ITEM_TUNING_JOBS"] = "tuningJobs";
1347
1347
  PagedItem["PAGED_ITEM_FILES"] = "files";
1348
1348
  PagedItem["PAGED_ITEM_CACHED_CONTENTS"] = "cachedContents";
1349
- })(PagedItem || (PagedItem = {}));
1349
+ })(exports.PagedItem || (exports.PagedItem = {}));
1350
1350
  /**
1351
1351
  * Pager class for iterating through paginated results.
1352
1352
  */
@@ -1514,6 +1514,7 @@ class Pager {
1514
1514
  * SPDX-License-Identifier: Apache-2.0
1515
1515
  */
1516
1516
  // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
1517
+ /** Required. Outcome of the code execution. */
1517
1518
  exports.Outcome = void 0;
1518
1519
  (function (Outcome) {
1519
1520
  Outcome["OUTCOME_UNSPECIFIED"] = "OUTCOME_UNSPECIFIED";
@@ -1521,11 +1522,13 @@ exports.Outcome = void 0;
1521
1522
  Outcome["OUTCOME_FAILED"] = "OUTCOME_FAILED";
1522
1523
  Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
1523
1524
  })(exports.Outcome || (exports.Outcome = {}));
1525
+ /** Required. Programming language of the `code`. */
1524
1526
  exports.Language = void 0;
1525
1527
  (function (Language) {
1526
1528
  Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
1527
1529
  Language["PYTHON"] = "PYTHON";
1528
1530
  })(exports.Language || (exports.Language = {}));
1531
+ /** Optional. The type of the data. */
1529
1532
  exports.Type = void 0;
1530
1533
  (function (Type) {
1531
1534
  Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
@@ -1536,6 +1539,7 @@ exports.Type = void 0;
1536
1539
  Type["ARRAY"] = "ARRAY";
1537
1540
  Type["OBJECT"] = "OBJECT";
1538
1541
  })(exports.Type || (exports.Type = {}));
1542
+ /** Required. Harm category. */
1539
1543
  exports.HarmCategory = void 0;
1540
1544
  (function (HarmCategory) {
1541
1545
  HarmCategory["HARM_CATEGORY_UNSPECIFIED"] = "HARM_CATEGORY_UNSPECIFIED";
@@ -1545,12 +1549,14 @@ exports.HarmCategory = void 0;
1545
1549
  HarmCategory["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
1546
1550
  HarmCategory["HARM_CATEGORY_CIVIC_INTEGRITY"] = "HARM_CATEGORY_CIVIC_INTEGRITY";
1547
1551
  })(exports.HarmCategory || (exports.HarmCategory = {}));
1552
+ /** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
1548
1553
  exports.HarmBlockMethod = void 0;
1549
1554
  (function (HarmBlockMethod) {
1550
1555
  HarmBlockMethod["HARM_BLOCK_METHOD_UNSPECIFIED"] = "HARM_BLOCK_METHOD_UNSPECIFIED";
1551
1556
  HarmBlockMethod["SEVERITY"] = "SEVERITY";
1552
1557
  HarmBlockMethod["PROBABILITY"] = "PROBABILITY";
1553
1558
  })(exports.HarmBlockMethod || (exports.HarmBlockMethod = {}));
1559
+ /** Required. The harm block threshold. */
1554
1560
  exports.HarmBlockThreshold = void 0;
1555
1561
  (function (HarmBlockThreshold) {
1556
1562
  HarmBlockThreshold["HARM_BLOCK_THRESHOLD_UNSPECIFIED"] = "HARM_BLOCK_THRESHOLD_UNSPECIFIED";
@@ -1560,11 +1566,16 @@ exports.HarmBlockThreshold = void 0;
1560
1566
  HarmBlockThreshold["BLOCK_NONE"] = "BLOCK_NONE";
1561
1567
  HarmBlockThreshold["OFF"] = "OFF";
1562
1568
  })(exports.HarmBlockThreshold || (exports.HarmBlockThreshold = {}));
1569
+ /** The mode of the predictor to be used in dynamic retrieval. */
1563
1570
  exports.Mode = void 0;
1564
1571
  (function (Mode) {
1565
1572
  Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
1566
1573
  Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
1567
1574
  })(exports.Mode || (exports.Mode = {}));
1575
+ /** Output only. The reason why the model stopped generating tokens.
1576
+
1577
+ If empty, the model has not stopped generating the tokens.
1578
+ */
1568
1579
  exports.FinishReason = void 0;
1569
1580
  (function (FinishReason) {
1570
1581
  FinishReason["FINISH_REASON_UNSPECIFIED"] = "FINISH_REASON_UNSPECIFIED";
@@ -1579,6 +1590,7 @@ exports.FinishReason = void 0;
1579
1590
  FinishReason["MALFORMED_FUNCTION_CALL"] = "MALFORMED_FUNCTION_CALL";
1580
1591
  FinishReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
1581
1592
  })(exports.FinishReason || (exports.FinishReason = {}));
1593
+ /** Output only. Harm probability levels in the content. */
1582
1594
  exports.HarmProbability = void 0;
1583
1595
  (function (HarmProbability) {
1584
1596
  HarmProbability["HARM_PROBABILITY_UNSPECIFIED"] = "HARM_PROBABILITY_UNSPECIFIED";
@@ -1587,6 +1599,7 @@ exports.HarmProbability = void 0;
1587
1599
  HarmProbability["MEDIUM"] = "MEDIUM";
1588
1600
  HarmProbability["HIGH"] = "HIGH";
1589
1601
  })(exports.HarmProbability || (exports.HarmProbability = {}));
1602
+ /** Output only. Harm severity levels in the content. */
1590
1603
  exports.HarmSeverity = void 0;
1591
1604
  (function (HarmSeverity) {
1592
1605
  HarmSeverity["HARM_SEVERITY_UNSPECIFIED"] = "HARM_SEVERITY_UNSPECIFIED";
@@ -1595,6 +1608,7 @@ exports.HarmSeverity = void 0;
1595
1608
  HarmSeverity["HARM_SEVERITY_MEDIUM"] = "HARM_SEVERITY_MEDIUM";
1596
1609
  HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
1597
1610
  })(exports.HarmSeverity || (exports.HarmSeverity = {}));
1611
+ /** Output only. Blocked reason. */
1598
1612
  exports.BlockedReason = void 0;
1599
1613
  (function (BlockedReason) {
1600
1614
  BlockedReason["BLOCKED_REASON_UNSPECIFIED"] = "BLOCKED_REASON_UNSPECIFIED";
@@ -1603,6 +1617,14 @@ exports.BlockedReason = void 0;
1603
1617
  BlockedReason["BLOCKLIST"] = "BLOCKLIST";
1604
1618
  BlockedReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
1605
1619
  })(exports.BlockedReason || (exports.BlockedReason = {}));
1620
+ /** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
1621
+ exports.TrafficType = void 0;
1622
+ (function (TrafficType) {
1623
+ TrafficType["TRAFFIC_TYPE_UNSPECIFIED"] = "TRAFFIC_TYPE_UNSPECIFIED";
1624
+ TrafficType["ON_DEMAND"] = "ON_DEMAND";
1625
+ TrafficType["PROVISIONED_THROUGHPUT"] = "PROVISIONED_THROUGHPUT";
1626
+ })(exports.TrafficType || (exports.TrafficType = {}));
1627
+ /** Server content modalities. */
1606
1628
  exports.Modality = void 0;
1607
1629
  (function (Modality) {
1608
1630
  Modality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
@@ -1610,17 +1632,21 @@ exports.Modality = void 0;
1610
1632
  Modality["IMAGE"] = "IMAGE";
1611
1633
  Modality["AUDIO"] = "AUDIO";
1612
1634
  })(exports.Modality || (exports.Modality = {}));
1613
- exports.State = void 0;
1614
- (function (State) {
1615
- State["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
1616
- State["ACTIVE"] = "ACTIVE";
1617
- State["ERROR"] = "ERROR";
1618
- })(exports.State || (exports.State = {}));
1635
+ /** The media resolution to use. */
1636
+ exports.MediaResolution = void 0;
1637
+ (function (MediaResolution) {
1638
+ MediaResolution["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
1639
+ MediaResolution["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
1640
+ MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
1641
+ MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
1642
+ })(exports.MediaResolution || (exports.MediaResolution = {}));
1643
+ /** Config for the dynamic retrieval config mode. */
1619
1644
  exports.DynamicRetrievalConfigMode = void 0;
1620
1645
  (function (DynamicRetrievalConfigMode) {
1621
1646
  DynamicRetrievalConfigMode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
1622
1647
  DynamicRetrievalConfigMode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
1623
1648
  })(exports.DynamicRetrievalConfigMode || (exports.DynamicRetrievalConfigMode = {}));
1649
+ /** Config for the function calling config mode. */
1624
1650
  exports.FunctionCallingConfigMode = void 0;
1625
1651
  (function (FunctionCallingConfigMode) {
1626
1652
  FunctionCallingConfigMode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
@@ -1628,13 +1654,7 @@ exports.FunctionCallingConfigMode = void 0;
1628
1654
  FunctionCallingConfigMode["ANY"] = "ANY";
1629
1655
  FunctionCallingConfigMode["NONE"] = "NONE";
1630
1656
  })(exports.FunctionCallingConfigMode || (exports.FunctionCallingConfigMode = {}));
1631
- exports.MediaResolution = void 0;
1632
- (function (MediaResolution) {
1633
- MediaResolution["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
1634
- MediaResolution["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
1635
- MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
1636
- MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
1637
- })(exports.MediaResolution || (exports.MediaResolution = {}));
1657
+ /** Enum that controls the safety filter level for objectionable content. */
1638
1658
  exports.SafetyFilterLevel = void 0;
1639
1659
  (function (SafetyFilterLevel) {
1640
1660
  SafetyFilterLevel["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
@@ -1642,12 +1662,14 @@ exports.SafetyFilterLevel = void 0;
1642
1662
  SafetyFilterLevel["BLOCK_ONLY_HIGH"] = "BLOCK_ONLY_HIGH";
1643
1663
  SafetyFilterLevel["BLOCK_NONE"] = "BLOCK_NONE";
1644
1664
  })(exports.SafetyFilterLevel || (exports.SafetyFilterLevel = {}));
1665
+ /** Enum that controls the generation of people. */
1645
1666
  exports.PersonGeneration = void 0;
1646
1667
  (function (PersonGeneration) {
1647
1668
  PersonGeneration["DONT_ALLOW"] = "DONT_ALLOW";
1648
1669
  PersonGeneration["ALLOW_ADULT"] = "ALLOW_ADULT";
1649
1670
  PersonGeneration["ALLOW_ALL"] = "ALLOW_ALL";
1650
1671
  })(exports.PersonGeneration || (exports.PersonGeneration = {}));
1672
+ /** Enum that specifies the language of the text in the prompt. */
1651
1673
  exports.ImagePromptLanguage = void 0;
1652
1674
  (function (ImagePromptLanguage) {
1653
1675
  ImagePromptLanguage["auto"] = "auto";
@@ -1656,6 +1678,7 @@ exports.ImagePromptLanguage = void 0;
1656
1678
  ImagePromptLanguage["ko"] = "ko";
1657
1679
  ImagePromptLanguage["hi"] = "hi";
1658
1680
  })(exports.ImagePromptLanguage || (exports.ImagePromptLanguage = {}));
1681
+ /** State for the lifecycle of a File. */
1659
1682
  exports.FileState = void 0;
1660
1683
  (function (FileState) {
1661
1684
  FileState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
@@ -1663,12 +1686,14 @@ exports.FileState = void 0;
1663
1686
  FileState["ACTIVE"] = "ACTIVE";
1664
1687
  FileState["FAILED"] = "FAILED";
1665
1688
  })(exports.FileState || (exports.FileState = {}));
1689
+ /** Source of the File. */
1666
1690
  exports.FileSource = void 0;
1667
1691
  (function (FileSource) {
1668
1692
  FileSource["SOURCE_UNSPECIFIED"] = "SOURCE_UNSPECIFIED";
1669
1693
  FileSource["UPLOADED"] = "UPLOADED";
1670
1694
  FileSource["GENERATED"] = "GENERATED";
1671
1695
  })(exports.FileSource || (exports.FileSource = {}));
1696
+ /** Enum representing the mask mode of a mask reference image. */
1672
1697
  exports.MaskReferenceMode = void 0;
1673
1698
  (function (MaskReferenceMode) {
1674
1699
  MaskReferenceMode["MASK_MODE_DEFAULT"] = "MASK_MODE_DEFAULT";
@@ -1677,6 +1702,7 @@ exports.MaskReferenceMode = void 0;
1677
1702
  MaskReferenceMode["MASK_MODE_FOREGROUND"] = "MASK_MODE_FOREGROUND";
1678
1703
  MaskReferenceMode["MASK_MODE_SEMANTIC"] = "MASK_MODE_SEMANTIC";
1679
1704
  })(exports.MaskReferenceMode || (exports.MaskReferenceMode = {}));
1705
+ /** Enum representing the control type of a control reference image. */
1680
1706
  exports.ControlReferenceType = void 0;
1681
1707
  (function (ControlReferenceType) {
1682
1708
  ControlReferenceType["CONTROL_TYPE_DEFAULT"] = "CONTROL_TYPE_DEFAULT";
@@ -1684,6 +1710,7 @@ exports.ControlReferenceType = void 0;
1684
1710
  ControlReferenceType["CONTROL_TYPE_SCRIBBLE"] = "CONTROL_TYPE_SCRIBBLE";
1685
1711
  ControlReferenceType["CONTROL_TYPE_FACE_MESH"] = "CONTROL_TYPE_FACE_MESH";
1686
1712
  })(exports.ControlReferenceType || (exports.ControlReferenceType = {}));
1713
+ /** Enum representing the subject type of a subject reference image. */
1687
1714
  exports.SubjectReferenceType = void 0;
1688
1715
  (function (SubjectReferenceType) {
1689
1716
  SubjectReferenceType["SUBJECT_TYPE_DEFAULT"] = "SUBJECT_TYPE_DEFAULT";
@@ -1691,6 +1718,44 @@ exports.SubjectReferenceType = void 0;
1691
1718
  SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
1692
1719
  SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
1693
1720
  })(exports.SubjectReferenceType || (exports.SubjectReferenceType = {}));
1721
+ /** Server content modalities. */
1722
+ exports.MediaModality = void 0;
1723
+ (function (MediaModality) {
1724
+ MediaModality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
1725
+ MediaModality["TEXT"] = "TEXT";
1726
+ MediaModality["IMAGE"] = "IMAGE";
1727
+ MediaModality["VIDEO"] = "VIDEO";
1728
+ MediaModality["AUDIO"] = "AUDIO";
1729
+ MediaModality["DOCUMENT"] = "DOCUMENT";
1730
+ })(exports.MediaModality || (exports.MediaModality = {}));
1731
+ /** Start of speech sensitivity. */
1732
+ exports.StartSensitivity = void 0;
1733
+ (function (StartSensitivity) {
1734
+ StartSensitivity["START_SENSITIVITY_UNSPECIFIED"] = "START_SENSITIVITY_UNSPECIFIED";
1735
+ StartSensitivity["START_SENSITIVITY_HIGH"] = "START_SENSITIVITY_HIGH";
1736
+ StartSensitivity["START_SENSITIVITY_LOW"] = "START_SENSITIVITY_LOW";
1737
+ })(exports.StartSensitivity || (exports.StartSensitivity = {}));
1738
+ /** End of speech sensitivity. */
1739
+ exports.EndSensitivity = void 0;
1740
+ (function (EndSensitivity) {
1741
+ EndSensitivity["END_SENSITIVITY_UNSPECIFIED"] = "END_SENSITIVITY_UNSPECIFIED";
1742
+ EndSensitivity["END_SENSITIVITY_HIGH"] = "END_SENSITIVITY_HIGH";
1743
+ EndSensitivity["END_SENSITIVITY_LOW"] = "END_SENSITIVITY_LOW";
1744
+ })(exports.EndSensitivity || (exports.EndSensitivity = {}));
1745
+ /** The different ways of handling user activity. */
1746
+ exports.ActivityHandling = void 0;
1747
+ (function (ActivityHandling) {
1748
+ ActivityHandling["ACTIVITY_HANDLING_UNSPECIFIED"] = "ACTIVITY_HANDLING_UNSPECIFIED";
1749
+ ActivityHandling["START_OF_ACTIVITY_INTERRUPTS"] = "START_OF_ACTIVITY_INTERRUPTS";
1750
+ ActivityHandling["NO_INTERRUPTION"] = "NO_INTERRUPTION";
1751
+ })(exports.ActivityHandling || (exports.ActivityHandling = {}));
1752
+ /** Options about which input is included in the user's turn. */
1753
+ exports.TurnCoverage = void 0;
1754
+ (function (TurnCoverage) {
1755
+ TurnCoverage["TURN_COVERAGE_UNSPECIFIED"] = "TURN_COVERAGE_UNSPECIFIED";
1756
+ TurnCoverage["TURN_INCLUDES_ONLY_ACTIVITY"] = "TURN_INCLUDES_ONLY_ACTIVITY";
1757
+ TurnCoverage["TURN_INCLUDES_ALL_INPUT"] = "TURN_INCLUDES_ALL_INPUT";
1758
+ })(exports.TurnCoverage || (exports.TurnCoverage = {}));
1694
1759
  /** A function response. */
1695
1760
  class FunctionResponse {
1696
1761
  }
@@ -1737,7 +1802,7 @@ function createPartFromFunctionResponse(id, name, response) {
1737
1802
  };
1738
1803
  }
1739
1804
  /**
1740
- * Creates a `Part` object from a `base64` `string`.
1805
+ * Creates a `Part` object from a `base64` encoded `string`.
1741
1806
  */
1742
1807
  function createPartFromBase64(data, mimeType) {
1743
1808
  return {
@@ -2037,6 +2102,9 @@ class CountTokensResponse {
2037
2102
  /** Response for computing tokens. */
2038
2103
  class ComputeTokensResponse {
2039
2104
  }
2105
+ /** Response with generated videos. */
2106
+ class GenerateVideosResponse {
2107
+ }
2040
2108
  /** Empty response for caches.delete method. */
2041
2109
  class DeleteCachedContentResponse {
2042
2110
  }
@@ -2114,12 +2182,18 @@ class Caches extends BaseModule {
2114
2182
  * ```
2115
2183
  */
2116
2184
  this.list = async (params = {}) => {
2117
- return new Pager(PagedItem.PAGED_ITEM_CACHED_CONTENTS, (x) => this.listInternal(x), await this.listInternal(params), params);
2185
+ return new Pager(exports.PagedItem.PAGED_ITEM_CACHED_CONTENTS, (x) => this.listInternal(x), await this.listInternal(params), params);
2118
2186
  };
2119
2187
  }
2120
2188
  /**
2121
2189
  * Creates a cached contents resource.
2122
2190
  *
2191
+ * @remarks
2192
+ * Context caching is only supported for specific models. See [Gemini
2193
+ * Developer API reference] (https://ai.google.dev/gemini-api/docs/caching?lang=node/context-cac)
2194
+ * and [Vertex AI reference] (https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-overview#supported_models)
2195
+ * for more information.
2196
+ *
2123
2197
  * @param params - The parameters for the create request.
2124
2198
  * @return The created cached content.
2125
2199
  *
@@ -2127,7 +2201,7 @@ class Caches extends BaseModule {
2127
2201
  * ```ts
2128
2202
  * const contents = ...; // Initialize the content to cache.
2129
2203
  * const response = await ai.caches.create({
2130
- * model: 'gemini-2.0-flash',
2204
+ * model: 'gemini-1.5-flash',
2131
2205
  * config: {
2132
2206
  * 'contents': contents,
2133
2207
  * 'displayName': 'test cache',
@@ -2807,9 +2881,10 @@ class Chat {
2807
2881
  * SPDX-License-Identifier: Apache-2.0
2808
2882
  */
2809
2883
  const CONTENT_TYPE_HEADER = 'Content-Type';
2884
+ const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
2810
2885
  const USER_AGENT_HEADER = 'User-Agent';
2811
2886
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
2812
- const SDK_VERSION = '0.6.1'; // x-release-please-version
2887
+ const SDK_VERSION = '0.8.0'; // x-release-please-version
2813
2888
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
2814
2889
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
2815
2890
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -2949,11 +3024,9 @@ class ApiClient {
2949
3024
  throw new Error('HTTP options are not correctly set.');
2950
3025
  }
2951
3026
  }
2952
- constructUrl(path, httpOptions) {
3027
+ constructUrl(path, httpOptions, prependProjectLocation) {
2953
3028
  const urlElement = [this.getRequestUrlInternal(httpOptions)];
2954
- if (this.clientOptions.vertexai &&
2955
- !this.clientOptions.apiKey &&
2956
- !path.startsWith('projects/')) {
3029
+ if (prependProjectLocation) {
2957
3030
  urlElement.push(this.getBaseResourcePath());
2958
3031
  }
2959
3032
  if (path !== '') {
@@ -2962,12 +3035,34 @@ class ApiClient {
2962
3035
  const url = new URL(`${urlElement.join('/')}`);
2963
3036
  return url;
2964
3037
  }
3038
+ shouldPrependVertexProjectPath(request) {
3039
+ if (this.clientOptions.apiKey) {
3040
+ return false;
3041
+ }
3042
+ if (!this.clientOptions.vertexai) {
3043
+ return false;
3044
+ }
3045
+ if (request.path.startsWith('projects/')) {
3046
+ // Assume the path already starts with
3047
+ // `projects/<project>/location/<location>`.
3048
+ return false;
3049
+ }
3050
+ if (request.httpMethod === 'GET' &&
3051
+ request.path.startsWith('publishers/google/models')) {
3052
+ // These paths are used by Vertex's models.get and models.list
3053
+ // calls. For base models Vertex does not accept a project/location
3054
+ // prefix (for tuned model the prefix is required).
3055
+ return false;
3056
+ }
3057
+ return true;
3058
+ }
2965
3059
  async request(request) {
2966
3060
  let patchedHttpOptions = this.clientOptions.httpOptions;
2967
3061
  if (request.httpOptions) {
2968
3062
  patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
2969
3063
  }
2970
- const url = this.constructUrl(request.path, patchedHttpOptions);
3064
+ const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
3065
+ const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
2971
3066
  if (request.queryParams) {
2972
3067
  for (const [key, value] of Object.entries(request.queryParams)) {
2973
3068
  url.searchParams.append(key, String(value));
@@ -3009,7 +3104,8 @@ class ApiClient {
3009
3104
  if (request.httpOptions) {
3010
3105
  patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
3011
3106
  }
3012
- const url = this.constructUrl(request.path, patchedHttpOptions);
3107
+ const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
3108
+ const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
3013
3109
  if (!url.searchParams.has('alt') || url.searchParams.get('alt') !== 'sse') {
3014
3110
  url.searchParams.set('alt', 'sse');
3015
3111
  }
@@ -3117,6 +3213,11 @@ class ApiClient {
3117
3213
  for (const [key, value] of Object.entries(httpOptions.headers)) {
3118
3214
  headers.append(key, value);
3119
3215
  }
3216
+ // Append a timeout header if it is set, note that the timeout option is
3217
+ // in milliseconds but the header is in seconds.
3218
+ if (httpOptions.timeout && httpOptions.timeout > 0) {
3219
+ headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
3220
+ }
3120
3221
  }
3121
3222
  await this.clientOptions.auth.addAuthHeaders(headers);
3122
3223
  return headers;
@@ -3145,7 +3246,7 @@ class ApiClient {
3145
3246
  }
3146
3247
  const uploader = this.clientOptions.uploader;
3147
3248
  const fileStat = await uploader.stat(file);
3148
- fileToUpload.sizeBytes = fileStat.size;
3249
+ fileToUpload.sizeBytes = String(fileStat.size);
3149
3250
  const mimeType = (_a = config === null || config === void 0 ? void 0 : config.mimeType) !== null && _a !== void 0 ? _a : fileStat.type;
3150
3251
  if (mimeType === undefined || mimeType === '') {
3151
3252
  throw new Error('Can not determine mimeType. Please provide mimeType in the config.');
@@ -3604,7 +3705,7 @@ class Files extends BaseModule {
3604
3705
  * ```
3605
3706
  */
3606
3707
  this.list = async (params = {}) => {
3607
- return new Pager(PagedItem.PAGED_ITEM_FILES, (x) => this.listInternal(x), await this.listInternal(params), params);
3708
+ return new Pager(exports.PagedItem.PAGED_ITEM_FILES, (x) => this.listInternal(x), await this.listInternal(params), params);
3608
3709
  };
3609
3710
  }
3610
3711
  /**
@@ -3631,8 +3732,9 @@ class Files extends BaseModule {
3631
3732
  * This section can contain multiple paragraphs and code examples.
3632
3733
  *
3633
3734
  * @param params - Optional parameters specified in the
3634
- * `common.UploadFileParameters` interface.
3635
- * Optional @see {@link common.UploadFileParameters}
3735
+ * `types.UploadFileParameters` interface.
3736
+ * @see {@link types.UploadFileParameters#config} for the optional
3737
+ * config in the parameters.
3636
3738
  * @return A promise that resolves to a `types.File` object.
3637
3739
  * @throws An error if called on a Vertex AI client.
3638
3740
  * @throws An error if the `mimeType` is not provided and can not be inferred,
@@ -4136,6 +4238,12 @@ function thinkingConfigToMldev(apiClient, fromObject) {
4136
4238
  if (fromIncludeThoughts != null) {
4137
4239
  setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
4138
4240
  }
4241
+ const fromThinkingBudget = getValueByPath(fromObject, [
4242
+ 'thinkingBudget',
4243
+ ]);
4244
+ if (fromThinkingBudget != null) {
4245
+ setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
4246
+ }
4139
4247
  return toObject;
4140
4248
  }
4141
4249
  function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
@@ -4439,6 +4547,18 @@ function generateImagesParametersToMldev(apiClient, fromObject) {
4439
4547
  }
4440
4548
  return toObject;
4441
4549
  }
4550
+ function getModelParametersToMldev(apiClient, fromObject) {
4551
+ const toObject = {};
4552
+ const fromModel = getValueByPath(fromObject, ['model']);
4553
+ if (fromModel != null) {
4554
+ setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
4555
+ }
4556
+ const fromConfig = getValueByPath(fromObject, ['config']);
4557
+ if (fromConfig != null) {
4558
+ setValueByPath(toObject, ['config'], fromConfig);
4559
+ }
4560
+ return toObject;
4561
+ }
4442
4562
  function countTokensConfigToMldev(apiClient, fromObject) {
4443
4563
  const toObject = {};
4444
4564
  if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
@@ -4475,6 +4595,91 @@ function countTokensParametersToMldev(apiClient, fromObject) {
4475
4595
  }
4476
4596
  return toObject;
4477
4597
  }
4598
+ function imageToMldev(apiClient, fromObject) {
4599
+ const toObject = {};
4600
+ if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
4601
+ throw new Error('gcsUri parameter is not supported in Gemini API.');
4602
+ }
4603
+ const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
4604
+ if (fromImageBytes != null) {
4605
+ setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
4606
+ }
4607
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
4608
+ if (fromMimeType != null) {
4609
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
4610
+ }
4611
+ return toObject;
4612
+ }
4613
+ function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
4614
+ const toObject = {};
4615
+ const fromNumberOfVideos = getValueByPath(fromObject, [
4616
+ 'numberOfVideos',
4617
+ ]);
4618
+ if (parentObject !== undefined && fromNumberOfVideos != null) {
4619
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfVideos);
4620
+ }
4621
+ if (getValueByPath(fromObject, ['outputGcsUri']) !== undefined) {
4622
+ throw new Error('outputGcsUri parameter is not supported in Gemini API.');
4623
+ }
4624
+ if (getValueByPath(fromObject, ['fps']) !== undefined) {
4625
+ throw new Error('fps parameter is not supported in Gemini API.');
4626
+ }
4627
+ const fromDurationSeconds = getValueByPath(fromObject, [
4628
+ 'durationSeconds',
4629
+ ]);
4630
+ if (parentObject !== undefined && fromDurationSeconds != null) {
4631
+ setValueByPath(parentObject, ['parameters', 'durationSeconds'], fromDurationSeconds);
4632
+ }
4633
+ if (getValueByPath(fromObject, ['seed']) !== undefined) {
4634
+ throw new Error('seed parameter is not supported in Gemini API.');
4635
+ }
4636
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
4637
+ if (parentObject !== undefined && fromAspectRatio != null) {
4638
+ setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
4639
+ }
4640
+ if (getValueByPath(fromObject, ['resolution']) !== undefined) {
4641
+ throw new Error('resolution parameter is not supported in Gemini API.');
4642
+ }
4643
+ const fromPersonGeneration = getValueByPath(fromObject, [
4644
+ 'personGeneration',
4645
+ ]);
4646
+ if (parentObject !== undefined && fromPersonGeneration != null) {
4647
+ setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
4648
+ }
4649
+ if (getValueByPath(fromObject, ['pubsubTopic']) !== undefined) {
4650
+ throw new Error('pubsubTopic parameter is not supported in Gemini API.');
4651
+ }
4652
+ const fromNegativePrompt = getValueByPath(fromObject, [
4653
+ 'negativePrompt',
4654
+ ]);
4655
+ if (parentObject !== undefined && fromNegativePrompt != null) {
4656
+ setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
4657
+ }
4658
+ if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
4659
+ throw new Error('enhancePrompt parameter is not supported in Gemini API.');
4660
+ }
4661
+ return toObject;
4662
+ }
4663
+ function generateVideosParametersToMldev(apiClient, fromObject) {
4664
+ const toObject = {};
4665
+ const fromModel = getValueByPath(fromObject, ['model']);
4666
+ if (fromModel != null) {
4667
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
4668
+ }
4669
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
4670
+ if (fromPrompt != null) {
4671
+ setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
4672
+ }
4673
+ const fromImage = getValueByPath(fromObject, ['image']);
4674
+ if (fromImage != null) {
4675
+ setValueByPath(toObject, ['instances[0]', 'image'], imageToMldev(apiClient, fromImage));
4676
+ }
4677
+ const fromConfig = getValueByPath(fromObject, ['config']);
4678
+ if (fromConfig != null) {
4679
+ setValueByPath(toObject, ['config'], generateVideosConfigToMldev(apiClient, fromConfig, toObject));
4680
+ }
4681
+ return toObject;
4682
+ }
4478
4683
  function partToVertex(apiClient, fromObject) {
4479
4684
  const toObject = {};
4480
4685
  const fromVideoMetadata = getValueByPath(fromObject, [
@@ -4799,6 +5004,12 @@ function thinkingConfigToVertex(apiClient, fromObject) {
4799
5004
  if (fromIncludeThoughts != null) {
4800
5005
  setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
4801
5006
  }
5007
+ const fromThinkingBudget = getValueByPath(fromObject, [
5008
+ 'thinkingBudget',
5009
+ ]);
5010
+ if (fromThinkingBudget != null) {
5011
+ setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
5012
+ }
4802
5013
  return toObject;
4803
5014
  }
4804
5015
  function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
@@ -5116,6 +5327,18 @@ function generateImagesParametersToVertex(apiClient, fromObject) {
5116
5327
  }
5117
5328
  return toObject;
5118
5329
  }
5330
+ function getModelParametersToVertex(apiClient, fromObject) {
5331
+ const toObject = {};
5332
+ const fromModel = getValueByPath(fromObject, ['model']);
5333
+ if (fromModel != null) {
5334
+ setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
5335
+ }
5336
+ const fromConfig = getValueByPath(fromObject, ['config']);
5337
+ if (fromConfig != null) {
5338
+ setValueByPath(toObject, ['config'], fromConfig);
5339
+ }
5340
+ return toObject;
5341
+ }
5119
5342
  function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
5120
5343
  const toObject = {};
5121
5344
  const fromSystemInstruction = getValueByPath(fromObject, [
@@ -5189,6 +5412,100 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
5189
5412
  }
5190
5413
  return toObject;
5191
5414
  }
5415
+ function imageToVertex(apiClient, fromObject) {
5416
+ const toObject = {};
5417
+ const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
5418
+ if (fromGcsUri != null) {
5419
+ setValueByPath(toObject, ['gcsUri'], fromGcsUri);
5420
+ }
5421
+ const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
5422
+ if (fromImageBytes != null) {
5423
+ setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
5424
+ }
5425
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
5426
+ if (fromMimeType != null) {
5427
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
5428
+ }
5429
+ return toObject;
5430
+ }
5431
+ function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
5432
+ const toObject = {};
5433
+ const fromNumberOfVideos = getValueByPath(fromObject, [
5434
+ 'numberOfVideos',
5435
+ ]);
5436
+ if (parentObject !== undefined && fromNumberOfVideos != null) {
5437
+ setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfVideos);
5438
+ }
5439
+ const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
5440
+ if (parentObject !== undefined && fromOutputGcsUri != null) {
5441
+ setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
5442
+ }
5443
+ const fromFps = getValueByPath(fromObject, ['fps']);
5444
+ if (parentObject !== undefined && fromFps != null) {
5445
+ setValueByPath(parentObject, ['parameters', 'fps'], fromFps);
5446
+ }
5447
+ const fromDurationSeconds = getValueByPath(fromObject, [
5448
+ 'durationSeconds',
5449
+ ]);
5450
+ if (parentObject !== undefined && fromDurationSeconds != null) {
5451
+ setValueByPath(parentObject, ['parameters', 'durationSeconds'], fromDurationSeconds);
5452
+ }
5453
+ const fromSeed = getValueByPath(fromObject, ['seed']);
5454
+ if (parentObject !== undefined && fromSeed != null) {
5455
+ setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
5456
+ }
5457
+ const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
5458
+ if (parentObject !== undefined && fromAspectRatio != null) {
5459
+ setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
5460
+ }
5461
+ const fromResolution = getValueByPath(fromObject, ['resolution']);
5462
+ if (parentObject !== undefined && fromResolution != null) {
5463
+ setValueByPath(parentObject, ['parameters', 'resolution'], fromResolution);
5464
+ }
5465
+ const fromPersonGeneration = getValueByPath(fromObject, [
5466
+ 'personGeneration',
5467
+ ]);
5468
+ if (parentObject !== undefined && fromPersonGeneration != null) {
5469
+ setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
5470
+ }
5471
+ const fromPubsubTopic = getValueByPath(fromObject, ['pubsubTopic']);
5472
+ if (parentObject !== undefined && fromPubsubTopic != null) {
5473
+ setValueByPath(parentObject, ['parameters', 'pubsubTopic'], fromPubsubTopic);
5474
+ }
5475
+ const fromNegativePrompt = getValueByPath(fromObject, [
5476
+ 'negativePrompt',
5477
+ ]);
5478
+ if (parentObject !== undefined && fromNegativePrompt != null) {
5479
+ setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
5480
+ }
5481
+ const fromEnhancePrompt = getValueByPath(fromObject, [
5482
+ 'enhancePrompt',
5483
+ ]);
5484
+ if (parentObject !== undefined && fromEnhancePrompt != null) {
5485
+ setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
5486
+ }
5487
+ return toObject;
5488
+ }
5489
+ function generateVideosParametersToVertex(apiClient, fromObject) {
5490
+ const toObject = {};
5491
+ const fromModel = getValueByPath(fromObject, ['model']);
5492
+ if (fromModel != null) {
5493
+ setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
5494
+ }
5495
+ const fromPrompt = getValueByPath(fromObject, ['prompt']);
5496
+ if (fromPrompt != null) {
5497
+ setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
5498
+ }
5499
+ const fromImage = getValueByPath(fromObject, ['image']);
5500
+ if (fromImage != null) {
5501
+ setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
5502
+ }
5503
+ const fromConfig = getValueByPath(fromObject, ['config']);
5504
+ if (fromConfig != null) {
5505
+ setValueByPath(toObject, ['config'], generateVideosConfigToVertex(apiClient, fromConfig, toObject));
5506
+ }
5507
+ return toObject;
5508
+ }
5192
5509
  function partFromMldev(apiClient, fromObject) {
5193
5510
  const toObject = {};
5194
5511
  const fromThought = getValueByPath(fromObject, ['thought']);
@@ -5445,6 +5762,64 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
5445
5762
  }
5446
5763
  return toObject;
5447
5764
  }
5765
+ function tunedModelInfoFromMldev(apiClient, fromObject) {
5766
+ const toObject = {};
5767
+ const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
5768
+ if (fromBaseModel != null) {
5769
+ setValueByPath(toObject, ['baseModel'], fromBaseModel);
5770
+ }
5771
+ const fromCreateTime = getValueByPath(fromObject, ['createTime']);
5772
+ if (fromCreateTime != null) {
5773
+ setValueByPath(toObject, ['createTime'], fromCreateTime);
5774
+ }
5775
+ const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
5776
+ if (fromUpdateTime != null) {
5777
+ setValueByPath(toObject, ['updateTime'], fromUpdateTime);
5778
+ }
5779
+ return toObject;
5780
+ }
5781
+ function modelFromMldev(apiClient, fromObject) {
5782
+ const toObject = {};
5783
+ const fromName = getValueByPath(fromObject, ['name']);
5784
+ if (fromName != null) {
5785
+ setValueByPath(toObject, ['name'], fromName);
5786
+ }
5787
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
5788
+ if (fromDisplayName != null) {
5789
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
5790
+ }
5791
+ const fromDescription = getValueByPath(fromObject, ['description']);
5792
+ if (fromDescription != null) {
5793
+ setValueByPath(toObject, ['description'], fromDescription);
5794
+ }
5795
+ const fromVersion = getValueByPath(fromObject, ['version']);
5796
+ if (fromVersion != null) {
5797
+ setValueByPath(toObject, ['version'], fromVersion);
5798
+ }
5799
+ const fromTunedModelInfo = getValueByPath(fromObject, ['_self']);
5800
+ if (fromTunedModelInfo != null) {
5801
+ setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromMldev(apiClient, fromTunedModelInfo));
5802
+ }
5803
+ const fromInputTokenLimit = getValueByPath(fromObject, [
5804
+ 'inputTokenLimit',
5805
+ ]);
5806
+ if (fromInputTokenLimit != null) {
5807
+ setValueByPath(toObject, ['inputTokenLimit'], fromInputTokenLimit);
5808
+ }
5809
+ const fromOutputTokenLimit = getValueByPath(fromObject, [
5810
+ 'outputTokenLimit',
5811
+ ]);
5812
+ if (fromOutputTokenLimit != null) {
5813
+ setValueByPath(toObject, ['outputTokenLimit'], fromOutputTokenLimit);
5814
+ }
5815
+ const fromSupportedActions = getValueByPath(fromObject, [
5816
+ 'supportedGenerationMethods',
5817
+ ]);
5818
+ if (fromSupportedActions != null) {
5819
+ setValueByPath(toObject, ['supportedActions'], fromSupportedActions);
5820
+ }
5821
+ return toObject;
5822
+ }
5448
5823
  function countTokensResponseFromMldev(apiClient, fromObject) {
5449
5824
  const toObject = {};
5450
5825
  const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
@@ -5459,35 +5834,125 @@ function countTokensResponseFromMldev(apiClient, fromObject) {
5459
5834
  }
5460
5835
  return toObject;
5461
5836
  }
5462
- function partFromVertex(apiClient, fromObject) {
5837
+ function videoFromMldev$1(apiClient, fromObject) {
5463
5838
  const toObject = {};
5464
- const fromVideoMetadata = getValueByPath(fromObject, [
5465
- 'videoMetadata',
5839
+ const fromUri = getValueByPath(fromObject, ['video', 'uri']);
5840
+ if (fromUri != null) {
5841
+ setValueByPath(toObject, ['uri'], fromUri);
5842
+ }
5843
+ const fromVideoBytes = getValueByPath(fromObject, [
5844
+ 'video',
5845
+ 'encodedVideo',
5466
5846
  ]);
5467
- if (fromVideoMetadata != null) {
5468
- setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
5847
+ if (fromVideoBytes != null) {
5848
+ setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
5469
5849
  }
5470
- const fromThought = getValueByPath(fromObject, ['thought']);
5471
- if (fromThought != null) {
5472
- setValueByPath(toObject, ['thought'], fromThought);
5850
+ const fromMimeType = getValueByPath(fromObject, ['encoding']);
5851
+ if (fromMimeType != null) {
5852
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
5473
5853
  }
5474
- const fromCodeExecutionResult = getValueByPath(fromObject, [
5475
- 'codeExecutionResult',
5854
+ return toObject;
5855
+ }
5856
+ function generatedVideoFromMldev$1(apiClient, fromObject) {
5857
+ const toObject = {};
5858
+ const fromVideo = getValueByPath(fromObject, ['_self']);
5859
+ if (fromVideo != null) {
5860
+ setValueByPath(toObject, ['video'], videoFromMldev$1(apiClient, fromVideo));
5861
+ }
5862
+ return toObject;
5863
+ }
5864
+ function generateVideosResponseFromMldev$1(apiClient, fromObject) {
5865
+ const toObject = {};
5866
+ const fromGeneratedVideos = getValueByPath(fromObject, [
5867
+ 'generatedSamples',
5476
5868
  ]);
5477
- if (fromCodeExecutionResult != null) {
5478
- setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
5869
+ if (fromGeneratedVideos != null) {
5870
+ if (Array.isArray(fromGeneratedVideos)) {
5871
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
5872
+ return generatedVideoFromMldev$1(apiClient, item);
5873
+ }));
5874
+ }
5875
+ else {
5876
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
5877
+ }
5479
5878
  }
5480
- const fromExecutableCode = getValueByPath(fromObject, [
5481
- 'executableCode',
5879
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
5880
+ 'raiMediaFilteredCount',
5482
5881
  ]);
5483
- if (fromExecutableCode != null) {
5484
- setValueByPath(toObject, ['executableCode'], fromExecutableCode);
5882
+ if (fromRaiMediaFilteredCount != null) {
5883
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
5485
5884
  }
5486
- const fromFileData = getValueByPath(fromObject, ['fileData']);
5487
- if (fromFileData != null) {
5488
- setValueByPath(toObject, ['fileData'], fromFileData);
5885
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
5886
+ 'raiMediaFilteredReasons',
5887
+ ]);
5888
+ if (fromRaiMediaFilteredReasons != null) {
5889
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
5489
5890
  }
5490
- const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5891
+ return toObject;
5892
+ }
5893
+ function generateVideosOperationFromMldev$1(apiClient, fromObject) {
5894
+ const toObject = {};
5895
+ const fromName = getValueByPath(fromObject, ['name']);
5896
+ if (fromName != null) {
5897
+ setValueByPath(toObject, ['name'], fromName);
5898
+ }
5899
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
5900
+ if (fromMetadata != null) {
5901
+ setValueByPath(toObject, ['metadata'], fromMetadata);
5902
+ }
5903
+ const fromDone = getValueByPath(fromObject, ['done']);
5904
+ if (fromDone != null) {
5905
+ setValueByPath(toObject, ['done'], fromDone);
5906
+ }
5907
+ const fromError = getValueByPath(fromObject, ['error']);
5908
+ if (fromError != null) {
5909
+ setValueByPath(toObject, ['error'], fromError);
5910
+ }
5911
+ const fromResponse = getValueByPath(fromObject, [
5912
+ 'response',
5913
+ 'generateVideoResponse',
5914
+ ]);
5915
+ if (fromResponse != null) {
5916
+ setValueByPath(toObject, ['response'], generateVideosResponseFromMldev$1(apiClient, fromResponse));
5917
+ }
5918
+ const fromResult = getValueByPath(fromObject, [
5919
+ 'response',
5920
+ 'generateVideoResponse',
5921
+ ]);
5922
+ if (fromResult != null) {
5923
+ setValueByPath(toObject, ['result'], generateVideosResponseFromMldev$1(apiClient, fromResult));
5924
+ }
5925
+ return toObject;
5926
+ }
5927
+ function partFromVertex(apiClient, fromObject) {
5928
+ const toObject = {};
5929
+ const fromVideoMetadata = getValueByPath(fromObject, [
5930
+ 'videoMetadata',
5931
+ ]);
5932
+ if (fromVideoMetadata != null) {
5933
+ setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
5934
+ }
5935
+ const fromThought = getValueByPath(fromObject, ['thought']);
5936
+ if (fromThought != null) {
5937
+ setValueByPath(toObject, ['thought'], fromThought);
5938
+ }
5939
+ const fromCodeExecutionResult = getValueByPath(fromObject, [
5940
+ 'codeExecutionResult',
5941
+ ]);
5942
+ if (fromCodeExecutionResult != null) {
5943
+ setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
5944
+ }
5945
+ const fromExecutableCode = getValueByPath(fromObject, [
5946
+ 'executableCode',
5947
+ ]);
5948
+ if (fromExecutableCode != null) {
5949
+ setValueByPath(toObject, ['executableCode'], fromExecutableCode);
5950
+ }
5951
+ const fromFileData = getValueByPath(fromObject, ['fileData']);
5952
+ if (fromFileData != null) {
5953
+ setValueByPath(toObject, ['fileData'], fromFileData);
5954
+ }
5955
+ const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
5491
5956
  if (fromFunctionCall != null) {
5492
5957
  setValueByPath(toObject, ['functionCall'], fromFunctionCall);
5493
5958
  }
@@ -5764,6 +6229,78 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
5764
6229
  }
5765
6230
  return toObject;
5766
6231
  }
6232
+ function endpointFromVertex(apiClient, fromObject) {
6233
+ const toObject = {};
6234
+ const fromName = getValueByPath(fromObject, ['endpoint']);
6235
+ if (fromName != null) {
6236
+ setValueByPath(toObject, ['name'], fromName);
6237
+ }
6238
+ const fromDeployedModelId = getValueByPath(fromObject, [
6239
+ 'deployedModelId',
6240
+ ]);
6241
+ if (fromDeployedModelId != null) {
6242
+ setValueByPath(toObject, ['deployedModelId'], fromDeployedModelId);
6243
+ }
6244
+ return toObject;
6245
+ }
6246
+ function tunedModelInfoFromVertex(apiClient, fromObject) {
6247
+ const toObject = {};
6248
+ const fromBaseModel = getValueByPath(fromObject, [
6249
+ 'labels',
6250
+ 'google-vertex-llm-tuning-base-model-id',
6251
+ ]);
6252
+ if (fromBaseModel != null) {
6253
+ setValueByPath(toObject, ['baseModel'], fromBaseModel);
6254
+ }
6255
+ const fromCreateTime = getValueByPath(fromObject, ['createTime']);
6256
+ if (fromCreateTime != null) {
6257
+ setValueByPath(toObject, ['createTime'], fromCreateTime);
6258
+ }
6259
+ const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
6260
+ if (fromUpdateTime != null) {
6261
+ setValueByPath(toObject, ['updateTime'], fromUpdateTime);
6262
+ }
6263
+ return toObject;
6264
+ }
6265
+ function modelFromVertex(apiClient, fromObject) {
6266
+ const toObject = {};
6267
+ const fromName = getValueByPath(fromObject, ['name']);
6268
+ if (fromName != null) {
6269
+ setValueByPath(toObject, ['name'], fromName);
6270
+ }
6271
+ const fromDisplayName = getValueByPath(fromObject, ['displayName']);
6272
+ if (fromDisplayName != null) {
6273
+ setValueByPath(toObject, ['displayName'], fromDisplayName);
6274
+ }
6275
+ const fromDescription = getValueByPath(fromObject, ['description']);
6276
+ if (fromDescription != null) {
6277
+ setValueByPath(toObject, ['description'], fromDescription);
6278
+ }
6279
+ const fromVersion = getValueByPath(fromObject, ['versionId']);
6280
+ if (fromVersion != null) {
6281
+ setValueByPath(toObject, ['version'], fromVersion);
6282
+ }
6283
+ const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
6284
+ if (fromEndpoints != null) {
6285
+ if (Array.isArray(fromEndpoints)) {
6286
+ setValueByPath(toObject, ['endpoints'], fromEndpoints.map((item) => {
6287
+ return endpointFromVertex(apiClient, item);
6288
+ }));
6289
+ }
6290
+ else {
6291
+ setValueByPath(toObject, ['endpoints'], fromEndpoints);
6292
+ }
6293
+ }
6294
+ const fromLabels = getValueByPath(fromObject, ['labels']);
6295
+ if (fromLabels != null) {
6296
+ setValueByPath(toObject, ['labels'], fromLabels);
6297
+ }
6298
+ const fromTunedModelInfo = getValueByPath(fromObject, ['_self']);
6299
+ if (fromTunedModelInfo != null) {
6300
+ setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromVertex(apiClient, fromTunedModelInfo));
6301
+ }
6302
+ return toObject;
6303
+ }
5767
6304
  function countTokensResponseFromVertex(apiClient, fromObject) {
5768
6305
  const toObject = {};
5769
6306
  const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
@@ -5780,6 +6317,87 @@ function computeTokensResponseFromVertex(apiClient, fromObject) {
5780
6317
  }
5781
6318
  return toObject;
5782
6319
  }
6320
+ function videoFromVertex$1(apiClient, fromObject) {
6321
+ const toObject = {};
6322
+ const fromUri = getValueByPath(fromObject, ['gcsUri']);
6323
+ if (fromUri != null) {
6324
+ setValueByPath(toObject, ['uri'], fromUri);
6325
+ }
6326
+ const fromVideoBytes = getValueByPath(fromObject, [
6327
+ 'bytesBase64Encoded',
6328
+ ]);
6329
+ if (fromVideoBytes != null) {
6330
+ setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
6331
+ }
6332
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
6333
+ if (fromMimeType != null) {
6334
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
6335
+ }
6336
+ return toObject;
6337
+ }
6338
+ function generatedVideoFromVertex$1(apiClient, fromObject) {
6339
+ const toObject = {};
6340
+ const fromVideo = getValueByPath(fromObject, ['_self']);
6341
+ if (fromVideo != null) {
6342
+ setValueByPath(toObject, ['video'], videoFromVertex$1(apiClient, fromVideo));
6343
+ }
6344
+ return toObject;
6345
+ }
6346
+ function generateVideosResponseFromVertex$1(apiClient, fromObject) {
6347
+ const toObject = {};
6348
+ const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
6349
+ if (fromGeneratedVideos != null) {
6350
+ if (Array.isArray(fromGeneratedVideos)) {
6351
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
6352
+ return generatedVideoFromVertex$1(apiClient, item);
6353
+ }));
6354
+ }
6355
+ else {
6356
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
6357
+ }
6358
+ }
6359
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
6360
+ 'raiMediaFilteredCount',
6361
+ ]);
6362
+ if (fromRaiMediaFilteredCount != null) {
6363
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
6364
+ }
6365
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
6366
+ 'raiMediaFilteredReasons',
6367
+ ]);
6368
+ if (fromRaiMediaFilteredReasons != null) {
6369
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
6370
+ }
6371
+ return toObject;
6372
+ }
6373
+ function generateVideosOperationFromVertex$1(apiClient, fromObject) {
6374
+ const toObject = {};
6375
+ const fromName = getValueByPath(fromObject, ['name']);
6376
+ if (fromName != null) {
6377
+ setValueByPath(toObject, ['name'], fromName);
6378
+ }
6379
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
6380
+ if (fromMetadata != null) {
6381
+ setValueByPath(toObject, ['metadata'], fromMetadata);
6382
+ }
6383
+ const fromDone = getValueByPath(fromObject, ['done']);
6384
+ if (fromDone != null) {
6385
+ setValueByPath(toObject, ['done'], fromDone);
6386
+ }
6387
+ const fromError = getValueByPath(fromObject, ['error']);
6388
+ if (fromError != null) {
6389
+ setValueByPath(toObject, ['error'], fromError);
6390
+ }
6391
+ const fromResponse = getValueByPath(fromObject, ['response']);
6392
+ if (fromResponse != null) {
6393
+ setValueByPath(toObject, ['response'], generateVideosResponseFromVertex$1(apiClient, fromResponse));
6394
+ }
6395
+ const fromResult = getValueByPath(fromObject, ['response']);
6396
+ if (fromResult != null) {
6397
+ setValueByPath(toObject, ['result'], generateVideosResponseFromVertex$1(apiClient, fromResult));
6398
+ }
6399
+ return toObject;
6400
+ }
5783
6401
 
5784
6402
  /**
5785
6403
  * @license
@@ -5838,6 +6456,23 @@ function liveServerMessageFromMldev(apiClient, fromObject) {
5838
6456
  fromToolCallCancellation !== null) {
5839
6457
  setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromMldev(apiClient, fromToolCallCancellation));
5840
6458
  }
6459
+ const fromUsageMetadata = getValueByPath(fromObject, [
6460
+ 'usageMetadata',
6461
+ ]);
6462
+ if (fromUsageMetadata != undefined && fromUsageMetadata != null) {
6463
+ setValueByPath(toObject, ['usageMetadata'], usageMetadataFromMldev(apiClient, fromUsageMetadata));
6464
+ }
6465
+ const fromGoAway = getValueByPath(fromObject, ['goAway']);
6466
+ if (fromGoAway !== undefined && fromGoAway !== null) {
6467
+ setValueByPath(toObject, ['goAway'], liveServerGoAwayFromMldev(fromGoAway));
6468
+ }
6469
+ const fromSessionResumptionUpdate = getValueByPath(fromObject, [
6470
+ 'sessionResumptionUpdate',
6471
+ ]);
6472
+ if (fromSessionResumptionUpdate !== undefined &&
6473
+ fromSessionResumptionUpdate !== null) {
6474
+ setValueByPath(toObject, ['sessionResumptionUpdate'], liveServerSessionResumptionUpdateFromMldev(fromSessionResumptionUpdate));
6475
+ }
5841
6476
  return toObject;
5842
6477
  }
5843
6478
  function liveServerMessageFromVertex(apiClient, fromObject) {
@@ -5865,6 +6500,181 @@ function liveServerMessageFromVertex(apiClient, fromObject) {
5865
6500
  fromToolCallCancellation !== null) {
5866
6501
  setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromVertex(apiClient, fromToolCallCancellation));
5867
6502
  }
6503
+ const fromGoAway = getValueByPath(fromObject, ['goAway']);
6504
+ if (fromGoAway !== undefined && fromGoAway !== null) {
6505
+ setValueByPath(toObject, ['goAway'], liveServerGoAwayFromVertex(fromGoAway));
6506
+ }
6507
+ const fromSessionResumptionUpdate = getValueByPath(fromObject, [
6508
+ 'sessionResumptionUpdate',
6509
+ ]);
6510
+ if (fromSessionResumptionUpdate !== undefined &&
6511
+ fromSessionResumptionUpdate !== null) {
6512
+ setValueByPath(toObject, ['sessionResumptionUpdate'], liveServerSessionResumptionUpdateFromVertex(fromSessionResumptionUpdate));
6513
+ }
6514
+ const fromUsageMetadata = getValueByPath(fromObject, [
6515
+ 'usageMetadata',
6516
+ ]);
6517
+ if (fromUsageMetadata != undefined && fromUsageMetadata != null) {
6518
+ setValueByPath(toObject, ['usageMetadata'], usageMetadataFromVertex(apiClient, fromUsageMetadata));
6519
+ }
6520
+ return toObject;
6521
+ }
6522
+ function slidingWindowToMldev(fromObject) {
6523
+ const toObject = {};
6524
+ const fromTargetTokens = getValueByPath(fromObject, ['targetTokens']);
6525
+ if (fromTargetTokens !== undefined && fromTargetTokens !== null) {
6526
+ setValueByPath(toObject, ['targetTokens'], fromTargetTokens);
6527
+ }
6528
+ return toObject;
6529
+ }
6530
+ function slidingWindowToVertex(fromObject) {
6531
+ const toObject = {};
6532
+ const fromTargetTokens = getValueByPath(fromObject, ['targetTokens']);
6533
+ if (fromTargetTokens !== undefined && fromTargetTokens !== null) {
6534
+ setValueByPath(toObject, ['targetTokens'], fromTargetTokens);
6535
+ }
6536
+ return toObject;
6537
+ }
6538
+ function contextWindowCompressionToMldev(fromObject) {
6539
+ const toObject = {};
6540
+ const fromTriggerTokens = getValueByPath(fromObject, [
6541
+ 'triggerTokens',
6542
+ ]);
6543
+ if (fromTriggerTokens !== undefined && fromTriggerTokens !== null) {
6544
+ setValueByPath(toObject, ['triggerTokens'], fromTriggerTokens);
6545
+ }
6546
+ const fromSlidingWindow = getValueByPath(fromObject, [
6547
+ 'slidingWindow',
6548
+ ]);
6549
+ if (fromSlidingWindow !== undefined && fromSlidingWindow !== null) {
6550
+ setValueByPath(toObject, ['slidingWindow'], slidingWindowToMldev(fromSlidingWindow));
6551
+ }
6552
+ return toObject;
6553
+ }
6554
+ function contextWindowCompressionToVertex(fromObject) {
6555
+ const toObject = {};
6556
+ const fromTriggerTokens = getValueByPath(fromObject, [
6557
+ 'triggerTokens',
6558
+ ]);
6559
+ if (fromTriggerTokens !== undefined && fromTriggerTokens !== null) {
6560
+ setValueByPath(toObject, ['triggerTokens'], fromTriggerTokens);
6561
+ }
6562
+ const fromSlidingWindow = getValueByPath(fromObject, [
6563
+ 'slidingWindow',
6564
+ ]);
6565
+ if (fromSlidingWindow !== undefined && fromSlidingWindow !== null) {
6566
+ setValueByPath(toObject, ['slidingWindow'], slidingWindowToVertex(fromSlidingWindow));
6567
+ }
6568
+ return toObject;
6569
+ }
6570
+ function automaticActivityDetectionToMldev(fromObject) {
6571
+ const toObject = {};
6572
+ const fromDisabled = getValueByPath(fromObject, ['disabled']);
6573
+ if (fromDisabled !== undefined && fromDisabled !== null) {
6574
+ setValueByPath(toObject, ['disabled'], fromDisabled);
6575
+ }
6576
+ const fromStartOfSpeechSensitivity = getValueByPath(fromObject, [
6577
+ 'startOfSpeechSensitivity',
6578
+ ]);
6579
+ if (fromStartOfSpeechSensitivity !== undefined &&
6580
+ fromStartOfSpeechSensitivity !== null) {
6581
+ setValueByPath(toObject, ['startOfSpeechSensitivity'], fromStartOfSpeechSensitivity);
6582
+ }
6583
+ const fromEndOfSpeechSensitivity = getValueByPath(fromObject, [
6584
+ 'endOfSpeechSensitivity',
6585
+ ]);
6586
+ if (fromEndOfSpeechSensitivity !== undefined &&
6587
+ fromEndOfSpeechSensitivity !== null) {
6588
+ setValueByPath(toObject, ['endOfSpeechSensitivity'], fromEndOfSpeechSensitivity);
6589
+ }
6590
+ const fromPrefixPaddingMs = getValueByPath(fromObject, [
6591
+ 'prefixPaddingMs',
6592
+ ]);
6593
+ if (fromPrefixPaddingMs !== undefined && fromPrefixPaddingMs !== null) {
6594
+ setValueByPath(toObject, ['prefixPaddingMs'], fromPrefixPaddingMs);
6595
+ }
6596
+ const fromSilenceDurationMs = getValueByPath(fromObject, [
6597
+ 'silenceDurationMs',
6598
+ ]);
6599
+ if (fromSilenceDurationMs !== undefined && fromSilenceDurationMs !== null) {
6600
+ setValueByPath(toObject, ['silenceDurationMs'], fromSilenceDurationMs);
6601
+ }
6602
+ return toObject;
6603
+ }
6604
+ function automaticActivityDetectionToVertex(fromObject) {
6605
+ const toObject = {};
6606
+ const fromDisabled = getValueByPath(fromObject, ['disabled']);
6607
+ if (fromDisabled !== undefined && fromDisabled !== null) {
6608
+ setValueByPath(toObject, ['disabled'], fromDisabled);
6609
+ }
6610
+ const fromStartOfSpeechSensitivity = getValueByPath(fromObject, [
6611
+ 'startOfSpeechSensitivity',
6612
+ ]);
6613
+ if (fromStartOfSpeechSensitivity !== undefined &&
6614
+ fromStartOfSpeechSensitivity !== null) {
6615
+ setValueByPath(toObject, ['startOfSpeechSensitivity'], fromStartOfSpeechSensitivity);
6616
+ }
6617
+ const fromEndOfSpeechSensitivity = getValueByPath(fromObject, [
6618
+ 'endOfSpeechSensitivity',
6619
+ ]);
6620
+ if (fromEndOfSpeechSensitivity !== undefined &&
6621
+ fromEndOfSpeechSensitivity !== null) {
6622
+ setValueByPath(toObject, ['endOfSpeechSensitivity'], fromEndOfSpeechSensitivity);
6623
+ }
6624
+ const fromPrefixPaddingMs = getValueByPath(fromObject, [
6625
+ 'prefixPaddingMs',
6626
+ ]);
6627
+ if (fromPrefixPaddingMs !== undefined && fromPrefixPaddingMs !== null) {
6628
+ setValueByPath(toObject, ['prefixPaddingMs'], fromPrefixPaddingMs);
6629
+ }
6630
+ const fromSilenceDurationMs = getValueByPath(fromObject, [
6631
+ 'silenceDurationMs',
6632
+ ]);
6633
+ if (fromSilenceDurationMs !== undefined && fromSilenceDurationMs !== null) {
6634
+ setValueByPath(toObject, ['silenceDurationMs'], fromSilenceDurationMs);
6635
+ }
6636
+ return toObject;
6637
+ }
6638
+ function realtimeInputConfigToMldev(fromObject) {
6639
+ const toObject = {};
6640
+ const fromAutomaticActivityDetection = getValueByPath(fromObject, [
6641
+ 'automaticActivityDetection',
6642
+ ]);
6643
+ if (fromAutomaticActivityDetection !== undefined &&
6644
+ fromAutomaticActivityDetection !== null) {
6645
+ setValueByPath(toObject, ['automaticActivityDetection'], automaticActivityDetectionToMldev(fromAutomaticActivityDetection));
6646
+ }
6647
+ const fromActivityHandling = getValueByPath(fromObject, [
6648
+ 'activityHandling',
6649
+ ]);
6650
+ if (fromActivityHandling !== undefined && fromActivityHandling !== null) {
6651
+ setValueByPath(toObject, ['activityHandling'], fromActivityHandling);
6652
+ }
6653
+ const fromTurnCoverage = getValueByPath(fromObject, ['turnCoverage']);
6654
+ if (fromTurnCoverage !== undefined && fromTurnCoverage !== null) {
6655
+ setValueByPath(toObject, ['turnCoverage'], fromTurnCoverage);
6656
+ }
6657
+ return toObject;
6658
+ }
6659
+ function realtimeInputConfigToVertex(fromObject) {
6660
+ const toObject = {};
6661
+ const fromAutomaticActivityDetection = getValueByPath(fromObject, [
6662
+ 'automaticActivityDetection',
6663
+ ]);
6664
+ if (fromAutomaticActivityDetection !== undefined &&
6665
+ fromAutomaticActivityDetection !== null) {
6666
+ setValueByPath(toObject, ['automaticActivityDetection'], automaticActivityDetectionToVertex(fromAutomaticActivityDetection));
6667
+ }
6668
+ const fromActivityHandling = getValueByPath(fromObject, [
6669
+ 'activityHandling',
6670
+ ]);
6671
+ if (fromActivityHandling !== undefined && fromActivityHandling !== null) {
6672
+ setValueByPath(toObject, ['activityHandling'], fromActivityHandling);
6673
+ }
6674
+ const fromTurnCoverage = getValueByPath(fromObject, ['turnCoverage']);
6675
+ if (fromTurnCoverage !== undefined && fromTurnCoverage !== null) {
6676
+ setValueByPath(toObject, ['turnCoverage'], fromTurnCoverage);
6677
+ }
5868
6678
  return toObject;
5869
6679
  }
5870
6680
  function liveConnectConfigToMldev(apiClient, fromObject) {
@@ -5899,6 +6709,26 @@ function liveConnectConfigToMldev(apiClient, fromObject) {
5899
6709
  return toolToMldev(apiClient, item);
5900
6710
  }));
5901
6711
  }
6712
+ const fromSessionResumption = getValueByPath(fromObject, [
6713
+ 'sessionResumption',
6714
+ ]);
6715
+ if (fromSessionResumption !== undefined && fromSessionResumption !== null) {
6716
+ setValueByPath(toObject, ['sessionResumption'], liveClientSessionResumptionConfigToMldev(fromSessionResumption));
6717
+ }
6718
+ const fromContextWindowCompression = getValueByPath(fromObject, [
6719
+ 'contextWindowCompression',
6720
+ ]);
6721
+ if (fromContextWindowCompression !== undefined &&
6722
+ fromContextWindowCompression !== null) {
6723
+ setValueByPath(toObject, ['contextWindowCompression'], contextWindowCompressionToMldev(fromContextWindowCompression));
6724
+ }
6725
+ const fromRealtimeInputConfig = getValueByPath(fromObject, [
6726
+ 'realtimeInputConfig',
6727
+ ]);
6728
+ if (fromRealtimeInputConfig !== undefined &&
6729
+ fromRealtimeInputConfig !== null) {
6730
+ setValueByPath(toObject, ['realtimeInputConfig'], realtimeInputConfigToMldev(fromRealtimeInputConfig));
6731
+ }
5902
6732
  return toObject;
5903
6733
  }
5904
6734
  function liveConnectConfigToVertex(apiClient, fromObject) {
@@ -5937,6 +6767,26 @@ function liveConnectConfigToVertex(apiClient, fromObject) {
5937
6767
  return toolToVertex(apiClient, item);
5938
6768
  }));
5939
6769
  }
6770
+ const fromSessionResumption = getValueByPath(fromObject, [
6771
+ 'sessionResumption',
6772
+ ]);
6773
+ if (fromSessionResumption !== undefined && fromSessionResumption !== null) {
6774
+ setValueByPath(toObject, ['sessionResumption'], liveClientSessionResumptionConfigToVertex(fromSessionResumption));
6775
+ }
6776
+ const fromContextWindowCompression = getValueByPath(fromObject, [
6777
+ 'contextWindowCompression',
6778
+ ]);
6779
+ if (fromContextWindowCompression !== undefined &&
6780
+ fromContextWindowCompression !== null) {
6781
+ setValueByPath(toObject, ['contextWindowCompression'], contextWindowCompressionToVertex(fromContextWindowCompression));
6782
+ }
6783
+ const fromRealtimeInputConfig = getValueByPath(fromObject, [
6784
+ 'realtimeInputConfig',
6785
+ ]);
6786
+ if (fromRealtimeInputConfig !== undefined &&
6787
+ fromRealtimeInputConfig !== null) {
6788
+ setValueByPath(toObject, ['realtimeInputConfig'], realtimeInputConfigToVertex(fromRealtimeInputConfig));
6789
+ }
5940
6790
  return toObject;
5941
6791
  }
5942
6792
  function liveServerContentFromMldev(apiClient, fromObject) {
@@ -5953,6 +6803,12 @@ function liveServerContentFromMldev(apiClient, fromObject) {
5953
6803
  if (fromInterrupted !== undefined) {
5954
6804
  setValueByPath(toObject, ['interrupted'], fromInterrupted);
5955
6805
  }
6806
+ const fromGenerationComplete = getValueByPath(fromObject, [
6807
+ 'generationComplete',
6808
+ ]);
6809
+ if (fromGenerationComplete != null) {
6810
+ setValueByPath(toObject, ['generationComplete'], fromGenerationComplete);
6811
+ }
5956
6812
  return toObject;
5957
6813
  }
5958
6814
  function liveServerContentFromVertex(apiClient, fromObject) {
@@ -5969,6 +6825,12 @@ function liveServerContentFromVertex(apiClient, fromObject) {
5969
6825
  if (fromInterrupted !== undefined) {
5970
6826
  setValueByPath(toObject, ['interrupted'], fromInterrupted);
5971
6827
  }
6828
+ const fromGenerationComplete = getValueByPath(fromObject, [
6829
+ 'generationComplete',
6830
+ ]);
6831
+ if (fromGenerationComplete != null) {
6832
+ setValueByPath(toObject, ['generationComplete'], fromGenerationComplete);
6833
+ }
5972
6834
  return toObject;
5973
6835
  }
5974
6836
  function functionCallFromMldev(apiClient, fromObject) {
@@ -6043,28 +6905,315 @@ function liveServerToolCallCancellationFromVertex(apiClient, fromObject) {
6043
6905
  }
6044
6906
  return toObject;
6045
6907
  }
6046
-
6047
- /**
6048
- * @license
6049
- * Copyright 2025 Google LLC
6050
- * SPDX-License-Identifier: Apache-2.0
6051
- */
6052
- const FUNCTION_RESPONSE_REQUIRES_ID = 'FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.';
6053
- /**
6054
- * Handles incoming messages from the WebSocket.
6055
- *
6056
- * @remarks
6057
- * This function is responsible for parsing incoming messages, transforming them
6058
- * into LiveServerMessages, and then calling the onmessage callback. Note that
6059
- * the first message which is received from the server is a setupComplete
6060
- * message.
6061
- *
6062
- * @param apiClient The ApiClient instance.
6063
- * @param onmessage The user-provided onmessage callback (if any).
6064
- * @param event The MessageEvent from the WebSocket.
6065
- */
6066
- async function handleWebSocketMessage(apiClient, onmessage, event) {
6067
- let serverMessage;
6908
+ function liveServerGoAwayFromMldev(fromObject) {
6909
+ const toObject = {};
6910
+ const fromTimeLeft = getValueByPath(fromObject, ['timeLeft']);
6911
+ if (fromTimeLeft !== undefined) {
6912
+ setValueByPath(toObject, ['timeLeft'], fromTimeLeft);
6913
+ }
6914
+ return toObject;
6915
+ }
6916
+ function liveServerGoAwayFromVertex(fromObject) {
6917
+ const toObject = {};
6918
+ const fromTimeLeft = getValueByPath(fromObject, ['timeLeft']);
6919
+ if (fromTimeLeft !== undefined) {
6920
+ setValueByPath(toObject, ['timeLeft'], fromTimeLeft);
6921
+ }
6922
+ return toObject;
6923
+ }
6924
+ function liveServerSessionResumptionUpdateFromMldev(fromObject) {
6925
+ const toObject = {};
6926
+ const fromNewHandle = getValueByPath(fromObject, ['newHandle']);
6927
+ if (fromNewHandle !== undefined) {
6928
+ setValueByPath(toObject, ['newHandle'], fromNewHandle);
6929
+ }
6930
+ const fromResumable = getValueByPath(fromObject, ['resumable']);
6931
+ if (fromResumable !== undefined) {
6932
+ setValueByPath(toObject, ['resumable'], fromResumable);
6933
+ }
6934
+ const fromLastConsumedClientMessageIndex = getValueByPath(fromObject, [
6935
+ 'lastConsumedClientMessageIndex',
6936
+ ]);
6937
+ if (fromLastConsumedClientMessageIndex !== undefined) {
6938
+ setValueByPath(toObject, ['lastConsumedClientMessageIndex'], fromLastConsumedClientMessageIndex);
6939
+ }
6940
+ return toObject;
6941
+ }
6942
+ function liveServerSessionResumptionUpdateFromVertex(fromObject) {
6943
+ const toObject = {};
6944
+ const fromNewHandle = getValueByPath(fromObject, ['newHandle']);
6945
+ if (fromNewHandle !== undefined) {
6946
+ setValueByPath(toObject, ['newHandle'], fromNewHandle);
6947
+ }
6948
+ const fromResumable = getValueByPath(fromObject, ['resumable']);
6949
+ if (fromResumable !== undefined) {
6950
+ setValueByPath(toObject, ['resumable'], fromResumable);
6951
+ }
6952
+ const fromLastConsumedClientMessageIndex = getValueByPath(fromObject, [
6953
+ 'lastConsumedClientMessageIndex',
6954
+ ]);
6955
+ if (fromLastConsumedClientMessageIndex !== undefined) {
6956
+ setValueByPath(toObject, ['lastConsumedClientMessageIndex'], fromLastConsumedClientMessageIndex);
6957
+ }
6958
+ return toObject;
6959
+ }
6960
+ function liveClientSessionResumptionConfigToMldev(fromObject) {
6961
+ const toObject = {};
6962
+ const fromHandle = getValueByPath(fromObject, ['handle']);
6963
+ if (fromHandle !== undefined) {
6964
+ setValueByPath(toObject, ['handle'], fromHandle);
6965
+ }
6966
+ if (getValueByPath(fromObject, ['transparent']) !== undefined) {
6967
+ throw new Error('transparent parameter is not supported in Gemini API.');
6968
+ }
6969
+ return toObject;
6970
+ }
6971
+ function liveClientSessionResumptionConfigToVertex(fromObject) {
6972
+ const toObject = {};
6973
+ const fromHandle = getValueByPath(fromObject, ['handle']);
6974
+ if (fromHandle !== undefined) {
6975
+ setValueByPath(toObject, ['handle'], fromHandle);
6976
+ }
6977
+ const fromTransparent = getValueByPath(fromObject, ['transparent']);
6978
+ if (fromTransparent !== undefined) {
6979
+ setValueByPath(toObject, ['transparent'], fromTransparent);
6980
+ }
6981
+ return toObject;
6982
+ }
6983
+ function modalityTokenCountFromMldev(apiClient, fromObject) {
6984
+ const toObject = {};
6985
+ const fromModality = getValueByPath(fromObject, ['modality']);
6986
+ if (fromModality != null) {
6987
+ setValueByPath(toObject, ['modality'], fromModality);
6988
+ }
6989
+ const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
6990
+ if (fromTokenCount != null) {
6991
+ setValueByPath(toObject, ['tokenCount'], fromTokenCount);
6992
+ }
6993
+ return toObject;
6994
+ }
6995
+ function usageMetadataFromMldev(apiClient, fromObject) {
6996
+ const toObject = {};
6997
+ const fromPromptTokenCount = getValueByPath(fromObject, [
6998
+ 'promptTokenCount',
6999
+ ]);
7000
+ if (fromPromptTokenCount != null) {
7001
+ setValueByPath(toObject, ['promptTokenCount'], fromPromptTokenCount);
7002
+ }
7003
+ const fromCachedContentTokenCount = getValueByPath(fromObject, [
7004
+ 'cachedContentTokenCount',
7005
+ ]);
7006
+ if (fromCachedContentTokenCount != null) {
7007
+ setValueByPath(toObject, ['cachedContentTokenCount'], fromCachedContentTokenCount);
7008
+ }
7009
+ const fromResponseTokenCount = getValueByPath(fromObject, [
7010
+ 'responseTokenCount',
7011
+ ]);
7012
+ if (fromResponseTokenCount != null) {
7013
+ setValueByPath(toObject, ['responseTokenCount'], fromResponseTokenCount);
7014
+ }
7015
+ const fromToolUsePromptTokenCount = getValueByPath(fromObject, [
7016
+ 'toolUsePromptTokenCount',
7017
+ ]);
7018
+ if (fromToolUsePromptTokenCount != null) {
7019
+ setValueByPath(toObject, ['toolUsePromptTokenCount'], fromToolUsePromptTokenCount);
7020
+ }
7021
+ const fromThoughtsTokenCount = getValueByPath(fromObject, [
7022
+ 'thoughtsTokenCount',
7023
+ ]);
7024
+ if (fromThoughtsTokenCount != null) {
7025
+ setValueByPath(toObject, ['thoughtsTokenCount'], fromThoughtsTokenCount);
7026
+ }
7027
+ const fromTotalTokenCount = getValueByPath(fromObject, [
7028
+ 'totalTokenCount',
7029
+ ]);
7030
+ if (fromTotalTokenCount != null) {
7031
+ setValueByPath(toObject, ['totalTokenCount'], fromTotalTokenCount);
7032
+ }
7033
+ const fromPromptTokensDetails = getValueByPath(fromObject, [
7034
+ 'promptTokensDetails',
7035
+ ]);
7036
+ if (fromPromptTokensDetails != null) {
7037
+ if (Array.isArray(fromPromptTokensDetails)) {
7038
+ setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails.map((item) => {
7039
+ return modalityTokenCountFromMldev(apiClient, item);
7040
+ }));
7041
+ }
7042
+ else {
7043
+ setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
7044
+ }
7045
+ }
7046
+ const fromCacheTokensDetails = getValueByPath(fromObject, [
7047
+ 'cacheTokensDetails',
7048
+ ]);
7049
+ if (fromCacheTokensDetails != null) {
7050
+ if (Array.isArray(fromCacheTokensDetails)) {
7051
+ setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails.map((item) => {
7052
+ return modalityTokenCountFromMldev(apiClient, item);
7053
+ }));
7054
+ }
7055
+ else {
7056
+ setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
7057
+ }
7058
+ }
7059
+ const fromResponseTokensDetails = getValueByPath(fromObject, [
7060
+ 'responseTokensDetails',
7061
+ ]);
7062
+ if (fromResponseTokensDetails != null) {
7063
+ if (Array.isArray(fromResponseTokensDetails)) {
7064
+ setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails.map((item) => {
7065
+ return modalityTokenCountFromMldev(apiClient, item);
7066
+ }));
7067
+ }
7068
+ else {
7069
+ setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
7070
+ }
7071
+ }
7072
+ const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
7073
+ 'toolUsePromptTokensDetails',
7074
+ ]);
7075
+ if (fromToolUsePromptTokensDetails != null) {
7076
+ if (Array.isArray(fromToolUsePromptTokensDetails)) {
7077
+ setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails.map((item) => {
7078
+ return modalityTokenCountFromMldev(apiClient, item);
7079
+ }));
7080
+ }
7081
+ else {
7082
+ setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
7083
+ }
7084
+ }
7085
+ return toObject;
7086
+ }
7087
+ function modalityTokenCountFromVertex(apiClient, fromObject) {
7088
+ const toObject = {};
7089
+ const fromModality = getValueByPath(fromObject, ['modality']);
7090
+ if (fromModality != null) {
7091
+ setValueByPath(toObject, ['modality'], fromModality);
7092
+ }
7093
+ const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
7094
+ if (fromTokenCount != null) {
7095
+ setValueByPath(toObject, ['tokenCount'], fromTokenCount);
7096
+ }
7097
+ return toObject;
7098
+ }
7099
+ function usageMetadataFromVertex(apiClient, fromObject) {
7100
+ const toObject = {};
7101
+ const fromPromptTokenCount = getValueByPath(fromObject, [
7102
+ 'promptTokenCount',
7103
+ ]);
7104
+ if (fromPromptTokenCount != null) {
7105
+ setValueByPath(toObject, ['promptTokenCount'], fromPromptTokenCount);
7106
+ }
7107
+ const fromCachedContentTokenCount = getValueByPath(fromObject, [
7108
+ 'cachedContentTokenCount',
7109
+ ]);
7110
+ if (fromCachedContentTokenCount != null) {
7111
+ setValueByPath(toObject, ['cachedContentTokenCount'], fromCachedContentTokenCount);
7112
+ }
7113
+ const fromResponseTokenCount = getValueByPath(fromObject, [
7114
+ 'candidatesTokenCount',
7115
+ ]);
7116
+ if (fromResponseTokenCount != null) {
7117
+ setValueByPath(toObject, ['responseTokenCount'], fromResponseTokenCount);
7118
+ }
7119
+ const fromToolUsePromptTokenCount = getValueByPath(fromObject, [
7120
+ 'toolUsePromptTokenCount',
7121
+ ]);
7122
+ if (fromToolUsePromptTokenCount != null) {
7123
+ setValueByPath(toObject, ['toolUsePromptTokenCount'], fromToolUsePromptTokenCount);
7124
+ }
7125
+ const fromThoughtsTokenCount = getValueByPath(fromObject, [
7126
+ 'thoughtsTokenCount',
7127
+ ]);
7128
+ if (fromThoughtsTokenCount != null) {
7129
+ setValueByPath(toObject, ['thoughtsTokenCount'], fromThoughtsTokenCount);
7130
+ }
7131
+ const fromTotalTokenCount = getValueByPath(fromObject, [
7132
+ 'totalTokenCount',
7133
+ ]);
7134
+ if (fromTotalTokenCount != null) {
7135
+ setValueByPath(toObject, ['totalTokenCount'], fromTotalTokenCount);
7136
+ }
7137
+ const fromPromptTokensDetails = getValueByPath(fromObject, [
7138
+ 'promptTokensDetails',
7139
+ ]);
7140
+ if (fromPromptTokensDetails != null) {
7141
+ if (Array.isArray(fromPromptTokensDetails)) {
7142
+ setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails.map((item) => {
7143
+ return modalityTokenCountFromVertex(apiClient, item);
7144
+ }));
7145
+ }
7146
+ else {
7147
+ setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
7148
+ }
7149
+ }
7150
+ const fromCacheTokensDetails = getValueByPath(fromObject, [
7151
+ 'cacheTokensDetails',
7152
+ ]);
7153
+ if (fromCacheTokensDetails != null) {
7154
+ if (Array.isArray(fromCacheTokensDetails)) {
7155
+ setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails.map((item) => {
7156
+ return modalityTokenCountFromVertex(apiClient, item);
7157
+ }));
7158
+ }
7159
+ else {
7160
+ setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
7161
+ }
7162
+ }
7163
+ const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
7164
+ 'toolUsePromptTokensDetails',
7165
+ ]);
7166
+ if (fromToolUsePromptTokensDetails != null) {
7167
+ if (Array.isArray(fromToolUsePromptTokensDetails)) {
7168
+ setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails.map((item) => {
7169
+ return modalityTokenCountFromVertex(apiClient, item);
7170
+ }));
7171
+ }
7172
+ else {
7173
+ setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
7174
+ }
7175
+ }
7176
+ const fromResponseTokensDetails = getValueByPath(fromObject, [
7177
+ 'candidatesTokensDetails',
7178
+ ]);
7179
+ if (fromResponseTokensDetails != null) {
7180
+ if (Array.isArray(fromResponseTokensDetails)) {
7181
+ setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails.map((item) => {
7182
+ return modalityTokenCountFromVertex(apiClient, item);
7183
+ }));
7184
+ }
7185
+ else {
7186
+ setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
7187
+ }
7188
+ }
7189
+ const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
7190
+ if (fromTrafficType != null) {
7191
+ setValueByPath(toObject, ['trafficType'], fromTrafficType);
7192
+ }
7193
+ return toObject;
7194
+ }
7195
+
7196
+ /**
7197
+ * @license
7198
+ * Copyright 2025 Google LLC
7199
+ * SPDX-License-Identifier: Apache-2.0
7200
+ */
7201
+ const FUNCTION_RESPONSE_REQUIRES_ID = 'FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.';
7202
+ /**
7203
+ * Handles incoming messages from the WebSocket.
7204
+ *
7205
+ * @remarks
7206
+ * This function is responsible for parsing incoming messages, transforming them
7207
+ * into LiveServerMessages, and then calling the onmessage callback. Note that
7208
+ * the first message which is received from the server is a setupComplete
7209
+ * message.
7210
+ *
7211
+ * @param apiClient The ApiClient instance.
7212
+ * @param onmessage The user-provided onmessage callback (if any).
7213
+ * @param event The MessageEvent from the WebSocket.
7214
+ */
7215
+ async function handleWebSocketMessage(apiClient, onmessage, event) {
7216
+ let serverMessage;
6068
7217
  let data;
6069
7218
  if (event.data instanceof Blob) {
6070
7219
  data = JSON.parse(await event.data.text());
@@ -6235,7 +7384,13 @@ class Session {
6235
7384
  throw new Error(`Failed to convert realtime input "media", type: '${typeof params.media}'`);
6236
7385
  }
6237
7386
  // LiveClientRealtimeInput
6238
- clientMessage = { realtimeInput: { mediaChunks: [params.media] } };
7387
+ clientMessage = {
7388
+ realtimeInput: {
7389
+ mediaChunks: [params.media],
7390
+ activityStart: params.activityStart,
7391
+ activityEnd: params.activityEnd,
7392
+ },
7393
+ };
6239
7394
  return clientMessage;
6240
7395
  }
6241
7396
  tLiveClienttToolResponse(apiClient, params) {
@@ -6246,6 +7401,9 @@ class Session {
6246
7401
  if (!Array.isArray(params.functionResponses)) {
6247
7402
  functionResponses = [params.functionResponses];
6248
7403
  }
7404
+ else {
7405
+ functionResponses = params.functionResponses;
7406
+ }
6249
7407
  if (functionResponses.length === 0) {
6250
7408
  throw new Error('functionResponses is required.');
6251
7409
  }
@@ -6851,6 +8009,66 @@ class Models extends BaseModule {
6851
8009
  });
6852
8010
  }
6853
8011
  }
8012
+ /**
8013
+ * Fetches information about a model by name.
8014
+ *
8015
+ * @example
8016
+ * ```ts
8017
+ * const modelInfo = await ai.models.get({model: 'gemini-2.0-flash'});
8018
+ * ```
8019
+ */
8020
+ async get(params) {
8021
+ var _a, _b;
8022
+ let response;
8023
+ let path = '';
8024
+ let queryParams = {};
8025
+ if (this.apiClient.isVertexAI()) {
8026
+ const body = getModelParametersToVertex(this.apiClient, params);
8027
+ path = formatMap('{name}', body['_url']);
8028
+ queryParams = body['_query'];
8029
+ delete body['config'];
8030
+ delete body['_url'];
8031
+ delete body['_query'];
8032
+ response = this.apiClient
8033
+ .request({
8034
+ path: path,
8035
+ queryParams: queryParams,
8036
+ body: JSON.stringify(body),
8037
+ httpMethod: 'GET',
8038
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
8039
+ })
8040
+ .then((httpResponse) => {
8041
+ return httpResponse.json();
8042
+ });
8043
+ return response.then((apiResponse) => {
8044
+ const resp = modelFromVertex(this.apiClient, apiResponse);
8045
+ return resp;
8046
+ });
8047
+ }
8048
+ else {
8049
+ const body = getModelParametersToMldev(this.apiClient, params);
8050
+ path = formatMap('{name}', body['_url']);
8051
+ queryParams = body['_query'];
8052
+ delete body['config'];
8053
+ delete body['_url'];
8054
+ delete body['_query'];
8055
+ response = this.apiClient
8056
+ .request({
8057
+ path: path,
8058
+ queryParams: queryParams,
8059
+ body: JSON.stringify(body),
8060
+ httpMethod: 'GET',
8061
+ httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
8062
+ })
8063
+ .then((httpResponse) => {
8064
+ return httpResponse.json();
8065
+ });
8066
+ return response.then((apiResponse) => {
8067
+ const resp = modelFromMldev(this.apiClient, apiResponse);
8068
+ return resp;
8069
+ });
8070
+ }
8071
+ }
6854
8072
  /**
6855
8073
  * Counts the number of tokens in the given contents. Multimodal input is
6856
8074
  * supported for Gemini models.
@@ -6975,6 +8193,431 @@ class Models extends BaseModule {
6975
8193
  throw new Error('This method is only supported by the Vertex AI.');
6976
8194
  }
6977
8195
  }
8196
+ /**
8197
+ * Generates videos based on a text description and configuration.
8198
+ *
8199
+ * @param params - The parameters for generating videos.
8200
+ * @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
8201
+ *
8202
+ * @example
8203
+ * ```ts
8204
+ * const operation = await ai.models.generateVideos({
8205
+ * model: 'veo-2.0-generate-001',
8206
+ * prompt: 'A neon hologram of a cat driving at top speed',
8207
+ * config: {
8208
+ * numberOfVideos: 1
8209
+ * });
8210
+ *
8211
+ * while (!operation.done) {
8212
+ * await new Promise(resolve => setTimeout(resolve, 10000));
8213
+ * operation = await ai.operations.getVideosOperation({operation: operation});
8214
+ * }
8215
+ *
8216
+ * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
8217
+ * ```
8218
+ */
8219
+ async generateVideos(params) {
8220
+ var _a, _b;
8221
+ let response;
8222
+ let path = '';
8223
+ let queryParams = {};
8224
+ if (this.apiClient.isVertexAI()) {
8225
+ const body = generateVideosParametersToVertex(this.apiClient, params);
8226
+ path = formatMap('{model}:predictLongRunning', body['_url']);
8227
+ queryParams = body['_query'];
8228
+ delete body['config'];
8229
+ delete body['_url'];
8230
+ delete body['_query'];
8231
+ response = this.apiClient
8232
+ .request({
8233
+ path: path,
8234
+ queryParams: queryParams,
8235
+ body: JSON.stringify(body),
8236
+ httpMethod: 'POST',
8237
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
8238
+ })
8239
+ .then((httpResponse) => {
8240
+ return httpResponse.json();
8241
+ });
8242
+ return response.then((apiResponse) => {
8243
+ const resp = generateVideosOperationFromVertex$1(this.apiClient, apiResponse);
8244
+ return resp;
8245
+ });
8246
+ }
8247
+ else {
8248
+ const body = generateVideosParametersToMldev(this.apiClient, params);
8249
+ path = formatMap('{model}:predictLongRunning', body['_url']);
8250
+ queryParams = body['_query'];
8251
+ delete body['config'];
8252
+ delete body['_url'];
8253
+ delete body['_query'];
8254
+ response = this.apiClient
8255
+ .request({
8256
+ path: path,
8257
+ queryParams: queryParams,
8258
+ body: JSON.stringify(body),
8259
+ httpMethod: 'POST',
8260
+ httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
8261
+ })
8262
+ .then((httpResponse) => {
8263
+ return httpResponse.json();
8264
+ });
8265
+ return response.then((apiResponse) => {
8266
+ const resp = generateVideosOperationFromMldev$1(this.apiClient, apiResponse);
8267
+ return resp;
8268
+ });
8269
+ }
8270
+ }
8271
+ }
8272
+
8273
+ /**
8274
+ * @license
8275
+ * Copyright 2025 Google LLC
8276
+ * SPDX-License-Identifier: Apache-2.0
8277
+ */
8278
+ function getOperationParametersToMldev(apiClient, fromObject) {
8279
+ const toObject = {};
8280
+ const fromOperationName = getValueByPath(fromObject, [
8281
+ 'operationName',
8282
+ ]);
8283
+ if (fromOperationName != null) {
8284
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
8285
+ }
8286
+ const fromConfig = getValueByPath(fromObject, ['config']);
8287
+ if (fromConfig != null) {
8288
+ setValueByPath(toObject, ['config'], fromConfig);
8289
+ }
8290
+ return toObject;
8291
+ }
8292
+ function getOperationParametersToVertex(apiClient, fromObject) {
8293
+ const toObject = {};
8294
+ const fromOperationName = getValueByPath(fromObject, [
8295
+ 'operationName',
8296
+ ]);
8297
+ if (fromOperationName != null) {
8298
+ setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
8299
+ }
8300
+ const fromConfig = getValueByPath(fromObject, ['config']);
8301
+ if (fromConfig != null) {
8302
+ setValueByPath(toObject, ['config'], fromConfig);
8303
+ }
8304
+ return toObject;
8305
+ }
8306
+ function fetchPredictOperationParametersToVertex(apiClient, fromObject) {
8307
+ const toObject = {};
8308
+ const fromOperationName = getValueByPath(fromObject, [
8309
+ 'operationName',
8310
+ ]);
8311
+ if (fromOperationName != null) {
8312
+ setValueByPath(toObject, ['operationName'], fromOperationName);
8313
+ }
8314
+ const fromResourceName = getValueByPath(fromObject, ['resourceName']);
8315
+ if (fromResourceName != null) {
8316
+ setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
8317
+ }
8318
+ const fromConfig = getValueByPath(fromObject, ['config']);
8319
+ if (fromConfig != null) {
8320
+ setValueByPath(toObject, ['config'], fromConfig);
8321
+ }
8322
+ return toObject;
8323
+ }
8324
+ function videoFromMldev(apiClient, fromObject) {
8325
+ const toObject = {};
8326
+ const fromUri = getValueByPath(fromObject, ['video', 'uri']);
8327
+ if (fromUri != null) {
8328
+ setValueByPath(toObject, ['uri'], fromUri);
8329
+ }
8330
+ const fromVideoBytes = getValueByPath(fromObject, [
8331
+ 'video',
8332
+ 'encodedVideo',
8333
+ ]);
8334
+ if (fromVideoBytes != null) {
8335
+ setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
8336
+ }
8337
+ const fromMimeType = getValueByPath(fromObject, ['encoding']);
8338
+ if (fromMimeType != null) {
8339
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
8340
+ }
8341
+ return toObject;
8342
+ }
8343
+ function generatedVideoFromMldev(apiClient, fromObject) {
8344
+ const toObject = {};
8345
+ const fromVideo = getValueByPath(fromObject, ['_self']);
8346
+ if (fromVideo != null) {
8347
+ setValueByPath(toObject, ['video'], videoFromMldev(apiClient, fromVideo));
8348
+ }
8349
+ return toObject;
8350
+ }
8351
+ function generateVideosResponseFromMldev(apiClient, fromObject) {
8352
+ const toObject = {};
8353
+ const fromGeneratedVideos = getValueByPath(fromObject, [
8354
+ 'generatedSamples',
8355
+ ]);
8356
+ if (fromGeneratedVideos != null) {
8357
+ if (Array.isArray(fromGeneratedVideos)) {
8358
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
8359
+ return generatedVideoFromMldev(apiClient, item);
8360
+ }));
8361
+ }
8362
+ else {
8363
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
8364
+ }
8365
+ }
8366
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
8367
+ 'raiMediaFilteredCount',
8368
+ ]);
8369
+ if (fromRaiMediaFilteredCount != null) {
8370
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
8371
+ }
8372
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
8373
+ 'raiMediaFilteredReasons',
8374
+ ]);
8375
+ if (fromRaiMediaFilteredReasons != null) {
8376
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
8377
+ }
8378
+ return toObject;
8379
+ }
8380
+ function generateVideosOperationFromMldev(apiClient, fromObject) {
8381
+ const toObject = {};
8382
+ const fromName = getValueByPath(fromObject, ['name']);
8383
+ if (fromName != null) {
8384
+ setValueByPath(toObject, ['name'], fromName);
8385
+ }
8386
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
8387
+ if (fromMetadata != null) {
8388
+ setValueByPath(toObject, ['metadata'], fromMetadata);
8389
+ }
8390
+ const fromDone = getValueByPath(fromObject, ['done']);
8391
+ if (fromDone != null) {
8392
+ setValueByPath(toObject, ['done'], fromDone);
8393
+ }
8394
+ const fromError = getValueByPath(fromObject, ['error']);
8395
+ if (fromError != null) {
8396
+ setValueByPath(toObject, ['error'], fromError);
8397
+ }
8398
+ const fromResponse = getValueByPath(fromObject, [
8399
+ 'response',
8400
+ 'generateVideoResponse',
8401
+ ]);
8402
+ if (fromResponse != null) {
8403
+ setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(apiClient, fromResponse));
8404
+ }
8405
+ const fromResult = getValueByPath(fromObject, [
8406
+ 'response',
8407
+ 'generateVideoResponse',
8408
+ ]);
8409
+ if (fromResult != null) {
8410
+ setValueByPath(toObject, ['result'], generateVideosResponseFromMldev(apiClient, fromResult));
8411
+ }
8412
+ return toObject;
8413
+ }
8414
+ function videoFromVertex(apiClient, fromObject) {
8415
+ const toObject = {};
8416
+ const fromUri = getValueByPath(fromObject, ['gcsUri']);
8417
+ if (fromUri != null) {
8418
+ setValueByPath(toObject, ['uri'], fromUri);
8419
+ }
8420
+ const fromVideoBytes = getValueByPath(fromObject, [
8421
+ 'bytesBase64Encoded',
8422
+ ]);
8423
+ if (fromVideoBytes != null) {
8424
+ setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
8425
+ }
8426
+ const fromMimeType = getValueByPath(fromObject, ['mimeType']);
8427
+ if (fromMimeType != null) {
8428
+ setValueByPath(toObject, ['mimeType'], fromMimeType);
8429
+ }
8430
+ return toObject;
8431
+ }
8432
+ function generatedVideoFromVertex(apiClient, fromObject) {
8433
+ const toObject = {};
8434
+ const fromVideo = getValueByPath(fromObject, ['_self']);
8435
+ if (fromVideo != null) {
8436
+ setValueByPath(toObject, ['video'], videoFromVertex(apiClient, fromVideo));
8437
+ }
8438
+ return toObject;
8439
+ }
8440
+ function generateVideosResponseFromVertex(apiClient, fromObject) {
8441
+ const toObject = {};
8442
+ const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
8443
+ if (fromGeneratedVideos != null) {
8444
+ if (Array.isArray(fromGeneratedVideos)) {
8445
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
8446
+ return generatedVideoFromVertex(apiClient, item);
8447
+ }));
8448
+ }
8449
+ else {
8450
+ setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
8451
+ }
8452
+ }
8453
+ const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
8454
+ 'raiMediaFilteredCount',
8455
+ ]);
8456
+ if (fromRaiMediaFilteredCount != null) {
8457
+ setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
8458
+ }
8459
+ const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
8460
+ 'raiMediaFilteredReasons',
8461
+ ]);
8462
+ if (fromRaiMediaFilteredReasons != null) {
8463
+ setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
8464
+ }
8465
+ return toObject;
8466
+ }
8467
+ function generateVideosOperationFromVertex(apiClient, fromObject) {
8468
+ const toObject = {};
8469
+ const fromName = getValueByPath(fromObject, ['name']);
8470
+ if (fromName != null) {
8471
+ setValueByPath(toObject, ['name'], fromName);
8472
+ }
8473
+ const fromMetadata = getValueByPath(fromObject, ['metadata']);
8474
+ if (fromMetadata != null) {
8475
+ setValueByPath(toObject, ['metadata'], fromMetadata);
8476
+ }
8477
+ const fromDone = getValueByPath(fromObject, ['done']);
8478
+ if (fromDone != null) {
8479
+ setValueByPath(toObject, ['done'], fromDone);
8480
+ }
8481
+ const fromError = getValueByPath(fromObject, ['error']);
8482
+ if (fromError != null) {
8483
+ setValueByPath(toObject, ['error'], fromError);
8484
+ }
8485
+ const fromResponse = getValueByPath(fromObject, ['response']);
8486
+ if (fromResponse != null) {
8487
+ setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(apiClient, fromResponse));
8488
+ }
8489
+ const fromResult = getValueByPath(fromObject, ['response']);
8490
+ if (fromResult != null) {
8491
+ setValueByPath(toObject, ['result'], generateVideosResponseFromVertex(apiClient, fromResult));
8492
+ }
8493
+ return toObject;
8494
+ }
8495
+
8496
+ /**
8497
+ * @license
8498
+ * Copyright 2025 Google LLC
8499
+ * SPDX-License-Identifier: Apache-2.0
8500
+ */
8501
+ class Operations extends BaseModule {
8502
+ constructor(apiClient) {
8503
+ super();
8504
+ this.apiClient = apiClient;
8505
+ }
8506
+ /**
8507
+ * Gets the status of a long-running operation.
8508
+ *
8509
+ * @param parameters The parameters for the get operation request.
8510
+ * @return The updated Operation object, with the latest status or result.
8511
+ */
8512
+ async getVideosOperation(parameters) {
8513
+ const operation = parameters.operation;
8514
+ const config = parameters.config;
8515
+ if (operation.name === undefined || operation.name === '') {
8516
+ throw new Error('Operation name is required.');
8517
+ }
8518
+ if (this.apiClient.isVertexAI()) {
8519
+ const resourceName = operation.name.split('/operations/')[0];
8520
+ var httpOptions = undefined;
8521
+ if (config && 'httpOptions' in config) {
8522
+ httpOptions = config.httpOptions;
8523
+ }
8524
+ return this.fetchPredictVideosOperationInternal({
8525
+ operationName: operation.name,
8526
+ resourceName: resourceName,
8527
+ config: { httpOptions: httpOptions },
8528
+ });
8529
+ }
8530
+ else {
8531
+ return this.getVideosOperationInternal({
8532
+ operationName: operation.name,
8533
+ config: config,
8534
+ });
8535
+ }
8536
+ }
8537
+ async getVideosOperationInternal(params) {
8538
+ var _a, _b;
8539
+ let response;
8540
+ let path = '';
8541
+ let queryParams = {};
8542
+ if (this.apiClient.isVertexAI()) {
8543
+ const body = getOperationParametersToVertex(this.apiClient, params);
8544
+ path = formatMap('{operationName}', body['_url']);
8545
+ queryParams = body['_query'];
8546
+ delete body['config'];
8547
+ delete body['_url'];
8548
+ delete body['_query'];
8549
+ response = this.apiClient
8550
+ .request({
8551
+ path: path,
8552
+ queryParams: queryParams,
8553
+ body: JSON.stringify(body),
8554
+ httpMethod: 'GET',
8555
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
8556
+ })
8557
+ .then((httpResponse) => {
8558
+ return httpResponse.json();
8559
+ });
8560
+ return response.then((apiResponse) => {
8561
+ const resp = generateVideosOperationFromVertex(this.apiClient, apiResponse);
8562
+ return resp;
8563
+ });
8564
+ }
8565
+ else {
8566
+ const body = getOperationParametersToMldev(this.apiClient, params);
8567
+ path = formatMap('{operationName}', body['_url']);
8568
+ queryParams = body['_query'];
8569
+ delete body['config'];
8570
+ delete body['_url'];
8571
+ delete body['_query'];
8572
+ response = this.apiClient
8573
+ .request({
8574
+ path: path,
8575
+ queryParams: queryParams,
8576
+ body: JSON.stringify(body),
8577
+ httpMethod: 'GET',
8578
+ httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
8579
+ })
8580
+ .then((httpResponse) => {
8581
+ return httpResponse.json();
8582
+ });
8583
+ return response.then((apiResponse) => {
8584
+ const resp = generateVideosOperationFromMldev(this.apiClient, apiResponse);
8585
+ return resp;
8586
+ });
8587
+ }
8588
+ }
8589
+ async fetchPredictVideosOperationInternal(params) {
8590
+ var _a;
8591
+ let response;
8592
+ let path = '';
8593
+ let queryParams = {};
8594
+ if (this.apiClient.isVertexAI()) {
8595
+ const body = fetchPredictOperationParametersToVertex(this.apiClient, params);
8596
+ path = formatMap('{resourceName}:fetchPredictOperation', body['_url']);
8597
+ queryParams = body['_query'];
8598
+ delete body['config'];
8599
+ delete body['_url'];
8600
+ delete body['_query'];
8601
+ response = this.apiClient
8602
+ .request({
8603
+ path: path,
8604
+ queryParams: queryParams,
8605
+ body: JSON.stringify(body),
8606
+ httpMethod: 'POST',
8607
+ httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
8608
+ })
8609
+ .then((httpResponse) => {
8610
+ return httpResponse.json();
8611
+ });
8612
+ return response.then((apiResponse) => {
8613
+ const resp = generateVideosOperationFromVertex(this.apiClient, apiResponse);
8614
+ return resp;
8615
+ });
8616
+ }
8617
+ else {
8618
+ throw new Error('This method is only supported by the Vertex AI.');
8619
+ }
8620
+ }
6978
8621
  }
6979
8622
 
6980
8623
  /**
@@ -7057,6 +8700,7 @@ class GoogleGenAI {
7057
8700
  this.chats = new Chats(this.models, this.apiClient);
7058
8701
  this.caches = new Caches(this.apiClient);
7059
8702
  this.files = new Files(this.apiClient);
8703
+ this.operations = new Operations(this.apiClient);
7060
8704
  }
7061
8705
  }
7062
8706
 
@@ -7069,11 +8713,13 @@ exports.CreateFileResponse = CreateFileResponse;
7069
8713
  exports.DeleteCachedContentResponse = DeleteCachedContentResponse;
7070
8714
  exports.DeleteFileResponse = DeleteFileResponse;
7071
8715
  exports.EmbedContentResponse = EmbedContentResponse;
8716
+ exports.Files = Files;
7072
8717
  exports.FunctionResponse = FunctionResponse;
7073
8718
  exports.GenerateContentResponse = GenerateContentResponse;
7074
8719
  exports.GenerateContentResponsePromptFeedback = GenerateContentResponsePromptFeedback;
7075
8720
  exports.GenerateContentResponseUsageMetadata = GenerateContentResponseUsageMetadata;
7076
8721
  exports.GenerateImagesResponse = GenerateImagesResponse;
8722
+ exports.GenerateVideosResponse = GenerateVideosResponse;
7077
8723
  exports.GoogleGenAI = GoogleGenAI;
7078
8724
  exports.HttpResponse = HttpResponse;
7079
8725
  exports.ListCachedContentsResponse = ListCachedContentsResponse;
@@ -7082,6 +8728,8 @@ exports.Live = Live;
7082
8728
  exports.LiveClientToolResponse = LiveClientToolResponse;
7083
8729
  exports.LiveSendToolResponseParameters = LiveSendToolResponseParameters;
7084
8730
  exports.Models = Models;
8731
+ exports.Operations = Operations;
8732
+ exports.Pager = Pager;
7085
8733
  exports.ReplayResponse = ReplayResponse;
7086
8734
  exports.Session = Session;
7087
8735
  exports.createModelContent = createModelContent;