@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.
@@ -7409,6 +7409,13 @@ class Files extends BaseModule {
7409
7409
  * Copyright 2025 Google LLC
7410
7410
  * SPDX-License-Identifier: Apache-2.0
7411
7411
  */
7412
+ function audioTranscriptionConfigToMldev$1(fromObject) {
7413
+ const toObject = {};
7414
+ if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
7415
+ throw new Error('languageCodes parameter is not supported in Gemini API.');
7416
+ }
7417
+ return toObject;
7418
+ }
7412
7419
  function authConfigToMldev$2(fromObject) {
7413
7420
  const toObject = {};
7414
7421
  const fromApiKey = getValueByPath(fromObject, ['apiKey']);
@@ -7785,13 +7792,13 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
7785
7792
  'inputAudioTranscription',
7786
7793
  ]);
7787
7794
  if (parentObject !== undefined && fromInputAudioTranscription != null) {
7788
- setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
7795
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromInputAudioTranscription));
7789
7796
  }
7790
7797
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
7791
7798
  'outputAudioTranscription',
7792
7799
  ]);
7793
7800
  if (parentObject !== undefined && fromOutputAudioTranscription != null) {
7794
- setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
7801
+ setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev$1(fromOutputAudioTranscription));
7795
7802
  }
7796
7803
  const fromRealtimeInputConfig = getValueByPath(fromObject, [
7797
7804
  'realtimeInputConfig',
@@ -12092,7 +12099,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
12092
12099
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
12093
12100
  const USER_AGENT_HEADER = 'User-Agent';
12094
12101
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
12095
- const SDK_VERSION = '1.44.0'; // x-release-please-version
12102
+ const SDK_VERSION = '1.45.0'; // x-release-please-version
12096
12103
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
12097
12104
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
12098
12105
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -15424,6 +15431,13 @@ class Operations extends BaseModule {
15424
15431
  * Copyright 2025 Google LLC
15425
15432
  * SPDX-License-Identifier: Apache-2.0
15426
15433
  */
15434
+ function audioTranscriptionConfigToMldev(fromObject) {
15435
+ const toObject = {};
15436
+ if (getValueByPath(fromObject, ['languageCodes']) !== undefined) {
15437
+ throw new Error('languageCodes parameter is not supported in Gemini API.');
15438
+ }
15439
+ return toObject;
15440
+ }
15427
15441
  function authConfigToMldev(fromObject) {
15428
15442
  const toObject = {};
15429
15443
  const fromApiKey = getValueByPath(fromObject, ['apiKey']);
@@ -15675,13 +15689,13 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
15675
15689
  'inputAudioTranscription',
15676
15690
  ]);
15677
15691
  if (parentObject !== undefined && fromInputAudioTranscription != null) {
15678
- setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], fromInputAudioTranscription);
15692
+ setValueByPath(parentObject, ['setup', 'inputAudioTranscription'], audioTranscriptionConfigToMldev(fromInputAudioTranscription));
15679
15693
  }
15680
15694
  const fromOutputAudioTranscription = getValueByPath(fromObject, [
15681
15695
  'outputAudioTranscription',
15682
15696
  ]);
15683
15697
  if (parentObject !== undefined && fromOutputAudioTranscription != null) {
15684
- setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], fromOutputAudioTranscription);
15698
+ setValueByPath(parentObject, ['setup', 'outputAudioTranscription'], audioTranscriptionConfigToMldev(fromOutputAudioTranscription));
15685
15699
  }
15686
15700
  const fromRealtimeInputConfig = getValueByPath(fromObject, [
15687
15701
  'realtimeInputConfig',
@@ -16943,6 +16957,30 @@ const FallbackEncoder = ({ headers, body }) => {
16943
16957
  };
16944
16958
  };
16945
16959
 
16960
+ /**
16961
+ * @license
16962
+ * Copyright 2025 Google LLC
16963
+ * SPDX-License-Identifier: Apache-2.0
16964
+ */
16965
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
16966
+ /**
16967
+ * Basic re-implementation of `qs.stringify` for primitive types.
16968
+ */
16969
+ function stringifyQuery(query) {
16970
+ return Object.entries(query)
16971
+ .filter(([_, value]) => typeof value !== 'undefined')
16972
+ .map(([key, value]) => {
16973
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
16974
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
16975
+ }
16976
+ if (value === null) {
16977
+ return `${encodeURIComponent(key)}=`;
16978
+ }
16979
+ 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.`);
16980
+ })
16981
+ .join('&');
16982
+ }
16983
+
16946
16984
  /**
16947
16985
  * @license
16948
16986
  * Copyright 2025 Google LLC
@@ -18086,18 +18124,7 @@ class BaseGeminiNextGenAPIClient {
18086
18124
  * Basic re-implementation of `qs.stringify` for primitive types.
18087
18125
  */
18088
18126
  stringifyQuery(query) {
18089
- return Object.entries(query)
18090
- .filter(([_, value]) => typeof value !== 'undefined')
18091
- .map(([key, value]) => {
18092
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
18093
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
18094
- }
18095
- if (value === null) {
18096
- return `${encodeURIComponent(key)}=`;
18097
- }
18098
- 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.`);
18099
- })
18100
- .join('&');
18127
+ return stringifyQuery(query);
18101
18128
  }
18102
18129
  getUserAgent() {
18103
18130
  return `${this.constructor.name}/JS ${VERSION}`;
@@ -18114,8 +18141,9 @@ class BaseGeminiNextGenAPIClient {
18114
18141
  new URL(path)
18115
18142
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
18116
18143
  const defaultQuery = this.defaultQuery();
18117
- if (!isEmptyObj(defaultQuery)) {
18118
- query = Object.assign(Object.assign({}, defaultQuery), query);
18144
+ const pathQuery = Object.fromEntries(url.searchParams);
18145
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
18146
+ query = Object.assign(Object.assign(Object.assign({}, pathQuery), defaultQuery), query);
18119
18147
  }
18120
18148
  if (typeof query === 'object' && query && !Array.isArray(query)) {
18121
18149
  url.search = this.stringifyQuery(query);
@@ -18336,9 +18364,9 @@ class BaseGeminiNextGenAPIClient {
18336
18364
  timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
18337
18365
  }
18338
18366
  }
18339
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
18340
- // just do what it says, but otherwise calculate a default
18341
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
18367
+ // If the API asks us to wait a certain amount of time, just do what it
18368
+ // says, but otherwise calculate a default
18369
+ if (timeoutMillis === undefined) {
18342
18370
  const maxRetries = (_b = options.maxRetries) !== null && _b !== void 0 ? _b : this.maxRetries;
18343
18371
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
18344
18372
  }