@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/node/index.cjs
CHANGED
|
@@ -12919,7 +12919,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12919
12919
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12920
12920
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12921
12921
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12922
|
-
const SDK_VERSION = '
|
|
12922
|
+
const SDK_VERSION = '2.0.1'; // x-release-please-version
|
|
12923
12923
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12924
12924
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12925
12925
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13184,6 +13184,24 @@ class ApiClient {
|
|
|
13184
13184
|
const abortController = new AbortController();
|
|
13185
13185
|
const signal = abortController.signal;
|
|
13186
13186
|
if (httpOptions.timeout && (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) > 0) {
|
|
13187
|
+
// In Node > 18, the built-in fetch is backed by Undici. Undici sets a global
|
|
13188
|
+
// dispatcher on the global scope which tracks its internal headersTimeout and
|
|
13189
|
+
// bodyTimeout using Symbol properties.
|
|
13190
|
+
const dispatcherSymbol = Symbol.for('undici.globalDispatcher.1');
|
|
13191
|
+
const globalDispatcher = globalThis[dispatcherSymbol];
|
|
13192
|
+
if (globalDispatcher) {
|
|
13193
|
+
const symbols = Object.getOwnPropertySymbols(globalDispatcher);
|
|
13194
|
+
for (const sym of symbols) {
|
|
13195
|
+
const desc = sym.description;
|
|
13196
|
+
if ((desc === null || desc === void 0 ? void 0 : desc.includes('headers timeout')) ||
|
|
13197
|
+
(desc === null || desc === void 0 ? void 0 : desc.includes('body timeout'))) {
|
|
13198
|
+
const currentTimeout = globalDispatcher[sym];
|
|
13199
|
+
if (typeof currentTimeout === 'number') {
|
|
13200
|
+
globalDispatcher[sym] = Math.max(currentTimeout, httpOptions.timeout);
|
|
13201
|
+
}
|
|
13202
|
+
}
|
|
13203
|
+
}
|
|
13204
|
+
}
|
|
13187
13205
|
const timeoutHandle = setTimeout(() => abortController.abort(), httpOptions.timeout);
|
|
13188
13206
|
if (timeoutHandle &&
|
|
13189
13207
|
typeof timeoutHandle.unref ===
|
|
@@ -13217,7 +13235,7 @@ class ApiClient {
|
|
|
13217
13235
|
throw e;
|
|
13218
13236
|
}
|
|
13219
13237
|
else {
|
|
13220
|
-
throw new Error(
|
|
13238
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
13221
13239
|
}
|
|
13222
13240
|
});
|
|
13223
13241
|
}
|
|
@@ -13232,7 +13250,7 @@ class ApiClient {
|
|
|
13232
13250
|
throw e;
|
|
13233
13251
|
}
|
|
13234
13252
|
else {
|
|
13235
|
-
throw new Error(
|
|
13253
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
13236
13254
|
}
|
|
13237
13255
|
});
|
|
13238
13256
|
}
|
|
@@ -13360,11 +13378,14 @@ class ApiClient {
|
|
|
13360
13378
|
for (const [key, value] of Object.entries(httpOptions.headers)) {
|
|
13361
13379
|
headers.append(key, value);
|
|
13362
13380
|
}
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13381
|
+
}
|
|
13382
|
+
// Append a timeout header if it is set, note that the timeout option is
|
|
13383
|
+
// in milliseconds but the header is in seconds.
|
|
13384
|
+
// NOTE: This is intentionally outside the httpOptions.headers guard above
|
|
13385
|
+
// so that the X-Server-Timeout header is always sent whenever a timeout
|
|
13386
|
+
// is configured, even if the caller did not supply any custom headers.
|
|
13387
|
+
if ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) && httpOptions.timeout > 0) {
|
|
13388
|
+
headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
|
|
13368
13389
|
}
|
|
13369
13390
|
await this.clientOptions.auth.addAuthHeaders(headers, url);
|
|
13370
13391
|
return headers;
|
|
@@ -19367,7 +19388,7 @@ class BaseGeminiNextGenAPIClient {
|
|
|
19367
19388
|
const authHeaders = await this.authHeaders(options);
|
|
19368
19389
|
let headers = buildHeaders([
|
|
19369
19390
|
idempotencyHeaders,
|
|
19370
|
-
{ Accept: 'application/json', 'User-Agent': this.getUserAgent() },
|
|
19391
|
+
{ Accept: 'application/json', 'User-Agent': this.getUserAgent(), 'Api-Revision': '2026-05-20' },
|
|
19371
19392
|
this._options.defaultHeaders,
|
|
19372
19393
|
bodyHeaders,
|
|
19373
19394
|
options.headers,
|
|
@@ -21268,7 +21289,6 @@ class GoogleGenAI {
|
|
|
21268
21289
|
if (this._interactions !== undefined) {
|
|
21269
21290
|
return this._interactions;
|
|
21270
21291
|
}
|
|
21271
|
-
console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
|
|
21272
21292
|
this._interactions = this.getNextGenClient().interactions;
|
|
21273
21293
|
return this._interactions;
|
|
21274
21294
|
}
|
package/dist/node/index.mjs
CHANGED
|
@@ -12897,7 +12897,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
12897
12897
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
12898
12898
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
12899
12899
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
12900
|
-
const SDK_VERSION = '
|
|
12900
|
+
const SDK_VERSION = '2.0.1'; // x-release-please-version
|
|
12901
12901
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
12902
12902
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
12903
12903
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -13162,6 +13162,24 @@ class ApiClient {
|
|
|
13162
13162
|
const abortController = new AbortController();
|
|
13163
13163
|
const signal = abortController.signal;
|
|
13164
13164
|
if (httpOptions.timeout && (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) > 0) {
|
|
13165
|
+
// In Node > 18, the built-in fetch is backed by Undici. Undici sets a global
|
|
13166
|
+
// dispatcher on the global scope which tracks its internal headersTimeout and
|
|
13167
|
+
// bodyTimeout using Symbol properties.
|
|
13168
|
+
const dispatcherSymbol = Symbol.for('undici.globalDispatcher.1');
|
|
13169
|
+
const globalDispatcher = globalThis[dispatcherSymbol];
|
|
13170
|
+
if (globalDispatcher) {
|
|
13171
|
+
const symbols = Object.getOwnPropertySymbols(globalDispatcher);
|
|
13172
|
+
for (const sym of symbols) {
|
|
13173
|
+
const desc = sym.description;
|
|
13174
|
+
if ((desc === null || desc === void 0 ? void 0 : desc.includes('headers timeout')) ||
|
|
13175
|
+
(desc === null || desc === void 0 ? void 0 : desc.includes('body timeout'))) {
|
|
13176
|
+
const currentTimeout = globalDispatcher[sym];
|
|
13177
|
+
if (typeof currentTimeout === 'number') {
|
|
13178
|
+
globalDispatcher[sym] = Math.max(currentTimeout, httpOptions.timeout);
|
|
13179
|
+
}
|
|
13180
|
+
}
|
|
13181
|
+
}
|
|
13182
|
+
}
|
|
13165
13183
|
const timeoutHandle = setTimeout(() => abortController.abort(), httpOptions.timeout);
|
|
13166
13184
|
if (timeoutHandle &&
|
|
13167
13185
|
typeof timeoutHandle.unref ===
|
|
@@ -13195,7 +13213,7 @@ class ApiClient {
|
|
|
13195
13213
|
throw e;
|
|
13196
13214
|
}
|
|
13197
13215
|
else {
|
|
13198
|
-
throw new Error(
|
|
13216
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
13199
13217
|
}
|
|
13200
13218
|
});
|
|
13201
13219
|
}
|
|
@@ -13210,7 +13228,7 @@ class ApiClient {
|
|
|
13210
13228
|
throw e;
|
|
13211
13229
|
}
|
|
13212
13230
|
else {
|
|
13213
|
-
throw new Error(
|
|
13231
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
13214
13232
|
}
|
|
13215
13233
|
});
|
|
13216
13234
|
}
|
|
@@ -13338,11 +13356,14 @@ class ApiClient {
|
|
|
13338
13356
|
for (const [key, value] of Object.entries(httpOptions.headers)) {
|
|
13339
13357
|
headers.append(key, value);
|
|
13340
13358
|
}
|
|
13341
|
-
|
|
13342
|
-
|
|
13343
|
-
|
|
13344
|
-
|
|
13345
|
-
|
|
13359
|
+
}
|
|
13360
|
+
// Append a timeout header if it is set, note that the timeout option is
|
|
13361
|
+
// in milliseconds but the header is in seconds.
|
|
13362
|
+
// NOTE: This is intentionally outside the httpOptions.headers guard above
|
|
13363
|
+
// so that the X-Server-Timeout header is always sent whenever a timeout
|
|
13364
|
+
// is configured, even if the caller did not supply any custom headers.
|
|
13365
|
+
if ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) && httpOptions.timeout > 0) {
|
|
13366
|
+
headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
|
|
13346
13367
|
}
|
|
13347
13368
|
await this.clientOptions.auth.addAuthHeaders(headers, url);
|
|
13348
13369
|
return headers;
|
|
@@ -19345,7 +19366,7 @@ class BaseGeminiNextGenAPIClient {
|
|
|
19345
19366
|
const authHeaders = await this.authHeaders(options);
|
|
19346
19367
|
let headers = buildHeaders([
|
|
19347
19368
|
idempotencyHeaders,
|
|
19348
|
-
{ Accept: 'application/json', 'User-Agent': this.getUserAgent() },
|
|
19369
|
+
{ Accept: 'application/json', 'User-Agent': this.getUserAgent(), 'Api-Revision': '2026-05-20' },
|
|
19349
19370
|
this._options.defaultHeaders,
|
|
19350
19371
|
bodyHeaders,
|
|
19351
19372
|
options.headers,
|
|
@@ -21246,7 +21267,6 @@ class GoogleGenAI {
|
|
|
21246
21267
|
if (this._interactions !== undefined) {
|
|
21247
21268
|
return this._interactions;
|
|
21248
21269
|
}
|
|
21249
|
-
console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
|
|
21250
21270
|
this._interactions = this.getNextGenClient().interactions;
|
|
21251
21271
|
return this._interactions;
|
|
21252
21272
|
}
|