@google/genai 1.52.0 → 2.0.1
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/README.md +1 -4
- package/dist/genai.d.ts +438 -432
- package/dist/index.cjs +30 -10
- package/dist/index.mjs +30 -10
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +30 -10
- package/dist/node/index.mjs +30 -10
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +438 -432
- package/dist/vertex_internal/index.cjs +29 -8
- package/dist/vertex_internal/index.cjs.map +1 -1
- package/dist/vertex_internal/index.js +29 -8
- package/dist/vertex_internal/index.js.map +1 -1
- package/dist/web/index.mjs +30 -10
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +438 -432
- package/package.json +2 -2
package/dist/web/index.mjs
CHANGED
|
@@ -12889,7 +12889,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12889
12889
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12890
12890
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12891
12891
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12892
|
-
const SDK_VERSION = '
|
|
12892
|
+
const SDK_VERSION = '2.0.1'; // x-release-please-version
|
|
12893
12893
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12894
12894
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12895
12895
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13154,6 +13154,24 @@ class ApiClient {
|
|
|
13154
13154
|
const abortController = new AbortController();
|
|
13155
13155
|
const signal = abortController.signal;
|
|
13156
13156
|
if (httpOptions.timeout && (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) > 0) {
|
|
13157
|
+
// In Node > 18, the built-in fetch is backed by Undici. Undici sets a global
|
|
13158
|
+
// dispatcher on the global scope which tracks its internal headersTimeout and
|
|
13159
|
+
// bodyTimeout using Symbol properties.
|
|
13160
|
+
const dispatcherSymbol = Symbol.for('undici.globalDispatcher.1');
|
|
13161
|
+
const globalDispatcher = globalThis[dispatcherSymbol];
|
|
13162
|
+
if (globalDispatcher) {
|
|
13163
|
+
const symbols = Object.getOwnPropertySymbols(globalDispatcher);
|
|
13164
|
+
for (const sym of symbols) {
|
|
13165
|
+
const desc = sym.description;
|
|
13166
|
+
if ((desc === null || desc === void 0 ? void 0 : desc.includes('headers timeout')) ||
|
|
13167
|
+
(desc === null || desc === void 0 ? void 0 : desc.includes('body timeout'))) {
|
|
13168
|
+
const currentTimeout = globalDispatcher[sym];
|
|
13169
|
+
if (typeof currentTimeout === 'number') {
|
|
13170
|
+
globalDispatcher[sym] = Math.max(currentTimeout, httpOptions.timeout);
|
|
13171
|
+
}
|
|
13172
|
+
}
|
|
13173
|
+
}
|
|
13174
|
+
}
|
|
13157
13175
|
const timeoutHandle = setTimeout(() => abortController.abort(), httpOptions.timeout);
|
|
13158
13176
|
if (timeoutHandle &&
|
|
13159
13177
|
typeof timeoutHandle.unref ===
|
|
@@ -13187,7 +13205,7 @@ class ApiClient {
|
|
|
13187
13205
|
throw e;
|
|
13188
13206
|
}
|
|
13189
13207
|
else {
|
|
13190
|
-
throw new Error(
|
|
13208
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
13191
13209
|
}
|
|
13192
13210
|
});
|
|
13193
13211
|
}
|
|
@@ -13202,7 +13220,7 @@ class ApiClient {
|
|
|
13202
13220
|
throw e;
|
|
13203
13221
|
}
|
|
13204
13222
|
else {
|
|
13205
|
-
throw new Error(
|
|
13223
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
13206
13224
|
}
|
|
13207
13225
|
});
|
|
13208
13226
|
}
|
|
@@ -13330,11 +13348,14 @@ class ApiClient {
|
|
|
13330
13348
|
for (const [key, value] of Object.entries(httpOptions.headers)) {
|
|
13331
13349
|
headers.append(key, value);
|
|
13332
13350
|
}
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
|
|
13351
|
+
}
|
|
13352
|
+
// Append a timeout header if it is set, note that the timeout option is
|
|
13353
|
+
// in milliseconds but the header is in seconds.
|
|
13354
|
+
// NOTE: This is intentionally outside the httpOptions.headers guard above
|
|
13355
|
+
// so that the X-Server-Timeout header is always sent whenever a timeout
|
|
13356
|
+
// is configured, even if the caller did not supply any custom headers.
|
|
13357
|
+
if ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) && httpOptions.timeout > 0) {
|
|
13358
|
+
headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
|
|
13338
13359
|
}
|
|
13339
13360
|
await this.clientOptions.auth.addAuthHeaders(headers, url);
|
|
13340
13361
|
return headers;
|
|
@@ -19337,7 +19358,7 @@ class BaseGeminiNextGenAPIClient {
|
|
|
19337
19358
|
const authHeaders = await this.authHeaders(options);
|
|
19338
19359
|
let headers = buildHeaders([
|
|
19339
19360
|
idempotencyHeaders,
|
|
19340
|
-
{ Accept: 'application/json', 'User-Agent': this.getUserAgent() },
|
|
19361
|
+
{ Accept: 'application/json', 'User-Agent': this.getUserAgent(), 'Api-Revision': '2026-05-20' },
|
|
19341
19362
|
this._options.defaultHeaders,
|
|
19342
19363
|
bodyHeaders,
|
|
19343
19364
|
options.headers,
|
|
@@ -20867,7 +20888,6 @@ class GoogleGenAI {
|
|
|
20867
20888
|
if (this._interactions !== undefined) {
|
|
20868
20889
|
return this._interactions;
|
|
20869
20890
|
}
|
|
20870
|
-
console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
|
|
20871
20891
|
this._interactions = this.getNextGenClient().interactions;
|
|
20872
20892
|
return this._interactions;
|
|
20873
20893
|
}
|