@ai-sdk/google 3.0.56 → 3.0.58

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.
@@ -245,11 +245,11 @@ The following optional provider options are available for Google Generative AI m
245
245
  Optional. Defines labels used in billing reports. Available on Vertex AI only.
246
246
  See [Google Cloud labels documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls).
247
247
 
248
- - **serviceTier** _'SERVICE_TIER_STANDARD' | 'SERVICE_TIER_FLEX' | 'SERVICE_TIER_PRIORITY'_
248
+ - **serviceTier** _'standard' | 'flex' | 'priority'_
249
249
 
250
250
  Optional. The service tier to use for the request.
251
- Set to 'SERVICE_TIER_FLEX' for 50% cheaper processing at the cost of increased latency.
252
- Set to 'SERVICE_TIER_PRIORITY' for ultra-low latency at a 75-100% price premium over 'SERVICE_TIER_STANDARD'.
251
+ Set to 'flex' for 50% cheaper processing at the cost of increased latency.
252
+ Set to 'priority' for ultra-low latency at a 75-100% price premium over 'standard'.
253
253
 
254
254
  - **threshold** _string_
255
255
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "3.0.56",
3
+ "version": "3.0.58",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -1,5 +1,10 @@
1
1
  import { LanguageModelV3Usage } from '@ai-sdk/provider';
2
2
 
3
+ export type GoogleGenerativeAITokenDetail = {
4
+ modality: string;
5
+ tokenCount: number;
6
+ };
7
+
3
8
  export type GoogleGenerativeAIUsageMetadata = {
4
9
  promptTokenCount?: number | null;
5
10
  candidatesTokenCount?: number | null;
@@ -7,6 +12,8 @@ export type GoogleGenerativeAIUsageMetadata = {
7
12
  cachedContentTokenCount?: number | null;
8
13
  thoughtsTokenCount?: number | null;
9
14
  trafficType?: string | null;
15
+ promptTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
16
+ candidatesTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
10
17
  };
11
18
 
12
19
  export function convertGoogleGenerativeAIUsage(
@@ -1110,6 +1110,15 @@ const getSafetyRatingSchema = () =>
1110
1110
  blocked: z.boolean().nullish(),
1111
1111
  });
1112
1112
 
1113
+ const tokenDetailsSchema = z
1114
+ .array(
1115
+ z.object({
1116
+ modality: z.string(),
1117
+ tokenCount: z.number(),
1118
+ }),
1119
+ )
1120
+ .nullish();
1121
+
1113
1122
  const usageSchema = z.object({
1114
1123
  cachedContentTokenCount: z.number().nullish(),
1115
1124
  thoughtsTokenCount: z.number().nullish(),
@@ -1118,6 +1127,9 @@ const usageSchema = z.object({
1118
1127
  totalTokenCount: z.number().nullish(),
1119
1128
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
1120
1129
  trafficType: z.string().nullish(),
1130
+ // https://ai.google.dev/api/generate-content#Modality
1131
+ promptTokensDetails: tokenDetailsSchema,
1132
+ candidatesTokensDetails: tokenDetailsSchema,
1121
1133
  });
1122
1134
 
1123
1135
  // https://ai.google.dev/api/generate-content#UrlRetrievalMetadata
@@ -192,13 +192,7 @@ export const googleLanguageModelOptions = lazySchema(() =>
192
192
  /**
193
193
  * Optional. The service tier to use for the request.
194
194
  */
195
- serviceTier: z
196
- .enum([
197
- 'SERVICE_TIER_STANDARD',
198
- 'SERVICE_TIER_FLEX',
199
- 'SERVICE_TIER_PRIORITY',
200
- ])
201
- .optional(),
195
+ serviceTier: z.enum(['standard', 'flex', 'priority']).optional(),
202
196
  }),
203
197
  ),
204
198
  );