@google/genai 1.44.0 → 1.45.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.
@@ -7439,6 +7439,13 @@ class Files extends BaseModule {
7439
7439
  * Copyright 2025 Google LLC
7440
7440
  * SPDX-License-Identifier: Apache-2.0
7441
7441
  */
7442
+ function audioTranscriptionConfigToMldev$1(fromObject) {
7443
+ const toObject = {};
7444
+ if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
7445
+ throw new Error('languageCodes parameter is not supported in Gemini API.');
7446
+ }
7447
+ return toObject;
7448
+ }
7442
7449
  function authConfigToMldev$2(fromObject) {
7443
7450
  const toObject = {};
7444
7451
  const fromApiKey = getValueByPath(fromObject, ['apiKey']);
@@ -7815,13 +7822,13 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
7815
7822
  'inputAudioTranscription',
7816
7823
  ]);
7817
7824
  if (parentObject !== undefined && fromInputAudioTranscription != null) {
7818
- setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
7825
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromInputAudioTranscription));
7819
7826
  }
7820
7827
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
7821
7828
  'outputAudioTranscription',
7822
7829
  ]);
7823
7830
  if (parentObject !== undefined && fromOutputAudioTranscription != null) {
7824
- setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
7831
+ setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromOutputAudioTranscription));
7825
7832
  }
7826
7833
  const fromRealtimeInputConfig = getValueByPath(fromObject, [
7827
7834
  'realtimeInputConfig',
@@ -12122,7 +12129,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
12122
12129
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
12123
12130
  const USER_AGENT_HEADER = 'User-Agent';
12124
12131
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
12125
- const SDK_VERSION = '1.44.0'; // x-release-please-version
12132
+ const SDK_VERSION = '1.45.0'; // x-release-please-version
12126
12133
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
12127
12134
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
12128
12135
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -15454,6 +15461,13 @@ class Operations extends BaseModule {
15454
15461
  * Copyright 2025 Google LLC
15455
15462
  * SPDX-License-Identifier: Apache-2.0
15456
15463
  */
15464
+ function audioTranscriptionConfigToMldev(fromObject) {
15465
+ const toObject = {};
15466
+ if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
15467
+ throw new Error('languageCodes parameter is not supported in Gemini API.');
15468
+ }
15469
+ return toObject;
15470
+ }
15457
15471
  function authConfigToMldev(fromObject) {
15458
15472
  const toObject = {};
15459
15473
  const fromApiKey = getValueByPath(fromObject, ['apiKey']);
@@ -15705,13 +15719,13 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
15705
15719
  'inputAudioTranscription',
15706
15720
  ]);
15707
15721
  if (parentObject !== undefined && fromInputAudioTranscription != null) {
15708
- setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
15722
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev(fromInputAudioTranscription));
15709
15723
  }
15710
15724
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
15711
15725
  'outputAudioTranscription',
15712
15726
  ]);
15713
15727
  if (parentObject !== undefined && fromOutputAudioTranscription != null) {
15714
- setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
15728
+ setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev(fromOutputAudioTranscription));
15715
15729
  }
15716
15730
  const fromRealtimeInputConfig = getValueByPath(fromObject, [
15717
15731
  'realtimeInputConfig',
@@ -16973,6 +16987,30 @@ const FallbackEncoder = ({ headers, body }) => {
16973
16987
  };
16974
16988
  };
16975
16989
 
16990
+ /**
16991
+ * @license
16992
+ * Copyright 2025 Google LLC
16993
+ * SPDX-License-Identifier: Apache-2.0
16994
+ */
16995
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
16996
+ /**
16997
+ * Basic re-implementation of `qs.stringify` for primitive types.
16998
+ */
16999
+ function stringifyQuery(query) {
17000
+ return Object.entries(query)
17001
+ .filter(([_, value]) => typeof value !== 'undefined')
17002
+ .map(([key, value]) => {
17003
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
17004
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
17005
+ }
17006
+ if (value === null) {
17007
+ return `${encodeURIComponent(key)}=`;
17008
+ }
17009
+ throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
17010
+ })
17011
+ .join('&');
17012
+ }
17013
+
16976
17014
  /**
16977
17015
  * @license
16978
17016
  * Copyright 2025 Google LLC
@@ -18116,18 +18154,7 @@ class BaseGeminiNextGenAPIClient {
18116
18154
  * Basic re-implementation of `qs.stringify` for primitive types.
18117
18155
  */
18118
18156
  stringifyQuery(query) {
18119
- return Object.entries(query)
18120
- .filter(([_, value]) => typeof value !== 'undefined')
18121
- .map(([key, value]) => {
18122
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
18123
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
18124
- }
18125
- if (value === null) {
18126
- return `${encodeURIComponent(key)}=`;
18127
- }
18128
- throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
18129
- })
18130
- .join('&');
18157
+ return stringifyQuery(query);
18131
18158
  }
18132
18159
  getUserAgent() {
18133
18160
  return `${this.constructor.name}/JS ${VERSION}`;
@@ -18144,8 +18171,9 @@ class BaseGeminiNextGenAPIClient {
18144
18171
  new URL(path)
18145
18172
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
18146
18173
  const defaultQuery = this.defaultQuery();
18147
- if (!isEmptyObj(defaultQuery)) {
18148
- query = Object.assign(Object.assign({}, defaultQuery), query);
18174
+ const pathQuery = Object.fromEntries(url.searchParams);
18175
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
18176
+ query = Object.assign(Object.assign(Object.assign({}, pathQuery), defaultQuery), query);
18149
18177
  }
18150
18178
  if (typeof query === 'object' && query && !Array.isArray(query)) {
18151
18179
  url.search = this.stringifyQuery(query);
@@ -18366,9 +18394,9 @@ class BaseGeminiNextGenAPIClient {
18366
18394
  timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
18367
18395
  }
18368
18396
  }
18369
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
18370
- // just do what it says, but otherwise calculate a default
18371
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
18397
+ // If the API asks us to wait a certain amount of time, just do what it
18398
+ // says, but otherwise calculate a default
18399
+ if (timeoutMillis === undefined) {
18372
18400
  const maxRetries = (_b = options.maxRetries) !== null && _b !== void 0 ? _b : this.maxRetries;
18373
18401
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
18374
18402
  }
@@ -7417,6 +7417,13 @@ class Files extends BaseModule {
7417
7417
  * Copyright 2025 Google LLC
7418
7418
  * SPDX-License-Identifier: Apache-2.0
7419
7419
  */
7420
+ function audioTranscriptionConfigToMldev$1(fromObject) {
7421
+ const toObject = {};
7422
+ if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
7423
+ throw new Error('languageCodes parameter is not supported in Gemini API.');
7424
+ }
7425
+ return toObject;
7426
+ }
7420
7427
  function authConfigToMldev$2(fromObject) {
7421
7428
  const toObject = {};
7422
7429
  const fromApiKey = getValueByPath(fromObject, ['apiKey']);
@@ -7793,13 +7800,13 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
7793
7800
  'inputAudioTranscription',
7794
7801
  ]);
7795
7802
  if (parentObject !== undefined && fromInputAudioTranscription != null) {
7796
- setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
7803
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromInputAudioTranscription));
7797
7804
  }
7798
7805
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
7799
7806
  'outputAudioTranscription',
7800
7807
  ]);
7801
7808
  if (parentObject !== undefined && fromOutputAudioTranscription != null) {
7802
- setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
7809
+ setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromOutputAudioTranscription));
7803
7810
  }
7804
7811
  const fromRealtimeInputConfig = getValueByPath(fromObject, [
7805
7812
  'realtimeInputConfig',
@@ -12100,7 +12107,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
12100
12107
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
12101
12108
  const USER_AGENT_HEADER = 'User-Agent';
12102
12109
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
12103
- const SDK_VERSION = '1.44.0'; // x-release-please-version
12110
+ const SDK_VERSION = '1.45.0'; // x-release-please-version
12104
12111
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
12105
12112
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
12106
12113
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -15432,6 +15439,13 @@ class Operations extends BaseModule {
15432
15439
  * Copyright 2025 Google LLC
15433
15440
  * SPDX-License-Identifier: Apache-2.0
15434
15441
  */
15442
+ function audioTranscriptionConfigToMldev(fromObject) {
15443
+ const toObject = {};
15444
+ if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
15445
+ throw new Error('languageCodes parameter is not supported in Gemini API.');
15446
+ }
15447
+ return toObject;
15448
+ }
15435
15449
  function authConfigToMldev(fromObject) {
15436
15450
  const toObject = {};
15437
15451
  const fromApiKey = getValueByPath(fromObject, ['apiKey']);
@@ -15683,13 +15697,13 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
15683
15697
  'inputAudioTranscription',
15684
15698
  ]);
15685
15699
  if (parentObject !== undefined && fromInputAudioTranscription != null) {
15686
- setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
15700
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev(fromInputAudioTranscription));
15687
15701
  }
15688
15702
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
15689
15703
  'outputAudioTranscription',
15690
15704
  ]);
15691
15705
  if (parentObject !== undefined && fromOutputAudioTranscription != null) {
15692
- setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
15706
+ setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev(fromOutputAudioTranscription));
15693
15707
  }
15694
15708
  const fromRealtimeInputConfig = getValueByPath(fromObject, [
15695
15709
  'realtimeInputConfig',
@@ -16951,6 +16965,30 @@ const FallbackEncoder = ({ headers, body }) => {
16951
16965
  };
16952
16966
  };
16953
16967
 
16968
+ /**
16969
+ * @license
16970
+ * Copyright 2025 Google LLC
16971
+ * SPDX-License-Identifier: Apache-2.0
16972
+ */
16973
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
16974
+ /**
16975
+ * Basic re-implementation of `qs.stringify` for primitive types.
16976
+ */
16977
+ function stringifyQuery(query) {
16978
+ return Object.entries(query)
16979
+ .filter(([_, value]) => typeof value !== 'undefined')
16980
+ .map(([key, value]) => {
16981
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
16982
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
16983
+ }
16984
+ if (value === null) {
16985
+ return `${encodeURIComponent(key)}=`;
16986
+ }
16987
+ throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
16988
+ })
16989
+ .join('&');
16990
+ }
16991
+
16954
16992
  /**
16955
16993
  * @license
16956
16994
  * Copyright 2025 Google LLC
@@ -18094,18 +18132,7 @@ class BaseGeminiNextGenAPIClient {
18094
18132
  * Basic re-implementation of `qs.stringify` for primitive types.
18095
18133
  */
18096
18134
  stringifyQuery(query) {
18097
- return Object.entries(query)
18098
- .filter(([_, value]) => typeof value !== 'undefined')
18099
- .map(([key, value]) => {
18100
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
18101
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
18102
- }
18103
- if (value === null) {
18104
- return `${encodeURIComponent(key)}=`;
18105
- }
18106
- throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
18107
- })
18108
- .join('&');
18135
+ return stringifyQuery(query);
18109
18136
  }
18110
18137
  getUserAgent() {
18111
18138
  return `${this.constructor.name}/JS ${VERSION}`;
@@ -18122,8 +18149,9 @@ class BaseGeminiNextGenAPIClient {
18122
18149
  new URL(path)
18123
18150
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
18124
18151
  const defaultQuery = this.defaultQuery();
18125
- if (!isEmptyObj(defaultQuery)) {
18126
- query = Object.assign(Object.assign({}, defaultQuery), query);
18152
+ const pathQuery = Object.fromEntries(url.searchParams);
18153
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
18154
+ query = Object.assign(Object.assign(Object.assign({}, pathQuery), defaultQuery), query);
18127
18155
  }
18128
18156
  if (typeof query === 'object' && query && !Array.isArray(query)) {
18129
18157
  url.search = this.stringifyQuery(query);
@@ -18344,9 +18372,9 @@ class BaseGeminiNextGenAPIClient {
18344
18372
  timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
18345
18373
  }
18346
18374
  }
18347
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
18348
- // just do what it says, but otherwise calculate a default
18349
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
18375
+ // If the API asks us to wait a certain amount of time, just do what it
18376
+ // says, but otherwise calculate a default
18377
+ if (timeoutMillis === undefined) {
18350
18378
  const maxRetries = (_b = options.maxRetries) !== null && _b !== void 0 ? _b : this.maxRetries;
18351
18379
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
18352
18380
  }