@ai-sdk/google 4.0.0-beta.34 → 4.0.0-beta.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.0-beta.34",
3
+ "version": "4.0.0-beta.36",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@ai-sdk/provider": "4.0.0-beta.10",
40
- "@ai-sdk/provider-utils": "5.0.0-beta.17"
40
+ "@ai-sdk/provider-utils": "5.0.0-beta.18"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "20.17.24",
@@ -7,13 +7,11 @@ import {
7
7
  } from '@ai-sdk/provider';
8
8
  import {
9
9
  combineHeaders,
10
- convertUint8ArrayToBase64,
11
10
  createJsonResponseHandler,
12
11
  delay,
13
12
  type FetchFunction,
14
13
  lazySchema,
15
14
  parseProviderOptions,
16
- postJsonToApi,
17
15
  zodSchema,
18
16
  getFromApi,
19
17
  } from '@ai-sdk/provider-utils';
@@ -41,11 +41,9 @@ import { googleFailedResponseHandler } from './google-error';
41
41
  import {
42
42
  GoogleGenerativeAIModelId,
43
43
  googleLanguageModelOptions,
44
+ VertexServiceTierMap,
44
45
  } from './google-generative-ai-options';
45
- import {
46
- GoogleGenerativeAIContentPart,
47
- GoogleGenerativeAIProviderMetadata,
48
- } from './google-generative-ai-prompt';
46
+ import { GoogleGenerativeAIProviderMetadata } from './google-generative-ai-prompt';
49
47
  import { prepareTools } from './google-prepare-tools';
50
48
  import { GoogleJSONAccumulator, PartialArg } from './google-json-accumulator';
51
49
  import { mapGoogleGenerativeAIFinishReason } from './map-google-generative-ai-finish-reason';
@@ -155,6 +153,12 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV4 {
155
153
  });
156
154
  }
157
155
 
156
+ // Vertex API requires another service tier format.
157
+ let sanitizedServiceTier: string | undefined = googleOptions?.serviceTier;
158
+ if (googleOptions?.serviceTier && isVertexProvider) {
159
+ sanitizedServiceTier = VertexServiceTierMap[googleOptions.serviceTier];
160
+ }
161
+
158
162
  const isGemmaModel = this.modelId.toLowerCase().startsWith('gemma-');
159
163
  const supportsFunctionResponseParts = this.modelId.startsWith('gemini-3');
160
164
 
@@ -256,7 +260,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV4 {
256
260
  toolConfig,
257
261
  cachedContent: googleOptions?.cachedContent,
258
262
  labels: googleOptions?.labels,
259
- serviceTier: googleOptions?.serviceTier,
263
+ serviceTier: sanitizedServiceTier,
260
264
  },
261
265
  warnings: [...warnings, ...toolWarnings],
262
266
  providerOptionsName,
@@ -1415,17 +1419,10 @@ const responseSchema = lazySchema(() =>
1415
1419
  ),
1416
1420
  );
1417
1421
 
1418
- type ContentSchema = NonNullable<
1419
- InferSchema<typeof responseSchema>['candidates'][number]['content']
1420
- >;
1421
1422
  export type GroundingMetadataSchema = NonNullable<
1422
1423
  InferSchema<typeof responseSchema>['candidates'][number]['groundingMetadata']
1423
1424
  >;
1424
1425
 
1425
- type GroundingChunkSchema = NonNullable<
1426
- GroundingMetadataSchema['groundingChunks']
1427
- >[number];
1428
-
1429
1426
  export type UrlContextMetadataSchema = NonNullable<
1430
1427
  InferSchema<typeof responseSchema>['candidates'][number]['urlContextMetadata']
1431
1428
  >;
@@ -212,3 +212,10 @@ export const googleLanguageModelOptions = lazySchema(() =>
212
212
  export type GoogleLanguageModelOptions = InferSchema<
213
213
  typeof googleLanguageModelOptions
214
214
  >;
215
+
216
+ // Vertex API requires another service tier format.
217
+ export const VertexServiceTierMap = {
218
+ standard: 'SERVICE_TIER_STANDARD',
219
+ flex: 'SERVICE_TIER_FLEX',
220
+ priority: 'SERVICE_TIER_PRIORITY',
221
+ } as const;