@ai-sdk/google-vertex 5.0.127 → 5.0.129
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/CHANGELOG.md +27 -0
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/edge/index.d.ts +2 -1
- package/dist/edge/index.d.ts.map +1 -1
- package/dist/edge/index.js +9 -7
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/maas/edge/index.js +1 -1
- package/dist/xai/edge/index.js +1 -1
- package/docs/16-google-vertex.mdx +6 -1
- package/package.json +6 -6
- package/src/edge/google-vertex-provider-edge.ts +7 -4
- package/src/google-vertex-provider-base.ts +22 -7
- package/src/google-vertex-provider.ts +7 -4
package/dist/xai/edge/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getRuntimeEnvironmentUserAgent, loadOptionalSetting, loadSetting, resol
|
|
|
2
2
|
import { NoSuchModelError } from "@ai-sdk/provider";
|
|
3
3
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
4
4
|
//#region src/version.ts
|
|
5
|
-
const VERSION = "5.0.
|
|
5
|
+
const VERSION = "5.0.129";
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/edge/google-vertex-auth-edge.ts
|
|
8
8
|
const loadCredentials = async () => {
|
|
@@ -292,7 +292,12 @@ const googleVertex = createGoogleVertex({
|
|
|
292
292
|
|
|
293
293
|
##### Optional Provider Settings
|
|
294
294
|
|
|
295
|
-
- **apiKey**
|
|
295
|
+
- **apiKey** _string | PromiseLike<string> | (() => string | PromiseLike<string>)_
|
|
296
|
+
|
|
297
|
+
Pass a callback to resolve the API key before each request. The callback can
|
|
298
|
+
return a string or a promise; token caching and renewal are handled by the caller.
|
|
299
|
+
A callback or promise selects API key authentication and must resolve to a
|
|
300
|
+
non-empty string; lookup failures do not switch authentication methods.
|
|
296
301
|
|
|
297
302
|
The API key for Google Vertex AI. When provided, the provider uses express mode with API key authentication instead of OAuth.
|
|
298
303
|
It uses the `GOOGLE_VERTEX_API_KEY` environment variable by default.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google-vertex",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.129",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@ai-sdk/anthropic": "4.0.
|
|
75
|
-
"@ai-sdk/google": "4.0.
|
|
76
|
-
"@ai-sdk/openai-compatible": "3.0.
|
|
77
|
-
"@ai-sdk/provider": "4.0.
|
|
78
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
74
|
+
"@ai-sdk/anthropic": "4.0.94",
|
|
75
|
+
"@ai-sdk/google": "4.0.109",
|
|
76
|
+
"@ai-sdk/openai-compatible": "3.0.82",
|
|
77
|
+
"@ai-sdk/provider": "4.0.35",
|
|
78
|
+
"@ai-sdk/provider-utils": "5.0.72",
|
|
79
79
|
"google-auth-library": "^11.3.1"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
@@ -22,10 +22,13 @@ export interface GoogleVertexProviderSettings extends GoogleVertexProviderSettin
|
|
|
22
22
|
export function createGoogleVertex(
|
|
23
23
|
options: GoogleVertexProviderSettings = {},
|
|
24
24
|
): GoogleVertexProvider {
|
|
25
|
-
const apiKey =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const apiKey =
|
|
26
|
+
typeof options.apiKey === 'string' || options.apiKey == null
|
|
27
|
+
? loadOptionalSetting({
|
|
28
|
+
settingValue: options.apiKey,
|
|
29
|
+
environmentVariableName: 'GOOGLE_VERTEX_API_KEY',
|
|
30
|
+
})
|
|
31
|
+
: options.apiKey;
|
|
29
32
|
|
|
30
33
|
if (apiKey) {
|
|
31
34
|
return createGoogleVertexOriginal(options);
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '@ai-sdk/google/internal';
|
|
9
9
|
import {
|
|
10
10
|
InvalidArgumentError,
|
|
11
|
+
LoadAPIKeyError,
|
|
11
12
|
type Experimental_VideoModelV4,
|
|
12
13
|
type ImageModelV4,
|
|
13
14
|
type LanguageModelV4,
|
|
@@ -58,15 +59,25 @@ function isEndpointModelId(modelId: string): boolean {
|
|
|
58
59
|
|
|
59
60
|
// set `x-goog-api-key` header to API key for express mode
|
|
60
61
|
function createExpressModeFetch(
|
|
61
|
-
apiKey: string
|
|
62
|
+
apiKey: Resolvable<string>,
|
|
62
63
|
customFetch?: FetchFunction,
|
|
63
64
|
): FetchFunction {
|
|
64
65
|
return async (url, init) => {
|
|
66
|
+
const resolvedApiKey = await resolve(apiKey);
|
|
67
|
+
if (
|
|
68
|
+
typeof apiKey !== 'string' &&
|
|
69
|
+
(typeof resolvedApiKey !== 'string' || !resolvedApiKey.trim())
|
|
70
|
+
) {
|
|
71
|
+
throw new LoadAPIKeyError({
|
|
72
|
+
message: 'Google Vertex API key must be a non-empty string.',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
65
76
|
const modifiedInit: RequestInit = {
|
|
66
77
|
...init,
|
|
67
78
|
headers: {
|
|
68
79
|
...(init?.headers ? normalizeHeaders(init.headers) : {}),
|
|
69
|
-
'x-goog-api-key':
|
|
80
|
+
'x-goog-api-key': resolvedApiKey,
|
|
70
81
|
},
|
|
71
82
|
};
|
|
72
83
|
return (customFetch ?? fetch)(url.toString(), modifiedInit);
|
|
@@ -153,8 +164,9 @@ export interface GoogleVertexProviderSettings {
|
|
|
153
164
|
* Optional. The API key for the Google Cloud project. If provided, the
|
|
154
165
|
* provider will use express mode with API key authentication. Defaults to
|
|
155
166
|
* the value of the `GOOGLE_VERTEX_API_KEY` environment variable.
|
|
167
|
+
* A callback is resolved before each request and must return a non-empty key.
|
|
156
168
|
*/
|
|
157
|
-
apiKey?: string
|
|
169
|
+
apiKey?: Resolvable<string>;
|
|
158
170
|
|
|
159
171
|
/**
|
|
160
172
|
* Your Google Vertex location. Defaults to the environment variable `GOOGLE_VERTEX_LOCATION`.
|
|
@@ -214,10 +226,13 @@ export interface GoogleVertexProviderSettings {
|
|
|
214
226
|
export function createGoogleVertex(
|
|
215
227
|
options: GoogleVertexProviderSettings = {},
|
|
216
228
|
): GoogleVertexProvider {
|
|
217
|
-
const apiKey =
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
229
|
+
const apiKey =
|
|
230
|
+
typeof options.apiKey === 'string' || options.apiKey == null
|
|
231
|
+
? loadOptionalSetting({
|
|
232
|
+
settingValue: options.apiKey,
|
|
233
|
+
environmentVariableName: 'GOOGLE_VERTEX_API_KEY',
|
|
234
|
+
})
|
|
235
|
+
: options.apiKey;
|
|
221
236
|
|
|
222
237
|
const loadGoogleVertexProject = () =>
|
|
223
238
|
loadSetting({
|
|
@@ -21,10 +21,13 @@ export type { GoogleVertexProvider };
|
|
|
21
21
|
export function createGoogleVertex(
|
|
22
22
|
options: GoogleVertexProviderSettings = {},
|
|
23
23
|
): GoogleVertexProvider {
|
|
24
|
-
const apiKey =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const apiKey =
|
|
25
|
+
typeof options.apiKey === 'string' || options.apiKey == null
|
|
26
|
+
? loadOptionalSetting({
|
|
27
|
+
settingValue: options.apiKey,
|
|
28
|
+
environmentVariableName: 'GOOGLE_VERTEX_API_KEY',
|
|
29
|
+
})
|
|
30
|
+
: options.apiKey;
|
|
28
31
|
|
|
29
32
|
if (apiKey) {
|
|
30
33
|
return createGoogleVertexOriginal(options);
|