@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/index.cjs
CHANGED
|
@@ -7631,7 +7631,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
7631
7631
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
7632
7632
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
7633
7633
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
7634
|
-
const SDK_VERSION = '
|
|
7634
|
+
const SDK_VERSION = '2.0.1'; // x-release-please-version
|
|
7635
7635
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
7636
7636
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
7637
7637
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -7896,6 +7896,24 @@ class ApiClient {
|
|
|
7896
7896
|
const abortController = new AbortController();
|
|
7897
7897
|
const signal = abortController.signal;
|
|
7898
7898
|
if (httpOptions.timeout && (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) > 0) {
|
|
7899
|
+
// In Node > 18, the built-in fetch is backed by Undici. Undici sets a global
|
|
7900
|
+
// dispatcher on the global scope which tracks its internal headersTimeout and
|
|
7901
|
+
// bodyTimeout using Symbol properties.
|
|
7902
|
+
const dispatcherSymbol = Symbol.for('undici.globalDispatcher.1');
|
|
7903
|
+
const globalDispatcher = globalThis[dispatcherSymbol];
|
|
7904
|
+
if (globalDispatcher) {
|
|
7905
|
+
const symbols = Object.getOwnPropertySymbols(globalDispatcher);
|
|
7906
|
+
for (const sym of symbols) {
|
|
7907
|
+
const desc = sym.description;
|
|
7908
|
+
if ((desc === null || desc === void 0 ? void 0 : desc.includes('headers timeout')) ||
|
|
7909
|
+
(desc === null || desc === void 0 ? void 0 : desc.includes('body timeout'))) {
|
|
7910
|
+
const currentTimeout = globalDispatcher[sym];
|
|
7911
|
+
if (typeof currentTimeout === 'number') {
|
|
7912
|
+
globalDispatcher[sym] = Math.max(currentTimeout, httpOptions.timeout);
|
|
7913
|
+
}
|
|
7914
|
+
}
|
|
7915
|
+
}
|
|
7916
|
+
}
|
|
7899
7917
|
const timeoutHandle = setTimeout(() => abortController.abort(), httpOptions.timeout);
|
|
7900
7918
|
if (timeoutHandle &&
|
|
7901
7919
|
typeof timeoutHandle.unref ===
|
|
@@ -7929,7 +7947,7 @@ class ApiClient {
|
|
|
7929
7947
|
throw e;
|
|
7930
7948
|
}
|
|
7931
7949
|
else {
|
|
7932
|
-
throw new Error(
|
|
7950
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
7933
7951
|
}
|
|
7934
7952
|
});
|
|
7935
7953
|
}
|
|
@@ -7944,7 +7962,7 @@ class ApiClient {
|
|
|
7944
7962
|
throw e;
|
|
7945
7963
|
}
|
|
7946
7964
|
else {
|
|
7947
|
-
throw new Error(
|
|
7965
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
7948
7966
|
}
|
|
7949
7967
|
});
|
|
7950
7968
|
}
|
|
@@ -8072,11 +8090,14 @@ class ApiClient {
|
|
|
8072
8090
|
for (const [key, value] of Object.entries(httpOptions.headers)) {
|
|
8073
8091
|
headers.append(key, value);
|
|
8074
8092
|
}
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8093
|
+
}
|
|
8094
|
+
// Append a timeout header if it is set, note that the timeout option is
|
|
8095
|
+
// in milliseconds but the header is in seconds.
|
|
8096
|
+
// NOTE: This is intentionally outside the httpOptions.headers guard above
|
|
8097
|
+
// so that the X-Server-Timeout header is always sent whenever a timeout
|
|
8098
|
+
// is configured, even if the caller did not supply any custom headers.
|
|
8099
|
+
if ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) && httpOptions.timeout > 0) {
|
|
8100
|
+
headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
|
|
8080
8101
|
}
|
|
8081
8102
|
await this.clientOptions.auth.addAuthHeaders(headers, url);
|
|
8082
8103
|
return headers;
|
|
@@ -11266,7 +11287,7 @@ class BaseGeminiNextGenAPIClient {
|
|
|
11266
11287
|
const authHeaders = await this.authHeaders(options);
|
|
11267
11288
|
let headers = buildHeaders([
|
|
11268
11289
|
idempotencyHeaders,
|
|
11269
|
-
{ Accept: 'application/json', 'User-Agent': this.getUserAgent() },
|
|
11290
|
+
{ Accept: 'application/json', 'User-Agent': this.getUserAgent(), 'Api-Revision': '2026-05-20' },
|
|
11270
11291
|
this._options.defaultHeaders,
|
|
11271
11292
|
bodyHeaders,
|
|
11272
11293
|
options.headers,
|
|
@@ -20825,7 +20846,6 @@ class GoogleGenAI {
|
|
|
20825
20846
|
if (this._interactions !== undefined) {
|
|
20826
20847
|
return this._interactions;
|
|
20827
20848
|
}
|
|
20828
|
-
console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
|
|
20829
20849
|
this._interactions = this.getNextGenClient().interactions;
|
|
20830
20850
|
return this._interactions;
|
|
20831
20851
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -7629,7 +7629,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
|
7629
7629
|
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
7630
7630
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
7631
7631
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
7632
|
-
const SDK_VERSION = '
|
|
7632
|
+
const SDK_VERSION = '2.0.1'; // x-release-please-version
|
|
7633
7633
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
7634
7634
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
7635
7635
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -7894,6 +7894,24 @@ class ApiClient {
|
|
|
7894
7894
|
const abortController = new AbortController();
|
|
7895
7895
|
const signal = abortController.signal;
|
|
7896
7896
|
if (httpOptions.timeout && (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) > 0) {
|
|
7897
|
+
// In Node > 18, the built-in fetch is backed by Undici. Undici sets a global
|
|
7898
|
+
// dispatcher on the global scope which tracks its internal headersTimeout and
|
|
7899
|
+
// bodyTimeout using Symbol properties.
|
|
7900
|
+
const dispatcherSymbol = Symbol.for('undici.globalDispatcher.1');
|
|
7901
|
+
const globalDispatcher = globalThis[dispatcherSymbol];
|
|
7902
|
+
if (globalDispatcher) {
|
|
7903
|
+
const symbols = Object.getOwnPropertySymbols(globalDispatcher);
|
|
7904
|
+
for (const sym of symbols) {
|
|
7905
|
+
const desc = sym.description;
|
|
7906
|
+
if ((desc === null || desc === void 0 ? void 0 : desc.includes('headers timeout')) ||
|
|
7907
|
+
(desc === null || desc === void 0 ? void 0 : desc.includes('body timeout'))) {
|
|
7908
|
+
const currentTimeout = globalDispatcher[sym];
|
|
7909
|
+
if (typeof currentTimeout === 'number') {
|
|
7910
|
+
globalDispatcher[sym] = Math.max(currentTimeout, httpOptions.timeout);
|
|
7911
|
+
}
|
|
7912
|
+
}
|
|
7913
|
+
}
|
|
7914
|
+
}
|
|
7897
7915
|
const timeoutHandle = setTimeout(() => abortController.abort(), httpOptions.timeout);
|
|
7898
7916
|
if (timeoutHandle &&
|
|
7899
7917
|
typeof timeoutHandle.unref ===
|
|
@@ -7927,7 +7945,7 @@ class ApiClient {
|
|
|
7927
7945
|
throw e;
|
|
7928
7946
|
}
|
|
7929
7947
|
else {
|
|
7930
|
-
throw new Error(
|
|
7948
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
7931
7949
|
}
|
|
7932
7950
|
});
|
|
7933
7951
|
}
|
|
@@ -7942,7 +7960,7 @@ class ApiClient {
|
|
|
7942
7960
|
throw e;
|
|
7943
7961
|
}
|
|
7944
7962
|
else {
|
|
7945
|
-
throw new Error(
|
|
7963
|
+
throw new Error(`exception ${e} sending request`, { cause: e });
|
|
7946
7964
|
}
|
|
7947
7965
|
});
|
|
7948
7966
|
}
|
|
@@ -8070,11 +8088,14 @@ class ApiClient {
|
|
|
8070
8088
|
for (const [key, value] of Object.entries(httpOptions.headers)) {
|
|
8071
8089
|
headers.append(key, value);
|
|
8072
8090
|
}
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8091
|
+
}
|
|
8092
|
+
// Append a timeout header if it is set, note that the timeout option is
|
|
8093
|
+
// in milliseconds but the header is in seconds.
|
|
8094
|
+
// NOTE: This is intentionally outside the httpOptions.headers guard above
|
|
8095
|
+
// so that the X-Server-Timeout header is always sent whenever a timeout
|
|
8096
|
+
// is configured, even if the caller did not supply any custom headers.
|
|
8097
|
+
if ((httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.timeout) && httpOptions.timeout > 0) {
|
|
8098
|
+
headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
|
|
8078
8099
|
}
|
|
8079
8100
|
await this.clientOptions.auth.addAuthHeaders(headers, url);
|
|
8080
8101
|
return headers;
|
|
@@ -11264,7 +11285,7 @@ class BaseGeminiNextGenAPIClient {
|
|
|
11264
11285
|
const authHeaders = await this.authHeaders(options);
|
|
11265
11286
|
let headers = buildHeaders([
|
|
11266
11287
|
idempotencyHeaders,
|
|
11267
|
-
{ Accept: 'application/json', 'User-Agent': this.getUserAgent() },
|
|
11288
|
+
{ Accept: 'application/json', 'User-Agent': this.getUserAgent(), 'Api-Revision': '2026-05-20' },
|
|
11268
11289
|
this._options.defaultHeaders,
|
|
11269
11290
|
bodyHeaders,
|
|
11270
11291
|
options.headers,
|
|
@@ -20823,7 +20844,6 @@ class GoogleGenAI {
|
|
|
20823
20844
|
if (this._interactions !== undefined) {
|
|
20824
20845
|
return this._interactions;
|
|
20825
20846
|
}
|
|
20826
|
-
console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
|
|
20827
20847
|
this._interactions = this.getNextGenClient().interactions;
|
|
20828
20848
|
return this._interactions;
|
|
20829
20849
|
}
|