@ai-sdk/google-vertex 4.0.204 → 4.0.206
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 +19 -23
- package/dist/anthropic/edge/index.js.map +1 -1
- package/dist/anthropic/edge/index.mjs +19 -23
- package/dist/anthropic/edge/index.mjs.map +1 -1
- package/dist/edge/index.js +24 -28
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/index.mjs +24 -28
- package/dist/edge/index.mjs.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/dist/maas/edge/index.js +19 -23
- package/dist/maas/edge/index.js.map +1 -1
- package/dist/maas/edge/index.mjs +19 -23
- package/dist/maas/edge/index.mjs.map +1 -1
- package/dist/xai/edge/index.js +19 -23
- package/dist/xai/edge/index.js.map +1 -1
- package/dist/xai/edge/index.mjs +19 -23
- package/dist/xai/edge/index.mjs.map +1 -1
- package/docs/16-google-vertex.mdx +30 -0
- package/package.json +6 -6
- package/src/edge/google-vertex-auth-edge.ts +21 -25
- package/src/google-vertex-image-model.ts +2 -2
|
@@ -132,30 +132,26 @@ const buildJwt = async (credentials: GoogleCredentials) => {
|
|
|
132
132
|
* with the Edge runtime.
|
|
133
133
|
*/
|
|
134
134
|
export async function generateAuthToken(credentials?: GoogleCredentials) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
throw new Error(`Token request failed: ${response.statusText}`);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const data = await response.json();
|
|
157
|
-
return data.access_token;
|
|
158
|
-
} catch (error) {
|
|
159
|
-
throw error;
|
|
135
|
+
const creds = credentials || (await loadCredentials());
|
|
136
|
+
const jwt = await buildJwt(creds);
|
|
137
|
+
|
|
138
|
+
const response = await fetch('https://oauth2.googleapis.com/token', {
|
|
139
|
+
method: 'POST',
|
|
140
|
+
headers: withUserAgentSuffix(
|
|
141
|
+
{ 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
142
|
+
`ai-sdk/google-vertex/${VERSION}`,
|
|
143
|
+
getRuntimeEnvironmentUserAgent(),
|
|
144
|
+
),
|
|
145
|
+
body: new URLSearchParams({
|
|
146
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
|
|
147
|
+
assertion: jwt,
|
|
148
|
+
}),
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (!response.ok) {
|
|
152
|
+
throw new Error(`Token request failed: ${response.statusText}`);
|
|
160
153
|
}
|
|
154
|
+
|
|
155
|
+
const data = await response.json();
|
|
156
|
+
return data.access_token;
|
|
161
157
|
}
|
|
@@ -309,10 +309,10 @@ export class GoogleVertexImageModel implements ImageModelV3 {
|
|
|
309
309
|
>['aspectRatio'],
|
|
310
310
|
}
|
|
311
311
|
: undefined,
|
|
312
|
-
...(
|
|
312
|
+
...(providerOptions?.vertex as Omit<
|
|
313
313
|
GoogleLanguageModelOptions,
|
|
314
314
|
'responseModalities' | 'imageConfig'
|
|
315
|
-
>)
|
|
315
|
+
>),
|
|
316
316
|
} satisfies GoogleLanguageModelOptions,
|
|
317
317
|
},
|
|
318
318
|
headers,
|